mirror of https://github.com/apache/jclouds.git
Replace calls to Closeables.closeQuietly
Guava 16 removes this API. Replace with Closeables2.closeQuietly. References JCLOUDS-413 and JCLOUDS-415.
This commit is contained in:
parent
f9e98681b6
commit
c7b0f66544
|
@ -22,6 +22,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.byon.Node;
|
import org.jclouds.byon.Node;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
import org.yaml.snakeyaml.DumperOptions;
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
import org.yaml.snakeyaml.Loader;
|
import org.yaml.snakeyaml.Loader;
|
||||||
|
@ -34,7 +35,6 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.ImmutableMap.Builder;
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serializes to the following
|
* Serializes to the following
|
||||||
|
@ -114,7 +114,7 @@ public class YamlNode {
|
||||||
try {
|
try {
|
||||||
return (YamlNode) new Yaml(new Loader(new Constructor(YamlNode.class))).load(in);
|
return (YamlNode) new Yaml(new Loader(new Constructor(YamlNode.class))).load(in);
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(in);
|
Closeables2.closeQuietly(in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,10 +28,10 @@ import org.jclouds.http.HttpResponseException;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.rest.ResourceNotFoundException;
|
import org.jclouds.rest.ResourceNotFoundException;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will parse and set an appropriate exception on the command object.
|
* This will parse and set an appropriate exception on the command object.
|
||||||
|
@ -82,7 +82,7 @@ public class CloudSigmaErrorHandler implements HttpErrorHandler {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(response.getPayload());
|
Closeables2.closeQuietly(response.getPayload());
|
||||||
command.setException(exception);
|
command.setException(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,10 @@ import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.rest.InsufficientResourcesException;
|
import org.jclouds.rest.InsufficientResourcesException;
|
||||||
import org.jclouds.rest.ResourceNotFoundException;
|
import org.jclouds.rest.ResourceNotFoundException;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -86,7 +86,7 @@ public class CloudStackErrorHandler implements HttpErrorHandler {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(response.getPayload());
|
Closeables2.closeQuietly(response.getPayload());
|
||||||
command.setException(exception);
|
command.setException(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,10 @@ import org.jclouds.http.HttpResponseException;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.rest.ResourceNotFoundException;
|
import org.jclouds.rest.ResourceNotFoundException;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will parse and set an appropriate exception on the command object.
|
* This will parse and set an appropriate exception on the command object.
|
||||||
|
@ -80,7 +80,7 @@ public class ElasticStackErrorHandler implements HttpErrorHandler {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(response.getPayload());
|
Closeables2.closeQuietly(response.getPayload());
|
||||||
command.setException(exception);
|
command.setException(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.io.Payload;
|
import org.jclouds.io.Payload;
|
||||||
import org.jclouds.io.payloads.PhantomPayload;
|
import org.jclouds.io.payloads.PhantomPayload;
|
||||||
import org.jclouds.io.payloads.StringPayload;
|
import org.jclouds.io.payloads.StringPayload;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
import org.testng.annotations.AfterMethod;
|
import org.testng.annotations.AfterMethod;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
|
@ -60,7 +61,6 @@ import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import com.google.common.io.InputSupplier;
|
import com.google.common.io.InputSupplier;
|
||||||
import com.google.inject.CreationException;
|
import com.google.inject.CreationException;
|
||||||
|
@ -710,7 +710,7 @@ public class FilesystemAsyncBlobStoreTest {
|
||||||
try {
|
try {
|
||||||
assertEquals(input.substring(1), Strings2.toString(payload));
|
assertEquals(input.substring(1), Strings2.toString(payload));
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(payload);
|
Closeables2.closeQuietly(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetOptions getOptionsRangeTail = new GetOptions();
|
GetOptions getOptionsRangeTail = new GetOptions();
|
||||||
|
@ -720,7 +720,7 @@ public class FilesystemAsyncBlobStoreTest {
|
||||||
try {
|
try {
|
||||||
assertEquals(input.substring(5), Strings2.toString(payload));
|
assertEquals(input.substring(5), Strings2.toString(payload));
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(payload);
|
Closeables2.closeQuietly(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetOptions getOptionsFragment = new GetOptions();
|
GetOptions getOptionsFragment = new GetOptions();
|
||||||
|
@ -730,7 +730,7 @@ public class FilesystemAsyncBlobStoreTest {
|
||||||
try {
|
try {
|
||||||
assertEquals(input.substring(4, 7), Strings2.toString(payload));
|
assertEquals(input.substring(4, 7), Strings2.toString(payload));
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(payload);
|
Closeables2.closeQuietly(payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ import org.jclouds.blobstore.attr.ConsistencyModel;
|
||||||
import org.jclouds.internal.BaseView;
|
import org.jclouds.internal.BaseView;
|
||||||
import org.jclouds.location.Provider;
|
import org.jclouds.location.Provider;
|
||||||
import org.jclouds.rest.Utils;
|
import org.jclouds.rest.Utils;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
|
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,7 +85,7 @@ public class BlobStoreContextImpl extends BaseView implements BlobStoreContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
Closeables.closeQuietly(delegate());
|
Closeables2.closeQuietly(delegate());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
|
@ -22,12 +22,12 @@ import org.jclouds.ContextBuilder;
|
||||||
import org.jclouds.blobstore.BlobStore;
|
import org.jclouds.blobstore.BlobStore;
|
||||||
import org.jclouds.blobstore.domain.StorageMetadata;
|
import org.jclouds.blobstore.domain.StorageMetadata;
|
||||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,6 +75,6 @@ public class ConcatenateContainerListsTest {
|
||||||
@AfterClass
|
@AfterClass
|
||||||
void close() {
|
void close() {
|
||||||
if (blobstore != null)
|
if (blobstore != null)
|
||||||
Closeables.closeQuietly(blobstore.getContext());
|
Closeables2.closeQuietly(blobstore.getContext());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,11 @@ import static org.testng.Assert.assertEquals;
|
||||||
import org.jclouds.ContextBuilder;
|
import org.jclouds.ContextBuilder;
|
||||||
import org.jclouds.blobstore.BlobStore;
|
import org.jclouds.blobstore.BlobStore;
|
||||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
import org.testng.annotations.AfterMethod;
|
import org.testng.annotations.AfterMethod;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,7 +50,7 @@ public class DeleteAllKeysInListTest {
|
||||||
|
|
||||||
@AfterMethod
|
@AfterMethod
|
||||||
void close() {
|
void close() {
|
||||||
Closeables.closeQuietly(blobstore.getContext());
|
Closeables2.closeQuietly(blobstore.getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExecuteWithoutOptionsClearsRecursively() {
|
public void testExecuteWithoutOptionsClearsRecursively() {
|
||||||
|
|
|
@ -23,8 +23,9 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A current connection to an exec'd command. Please ensure you call {@link ExecChannel#close}
|
* A current connection to an exec'd command. Please ensure you call {@link ExecChannel#close}
|
||||||
|
@ -86,9 +87,9 @@ public class ExecChannel implements Closeable {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
Closeables.closeQuietly(input);
|
Closeables2.closeQuietly(input);
|
||||||
Closeables.closeQuietly(output);
|
Closeables2.closeQuietly(output);
|
||||||
Closeables.closeQuietly(error);
|
Closeables2.closeQuietly(error);
|
||||||
closer.close();
|
closer.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,10 @@ import static com.google.common.base.Throwables.propagate;
|
||||||
import static com.google.common.base.Throwables.propagateIfInstanceOf;
|
import static com.google.common.base.Throwables.propagateIfInstanceOf;
|
||||||
import static com.google.common.io.BaseEncoding.base64;
|
import static com.google.common.io.BaseEncoding.base64;
|
||||||
import static com.google.common.io.ByteStreams.readBytes;
|
import static com.google.common.io.ByteStreams.readBytes;
|
||||||
import static com.google.common.io.Closeables.closeQuietly;
|
|
||||||
import static org.jclouds.crypto.ASN1Codec.decodeRSAPrivateKey;
|
import static org.jclouds.crypto.ASN1Codec.decodeRSAPrivateKey;
|
||||||
import static org.jclouds.crypto.ASN1Codec.decodeRSAPublicKey;
|
import static org.jclouds.crypto.ASN1Codec.decodeRSAPublicKey;
|
||||||
import static org.jclouds.crypto.ASN1Codec.encode;
|
import static org.jclouds.crypto.ASN1Codec.encode;
|
||||||
|
import static org.jclouds.util.Closeables2.closeQuietly;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
|
|
@ -30,7 +30,6 @@ import static com.google.common.collect.Iterables.size;
|
||||||
import static com.google.common.collect.Multimaps.filterKeys;
|
import static com.google.common.collect.Multimaps.filterKeys;
|
||||||
import static com.google.common.io.BaseEncoding.base64;
|
import static com.google.common.io.BaseEncoding.base64;
|
||||||
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.net.HttpHeaders.CONTENT_DISPOSITION;
|
import static com.google.common.net.HttpHeaders.CONTENT_DISPOSITION;
|
||||||
import static com.google.common.net.HttpHeaders.CONTENT_ENCODING;
|
import static com.google.common.net.HttpHeaders.CONTENT_ENCODING;
|
||||||
import static com.google.common.net.HttpHeaders.CONTENT_LANGUAGE;
|
import static com.google.common.net.HttpHeaders.CONTENT_LANGUAGE;
|
||||||
|
@ -38,6 +37,7 @@ import static com.google.common.net.HttpHeaders.CONTENT_LENGTH;
|
||||||
import static com.google.common.net.HttpHeaders.CONTENT_MD5;
|
import static com.google.common.net.HttpHeaders.CONTENT_MD5;
|
||||||
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
||||||
import static com.google.common.net.HttpHeaders.EXPIRES;
|
import static com.google.common.net.HttpHeaders.EXPIRES;
|
||||||
|
import static org.jclouds.util.Closeables2.closeQuietly;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
|
@ -30,12 +30,12 @@ import javax.annotation.Resource;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.json.internal.GsonWrapper;
|
import org.jclouds.json.internal.GsonWrapper;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
import com.google.common.util.concurrent.Atomics;
|
import com.google.common.util.concurrent.Atomics;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonToken;
|
import com.google.gson.stream.JsonToken;
|
||||||
|
@ -88,7 +88,7 @@ public class ParseFirstJsonValueNamed<T> implements Function<HttpResponse, T> {
|
||||||
throw new RuntimeException(String.format(
|
throw new RuntimeException(String.format(
|
||||||
"error reading from stream, parsing object named %s from http response %s", nameChoices, arg0), e);
|
"error reading from stream, parsing object named %s from http response %s", nameChoices, arg0), e);
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(reader);
|
Closeables2.closeQuietly(reader);
|
||||||
arg0.getPayload().release();
|
arg0.getPayload().release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ package org.jclouds.http.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.io.Closeables.closeQuietly;
|
|
||||||
import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream;
|
import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream;
|
||||||
|
import static org.jclouds.util.Closeables2.closeQuietly;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -41,7 +41,7 @@ import org.xml.sax.helpers.DefaultHandler;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.io.Closeables;
|
import org.jclouds.util.Closeables2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This object will parse the body of an HttpResponse and return the result of type <T> back to the
|
* This object will parse the body of an HttpResponse and return the result of type <T> back to the
|
||||||
|
@ -85,7 +85,7 @@ public class ParseSax<T> implements Function<HttpResponse, T>, InvocationContext
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
return addDetailsAndPropagate(from, e);
|
return addDetailsAndPropagate(from, e);
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(is);
|
Closeables2.closeQuietly(is);
|
||||||
from.getPayload().release();
|
from.getPayload().release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,12 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Throwables.propagate;
|
import static com.google.common.base.Throwables.propagate;
|
||||||
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.net.HttpHeaders.CONTENT_LENGTH;
|
import static com.google.common.net.HttpHeaders.CONTENT_LENGTH;
|
||||||
import static com.google.common.net.HttpHeaders.HOST;
|
import static com.google.common.net.HttpHeaders.HOST;
|
||||||
import static com.google.common.net.HttpHeaders.USER_AGENT;
|
import static com.google.common.net.HttpHeaders.USER_AGENT;
|
||||||
import static org.jclouds.http.HttpUtils.filterOutContentHeaders;
|
import static org.jclouds.http.HttpUtils.filterOutContentHeaders;
|
||||||
import static org.jclouds.io.Payloads.newInputStreamPayload;
|
import static org.jclouds.io.Payloads.newInputStreamPayload;
|
||||||
|
import static org.jclouds.util.Closeables2.closeQuietly;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
|
@ -19,9 +19,9 @@ package org.jclouds.internal;
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static com.google.common.base.Objects.toStringHelper;
|
import static com.google.common.base.Objects.toStringHelper;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.io.Closeables.closeQuietly;
|
|
||||||
|
|
||||||
import static org.jclouds.lifecycle.Closer.State.AVAILABLE;
|
import static org.jclouds.lifecycle.Closer.State.AVAILABLE;
|
||||||
|
import static org.jclouds.util.Closeables2.closeQuietly;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
|
@ -22,11 +22,11 @@ import java.io.InputStream;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
import com.google.common.io.InputSupplier;
|
import com.google.common.io.InputSupplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +56,7 @@ public class CopyInputStreamIntoSupplier implements Function<InputStream, InputS
|
||||||
logger.warn(e, "ignoring problem retrieving credentials");
|
logger.warn(e, "ignoring problem retrieving credentials");
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(from);
|
Closeables2.closeQuietly(from);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.jclouds.io.payloads;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.io.ByteStreams.copy;
|
import static com.google.common.io.ByteStreams.copy;
|
||||||
import static com.google.common.io.Closeables.closeQuietly;
|
import static org.jclouds.util.Closeables2.closeQuietly;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.io.payloads;
|
package org.jclouds.io.payloads;
|
||||||
|
|
||||||
import static com.google.common.io.Closeables.closeQuietly;
|
import static org.jclouds.util.Closeables2.closeQuietly;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.io.payloads;
|
package org.jclouds.io.payloads;
|
||||||
|
|
||||||
import static com.google.common.io.Closeables.closeQuietly;
|
import static org.jclouds.util.Closeables2.closeQuietly;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.io.payloads;
|
package org.jclouds.io.payloads;
|
||||||
|
|
||||||
import static com.google.common.io.Closeables.closeQuietly;
|
import static org.jclouds.util.Closeables2.closeQuietly;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
package org.jclouds.logging.internal;
|
package org.jclouds.logging.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.io.Closeables.closeQuietly;
|
|
||||||
import static org.jclouds.io.Payloads.newPayload;
|
import static org.jclouds.io.Payloads.newPayload;
|
||||||
|
import static org.jclouds.util.Closeables2.closeQuietly;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.util;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
|
import com.google.common.io.Closeables;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public class Closeables2 {
|
||||||
|
private Closeables2() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equivalent to calling {@code Closeables.close(closeable, true)}, but with no IOException in the signature.
|
||||||
|
*
|
||||||
|
* @param closeable the {@code Closeable} object to be closed, or null, in which case this method
|
||||||
|
* does nothing
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static void closeQuietly(@Nullable Closeable closeable) {
|
||||||
|
try {
|
||||||
|
Closeables.close(closeable, true);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw Throwables.propagate(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,7 +17,7 @@
|
||||||
package org.jclouds.util;
|
package org.jclouds.util;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.io.Closeables.closeQuietly;
|
import static org.jclouds.util.Closeables2.closeQuietly;
|
||||||
import static org.jclouds.util.Patterns.TOKEN_TO_PATTERN;
|
import static org.jclouds.util.Patterns.TOKEN_TO_PATTERN;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
package org.jclouds.apis;
|
package org.jclouds.apis;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.io.Closeables.closeQuietly;
|
|
||||||
import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME;
|
import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME;
|
||||||
import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS;
|
import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS;
|
||||||
|
import static org.jclouds.util.Closeables2.closeQuietly;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
|
@ -29,11 +29,11 @@ import org.jclouds.logging.LoggingModules;
|
||||||
import org.jclouds.logging.config.LoggingModule;
|
import org.jclouds.logging.config.LoggingModule;
|
||||||
import org.jclouds.providers.ProviderMetadata;
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
import org.jclouds.providers.Providers;
|
import org.jclouds.providers.Providers;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public abstract class BaseContextLiveTest<C extends Context> {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initializeContext() {
|
protected void initializeContext() {
|
||||||
Closeables.closeQuietly(context);
|
Closeables2.closeQuietly(context);
|
||||||
context = createContext(setupProperties(), setupModules());
|
context = createContext(setupProperties(), setupModules());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +140,6 @@ public abstract class BaseContextLiveTest<C extends Context> {
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
protected void tearDownContext() {
|
protected void tearDownContext() {
|
||||||
Closeables.closeQuietly(context);
|
Closeables2.closeQuietly(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@ import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.Context;
|
import org.jclouds.Context;
|
||||||
import org.jclouds.View;
|
import org.jclouds.View;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
|
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public abstract class BaseViewLiveTest<V extends View> extends BaseContextLiveTe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initializeContext() {
|
protected void initializeContext() {
|
||||||
Closeables.closeQuietly(context);
|
Closeables2.closeQuietly(context);
|
||||||
view = createView(setupProperties(), setupModules());
|
view = createView(setupProperties(), setupModules());
|
||||||
context = view.unwrap();
|
context = view.unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,12 @@ package org.jclouds.http;
|
||||||
|
|
||||||
import static com.google.common.hash.Hashing.md5;
|
import static com.google.common.hash.Hashing.md5;
|
||||||
import static com.google.common.io.BaseEncoding.base64;
|
import static com.google.common.io.BaseEncoding.base64;
|
||||||
import static com.google.common.io.Closeables.closeQuietly;
|
|
||||||
import static java.lang.String.format;
|
import static java.lang.String.format;
|
||||||
import static org.jclouds.http.options.GetOptions.Builder.tail;
|
import static org.jclouds.http.options.GetOptions.Builder.tail;
|
||||||
import static org.jclouds.io.ByteSources.asByteSource;
|
import static org.jclouds.io.ByteSources.asByteSource;
|
||||||
import static org.jclouds.io.Payloads.newFilePayload;
|
import static org.jclouds.io.Payloads.newFilePayload;
|
||||||
import static org.jclouds.io.Payloads.newStringPayload;
|
import static org.jclouds.io.Payloads.newStringPayload;
|
||||||
|
import static org.jclouds.util.Closeables2.closeQuietly;
|
||||||
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
|
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
|
@ -23,7 +23,6 @@ import static com.google.common.io.ByteStreams.copy;
|
||||||
import static com.google.common.io.ByteStreams.join;
|
import static com.google.common.io.ByteStreams.join;
|
||||||
import static com.google.common.io.ByteStreams.newInputStreamSupplier;
|
import static com.google.common.io.ByteStreams.newInputStreamSupplier;
|
||||||
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.net.HttpHeaders.CONTENT_DISPOSITION;
|
import static com.google.common.net.HttpHeaders.CONTENT_DISPOSITION;
|
||||||
import static com.google.common.net.HttpHeaders.CONTENT_ENCODING;
|
import static com.google.common.net.HttpHeaders.CONTENT_ENCODING;
|
||||||
import static com.google.common.net.HttpHeaders.CONTENT_LANGUAGE;
|
import static com.google.common.net.HttpHeaders.CONTENT_LANGUAGE;
|
||||||
|
@ -33,6 +32,7 @@ import static javax.servlet.http.HttpServletResponse.SC_OK;
|
||||||
import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME;
|
import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME;
|
||||||
import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS;
|
import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS;
|
||||||
import static org.jclouds.io.ByteSources.asByteSource;
|
import static org.jclouds.io.ByteSources.asByteSource;
|
||||||
|
import static org.jclouds.util.Closeables2.closeQuietly;
|
||||||
import static org.jclouds.util.Strings2.toStringAndClose;
|
import static org.jclouds.util.Strings2.toStringAndClose;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpUtils;
|
import org.jclouds.http.HttpUtils;
|
||||||
import org.jclouds.io.ContentMetadataCodec;
|
import org.jclouds.io.ContentMetadataCodec;
|
||||||
import org.jclouds.io.Payload;
|
import org.jclouds.io.Payload;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
|
|
||||||
import com.google.appengine.api.urlfetch.FetchOptions;
|
import com.google.appengine.api.urlfetch.FetchOptions;
|
||||||
import com.google.appengine.api.urlfetch.HTTPHeader;
|
import com.google.appengine.api.urlfetch.HTTPHeader;
|
||||||
|
@ -42,7 +43,6 @@ import com.google.appengine.api.urlfetch.HTTPRequest;
|
||||||
import com.google.appengine.repackaged.com.google.common.base.Throwables;
|
import com.google.appengine.repackaged.com.google.common.base.Throwables;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -113,7 +113,7 @@ public class ConvertToGaeRequest implements Function<HttpRequest, HTTPRequest> {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Throwables.propagate(e);
|
Throwables.propagate(e);
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(input);
|
Closeables2.closeQuietly(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Entry<String, String> header : contentMetadataCodec.toHeaders(
|
for (Entry<String, String> header : contentMetadataCodec.toHeaders(
|
||||||
|
|
|
@ -52,6 +52,7 @@ import org.jclouds.proxy.ProxyConfig;
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.SshException;
|
import org.jclouds.ssh.SshException;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
@ -59,7 +60,6 @@ import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
import com.google.common.net.HostAndPort;
|
import com.google.common.net.HostAndPort;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.jcraft.jsch.ChannelExec;
|
import com.jcraft.jsch.ChannelExec;
|
||||||
|
@ -273,7 +273,7 @@ public class JschSshClient implements SshClient {
|
||||||
try {
|
try {
|
||||||
sftp.put(is, path);
|
sftp.put(is, path);
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(contents);
|
Closeables2.closeQuietly(contents);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -353,9 +353,9 @@ public class JschSshClient implements SshClient {
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
if (inputStream != null)
|
if (inputStream != null)
|
||||||
Closeables.closeQuietly(inputStream);
|
Closeables2.closeQuietly(inputStream);
|
||||||
if (errStream != null)
|
if (errStream != null)
|
||||||
Closeables.closeQuietly(errStream);
|
Closeables2.closeQuietly(errStream);
|
||||||
if (executor != null)
|
if (executor != null)
|
||||||
executor.disconnect();
|
executor.disconnect();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ import org.jclouds.io.Payloads;
|
||||||
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -49,7 +50,6 @@ import com.google.common.base.Charsets;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import com.google.common.net.HostAndPort;
|
import com.google.common.net.HostAndPort;
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
|
@ -273,7 +273,7 @@ public class JschSshClientLiveTest {
|
||||||
assertEquals(Strings2.toStringAndClose(response.getError()), "");
|
assertEquals(Strings2.toStringAndClose(response.getError()), "");
|
||||||
assertEquals(Strings2.toStringAndClose(response.getOutput()), "");
|
assertEquals(Strings2.toStringAndClose(response.getOutput()), "");
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(response);
|
Closeables2.closeQuietly(response);
|
||||||
}
|
}
|
||||||
assertEquals(response.getExitStatus().get(), Integer.valueOf(0));
|
assertEquals(response.getExitStatus().get(), Integer.valueOf(0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.SshException;
|
import org.jclouds.ssh.SshException;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
import org.jclouds.util.Throwables2;
|
import org.jclouds.util.Throwables2;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
@ -73,7 +74,6 @@ import com.google.common.base.Splitter;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
import com.google.common.net.HostAndPort;
|
import com.google.common.net.HostAndPort;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
@ -475,7 +475,7 @@ public class SshjSshClient implements SshClient {
|
||||||
if (session != null)
|
if (session != null)
|
||||||
session.close();
|
session.close();
|
||||||
if (sshClientConnection != null)
|
if (sshClientConnection != null)
|
||||||
Closeables.closeQuietly(sshClientConnection);
|
Closeables2.closeQuietly(sshClientConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -505,8 +505,8 @@ public class SshjSshClient implements SshClient {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
Closeables.closeQuietly(output);
|
Closeables2.closeQuietly(output);
|
||||||
Closeables.closeQuietly(session);
|
Closeables2.closeQuietly(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.jclouds.io.Payloads;
|
||||||
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -42,7 +43,6 @@ import org.testng.annotations.Test;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import com.google.common.net.HostAndPort;
|
import com.google.common.net.HostAndPort;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
|
@ -182,7 +182,7 @@ public class SshjSshClientLiveTest {
|
||||||
assertEquals(Strings2.toStringAndClose(response.getError()), "");
|
assertEquals(Strings2.toStringAndClose(response.getError()), "");
|
||||||
assertEquals(Strings2.toStringAndClose(response.getOutput()), "");
|
assertEquals(Strings2.toStringAndClose(response.getOutput()), "");
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(response);
|
Closeables2.closeQuietly(response);
|
||||||
}
|
}
|
||||||
assertEquals(response.getExitStatus().get(), Integer.valueOf(0));
|
assertEquals(response.getExitStatus().get(), Integer.valueOf(0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@ import org.jclouds.loadbalancer.LoadBalancerService;
|
||||||
import org.jclouds.loadbalancer.LoadBalancerServiceContext;
|
import org.jclouds.loadbalancer.LoadBalancerServiceContext;
|
||||||
import org.jclouds.location.Provider;
|
import org.jclouds.location.Provider;
|
||||||
import org.jclouds.rest.Utils;
|
import org.jclouds.rest.Utils;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
|
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,7 +59,7 @@ public class LoadBalancerServiceContextImpl extends BaseView implements LoadBala
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
Closeables.closeQuietly(delegate());
|
Closeables2.closeQuietly(delegate());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
|
@ -26,10 +26,10 @@ import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.HttpResponseException;
|
import org.jclouds.http.HttpResponseException;
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.rest.ResourceNotFoundException;
|
import org.jclouds.rest.ResourceNotFoundException;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will parse and set an appropriate exception on the command object.
|
* This will parse and set an appropriate exception on the command object.
|
||||||
|
@ -72,7 +72,7 @@ public class GleSYSErrorHandler implements HttpErrorHandler {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(response.getPayload());
|
Closeables2.closeQuietly(response.getPayload());
|
||||||
command.setException(exception);
|
command.setException(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,9 @@ import org.jclouds.ContextBuilder;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.glesys.GleSYSProviderMetadata;
|
import org.jclouds.glesys.GleSYSProviderMetadata;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -50,7 +49,7 @@ public class GleSYSExperimentLiveTest extends BaseComputeServiceContextLiveTest
|
||||||
assertEquals(context.getComputeService().listAssignableLocations().size(), 4);
|
assertEquals(context.getComputeService().listAssignableLocations().size(), 4);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(context);
|
Closeables2.closeQuietly(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,10 @@ import org.jclouds.http.HttpResponseException;
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.rest.ResourceNotFoundException;
|
import org.jclouds.rest.ResourceNotFoundException;
|
||||||
import org.jclouds.softlayer.exceptions.SoftLayerOrderItemDuplicateException;
|
import org.jclouds.softlayer.exceptions.SoftLayerOrderItemDuplicateException;
|
||||||
|
import org.jclouds.util.Closeables2;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will parse and set an appropriate exception on the command object.
|
* This will parse and set an appropriate exception on the command object.
|
||||||
|
@ -71,7 +71,7 @@ public class SoftLayerErrorHandler implements HttpErrorHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(response.getPayload());
|
Closeables2.closeQuietly(response.getPayload());
|
||||||
command.setException(exception);
|
command.setException(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue