Commenting out "response.close();" has no effect. It still fails on
"client.close();".
java.lang.UnsupportedOperationException: method is not supported because of the
TLS half-close policy
at sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:765)
at sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:743)
at
org.apache.hc.core5.http.impl.io.BHttpConnectionBase.close(BHttpConnectionBase.java:255)
at
org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection.close(DefaultBHttpClientConnection.java:71)
at
org.apache.hc.client5.http.impl.io.DefaultManagedHttpClientConnection.close(DefaultManagedHttpClientConnection.java:176)
at
org.apache.hc.core5.pool.PoolEntry.discardConnection(PoolEntry.java:180)
at
org.apache.hc.core5.pool.StrictConnPool$PerRoutePool.shutdown(StrictConnPool.java:839)
at
org.apache.hc.core5.pool.StrictConnPool.close(StrictConnPool.java:142)
at
org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.close(PoolingHttpClientConnectionManager.java:277)
at
org.apache.hc.client5.http.impl.classic.InternalHttpClient.close(InternalHttpClient.java:198)
at
org.apache.hc.client5.http.impl.classic.InternalHttpClient.close(InternalHttpClient.java:188)
at
com.realobjects.util.url.http.client.J8HttpsErrorTest.main(J8HttpsErrorTest.java:21)
Bernhard
-----Original Message-----
From: Gary Gregory <[email protected]>
Sent: Tuesday, October 8, 2024 10:51
To: HttpClient User Discussion <[email protected]>
Subject: Re: Exception in version 5.4 with Java 8, potential bug
What happens if you remove "response.close();" ?
Gary
On Tue, Oct 8, 2024, 4:36 AM Bernhard Fey <[email protected]>
wrote:
> Hello, I hope this is the right place to report potential bugs.
>
> When updating to version 5.4 our Java 8 tests fail with the following
> exception:
>
> java.lang.UnsupportedOperationException: method is not supported
> because of the TLS half-close policy
> at sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:765)
> at sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:743)
> at
> org.apache.hc.core5.http.impl.io.BHttpConnectionBase.close(BHttpConnectionBase.java:255)
> at
> org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection.close(DefaultBHttpClientConnection.java:71)
> at org.apache.hc.client5.http.impl.io
> .DefaultManagedHttpClientConnection.close(DefaultManagedHttpClientConnection.java:176)
> at
> org.apache.hc.core5.pool.PoolEntry.discardConnection(PoolEntry.java:180)
> at
> org.apache.hc.core5.pool.StrictConnPool$PerRoutePool.shutdown(StrictConnPool.java:839)
> at
> org.apache.hc.core5.pool.StrictConnPool.close(StrictConnPool.java:142)
> at org.apache.hc.client5.http.impl.io
> .PoolingHttpClientConnectionManager.close(PoolingHttpClientConnectionManager.java:277)
> at
> org.apache.hc.client5.http.impl.classic.InternalHttpClient.close(InternalHttpClient.java:198)
> at
> org.apache.hc.client5.http.impl.classic.InternalHttpClient.close(InternalHttpClient.java:188)
> at J8HttpsErrorTest.main(J8HttpsErrorTest.java:21)
>
> It seems to be a bug, but please let me know if it is a mistake on our
> side.
>
> I have put together the following test class, which fails in Java 8
> with the above exception, but finishes correctly with Java 11 (tested
> on Windows 10, but the Java 8 exception also occurs on Linux in our
> integration):
>
> import org.apache.hc.client5.http.classic.methods.HttpGet;
> import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
> import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
> public class J8HttpsErrorTest {
> public static void main(String[] args) {
> System.out.println(System.getProperty("java.vm.vendor")
> + " " + System.getProperty("java.vm.name")
> + " " + System.getProperty("java.vm.version"));
> try {
> CloseableHttpClient client =
> HttpClientBuilder.create().build();
> String responseStr = client.execute(new HttpGet(
> https://www.google.com/), response -> {
> byte[] content = new byte[1024];
> int length =
> response.getEntity().getContent().read(content); // just read the
> first view bytes to show the connection works
> String str = new String(content, 0, length);
> response.close();
> return str;
> });
> System.out.println("Sucessfully loaded: " +
> responseStr.replaceAll(file://s, " "));
> System.out.println(">>>");
> client.close(); // this causes the
> ExceUnsupportedOperationExceptionption in Java 8
> System.out.println("<<<"); // <== success expected, except
> for Java 8
> } catch (UnsupportedOperationException e) {
> System.out.println("!!!");
> e.printStackTrace(System.out); // <== exception expected
> for Java 8
> } catch (Throwable e) {
> System.out.println("!!!!!");
> e.printStackTrace(System.out); // unexpected!
> }
> }
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>