summaryrefslogtreecommitdiffstats
path: root/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyInputStream.java
blob: 913a5000d2289e1ed3157d7b7ec5addb6c062464 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.woorea.openstack.connector;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.SocketException;

import org.jboss.resteasy.client.ClientExecutor;


public class RESTEasyInputStream extends FilterInputStream {

	protected ClientExecutor clientExecutor;

	public RESTEasyInputStream(InputStream inputStream, ClientExecutor clientExecutor) {
		super(inputStream);
		this.clientExecutor = clientExecutor;
	}

	@Override
	public void close() throws IOException {
		try {
			clientExecutor.close();
		} catch (Exception e) {
			// Silently skip errors in the socket close errors
		}

		try {
			super.close();
		} catch (SocketException e) {
			// We expect this exception because the socket is closed
		} catch (IllegalStateException e) {
			// We expect this exception because the socket is closed (httpclient 4.2)
		}
	}

}