Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve][schema]Improve the getSchema() method in SchemaRegistryServiceImpl.java #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,7 @@ public class SchemaRegistryServiceImpl implements SchemaRegistryService {
@Override
@NotNull
public CompletableFuture<SchemaAndMetadata> getSchema(String schemaId) {
return getSchema(schemaId, SchemaVersion.Latest).thenApply((schema) -> {
if (schema != null && schema.schema.isDeleted()) {
return null;
} else {
return schema;
}
});
return getSchema(schemaId, SchemaVersion.Latest);
}

@Override
Expand Down Expand Up @@ -133,7 +127,17 @@ public CompletableFuture<SchemaAndMetadata> getSchema(String schemaId, SchemaVer
} else {
return Functions.bytesToSchemaInfo(stored.data)
.thenApply(Functions::schemaInfoToSchema)
.thenApply(schema -> new SchemaAndMetadata(schemaId, schema, stored.version));
.thenApply(schema -> new SchemaAndMetadata(schemaId, schema, stored.version))
.thenApply((schema) -> {
if (version == SchemaVersion.Latest) {
if (schema != null && schema.schema.isDeleted()) {
return null;
} else {
return schema;
}
}
return schema;
});
}
})
.whenComplete((v, t) -> {
Expand Down
Loading