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

Add frameType method to Http2Frame. #13989

Open
wants to merge 1 commit into
base: 4.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -87,6 +87,11 @@ public DefaultHttp2DataFrame stream(Http2FrameStream stream) {
return this;
}

@Override
public byte frameType() {
return Http2FrameTypes.DATA;
}

@Override
public String name() {
return "DATA";
Expand Down
Expand Up @@ -83,6 +83,11 @@ public DefaultHttp2GoAwayFrame(long errorCode, ByteBuf content) {
this.lastStreamId = lastStreamId;
}

@Override
public byte frameType() {
return Http2FrameTypes.GO_AWAY;
}

@Override
public String name() {
return "GOAWAY";
Expand Down
Expand Up @@ -69,6 +69,11 @@ public DefaultHttp2HeadersFrame stream(Http2FrameStream stream) {
return this;
}

@Override
public byte frameType() {
return Http2FrameTypes.HEADERS;
}

@Override
public String name() {
return "HEADERS";
Expand Down
Expand Up @@ -42,6 +42,11 @@ public boolean ack() {
return ack;
}

@Override
public byte frameType() {
return Http2FrameTypes.PING;
}

@Override
public String name() {
return "PING";
Expand Down
Expand Up @@ -54,6 +54,11 @@ public DefaultHttp2PriorityFrame stream(Http2FrameStream stream) {
return this;
}

@Override
public byte frameType() {
return Http2FrameTypes.PRIORITY;
}

@Override
public String name() {
return "PRIORITY_FRAME";
Expand Down
Expand Up @@ -84,6 +84,11 @@ public Http2FrameStream stream() {
return streamFrame;
}

@Override
public byte frameType() {
return Http2FrameTypes.PUSH_PROMISE;
}

@Override
public String name() {
return "PUSH_PROMISE_FRAME";
Expand Down
Expand Up @@ -52,6 +52,11 @@ public DefaultHttp2ResetFrame stream(Http2FrameStream stream) {
return this;
}

@Override
public byte frameType() {
return Http2FrameTypes.RST_STREAM;
}

@Override
public String name() {
return "RST_STREAM";
Expand Down
Expand Up @@ -21,6 +21,12 @@
* The default {@link Http2SettingsAckFrame} implementation.
*/
final class DefaultHttp2SettingsAckFrame implements Http2SettingsAckFrame {

@Override
public byte frameType() {
return Http2FrameTypes.SETTINGS;
}

@Override
public String name() {
return "SETTINGS(ACK)";
Expand Down
Expand Up @@ -37,6 +37,11 @@ public Http2Settings settings() {
return settings;
}

@Override
public byte frameType() {
return Http2FrameTypes.SETTINGS;
}

@Override
public String name() {
return "SETTINGS";
Expand Down
Expand Up @@ -36,6 +36,11 @@ public DefaultHttp2WindowUpdateFrame stream(Http2FrameStream stream) {
return this;
}

@Override
public byte frameType() {
return Http2FrameTypes.WINDOW_UPDATE;
}

@Override
public String name() {
return "WINDOW_UPDATE";
Expand Down
Expand Up @@ -15,12 +15,20 @@
*/
package io.netty.handler.codec.http2;

import io.netty.util.NotImplementedYetException;
import io.netty.util.internal.UnstableApi;

/** An HTTP/2 frame. */
@UnstableApi
public interface Http2Frame {

/**
* Returns the type of the HTTP/2 frame e.g. DATA, GOAWAY, etc.
*/
default byte frameType() {
throw new NotImplementedYetException();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think with Java 8's default method, this will not cause any problem.


/**
* Returns the name of the HTTP/2 frame e.g. DATA, GOAWAY, etc.
*/
Expand Down
Expand Up @@ -28,6 +28,7 @@ public interface Http2UnknownFrame extends Http2StreamFrame, ByteBufHolder {
@Override
Http2UnknownFrame stream(Http2FrameStream stream);

@Override
byte frameType();

Http2Flags flags();
Expand Down
27 changes: 27 additions & 0 deletions common/src/main/java/io/netty/util/NotImplementedYetException.java
@@ -0,0 +1,27 @@
/*
* Copyright 2020 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

package io.netty.util;

public final class NotImplementedYetException extends RuntimeException {
public NotImplementedYetException(String message) {
super(message);
}

public NotImplementedYetException() {
super("Not implemented yet.");
}
}
6 changes: 6 additions & 0 deletions pom.xml
Expand Up @@ -1323,6 +1323,12 @@
<new>method io.netty.handler.codec.http2.Http2ConnectionHandlerBuilder io.netty.handler.codec.http2.Http2ConnectionHandlerBuilder::decoderEnforceMaxRstFramesPerWindow(int, int)</new>
<justification>Acceptable incompatibility for required change, because the method was not previously exposed; protected visiblity in super-class, not made public in final sub-class until now</justification>
</item>
<item>
<ignore>true</ignore>
<code>java.method.addedToInterface</code>
<new>method byte io.netty.handler.codec.http2.Http2Frame::frameType()</new>
<justification>Acceptable incompatibility for required change</justification>
</item>
</differences>
</revapi.differences>
</analysisConfiguration>
Expand Down