Technoboy- commented on a change in pull request #14317:
URL: https://github.com/apache/pulsar/pull/14317#discussion_r808883245



##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/AbstractSchema.java
##########
@@ -74,14 +74,13 @@ public T decode(ByteBuf byteBuf, byte[] schemaVersion) {
      * @param schemaVersion the version
      * @return the schema at that specific version
      * @throws SchemaSerializationException in case of unknown schema version
-     * @throws NullPointerException in case of null schemaVersion
+     * @throws NullPointerException in case of null schemaVersion and 
supportSchemaVersioning is true
      */
     public Schema<?> atSchemaVersion(byte[] schemaVersion) throws 
SchemaSerializationException {
-        Objects.requireNonNull(schemaVersion);
         if (!supportSchemaVersioning()) {
             return this;
-        } else {
-            throw new SchemaSerializationException("Not implemented for " + 
this.getClass());
         }
+        Objects.requireNonNull(schemaVersion);

Review comment:
       Why do we need to check null for `schemaVersion` ?  It's very strange 
here and outside return Optional.
   ```
   else if (schema instanceof AbstractSchema) {
               byte[] schemaVersion = getSchemaVersion();
               return Optional.of(((AbstractSchema<?>) schema)
                       .atSchemaVersion(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