While reading content ( attachment in response ) from the input stream in SSL
mode throws java.net.SocketException: Socket Closed
Note: This Exception is thrown only when response has an attachment.
In non ssl mode there is no issue.
InputStream instream = entity.getContent();
int l;
byte[] tmp = new byte[2048];
while ((l = instream.read(tmp)) != -1) {
}
java.net.SocketException: Socket Closed
at java.net.PlainSocketImpl.setOption(PlainSocketImpl.java:201)
at java.net.Socket.setSoTimeout(Socket.java:997)
at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.setSoTimeout(SSLSocketImpl.java:2061)
at
org.apache.http.impl.io.SocketInputBuffer.isDataAvailable(SocketInputBuffer.java:145)
at
org.apache.http.impl.io.IdentityInputStream.available(IdentityInputStream.java:74)
at
org.apache.http.conn.EofSensorInputStream.available(EofSensorInputStream.java:171)
Making use of BufferedHttpEntity solves this issue. (Is it a right approach?)
entity = new BufferedHttpEntity(entity)
entity.getContent();
Use of BufferedHttpEntity() has any performance impact?