You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/10/20 14:46:08 UTC

[1/2] httpcomponents-core git commit: Compatibility with Java 9 (tested with Oracle JDK 9.0.1)

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 <ol...@apache.org>
Authored: Fri Oct 20 16:39:53 2017 +0200
Committer: Oleg Kalnichevski <ol...@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));
         }
     }
 


[2/2] httpcomponents-core git commit: Added Oracle JDK 9 to Travis CI config

Posted by ol...@apache.org.
Added Oracle JDK 9 to Travis CI config


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

Branch: refs/heads/master
Commit: 1464955e4e4c7ac1a04b2febbd9641b04c0b9f42
Parents: 6349e6c
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Fri Oct 20 16:45:51 2017 +0200
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Fri Oct 20 16:45:51 2017 +0200

----------------------------------------------------------------------
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/1464955e/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index c1335bd..8893f59 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,6 +19,7 @@ sudo: false
 jdk:
   - openjdk7
   - oraclejdk8
+  - oraclejdk9
 
 after_success:
   - mvn clean cobertura:cobertura coveralls:report