ijuma commented on a change in pull request #4090:
URL: https://github.com/apache/kafka/pull/4090#discussion_r492811318



##########
File path: core/src/main/scala/kafka/utils/Json.scala
##########
@@ -69,8 +70,11 @@ object Json {
    * @return An `Either` which in case of `Left` means an exception and 
`Right` is the actual return value.
    */
   def tryParseFull(input: String): Either[JsonProcessingException, JsonValue] =
-    try Right(mapper.readTree(input)).map(JsonValue(_))
-    catch { case e: JsonProcessingException => Left(e) }
+    if (input != null && input.isEmpty)

Review comment:
       I think we should say `if (input == null || input.isEmpty)` instead. 
It's unexpected to get an exception instead of `Left` in a method that returns 
`Either`.

##########
File path: core/src/main/scala/kafka/utils/Json.scala
##########
@@ -69,8 +70,11 @@ object Json {
    * @return An `Either` which in case of `Left` means an exception and 
`Right` is the actual return value.
    */
   def tryParseFull(input: String): Either[JsonProcessingException, JsonValue] =
-    try Right(mapper.readTree(input)).map(JsonValue(_))
-    catch { case e: JsonProcessingException => Left(e) }
+    if (input != null && input.isEmpty)
+      Left(new JsonParseException(MissingNode.getInstance().traverse(), "The 
input string shouldn't be empty"))

Review comment:
       This seems fine.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to