Protobuf Validation & Conversion#691
Conversation
jfallows
left a comment
There was a problem hiding this comment.
Looks pretty good so far!
| catalog0: | ||
| - subject: test0 | ||
| version: latest | ||
| record: SimpleMessage |
There was a problem hiding this comment.
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.
| 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.
Perhaps findByIndexes should return Descriptor directly?
| builder.mergeFrom(in); | ||
| DynamicMessage message = builder.build(); |
There was a problem hiding this comment.
| 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.
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.
| 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.
| 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.
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.
| 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.
This byte[] should be a constant.
| catch (IOException e) | ||
| { | ||
| e.printStackTrace(); | ||
| } |
There was a problem hiding this comment.
| catch (IOException e) | |
| { | |
| e.printStackTrace(); | |
| } | |
| catch (IOException ex) | |
| { | |
| ex.printStackTrace(); | |
| } |
Fixes #457
Fixes #458