gaoran10 commented on a change in pull request #10811:
URL: https://github.com/apache/pulsar/pull/10811#discussion_r644969977
##########
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:
The method `message.getValue()` will use the AutoConsumeSchema to decode
data.
Because the schema version is null, so fallback uses the BYTES schema to
decode data.
##########
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:
Oh, I forgot to remove this, thanks.
##########
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:
If using Python client produces messages without specifying a schema,
the schema version will be null.
##########
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:
Does the static method have some advantage?
##########
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:
Ok, I'll fix this.
##########
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:
Ok, I'll fix this, thanks.
--
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]