[ 
https://issues.apache.org/jira/browse/HTTPCORE-737?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17706562#comment-17706562
 ] 

Arun Katkere commented on HTTPCORE-737:
---------------------------------------

This seems to work with both Java 8 and Java 11.
{code:java}
diff --git a/pom.xml b/pom.xml
index 848bd461f..b468c3d0a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -84,6 +84,18 @@
     
<hc.animal-sniffer.signature.ignores>javax.net.ssl.SSLEngine,javax.net.ssl.SSLParameters,java.nio.ByteBuffer,java.nio.CharBuffer</hc.animal-sniffer.signature.ignores>
   </properties>
 
+  <profiles>
+    <profile>
+      <id>java-8-api</id>
+      <activation>
+        <jdk>[9,)</jdk>
+      </activation>
+      <properties>
+        <maven.compiler.release>8</maven.compiler.release>
+      </properties>
+    </profile>
+  </profiles>
+
   <dependencyManagement>
     <dependencies>
       <dependency>
 {code}

> HttpClient not working with Java 8 runtime
> ------------------------------------------
>
>                 Key: HTTPCORE-737
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-737
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore
>    Affects Versions: 5.2.1
>            Reporter: Arun Katkere
>            Priority: Major
>
> When we try to run HttpClient 5.2.1 with Java 8 runtime, it fails with:
>  
> {{java.lang.NoSuchMethodError: 
> java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;}}
> {{at org.apache.hc.core5.net.PercentCodec.decode(PercentCodec.java:155)}}
> {{at org.apache.hc.core5.net.PercentCodec.decode(PercentCodec.java:160)}}
> {{at org.apache.hc.core5.net.URIBuilder.parsePath(URIBuilder.java:277)}}
> {{at org.apache.hc.core5.net.URIBuilder.digestURI(URIBuilder.java:407)}}
> {{at org.apache.hc.core5.net.URIBuilder.<init>(URIBuilder.java:134)}}
> {{at org.apache.hc.core5.net.URIBuilder.<init>(URIBuilder.java:106)}}
> {{at 
> org.apache.hc.client5.http.impl.RequestSupport.extractPathPrefix(RequestSupport.java:49)}}
> {{at 
> org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:152)}}
> {{at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)}}
> {{at 
> org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:96)}}
> {{at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)}}
> {{at 
> org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:152)}}
> {{at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)}}
> {{at 
> org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:115)}}
> {{at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)}}
> {{at 
> org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:170)}}
> {{at 
> org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:123)}}
>  
> It runs fine in a Java 11 runtime.
>  
> Java 8 java.nio.ByteBuffer does not define “{{{}java.nio.ByteBuffer 
> flip({}}})” method. Instead it just inherits “{{{}java.nio.Buffer flip(){}}}” 
> from its super class. However, Java 9 and newer versions have the additional 
> flip method. I believe if pom.xml contains 
> {{<maven.compiler.release>8</maven.compiler.release>}} it should fix this 
> issue. Alternatively, this component can be built with Java 8.
> According to the documentation 
> [https://hc.apache.org/httpcomponents-client-5.2.x/quickstart.html] 
> "HttpClient 5.2 requires Java 1.8 or newer." so the expectation here is that 
> it works with Java 1.8/8 runtime.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to