nicoloboschi opened a new issue #14522: URL: https://github.com/apache/pulsar/issues/14522
**Describe the bug** During the development of https://github.com/apache/pulsar/pull/14508, we noticed that `SchemaInfoImpl` (the default implementation of `SchemaInfo`) is a non thread-safe mutable object. All the default schema implementations created inside `org.apache.pulsar.client.api.SchemaInfo` are creating and saving the `SchemaInfo` instance as static field. The issue would be that a thread can access the `SchemaInfoImpl` implementation and modify the fields, leading to unexpected behaviours. Another clue that says that the SchemaInfo is supposed to be immutable is that the implementation of the `clone()` method just return the same instance. **To Reproduce** ``` final Schema<Integer> integerSchema = Schema.INT32; // example 1 ((SchemaInfoImpl) integerSchema.getSchemaInfo()).getProperties().clear(); // example 2 ((SchemaInfoImpl) integerSchema.getSchemaInfo()).setProperties(map); // example 3 ((SchemaInfoImpl) integerSchema.getSchemaInfo()).setType(SchemaType.BYTES); ``` **Expected behavior** SchemaInfo default implementations are supposed to be completely immutable, avoiding unpredictable side effects. **Additional context** It applies to all the active branches, even master branch. -- 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]
