eolivelli commented on a change in pull request #10811:
URL: https://github.com/apache/pulsar/pull/10811#discussion_r644778867



##########
File path: 
pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/AutoConsumeSchemaTest.java
##########
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.impl.schema;
+
+import java.nio.ByteBuffer;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.pulsar.client.api.Schema;
+import org.apache.pulsar.client.api.schema.GenericRecord;
+import org.apache.pulsar.client.impl.MessageImpl;
+import org.apache.pulsar.common.api.proto.MessageMetadata;
+import org.junit.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * AutoConsumeSchema test.
+ */
+@Slf4j
+public class AutoConsumeSchemaTest {
+
+    @Test
+    public void decodeDataWithNullSchemaVersion() {
+        Schema<GenericRecord> autoConsumeSchema = new AutoConsumeSchema();
+        byte[] bytes = "bytes data".getBytes();
+        MessageImpl<GenericRecord> message = MessageImpl.create(
+                new MessageMetadata(), ByteBuffer.wrap(bytes), 
autoConsumeSchema);
+        Assert.assertNull(message.getSchemaVersion());

Review comment:
       how can it happen that we receive a message with null schemaVersion ?
   Autoconsume is meant to be used only on the Consumer side, on a real message.

##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/AutoConsumeSchema.java
##########
@@ -308,13 +311,26 @@ public void fetchSchemaIfNeeded(SchemaVersion 
schemaVersion) throws SchemaSerial
         }
     }
 
+    private SchemaVersion getSchemaVersion(byte[] schemaVersion) {

Review comment:
       static ?

##########
File path: 
pulsar-client/src/test/java/org/apache/pulsar/client/impl/TypedMessageBuilderImplTest.java
##########
@@ -225,5 +226,12 @@ public void testSetKeyBytesEncodingTypeSeparated() {
         }
     }
 
+    @Test
+    public void test() {
+        producerBase = mock(ProducerBase.class);
+        TypedMessageBuilderImpl builder =  new 
TypedMessageBuilderImpl(producerBase, null);
+        AutoConsumeSchema autoConsumeSchema = new AutoConsumeSchema();

Review comment:
       I do not understand this test.
   
   what is it supposed to test ? autoConsumeSchema is not used

##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/AutoConsumeSchema.java
##########
@@ -308,13 +311,26 @@ public void fetchSchemaIfNeeded(SchemaVersion 
schemaVersion) throws SchemaSerial
         }
     }
 
+    private SchemaVersion getSchemaVersion(byte[] schemaVersion) {

Review comment:
       Probably not a big deal from a performance perspective.
   But if a method does not use state from the instance it is better to mark it 
'static'.
   
    

##########
File path: 
pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/AutoConsumeSchemaTest.java
##########
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.impl.schema;
+
+import java.nio.ByteBuffer;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.pulsar.client.api.Schema;
+import org.apache.pulsar.client.api.schema.GenericRecord;
+import org.apache.pulsar.client.impl.MessageImpl;
+import org.apache.pulsar.common.api.proto.MessageMetadata;
+import org.junit.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * AutoConsumeSchema test.
+ */
+@Slf4j
+public class AutoConsumeSchemaTest {
+
+    @Test
+    public void decodeDataWithNullSchemaVersion() {
+        Schema<GenericRecord> autoConsumeSchema = new AutoConsumeSchema();
+        byte[] bytes = "bytes data".getBytes();
+        MessageImpl<GenericRecord> message = MessageImpl.create(
+                new MessageMetadata(), ByteBuffer.wrap(bytes), 
autoConsumeSchema);
+        Assert.assertNull(message.getSchemaVersion());

Review comment:
       Very interesting.
   I didn't know 




-- 
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:
[email protected]


Reply via email to