-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Remove proto size restriction when parsing protos. #836
Conversation
CodedInputStream codedInput = CodedInputStream.newInstance(stream); | ||
codedInput.setSizeLimit(Integer.MAX_VALUE); | ||
|
||
return parser.parseFrom(codedInput); |
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.
In the documentation for parseFrom(CodedInputStream)
:
Note: The caller should call CodedInputStream#checkLastTagWas(int) after calling this to verify that the last tag seen was the appropriate end-group tag, or zero for EOF.
In my comment in #832, I say:
The only gotcha I see is that we need to call
checkLastTagWas(0)
afterward.
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.
Ah good catch ... missed that. Done!
@ejona86 PTAL |
Do we want to do the same thing that proto does if the message was incomplete? try {
codedInput.checkLastTagWas(0);
} catch (InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(message);
} That does actually look useful, as you can piece together what the message was a bit, but aren't accidentally going to trust it. That does seem useful for debugging. |
// when parsing. | ||
CodedInputStream codedInput = CodedInputStream.newInstance(stream); | ||
codedInput.setSizeLimit(Integer.MAX_VALUE); | ||
codedInput.checkLastTagWas(0); |
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 has to happen after parseFrom()
to have any purpose.
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.
done.
@ejona86 PTAL |
@nmittler LGTM |
Cherry-picked as 573f79a |
@ejona86 PTAL .. this is the first part of the change to support maxMessageSize.