cleaned exception handling

This commit is contained in:
Adrian Cole 2011-04-20 17:37:02 -07:00
parent d0a5278ca0
commit cfb180f638

View File

@ -25,7 +25,6 @@ import static com.google.common.collect.Iterables.getLast;
import static com.google.common.io.ByteStreams.toByteArray; import static com.google.common.io.ByteStreams.toByteArray;
import static com.google.common.io.Closeables.closeQuietly; import static com.google.common.io.Closeables.closeQuietly;
import static org.jclouds.io.Payloads.newInputStreamPayload; import static org.jclouds.io.Payloads.newInputStreamPayload;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
@ -107,15 +106,12 @@ public class JavaUrlHttpCommandExecutorService extends BaseHttpCommandExecutorSe
InputStream in = null; InputStream in = null;
try { try {
in = consumeOnClose(connection.getInputStream()); in = consumeOnClose(connection.getInputStream());
} catch (Exception e) { } catch (IOException e) {
IOException ioe = getFirstThrowableOfType(e, IOException.class); in = bufferAndCloseStream(connection.getErrorStream());
if (ioe != null) { } catch (RuntimeException e) {
in = bufferAndCloseStream(connection.getErrorStream()); closeQuietly(in);
} else { propagate(e);
closeQuietly(in); assert false : "should have propagated exception";
propagate(e);
assert false : "should have propagated exception";
}
} }
int responseCode = connection.getResponseCode(); int responseCode = connection.getResponseCode();