nodece commented on code in PR #16659:
URL: https://github.com/apache/pulsar/pull/16659#discussion_r925282585


##########
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/Schema.java:
##########
@@ -120,6 +123,36 @@ default T decode(byte[] bytes, byte[] schemaVersion) {
         return decode(bytes);
     }
 
+    /**
+     * Decode a byte array into an object using the schema definition and 
deserializer implementation.
+     *
+     * @param input the inputstream to decode
+     * @return the deserialized object
+     */
+    default T decode(InputStream input) {
+        try {
+            return decode(IOUtils.readAllBytes(input));
+        } catch (IOException ex) {
+            throw new SchemaSerializationException(ex);
+        }
+    }
+
+    /**
+     * Decode a byte array into an object using a given version.
+     *
+     * @param input the inputstream to decode
+     * @param schemaVersion
+     *            the schema version to decode the object. null indicates 
using latest version.
+     * @return the deserialized object
+     */
+    default T decode(InputStream input, byte[] schemaVersion) {
+        try {
+            return decode(IOUtils.readAllBytes(input), schemaVersion);

Review Comment:
   ```suggestion
               return decode(org.apache.commons.io.IOUtils.toByteArray(input), 
schemaVersion);
   ```



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to