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

Make Http2UnknownFrame extend Http2StreamFrame rather than Http2Frame #7969

Closed
Bennett-Lynch opened this issue May 24, 2018 · 4 comments · Fixed by #7976
Closed

Make Http2UnknownFrame extend Http2StreamFrame rather than Http2Frame #7969

Bennett-Lynch opened this issue May 24, 2018 · 4 comments · Fixed by #7976
Milestone

Comments

@Bennett-Lynch
Copy link
Contributor

Bennett-Lynch commented May 24, 2018

This is a follow-up issue regarding: #7860

Expected behavior

Writing an Http2UnknownFrame to a child channel will be written to the parent channel and underlying HTTP/2 connection via Http2MultiplexCodec.

When Http2MultiplexCodec reads an Http2UnknownFrame, it will be propagated to the correct child channel.

Actual behavior

Http2MultiplexCodec rejects the write since Http2UnknownFrame is not an instanceof Http2StreamFrame.

} else {
String msgStr = msg.toString();
ReferenceCountUtil.release(msg);
promise.setFailure(new IllegalArgumentException(
"Message must be an " + StringUtil.simpleClassName(Http2StreamFrame.class) +
": " + msgStr));
return;
}

Http2MultiplexCodec does not propagate reads to child channels since Http2UnknownFrame is not an instanceof Http2StreamFrame.

if (frame instanceof Http2StreamFrame) {
Http2StreamFrame streamFrame = (Http2StreamFrame) frame;
onHttp2StreamFrame(((Http2MultiplexCodecStream) streamFrame.stream()).channel, streamFrame);

Proposal

Http2UnknownFrame should extend Http2StreamFrame, rather than Http2Frame, as it already defines the two stream-related methods that the two interfaces differ in.

Should it possibly declare an isEndStream method as well, similar to Http2DataFrame?

@normanmaurer
Copy link
Member

@Bennett-Lynch let it extend Http2StreamFrame sounds like the correct thing to do. Would you be interested in proving a PR ?

I think I would leave the isEndStream as it is and just use the Http2Flags for it.

@normanmaurer normanmaurer added this to the 4.1.26.Final milestone May 27, 2018
normanmaurer added a commit that referenced this issue May 28, 2018
…e with Http2MultiplexCodec.

Motivation:

This is a followup for #7860. In the fix for #7860 we only partly fixed the problem as Http2UnknownFrame did not correctly extend HttpStreamFrame and so only worked when using the Http2FrameCodec. We need to have it extend HttpStreamFrame as otherwise Http2MultiplexCodec will reject to handle it correctly.

Modifications:

- Let Http2UnknownFrame extend HttpStreamFrame
- Add unit tests for writing and reading Http2UnkownFrame instances when the Http2MultiplexCodec is used.

Result:

Fixes #7969.
@normanmaurer
Copy link
Member

@Bennett-Lynch I had a bit time this morning so I just did it myself and adding unit tests:

#7976

PTAL

@Bennett-Lynch
Copy link
Contributor Author

Thanks, @normanmaurer -- change looks good to me.

Fine with using Http2Flags for detecting isEndStream, but may I ask your reasoning for it? Maintaining a consistent interface across frame types seems more ideal, but I realize these UnknownFrames are a bit of an edge case.

@normanmaurer
Copy link
Member

@Bennett-Lynch because its redundant as it exists in the flags already (and you can have other flags as well).

normanmaurer added a commit that referenced this issue May 29, 2018
…e with Http2MultiplexCodec. (#7976)

Motivation:

This is a followup for #7860. In the fix for #7860 we only partly fixed the problem as Http2UnknownFrame did not correctly extend HttpStreamFrame and so only worked when using the Http2FrameCodec. We need to have it extend HttpStreamFrame as otherwise Http2MultiplexCodec will reject to handle it correctly.

Modifications:

- Let Http2UnknownFrame extend HttpStreamFrame
- Add unit tests for writing and reading Http2UnkownFrame instances when the Http2MultiplexCodec is used.

Result:

Fixes #7969.
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 a pull request may close this issue.

2 participants