-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Supressing warning messages on Netty deprecated Handler object
- Loading branch information
Showing
4 changed files
with
120 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...m.ibm.ws.transport.http/src/io/openliberty/http/netty/channel/AllocatorContextSetter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package io.openliberty.http.netty.channel; | ||
|
||
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.channel.ChannelInboundHandlerAdapter; | ||
import io.netty.channel.RecvByteBufAllocator; | ||
|
||
/** | ||
* A handler that, when added to the pipeline, checks if the current channel's | ||
* {@link RecvByteBufAllocator.Handle} is a {@link LoggingRecvByteBufAllocator.LoggingHandle} | ||
* and sets the {@link ChannelHandlerContext} so the allocator can log | ||
* read requests with contextual information. | ||
*/ | ||
public class AllocatorContextSetter extends ChannelInboundHandlerAdapter { | ||
|
||
/** | ||
* Constructs a new context setter for the specified logging allocator. | ||
* | ||
*/ | ||
public AllocatorContextSetter() {} | ||
|
||
/** | ||
* Called when the handler is added to the pipeline. Checks the current | ||
* {@link RecvByteBufAllocator.Handle} and sets the context if it's a logging handle. | ||
* | ||
* @param ctx the context for this handler | ||
* @throws Exception if any error occurs | ||
*/ | ||
@Override | ||
@SuppressWarnings("deprecation") | ||
public void handlerAdded(ChannelHandlerContext ctx) throws Exception { | ||
super.handlerAdded(ctx); | ||
|
||
// Netty doesn't have an non-deprecated approach, so for now | ||
// suppress the warnings. | ||
RecvByteBufAllocator.Handle handle = ctx.channel().unsafe().recvBufAllocHandle(); | ||
|
||
// If the handle is one of our logging handles, set the context to enable logging | ||
if (handle instanceof LoggingRecvByteBufAllocator.LoggingHandle) { | ||
((LoggingRecvByteBufAllocator.LoggingHandle) handle).setChannelHandlerContext(ctx); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
dev/com.ibm.ws.transport.http/src/io/openliberty/http/netty/channel/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
|
||
@org.osgi.annotation.versioning.Version("1.0") | ||
package io.openliberty.http.netty.channel; |