[improve][schema]Improve the getSchema() method in SchemaRegistryServiceImpl.java #23354
[improve][schema]Improve the getSchema() method in SchemaRegistryServiceImpl.java #23354nikam14 wants to merge 5 commits intoapache:masterfrom
Conversation
| .thenApply(schema -> new SchemaAndMetadata(schemaId, schema, stored.version)); | ||
| .thenApply(schema -> new SchemaAndMetadata(schemaId, schema, stored.version)) | ||
| .thenApply((schema) -> { | ||
| if (version == SchemaVersion.Latest) { |
There was a problem hiding this comment.
Please add a test to show the changes make sense
There was a problem hiding this comment.
changes are covered in SchemaServiceTest.java
There was a problem hiding this comment.
changes are covered in
SchemaServiceTest.java
@nikam14 Please add a test that shows that this change was needed. I don't see any test changes in this PR, so that is missing.
Instead of explaining how the code is implemented, please explain why it was a problem instead. You can show this is a test too. |
|
These changes not cover any issue. |
@nikam14 That doesn't make much sense. |
|
changes are covered in Test |
please check my comment #23354 (comment) . What is the potential future issue you would like to prepare for? Could you please add a test case for that? |
Motivation
In SchemaRegistryServiceImpl.java there are two
getSchema()methods.1 -
getSchema(String schemaId)2 -
getSchema(String schemaId, SchemaVersion version)In the first method after getting Schema it is checked that whether the Schema is deleted or not. In Second method it is not checked when Schema.version=Latest . Which means it may return a deleted Schema.
So, checking it in
getSchema(String schemaId, SchemaVersion version)can improve code, prevent from any future issue.Modifications
checking Schema is deleted or not before return in
getSchema(String schemaId, SchemaVersion version)method.If it is deleted then return
Nullelse returnSchema.Removing the check from
getSchema(String schemaId)and adding it ingetSchema(String schemaId, SchemaVersion version).Verifying this change
This change is already covered by existing tests.
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository