You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/06/23 11:58:09 UTC

[GitHub] [kafka] viktorsomogyi commented on a change in pull request #4090: [KAFKA-6084] Propagate JSON parsing errors in ReassignPartitionsCommand

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



##########
File path: core/src/main/scala/kafka/utils/Json.scala
##########
@@ -65,6 +63,16 @@ object Json {
     catch { case e: JsonProcessingException => Left(e) }
   }
 
+  /**
+    * Parse a JSON string into a JsonValue if possible. It returns an `Either` where `Left` will be an exception and
+    * `Right` is the `JsonValue`.
+    * @param input a JSON string to parse
+    * @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(_))

Review comment:
       Added them




----------------------------------------------------------------
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:
users@infra.apache.org