-
Notifications
You must be signed in to change notification settings - Fork 56
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
Protobuf Validation & Conversion #691
Protobuf Validation & Conversion #691
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good so far!
catalog0: | ||
- subject: test0 | ||
version: latest | ||
record: SimpleMessage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does SimpleMessage
not need to align with one of the message names, like example
?
Also, perhaps it needs a package prefix too?
if (catalog.id != NO_SCHEMA_ID) | ||
{ | ||
schemaId = catalog.id; | ||
} | ||
else | ||
{ | ||
schemaId = handler.resolve(subject, catalog.version); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (catalog.id != NO_SCHEMA_ID) | |
{ | |
schemaId = catalog.id; | |
} | |
else | |
{ | |
schemaId = handler.resolve(subject, catalog.version); | |
} | |
schemaId = catalog.id != NO_SCHEMA_ID ? catalog.id : handler.resolve(subject, catalog.version); |
DescriptorTree tree = supplyDescriptorTree(schemaId); | ||
if (tree != null) | ||
{ | ||
tree = tree.findByIndexes(indexes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps findByIndexes
should return Descriptor
directly?
builder.mergeFrom(in); | ||
DynamicMessage message = builder.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
builder.mergeFrom(in); | |
DynamicMessage message = builder.build(); | |
DynamicMessage message = builder.mergeFrom(in).build(); |
builder.mergeFrom(in); | ||
DynamicMessage message = builder.build(); | ||
builder.clear(); | ||
if (!message.getUnknownFields().asMap().isEmpty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This .asMap()
still has allocation logic, but it may be the best we can do with these APIs.
catch (IOException e) | ||
{ | ||
e.printStackTrace(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catch (IOException e) | |
{ | |
e.printStackTrace(); | |
} | |
catch (IOException ex) | |
{ | |
ex.printStackTrace(); | |
} |
We typically use ex
for exception variables.
catch (InvalidProtocolBufferException e) | ||
{ | ||
e.printStackTrace(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catch (InvalidProtocolBufferException e) | |
{ | |
e.printStackTrace(); | |
} | |
catch (InvalidProtocolBufferException ex) | |
{ | |
ex.printStackTrace(); | |
} |
in.wrap(buffer, index, length); | ||
DynamicMessage message = DynamicMessage.parseFrom(descriptor, in); | ||
status = message.getUnknownFields().asMap().isEmpty(); | ||
padding = 2 + JsonFormat.printer().print(descriptor.toProto()).length(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should reuse this printer
?
How often is this method called when messages are flowing?
Why 2 + ...
? Suggest using a constant to better document the intent.
catch (IOException e) | ||
{ | ||
e.printStackTrace(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catch (IOException e) | |
{ | |
e.printStackTrace(); | |
} | |
catch (IOException ex) | |
{ | |
ex.printStackTrace(); | |
} |
int valLength = 0; | ||
if (indexes.size() == 2 && indexes.get(0) == 1 && indexes.get(1) == 0) | ||
{ | ||
indexesRO.wrap(new byte[]{ZERO_INDEX}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This byte[]
should be a constant.
catch (IOException e) | ||
{ | ||
e.printStackTrace(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catch (IOException e) | |
{ | |
e.printStackTrace(); | |
} | |
catch (IOException ex) | |
{ | |
ex.printStackTrace(); | |
} |
Fixes #457
Fixes #458