913a5000d2289e1ed3157d7b7ec5addb6c062464
[so/libs.git] /
1 package com.woorea.openstack.connector;
2
3 import java.io.FilterInputStream;
4 import java.io.IOException;
5 import java.io.InputStream;
6 import java.net.SocketException;
7
8 import org.jboss.resteasy.client.ClientExecutor;
9
10
11 public class RESTEasyInputStream extends FilterInputStream {
12
13         protected ClientExecutor clientExecutor;
14
15         public RESTEasyInputStream(InputStream inputStream, ClientExecutor clientExecutor) {
16                 super(inputStream);
17                 this.clientExecutor = clientExecutor;
18         }
19
20         @Override
21         public void close() throws IOException {
22                 try {
23                         clientExecutor.close();
24                 } catch (Exception e) {
25                         // Silently skip errors in the socket close errors
26                 }
27
28                 try {
29                         super.close();
30                 } catch (SocketException e) {
31                         // We expect this exception because the socket is closed
32                 } catch (IllegalStateException e) {
33                         // We expect this exception because the socket is closed (httpclient 4.2)
34                 }
35         }
36
37 }