diff --git a/discovery/src/main/java/com/proofpoint/discovery/client/ServiceTypeImpl.java b/discovery/src/main/java/com/proofpoint/discovery/client/ServiceTypeImpl.java index 9240adc7b..3e77f17ff 100644 --- a/discovery/src/main/java/com/proofpoint/discovery/client/ServiceTypeImpl.java +++ b/discovery/src/main/java/com/proofpoint/discovery/client/ServiceTypeImpl.java @@ -39,8 +39,7 @@ public String value() @Override public String toString() { - var isJava11 = System.getProperty("java.version").startsWith("11."); - return String.format("@%s(%s\"%s\")", ServiceType.class.getName(), isJava11 ? "value=" : "", value.replaceAll("([\\\\\"])", "\\\\$1")); + return String.format("@%s(%s\"%s\")", ServiceType.class.getName(), "", value.replaceAll("([\\\\\"])", "\\\\$1")); } @Override diff --git a/http-client/src/main/java/com/proofpoint/http/client/ServiceTypeImpl.java b/http-client/src/main/java/com/proofpoint/http/client/ServiceTypeImpl.java index 36ec3727c..dfbd9afae 100644 --- a/http-client/src/main/java/com/proofpoint/http/client/ServiceTypeImpl.java +++ b/http-client/src/main/java/com/proofpoint/http/client/ServiceTypeImpl.java @@ -39,8 +39,7 @@ public String value() @Override public String toString() { - var isJava11 = System.getProperty("java.version").startsWith("11."); - return String.format("@%s(%s\"%s\")", ServiceType.class.getName(), isJava11 ? "value=" : "", value.replaceAll("([\\\\\"])", "\\\\$1")); + return String.format("@%s(%s\"%s\")", ServiceType.class.getName(), "", value.replaceAll("([\\\\\"])", "\\\\$1")); } @Override diff --git a/http-client/src/main/java/com/proofpoint/http/client/jetty/JettyHttpClient.java b/http-client/src/main/java/com/proofpoint/http/client/jetty/JettyHttpClient.java index 187d31aaf..6fc140776 100644 --- a/http-client/src/main/java/com/proofpoint/http/client/jetty/JettyHttpClient.java +++ b/http-client/src/main/java/com/proofpoint/http/client/jetty/JettyHttpClient.java @@ -76,8 +76,7 @@ public class JettyHttpClient { private static final Logger log = Logger.get(JettyHttpClient.class); - private static final String[] ENABLED_PROTOCOLS = System.getProperty("java.version").matches("11(\\.0\\.[12])?") ? - new String[] {"TLSv1.2"} : new String[] {"TLSv1.2", "TLSv1.3"}; + private static final String[] ENABLED_PROTOCOLS = {"TLSv1.2", "TLSv1.3"}; private static final String[] ENABLED_CIPHERS = { "TLS_AES_128_GCM_SHA256", "TLS_AES_256_GCM_SHA384", diff --git a/http-server/src/main/java/com/proofpoint/http/server/HttpServer.java b/http-server/src/main/java/com/proofpoint/http/server/HttpServer.java index fba441252..151317874 100644 --- a/http-server/src/main/java/com/proofpoint/http/server/HttpServer.java +++ b/http-server/src/main/java/com/proofpoint/http/server/HttpServer.java @@ -93,8 +93,7 @@ public class HttpServer { - private static final String[] ENABLED_PROTOCOLS = System.getProperty("java.version").matches("11(\\.0\\.[12])?") ? - new String[] {"TLSv1.2"} : new String[] {"TLSv1.2", "TLSv1.3"}; + private static final String[] ENABLED_PROTOCOLS = {"TLSv1.2", "TLSv1.3"}; private static final String[] ENABLED_CIPHERS = { "TLS_AES_128_GCM_SHA256", "TLS_AES_256_GCM_SHA384", @@ -270,8 +269,6 @@ protected void runJob(Runnable job) private ServerConnector createHttpsServerConnector(HttpServerConfig config, ServerSocketChannel serverSocketChannel, HttpConfiguration configuration, Executor threadPool, int acceptors, int selectors) throws IOException { - checkState(!System.getProperty("java.version").startsWith("1.8."), "Java 8 is no longer supported"); - SecureRequestCustomizer customizer = new SecureRequestCustomizer(); customizer.setSniHostCheck(false); customizer.setSniRequired(false); diff --git a/jmx/src/main/java/com/proofpoint/jmx/JavaVersion.java b/jmx/src/main/java/com/proofpoint/jmx/JavaVersion.java deleted file mode 100644 index 7e688a5b4..000000000 --- a/jmx/src/main/java/com/proofpoint/jmx/JavaVersion.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.proofpoint.jmx; - -import com.google.common.base.StandardSystemProperty; - -import java.util.Objects; -import java.util.Optional; -import java.util.OptionalInt; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static com.google.common.base.MoreObjects.toStringHelper; -import static java.lang.String.format; - -// TODO: remove this when we upgrade to Java 9 (replace with java.lang.Runtime.getVersion()) -class JavaVersion -{ - // As described in JEP-223 - private static final String VERSION_NUMBER = "(?[1-9][0-9]*)(\\.(?(0|[1-9][0-9]*))(\\.(?:(0|[1-9][0-9]*)))*)?"; - private static final String PRE = "(?:-(?:[a-zA-Z0-9]+))?"; - private static final String BUILD = "(?:(?:\\+)(?:0|[1-9][0-9]*)?)?"; - private static final String OPT = "(?:-(?:[-a-zA-Z0-9.]+))?"; - private static final Pattern PATTERN = Pattern.compile(VERSION_NUMBER + PRE + BUILD + OPT); - - // For Java 8 and below - private static final Pattern LEGACY_PATTERN = Pattern.compile("1\\.(?[0-9]+)(\\.(?(0|[1-9][0-9]*)))?(_(?[1-9][0-9]*))?(?:-[a-zA-Z0-9.]+)*"); - - private final int major; - private final int minor; - private final OptionalInt update; - - public static JavaVersion current() - { - return parse(StandardSystemProperty.JAVA_VERSION.value()); - } - - public static JavaVersion parse(String version) - { - Matcher matcher = LEGACY_PATTERN.matcher(version); - if (matcher.matches()) { - int major = Integer.parseInt(matcher.group("MAJOR")); - int minor = Optional.ofNullable(matcher.group("MINOR")) - .map(Integer::parseInt) - .orElse(0); - - String update = matcher.group("UPDATE"); - if (update == null) { - return new JavaVersion(major, minor); - } - - return new JavaVersion(major, minor, OptionalInt.of(Integer.parseInt(update))); - } - - matcher = PATTERN.matcher(version); - if (matcher.matches()) { - int major = Integer.parseInt(matcher.group("MAJOR")); - int minor = Optional.ofNullable(matcher.group("MINOR")) - .map(Integer::parseInt) - .orElse(0); - - return new JavaVersion(major, minor); - } - - throw new IllegalArgumentException(format("Cannot parse version %s", version)); - } - - public JavaVersion(int major, int minor, OptionalInt update) - { - this.major = major; - this.minor = minor; - this.update = update; - } - - public JavaVersion(int major, int minor) - { - this(major, minor, OptionalInt.empty()); - } - - public int getMajor() - { - return major; - } - - public int getMinor() - { - return minor; - } - - public OptionalInt getUpdate() - { - return update; - } - - @Override - public boolean equals(Object o) - { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - JavaVersion that = (JavaVersion) o; - return major == that.major && - minor == that.minor && - Objects.equals(update, that.update); - } - - @Override - public int hashCode() - { - return Objects.hash(major, minor, update); - } - - @Override - public String toString() - { - return toStringHelper(this) - .add("major", major) - .add("minor", minor) - .add("update", update) - .toString(); - } -} diff --git a/jmx/src/test/java/com/proofpoint/jmx/TestJavaVersion.java b/jmx/src/test/java/com/proofpoint/jmx/TestJavaVersion.java deleted file mode 100644 index e7715e30e..000000000 --- a/jmx/src/test/java/com/proofpoint/jmx/TestJavaVersion.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2017 Proofpoint, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.proofpoint.jmx; - -import org.testng.annotations.Test; - -import java.util.OptionalInt; - -import static org.testng.Assert.assertEquals; - -public class TestJavaVersion -{ - @Test - public void testParseLegacy() - { - assertEquals(JavaVersion.parse("1.8"), new JavaVersion(8, 0)); - assertEquals(JavaVersion.parse("1.8.0"), new JavaVersion(8, 0)); - assertEquals(JavaVersion.parse("1.8.0_5"), new JavaVersion(8, 0, OptionalInt.of(5))); - assertEquals(JavaVersion.parse("1.8.0_20"), new JavaVersion(8, 0, OptionalInt.of(20))); - assertEquals(JavaVersion.parse("1.8.1_25"), new JavaVersion(8, 1, OptionalInt.of(25))); - assertEquals(JavaVersion.parse("1.8.0_60-ea"), new JavaVersion(8, 0, OptionalInt.of(60))); - assertEquals(JavaVersion.parse("1.8.0_131-foo-bar-baz-qux"), new JavaVersion(8, 0, OptionalInt.of(131))); - } - - @Test - public void testParseNew() - { - assertEquals(JavaVersion.parse("9-ea+19"), new JavaVersion(9, 0)); - assertEquals(JavaVersion.parse("9+100"), new JavaVersion(9, 0)); - assertEquals(JavaVersion.parse("9.0.1+20"), new JavaVersion(9, 0)); - assertEquals(JavaVersion.parse("9.1.1+20"), new JavaVersion(9, 1)); - assertEquals(JavaVersion.parse("11.0.9"), new JavaVersion(11, 0)); - assertEquals(JavaVersion.parse("11.0.9.1"), new JavaVersion(11, 0)); - assertEquals(JavaVersion.parse("11.0.9.1+1-LTS"), new JavaVersion(11, 0)); - } -}