JBoss is unresponsive with threads hanging in HttpURLConnection
Issue
- JBoss/Tomcat becomes unresponsive. In thread dumps, we've discovered that all the connector threads are getting stuck on a Socket, executing code in sun.net.www.http.HttpClient:
at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) at java.io.BufferedInputStream.read1(BufferedInputStream.java:258) at java.io.BufferedInputStream.read(BufferedInputStream.java:317) - locked <0xa3dd4820> (a java.io.BufferedInputStream) at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687) at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1195)
- I am using the below code and want to set
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
String userCredentials = "bpmsAdmin:Admin12345!";
String basicAuth = "Basic " + new String(new Base64().encode(userCredentials.getBytes()));
con.setRequestProperty ("Authorization", basicAuth);
con.setRequestMethod("POST");
con.setRequestProperty("User-Agent", USER_AGENT);
con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
Which code can I use for a rest client (can I use standard java SE code?) that I will also be able to specify timeout?
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 5.x
- 6.x
- 7.x
- Apache Tomcat
- 6.x
- 7.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.