sijie commented on a change in pull request #2730: [schema] provide a flag to 
disable/enable schema validation on broker and change default bytes producer to 
use `AUTO_PRODUCE_BYTES`
URL: https://github.com/apache/pulsar/pull/2730#discussion_r223093861
 
 

 ##########
 File path: 
pulsar-client-schema/src/main/java/org/apache/pulsar/client/api/Schema.java
 ##########
 @@ -40,6 +40,22 @@
  */
 public interface Schema<T> {
 
+    /**
+     * Check if the message is a valid object for this schema.
+     *
+     * <p>The implementation can choose what its most efficient approach to 
validate the schema.
+     * If the implementation doesn't provide it, it will attempt to use {@link 
#decode(byte[])}
+     * to see if this schema can decode this message or not as a validation 
mechanism to verify
+     * the bytes.
+     *
+     * @param message the messages to verify
+     * @return true if it is a valid message
+     * @throws SchemaSerializationException if it is not a valid message
+     */
+    default void validate(byte[] message) {
 
 Review comment:
   it throws SchemaSerializationException, it aligns with what other methods 
are doing. it just makes `validate` to be reused in other methods like `encode` 
and `decode`. if we change it to return boolean or throw a checked exception, 
it requires more changes if validate is going to be used in other methods. 
   
   however I am not strong on this, if you think it should return a boolean or 
throw a checked exception, let me know, I can make the change.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services

Reply via email to