You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2018/10/12 16:10:57 UTC

[pulsar] branch master updated: fix: unsafe cast of schema to JSONSchema (#2779)

This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new b6a25f0  fix: unsafe cast of schema to JSONSchema (#2779)
b6a25f0 is described below

commit b6a25f034bd8a9c3b30aa4a90eefdd45a0f0ee67
Author: Boyang Jerry Peng <je...@gmail.com>
AuthorDate: Fri Oct 12 11:10:51 2018 -0500

    fix: unsafe cast of schema to JSONSchema (#2779)
---
 .../src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java     | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
index 8551510..621c86c 100644
--- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
@@ -896,9 +896,11 @@ public class ProducerImpl<T> extends ProducerBase<T> implements TimerTask, Conne
                     // but now we have standardized on every schema to generate an Avro based schema
                     if (Commands.peerSupportJsonSchemaAvroFormat(cnx.getRemoteEndpointProtocolVersion())) {
                         schemaInfo = schema.getSchemaInfo();
-                    } else {
+                    } else if (schema instanceof JSONSchema){
                         JSONSchema jsonSchema = (JSONSchema) schema;
                         schemaInfo = jsonSchema.getBackwardsCompatibleJsonSchemaInfo();
+                    } else {
+                        schemaInfo = schema.getSchemaInfo();
                     }
                 } else if (schema.getSchemaInfo().getType() == SchemaType.BYTES) {
                     // don't set schema info for Schema.BYTES