hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [1/2] httpcomponents-core git commit: Compatibility with Java 9 (tested with Oracle JDK 9.0.1)
Date Fri, 20 Oct 2017 14:46:08 GMT
Repository: httpcomponents-core
Updated Branches:
  refs/heads/master a85694c58 -> 1464955e4


Compatibility with Java 9 (tested with Oracle JDK 9.0.1)


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/6349e6c2
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/6349e6c2
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/6349e6c2

Branch: refs/heads/master
Commit: 6349e6c24443c10dc91408e309ad1689e1c2d1cb
Parents: a85694c
Author: Oleg Kalnichevski <olegk@apache.org>
Authored: Fri Oct 20 16:39:53 2017 +0200
Committer: Oleg Kalnichevski <olegk@apache.org>
Committed: Fri Oct 20 16:39:53 2017 +0200

----------------------------------------------------------------------
 .../Http2SSLRequestExecutionExample.java        | 13 +++------
 .../nio/Http2ProtocolNegotiationTest.java       | 28 +++++++++-----------
 2 files changed, 17 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/6349e6c2/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2SSLRequestExecutionExample.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2SSLRequestExecutionExample.java
b/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2SSLRequestExecutionExample.java
index ea6a185..5f9151c 100644
--- a/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2SSLRequestExecutionExample.java
+++ b/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2SSLRequestExecutionExample.java
@@ -92,16 +92,11 @@ public class Http2SSLRequestExecutionExample {
 
                     @Override
                     public TlsDetails verify(final NamedEndpoint endpoint, final SSLEngine
sslEngine) throws SSLException {
-                        // IMPORTANT
-                        // In order for HTTP/2 protocol negotiation to succeed one must allow
access
-                        // to Java 9 specific properties of SSLEngine via reflection
-                        // by adding the following line to the JVM arguments
-                        //
-                        // --add-opens java.base/sun.security.ssl=ALL-UNNAMED
-                        //
-                        // or uncomment the method below
-
+                        // IMPORTANT uncomment the following line when running Java 9 or
older
+                        // in order to avoid the illegal reflective access operation warning
+                        // ====
                         // return new TlsDetails(sslEngine.getSession(), sslEngine.getApplicationProtocol());
+                        // ====
                         return null;
                     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/6349e6c2/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ProtocolNegotiationTest.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ProtocolNegotiationTest.java
b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ProtocolNegotiationTest.java
index a652875..109e03e 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ProtocolNegotiationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ProtocolNegotiationTest.java
@@ -180,29 +180,29 @@ public class Http2ProtocolNegotiationTest {
 
     };
 
-    private static int version;
+    private static int javaVersion;
 
     @BeforeClass
     public static void determineJavaVersion() {
-        version = 7;
+        javaVersion = 7;
         final String s = System.getProperty("java.version");
-        if (s.equals("9-ea")) {
-            version = 9;
-        }
         final String[] parts = s.split("\\.");
-        if (parts.length >= 2) {
-            if (parts[0].equals("1")) {
-                try {
-                    version = Integer.parseInt(parts[1]);
-                } catch (NumberFormatException ignore) {
+        if (parts.length > 0) {
+            try {
+                final int majorVersion = Integer.parseInt(parts[0]);
+                if (majorVersion > 1) {
+                    javaVersion = majorVersion;
+                } else if (majorVersion == 1 && parts.length > 1) {
+                    javaVersion = Integer.parseInt(parts[1]);
                 }
+            } catch (final NumberFormatException ignore) {
             }
         }
     }
 
     @Before
     public void checkVersion() {
-        Assume.assumeTrue("Java version must be 1.8 or greater", version > 7);
+        Assume.assumeTrue("Java version must be 1.8 or greater", javaVersion > 7);
     }
 
     @Test
@@ -272,12 +272,10 @@ public class Http2ProtocolNegotiationTest {
         final HttpResponse response1 = message1.getHead();
         Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
 
-        if (version < 9) {
+        if (javaVersion < 9) {
             Assert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_1_1));
         } else {
-//            Assert.assertThat("Requires --add-opens java.base/sun.security.ssl=ALL-UNNAMED
with Java 1.9+ " +
-//                    " in order to enable reflective access to SSLEngine",
-//                    response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_2));
+            Assert.assertThat(response1.getVersion(), CoreMatchers.<ProtocolVersion>equalTo(HttpVersion.HTTP_2));
         }
     }
 


Mime
View raw message