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



##########
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:
       It seems like that the most adequate JsonProcessingException is 
JsonParseException that could apply here. Another possibility is to change the 
exception in return type to something like IOException and throw that here but 
it seems it's more vague than throwing JsonParseException.
   Another option is to simple throw IllegalArgumentException here instead of 
Left. That would correspond to the `readTree(InputStream)` as well. What do you 
think?




----------------------------------------------------------------
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