Skip to content

Commit

Permalink
drop check on java version
Browse files Browse the repository at this point in the history
as java8 is a compile time requirement, the checks for jvm version
before java7 makes no sense anymore.

Remove unused JdkVersion class.

Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
  • Loading branch information
kofemann committed Jul 25, 2022
1 parent bdbe8cb commit ecfddb8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 209 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;

Expand All @@ -48,21 +47,15 @@
@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";
final String msg = "Hello world!";

final Attribute<String> sniHostAttr =
Grizzly.DEFAULT_ATTRIBUTE_BUILDER.createAttribute("sni-host-attr");

if (!JDK7_OR_HIGHER) {
return;
}


final SSLEngineConfigurator sslServerEngineConfig =
new SSLEngineConfigurator(
createSSLContextConfigurator().createSSLContext(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;

/**
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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<SSLHandshakeContext> handshakeContextAttr;
private final SSLEngineConfigurator clientSSLEngineConfigurator;
Expand Down Expand Up @@ -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
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,7 +19,6 @@
import java.nio.charset.Charset;

import org.glassfish.grizzly.Grizzly;
import org.glassfish.grizzly.utils.JdkVersion;

/**
* {@link HttpServerFilter} configuration.
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit ecfddb8

Please sign in to comment.