diff --git a/extras/tls-sni/src/main/java/org/glassfish/grizzly/sni/SNIFilter.java b/extras/tls-sni/src/main/java/org/glassfish/grizzly/sni/SNIFilter.java index cf1346c650..88649ead03 100644 --- a/extras/tls-sni/src/main/java/org/glassfish/grizzly/sni/SNIFilter.java +++ b/extras/tls-sni/src/main/java/org/glassfish/grizzly/sni/SNIFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -38,7 +38,6 @@ import org.glassfish.grizzly.ssl.SSLEngineConfigurator; import org.glassfish.grizzly.ssl.SSLFilter; import org.glassfish.grizzly.utils.Charsets; -import org.glassfish.grizzly.utils.JdkVersion; /** * TLS Server Name Indication (SNI) {@link Filter} implementation. This filter supports SNI extension on both client and @@ -57,7 +56,6 @@ */ public class SNIFilter extends SSLFilter { private static final Logger LOGGER = Grizzly.logger(SNIFilter.class); - private static final boolean JDK7_OR_HIGHER = JdkVersion.getJdkVersion().compareTo(JdkVersion.parseVersion("1.7")) >= 0; private static final byte HANDSHAKE_TYPE = 0x16; private static final int MIN_TLS_VERSION = 0x0301; @@ -125,10 +123,6 @@ public SNIClientConfigResolver getClientSSLConfigResolver() { * @param resolver */ public void setClientSSLConfigResolver(final SNIClientConfigResolver resolver) { - if (!JDK7_OR_HIGHER) { - LOGGER.warning("Client side SNI support requires JDK 1.7+"); - } - this.clientResolver = resolver; } @@ -141,10 +135,6 @@ protected SSLTransportFilterWrapper createOptimizedTransportFilter(final Transpo @Override public NextAction handleConnect(final FilterChainContext ctx) throws IOException { - if (!JDK7_OR_HIGHER) { - return super.handleConnect(ctx); - } - // new client-side connection final Connection c = ctx.getConnection(); diff --git a/extras/tls-sni/src/test/java/org/glassfish/grizzly/sni/SNITest.java b/extras/tls-sni/src/test/java/org/glassfish/grizzly/sni/SNITest.java index 2f647d4420..46b9ec7a54 100644 --- a/extras/tls-sni/src/test/java/org/glassfish/grizzly/sni/SNITest.java +++ b/extras/tls-sni/src/test/java/org/glassfish/grizzly/sni/SNITest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -34,7 +34,6 @@ import org.glassfish.grizzly.ssl.SSLContextConfigurator; import org.glassfish.grizzly.ssl.SSLEngineConfigurator; import org.glassfish.grizzly.utils.Futures; -import org.glassfish.grizzly.utils.JdkVersion; import org.glassfish.grizzly.utils.StringFilter; import org.junit.Test; @@ -48,9 +47,7 @@ @SuppressWarnings("unchecked") public class SNITest { public static final int PORT = 19283; - private static final boolean JDK7_OR_HIGHER = JdkVersion.getJdkVersion() - .compareTo(JdkVersion.parseVersion("1.7")) >= 0; - + @Test public void testClientServerSNI() throws Exception { final String sniHostValue = "sni-test.com"; @@ -58,11 +55,7 @@ public void testClientServerSNI() throws Exception { final Attribute sniHostAttr = Grizzly.DEFAULT_ATTRIBUTE_BUILDER.createAttribute("sni-host-attr"); - - if (!JDK7_OR_HIGHER) { - return; - } - + final SSLEngineConfigurator sslServerEngineConfig = new SSLEngineConfigurator( createSSLContextConfigurator().createSSLContext(), diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/nio/transport/UDPNIOConnection.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/nio/transport/UDPNIOConnection.java index e5aa6ea35a..b7f9b73495 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/nio/transport/UDPNIOConnection.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/nio/transport/UDPNIOConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -42,7 +42,6 @@ import org.glassfish.grizzly.nio.SelectorRunner; import org.glassfish.grizzly.utils.Exceptions; import org.glassfish.grizzly.utils.Holder; -import org.glassfish.grizzly.utils.JdkVersion; import org.glassfish.grizzly.utils.NullaryFunction; /** @@ -65,28 +64,25 @@ public class UDPNIOConnection extends NIOConnection { private static final Method MK_UNBLOCK_METHOD; static { - JdkVersion jdkVersion = JdkVersion.getJdkVersion(); - JdkVersion minimumVersion = JdkVersion.parseVersion("1.7.0"); boolean isInitialized = false; Method join = null, joinWithSource = null, mkGetNetworkInterface = null, mkGetSourceAddress = null, mkDrop = null, mkBlock = null, mkUnblock = null; - if (minimumVersion.compareTo(jdkVersion) <= 0) { // If JDK version is >= 1.7 - try { - join = DatagramChannel.class.getMethod("join", InetAddress.class, NetworkInterface.class); - joinWithSource = DatagramChannel.class.getMethod("join", InetAddress.class, NetworkInterface.class, InetAddress.class); - final Class membershipKeyClass = loadClass("java.nio.channels.MembershipKey"); + try { + join = DatagramChannel.class.getMethod("join", InetAddress.class, NetworkInterface.class); + joinWithSource = DatagramChannel.class.getMethod("join", InetAddress.class, NetworkInterface.class, InetAddress.class); - mkGetNetworkInterface = membershipKeyClass.getDeclaredMethod("networkInterface"); - mkGetSourceAddress = membershipKeyClass.getDeclaredMethod("sourceAddress"); - mkDrop = membershipKeyClass.getDeclaredMethod("drop"); + final Class membershipKeyClass = loadClass("java.nio.channels.MembershipKey"); - mkBlock = membershipKeyClass.getDeclaredMethod("block", InetAddress.class); - mkUnblock = membershipKeyClass.getDeclaredMethod("unblock", InetAddress.class); - isInitialized = true; - } catch (Throwable t) { - LOGGER.log(Level.WARNING, LogMessages.WARNING_GRIZZLY_CONNECTION_UDPMULTICASTING_EXCEPTIONE(), t); - } + mkGetNetworkInterface = membershipKeyClass.getDeclaredMethod("networkInterface"); + mkGetSourceAddress = membershipKeyClass.getDeclaredMethod("sourceAddress"); + mkDrop = membershipKeyClass.getDeclaredMethod("drop"); + + mkBlock = membershipKeyClass.getDeclaredMethod("block", InetAddress.class); + mkUnblock = membershipKeyClass.getDeclaredMethod("unblock", InetAddress.class); + isInitialized = true; + } catch (Throwable t) { + LOGGER.log(Level.WARNING, LogMessages.WARNING_GRIZZLY_CONNECTION_UDPMULTICASTING_EXCEPTIONE(), t); } if (isInitialized) { diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/ssl/SSLFilter.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/ssl/SSLFilter.java index 85f098c794..bbe7cd9fb9 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/ssl/SSLFilter.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/ssl/SSLFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -42,7 +42,6 @@ import org.glassfish.grizzly.filterchain.FilterChainContext.Operation; import org.glassfish.grizzly.filterchain.NextAction; import org.glassfish.grizzly.utils.Exceptions; -import org.glassfish.grizzly.utils.JdkVersion; /** * SSL {@link Filter} to operate with SSL encrypted data. @@ -51,7 +50,6 @@ */ public class SSLFilter extends SSLBaseFilter { private static final Logger LOGGER = Grizzly.logger(SSLFilter.class); - private static final boolean IS_JDK7_OR_HIGHER = JdkVersion.getJdkVersion().compareTo("1.7.0") >= 0; private final Attribute handshakeContextAttr; private final SSLEngineConfigurator clientSSLEngineConfigurator; @@ -268,8 +266,7 @@ protected Buffer doHandshakeStep(final SSLConnectionContext sslCtx, final Filter protected SSLEngine createClientSSLEngine(final SSLConnectionContext sslCtx, final SSLEngineConfigurator sslEngineConfigurator) { - return IS_JDK7_OR_HIGHER ? sslEngineConfigurator.createSSLEngine(HostNameResolver.getPeerHostName(sslCtx.getConnection()), -1) - : sslEngineConfigurator.createSSLEngine(); + return sslEngineConfigurator.createSSLEngine(HostNameResolver.getPeerHostName(sslCtx.getConnection()), -1); } // ----------------------------------------------------------- Inner Classes diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/utils/JdkVersion.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/utils/JdkVersion.java deleted file mode 100644 index b60472746b..0000000000 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/utils/JdkVersion.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package org.glassfish.grizzly.utils; - -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.glassfish.grizzly.Grizzly; - -/** - * - * @since 2.2.11 - */ -public class JdkVersion implements Comparable { - private static final Logger LOGGER = Grizzly.logger(JdkVersion.class); - - // take max 4 parts of the JDK version and cut the rest (usually the build number) - private static final Pattern VERSION_PATTERN = Pattern.compile("([0-9]+)(\\.([0-9]+))?(\\.([0-9]+))?([_\\.]([0-9]+))?.*"); - - private static final JdkVersion UNKNOWN_VERSION = new JdkVersion(-1, -1, -1, -1); - private static final JdkVersion JDK_VERSION = parseVersion(System.getProperty("java.version")); - - private final int major; - private final int minor; - private final int maintenance; - private final int update; - - // ------------------------------------------------------------ Constructors - - private JdkVersion(final int major, final int minor, final int maintenance, final int update) { - this.major = major; - this.minor = minor; - this.maintenance = maintenance; - this.update = update; - } - - // ---------------------------------------------------------- Public Methods - - public static JdkVersion parseVersion(final String versionString) { - - try { - final Matcher matcher = VERSION_PATTERN.matcher(versionString); - if (matcher.matches()) { - return new JdkVersion(parseInt(matcher.group(1)), parseInt(matcher.group(3)), parseInt(matcher.group(5)), parseInt(matcher.group(7))); - } - - LOGGER.log(Level.FINE, "Can't parse the JDK version {0}", versionString); - - } catch (Exception e) { - LOGGER.log(Level.FINE, "Error parsing the JDK version " + versionString, e); - } - - return UNKNOWN_VERSION; - } - - public static JdkVersion getJdkVersion() { - return JDK_VERSION; - } - - @SuppressWarnings("UnusedDeclaration") - public int getMajor() { - return major; - } - - @SuppressWarnings("UnusedDeclaration") - public int getMinor() { - return minor; - } - - @SuppressWarnings("UnusedDeclaration") - public int getMaintenance() { - return maintenance; - } - - @SuppressWarnings("UnusedDeclaration") - public int getUpdate() { - return update; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("JdkVersion"); - sb.append("{major=").append(major); - sb.append(", minor=").append(minor); - sb.append(", maintenance=").append(maintenance); - sb.append(", update=").append(update); - sb.append('}'); - return sb.toString(); - } - - // ------------------------------------------------- Methods from Comparable - - public int compareTo(String versionString) { - return compareTo(JdkVersion.parseVersion(versionString)); - } - - @Override - public int compareTo(JdkVersion otherVersion) { - if (major < otherVersion.major) { - return -1; - } - if (major > otherVersion.major) { - return 1; - } - if (minor < otherVersion.minor) { - return -1; - } - if (minor > otherVersion.minor) { - return 1; - } - if (maintenance < otherVersion.maintenance) { - return -1; - } - if (maintenance > otherVersion.maintenance) { - return 1; - } - if (update < otherVersion.update) { - return -1; - } - if (update > otherVersion.update) { - return 1; - } - return 0; - } - - private static int parseInt(final String s) { - return s != null ? Integer.parseInt(s) : 0; - } -} diff --git a/modules/http-server/src/main/java/org/glassfish/grizzly/http/server/ServerFilterConfiguration.java b/modules/http-server/src/main/java/org/glassfish/grizzly/http/server/ServerFilterConfiguration.java index 21a7d3729c..0050d8d302 100644 --- a/modules/http-server/src/main/java/org/glassfish/grizzly/http/server/ServerFilterConfiguration.java +++ b/modules/http-server/src/main/java/org/glassfish/grizzly/http/server/ServerFilterConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -19,7 +19,6 @@ import java.nio.charset.Charset; import org.glassfish.grizzly.Grizzly; -import org.glassfish.grizzly.utils.JdkVersion; /** * {@link HttpServerFilter} configuration. @@ -482,7 +481,7 @@ public void setSessionManager(SessionManager sessionManager) { private void configureSendFileSupport() { - if (System.getProperty("os.name").equalsIgnoreCase("linux") && !linuxSendFileSupported() || System.getProperty("os.name").equalsIgnoreCase("HP-UX")) { + if (System.getProperty("os.name").equalsIgnoreCase("HP-UX")) { sendFileEnabled = false; } @@ -493,10 +492,4 @@ private void configureSendFileSupport() { } - private static boolean linuxSendFileSupported() { - JdkVersion jdkVersion = JdkVersion.getJdkVersion(); - JdkVersion minimumVersion = JdkVersion.parseVersion("1.6.0_18"); - return minimumVersion.compareTo(jdkVersion) <= 0; - } - } diff --git a/samples/framework-samples/src/main/java/org/glassfish/grizzly/samples/udpmulticast/MulticastChat.java b/samples/framework-samples/src/main/java/org/glassfish/grizzly/samples/udpmulticast/MulticastChat.java index 2d4857d566..4bb5804b02 100644 --- a/samples/framework-samples/src/main/java/org/glassfish/grizzly/samples/udpmulticast/MulticastChat.java +++ b/samples/framework-samples/src/main/java/org/glassfish/grizzly/samples/udpmulticast/MulticastChat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -25,7 +25,6 @@ import org.glassfish.grizzly.nio.transport.UDPNIOConnection; import org.glassfish.grizzly.nio.transport.UDPNIOTransport; import org.glassfish.grizzly.nio.transport.UDPNIOTransportBuilder; -import org.glassfish.grizzly.utils.JdkVersion; import org.glassfish.grizzly.utils.StringFilter; /** @@ -96,14 +95,6 @@ public static void main(String[] args) throws Exception { } private void run() throws Exception { - // Check if current JDK version is higher or equals to 1.7.0 - final JdkVersion jdkVersion = JdkVersion.getJdkVersion(); - final JdkVersion minimumVersion = JdkVersion.parseVersion("1.7.0"); - - if (minimumVersion.compareTo(jdkVersion) > 0) { // If JDK version is >= 1.7 - System.out.println("Sample requires JDK 1.7+"); - System.exit(1); - } // Build FilterChain to parse incoming UDP packets and print to System.out final FilterChain filterChain = FilterChainBuilder.stateless()