Skip to content

Conversation

@tgroh
Copy link
Member

@tgroh tgroh commented Apr 4, 2016

Be sure to do all of the following to help us incorporate your contribution
quickly and easily:

  • Make sure the PR title is formatted like:
    [BEAM-<Jira issue #>] Description of pull request
  • Make sure tests pass via mvn clean verify. (Even better, enable
    Travis-CI on your fork and ensure the whole test matrix passes).
  • Replace "<Jira issue #>" in the title with the actual Jira issue
    number, if there is one.
  • If this contribution is large, please file an Apache
    Individual Contributor License Agreement.

JAXBCoder in the nested context is broken with any coder that writes
content after the output of the XML stream, as decode will read the
entire remaining stream and fail.

In the nested context, prepend a long representing the size of the XML
while encoding, and limit the size of the returned stream while
decoding.

Replaces #112

This should not be ported to the DataflowJavaSDK

JAXBCoder in the nested context is broken with any coder that writes
content after the output of the XML stream, as decode will read the
entire remaining stream and fail.

In the nested context, prepend a long representing the size of the XML
while encoding, and limit the size of the returned stream while
decoding.
@tgroh
Copy link
Member Author

tgroh commented Apr 4, 2016

R: @dhalperi

}
if (context.equals(Context.NESTED)) {
CountingOutputStream countingStream =
new CountingOutputStream(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@Override
public void close() {
// Do nothing. JAXB closes the underyling stream so we must filter out those calls.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove newline.

Also, I was wrong about flush -- no need to flush an input stream (duh)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

jaxbUnmarshaller.unmarshal(
new CloseIgnoringInputStream(ByteStreams.limit(inStream, limit)));
return obj;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about extracting the common core for simplicity?

InputStream stream = inStream;
if (!context.isWholeStream) {
    long limit = VarInt.decodeLong();
    stream = ByteStreams.limit(stream, limit);
}
@SuppressWarnings("unchecked")
T obj = (T) jaxbUnmarshaller.unmarshal(new CloseIgnoringInputStream(stream));
return obj;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@dhalperi
Copy link
Contributor

dhalperi commented Apr 4, 2016

beam issue?


@Override
public void close() {
// Do nothing. JAXB closes the underyling stream so we must filter out those calls.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: underlying

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@tgroh tgroh changed the title Fix JAXBCoder in the nested context [BEAM-171] Fix JAXBCoder in the nested context Apr 4, 2016
@tgroh tgroh force-pushed the jaxb_coder_nested branch from e107734 to b4afa46 Compare April 4, 2016 23:27
new FilterOutputStream(outStream) {
// JAXB closes the underlying stream so we must filter out those calls.
@Override
public void close() throws IOException {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one needs the flush, I think. It's an output stream.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should be backported.

Also, why separate out CloseIgnoringInputStream but not CloseIgnoringOutputStream?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An artifact of the implementation.

@tgroh
Copy link
Member Author

tgroh commented Apr 6, 2016

Stopped flushing, as discussed, as the marshaller must have already written its contents to the stream before closed, and the stream will be flushed and closed by the actual owner.

@dhalperi
Copy link
Contributor

dhalperi commented Apr 6, 2016

LGTM, merging

@asfgit asfgit closed this in cdfe509 Apr 6, 2016
iemejia referenced this pull request in iemejia/beam Jan 12, 2018
mareksimunek pushed a commit to mareksimunek/beam that referenced this pull request May 9, 2018
pl04351820 pushed a commit to pl04351820/beam that referenced this pull request Dec 20, 2023
* chore: update minimum version of protoplus to ensure DatetimeWithNanoseconds availability

* feat: Incorporate nanoseconds back into components, such as hashing

* blacken

* remove unused imports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants