Skip to content

Update maxOpenConnections tests and update Netty implementation #31225

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

Draft
wants to merge 4 commits into
base: integration
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2022 IBM Corporation and others.
* Copyright (c) 2021, 2025 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
Expand All @@ -14,6 +14,7 @@
import com.ibm.websphere.ras.Tr;
import com.ibm.websphere.ras.TraceComponent;

import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
Expand Down Expand Up @@ -47,6 +48,15 @@ public void channelActive(ChannelHandlerContext ctx) throws Exception {
long currentTime = System.currentTimeMillis();
if (currentTime > (lastConnExceededTime + 600000L)) {
String channelName = ctx.channel().attr(ConfigConstants.NAME_KEY).get();

// If the channelName is null check the parent for a name.
if (channelName == null) {
Channel parentChannel = ctx.channel().parent();
if (parentChannel != null) {
channelName = parentChannel.attr(ConfigConstants.NAME_KEY).get();
}
}

Tr.warning(tc, TCPMessageConstants.MAX_CONNS_EXCEEDED, channelName, maxConnections);
lastConnExceededTime = currentTime;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2023 IBM Corporation and others.
* Copyright (c) 2021, 2025 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
Expand Down Expand Up @@ -34,13 +34,13 @@ public class TCPChannelInitializerImpl extends ChannelInitializerWrapper {
TCPMessageConstants.TCP_BUNDLE, TCPChannelInitializerImpl.class.getName());

TCPConfigurationImpl config;

NettyFrameworkImpl bundle;
MaxOpenConnectionsHandler maxHandler;

public TCPChannelInitializerImpl(BootstrapConfiguration config, NettyFrameworkImpl bundle) {
this.bundle = bundle;
this.config = (TCPConfigurationImpl) config;
maxHandler = new MaxOpenConnectionsHandler(this.config.getMaxOpenConnections());
}

@Override
Expand All @@ -59,7 +59,6 @@ protected void initChannel(Channel channel) throws Exception {
if (config.getInactivityTimeout() > 0) {
channel.pipeline().addLast(NettyConstants.INACTIVITY_TIMEOUT_HANDLER_NAME, new InactivityTimeoutHandler(0, 0, config.getInactivityTimeout(), TimeUnit.MILLISECONDS));
}
MaxOpenConnectionsHandler maxHandler = new MaxOpenConnectionsHandler(config.getMaxOpenConnections());
if (config.getAccessLists() != null) {
AccessListHandler includeHandler = new AccessListHandler(config.getAccessLists());
channel.pipeline().addLast(NettyConstants.ACCESSLIST_HANDLER_NAME, includeHandler);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2022 IBM Corporation and others.
* Copyright (c) 2021, 2025 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
Expand Down Expand Up @@ -118,6 +118,10 @@ public TCPConfigurationImpl(Map<String, Object> options, boolean inbound) throws
this.channelProperties = options;

if (this.channelProperties != null) {
// Set the name of the channel before setting the values of the other properties. This ensures it is available
// if a validation error occurs.
this.externalName = (String) this.channelProperties.get(ConfigConstants.EXTERNAL_NAME);

// read in values now, to save time reading them in each time
// they are requested
setValues();
Expand Down Expand Up @@ -160,7 +164,10 @@ public AddressAndHostNameAccessLists getAccessLists() {

//@formatter:off
private boolean skipKey(String key) {
return key.equals("id") ||
// We set externalName in the constructor. If we don't skip it while processing the rest of the properties the below error occurs:
// CWWKO0212W: TCP Channel defaultHttpEndpoint has been constructed with an incorrect configuration property. Property Name: ExternalName Value: defaultHttpEndpoint
return key.equals(ConfigConstants.EXTERNAL_NAME) ||
key.equals("id") ||
key.equals("type") ||
key.startsWith("service.") ||
key.startsWith("component.") ||
Expand Down Expand Up @@ -199,13 +206,7 @@ private void setValues() throws NettyException {
value = entry.getValue();

if (skipKey(key)) {
// skip osgi standard properties
continue;
}

// add the name for the channel
if (key.equalsIgnoreCase(ConfigConstants.EXTERNAL_NAME)) {
this.externalName = (String) value;
// skip osgi standard properties and ExternalName
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@RunWith(Suite.class)
@SuiteClasses({
AccessListsTests.class,
MaxOpenConnectionsTest.class
MaxOpenConnectionsTests.class
})
public class FATSuite {

Expand Down

This file was deleted.

Loading