BewareMyPower opened a new pull request, #17256:
URL: https://github.com/apache/pulsar/pull/17256

   ### Motivation
   
   First, it's hard to know the default encoding type of a KeyValue schema
   from the API and its JavaDocs, see
   
https://github.com/apache/pulsar/blob/fd9489771959f3e722656e4b70d4bd891a13f690/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/Schema.java#L386-L391
   
   The default encoding type could only be found in `KeyValueSchemaImpl#of`
   method from another module (`pulsar-client`).
   
   Second, there are much raw use of parameterized class, including
   `KeyValueSchema` and `KeyValue` from `pulsar-common` module. This use
   harms the code quality because it could lose the type safety.
   
   ### Modifications
   
   For the 1st issue, call another overload of `Schema#KeyValue` method and
   note the default encoding type so that it's clear that the encoding
   type of `Schema#KeyValue(Schema<K>, Schema<V>)` method is `INLINE`.
   
   For the 2nd issue, leverage Java's type inference feature to make sure
   the type arguments of `KeyValue` are the same as the type arguments of
   `KeyValueSchema` in a `TypedMessageBuilderImpl` instane.
   `getKeyValueSchema` method is added to simplify the code.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   This change is already covered by existing tests, such as `SchemaTest` and
   `NullValueTest` in `pulsar-broker` module.
   
   ### Documentation
   
   Check the box below or label this PR directly.
   
   Need to update docs? 
   
   - [ ] `doc-required` 
   (Your PR needs to update docs and you will update later)
     
   - [x] `doc-not-needed` 
   (Please explain why)
     
   - [ ] `doc` 
   (Your PR contains doc changes)
   
   - [ ] `doc-complete`
   (Docs have been already added)


-- 
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