From fef73487a3337674d0c37ead96223eb6e30e02e5 Mon Sep 17 00:00:00 2001 From: Emmanuel Hugonnet Date: Thu, 16 Nov 2023 20:52:23 +0100 Subject: [PATCH] Updating to support Java 11 * Using ByteBufferPool instead of ByteBufferSlicePool. * Creating a profile for Java > 8 with BC as a dependency for certificate creation and an updated version of jboss logging. Signed-off-by: Emmanuel Hugonnet --- pom.xml | 141 ++++++++++++------ .../netty/buffer/XnioByteBufAllocator.java | 5 +- .../xnio/netty/buffer/XnioByteBufUtil.java | 8 +- .../netty/transport/XnioTestsuiteUtils.java | 6 +- 4 files changed, 108 insertions(+), 52 deletions(-) diff --git a/pom.xml b/pom.xml index 02b7ccf..305dcff 100644 --- a/pom.xml +++ b/pom.xml @@ -33,36 +33,36 @@ jar - JBoss, a division of Red Hat - http://www.jboss.org/ + JBoss, a division of Red Hat + http://www.jboss.org/ - - ASL 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - + + ASL 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + - scm:git:git://github.com/xnio/netty-xnio-transport.git - scm:git:https://github.com/xnio/netty-xnio-transport.git - https://github.com/xnio/netty-xnio-transport + scm:git:git://github.com/xnio/netty-xnio-transport.git + scm:git:https://github.com/xnio/netty-xnio-transport.git + https://github.com/xnio/netty-xnio-transport HEAD - - jboss-releases-repository - JBoss Releases Repository - https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/ - - - jboss-snapshots-repository - JBoss Snapshots Repository - https://repository.jboss.org/nexus/content/repositories/snapshots/ - + + jboss-releases-repository + JBoss Releases Repository + https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/ + + + jboss-snapshots-repository + JBoss Snapshots Repository + https://repository.jboss.org/nexus/content/repositories/snapshots/ + @@ -99,6 +99,11 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.3 + @@ -125,25 +130,25 @@ test - - - org.junit.jupiter - junit-jupiter-api - ${junit.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit.version} - test - - - org.junit.jupiter - junit-jupiter-params - ${junit.version} - test - + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-params + ${junit.version} + test + org.jboss.xnio xnio-nio @@ -166,6 +171,56 @@ 5.9.0 + + + java11 + + [11,) + + + 3.5.3.Final + 1.70 + + + + org.bouncycastle + bcpkix-jdk15on + ${org.bouncycastle.version} + test + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + --add-opens java.base/jdk.internal.misc=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce-java + + enforce + + + + + [11,) + + + + + + + + + + @@ -191,10 +246,10 @@ https://repository.jboss.org/nexus/content/groups/public/ true - - - true - + + + true + diff --git a/src/main/java/org/xnio/netty/buffer/XnioByteBufAllocator.java b/src/main/java/org/xnio/netty/buffer/XnioByteBufAllocator.java index 82b3134..2fb18ee 100644 --- a/src/main/java/org/xnio/netty/buffer/XnioByteBufAllocator.java +++ b/src/main/java/org/xnio/netty/buffer/XnioByteBufAllocator.java @@ -19,6 +19,7 @@ import io.netty.buffer.AbstractByteBufAllocator; import io.netty.buffer.ByteBuf; import io.netty.util.internal.PlatformDependent; +import org.xnio.ByteBufferPool; import org.xnio.ByteBufferSlicePool; /** @@ -28,9 +29,9 @@ * @author Norman Maurer */ public final class XnioByteBufAllocator extends AbstractByteBufAllocator { - final ByteBufferSlicePool pool; + final ByteBufferPool pool; - public XnioByteBufAllocator(ByteBufferSlicePool pool) { + public XnioByteBufAllocator(ByteBufferPool pool) { if (pool == null) { throw new NullPointerException("pool"); } diff --git a/src/main/java/org/xnio/netty/buffer/XnioByteBufUtil.java b/src/main/java/org/xnio/netty/buffer/XnioByteBufUtil.java index c651d9f..0deeedc 100644 --- a/src/main/java/org/xnio/netty/buffer/XnioByteBufUtil.java +++ b/src/main/java/org/xnio/netty/buffer/XnioByteBufUtil.java @@ -17,10 +17,10 @@ package org.xnio.netty.buffer; import io.netty.util.internal.PlatformDependent; -import org.xnio.ByteBufferSlicePool; import org.xnio.Pooled; import java.nio.ByteBuffer; +import org.xnio.ByteBufferPool; /** * @author Norman Maurer @@ -31,10 +31,10 @@ private XnioByteBufUtil() { // Utility } - static Pooled allocateDirect(ByteBufferSlicePool pool, int initialCapacity) { + static Pooled allocateDirect(ByteBufferPool pool, int initialCapacity) { Pooled pooled; - if (initialCapacity <= pool.getBufferSize()) { - pooled = pool.allocate(); + if (initialCapacity <= pool.getSize()) { + pooled = new PooledByteBuf(pool.allocate()); } else { pooled = new PooledByteBuf(ByteBuffer.allocateDirect(initialCapacity)); } diff --git a/src/test/java/org/xnio/netty/transport/XnioTestsuiteUtils.java b/src/test/java/org/xnio/netty/transport/XnioTestsuiteUtils.java index ef1ba93..56ddfe6 100644 --- a/src/test/java/org/xnio/netty/transport/XnioTestsuiteUtils.java +++ b/src/test/java/org/xnio/netty/transport/XnioTestsuiteUtils.java @@ -21,13 +21,13 @@ import io.netty.buffer.ByteBufAllocator; import io.netty.channel.EventLoopGroup; import io.netty.testsuite.transport.TestsuitePermutation; -import org.xnio.ByteBufferSlicePool; import org.xnio.netty.buffer.XnioByteBufAllocator; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.xnio.ByteBufferPool; /** * @@ -45,8 +45,8 @@ final class XnioTestsuiteUtils { } static List newAllocators(List allocs) { - List allocators = new ArrayList(allocs); - allocators.add(new XnioByteBufAllocator(new ByteBufferSlicePool(1024 * 16, 1024 * 32))); + List allocators = new ArrayList<>(allocs); + allocators.add(new XnioByteBufAllocator(ByteBufferPool.LARGE_DIRECT)); return allocators; }