mirror of https://github.com/apache/jclouds.git
Merge pull request #569 from andrewgaul/throwables-propagate
Throw return value instead of returning null
This commit is contained in:
commit
1aff618529
|
@ -81,8 +81,7 @@ public class SupplyFromProviderURIOrNodesProperty implements Supplier<InputStrea
|
||||||
return input.toURL().openStream();
|
return input.toURL().openStream();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error(e, "URI could not be read: %s", url);
|
logger.error(e, "URI could not be read: %s", url);
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,8 +70,7 @@ public class InputSupplierMap<K, V> extends AbstractMap<K, V> {
|
||||||
try {
|
try {
|
||||||
return (value != null || toMap.containsKey(key)) ? value.getInput() : null;
|
return (value != null || toMap.containsKey(key)) ? value.getInput() : null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,8 +79,7 @@ public class InputSupplierMap<K, V> extends AbstractMap<K, V> {
|
||||||
try {
|
try {
|
||||||
return toMap.containsKey(key) ? toMap.remove(key).getInput() : null;
|
return toMap.containsKey(key) ? toMap.remove(key).getInput() : null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,8 +122,7 @@ public class InputSupplierMap<K, V> extends AbstractMap<K, V> {
|
||||||
try {
|
try {
|
||||||
return entry.getValue().getInput();
|
return entry.getValue().getInput();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -176,8 +176,7 @@ public class CryptoStreams {
|
||||||
try {
|
try {
|
||||||
return digest(supplier, MessageDigest.getInstance("SHA1"));
|
return digest(supplier, MessageDigest.getInstance("SHA1"));
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,8 +184,7 @@ public class CryptoStreams {
|
||||||
try {
|
try {
|
||||||
return sha1(ByteStreams.newInputStreamSupplier(in));
|
return sha1(ByteStreams.newInputStreamSupplier(in));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,8 +205,7 @@ public class CryptoStreams {
|
||||||
try {
|
try {
|
||||||
return digest(supplier, MessageDigest.getInstance("MD5"));
|
return digest(supplier, MessageDigest.getInstance("MD5"));
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,8 +213,7 @@ public class CryptoStreams {
|
||||||
try {
|
try {
|
||||||
return md5(ByteStreams.newInputStreamSupplier(in));
|
return md5(ByteStreams.newInputStreamSupplier(in));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,8 +169,7 @@ public class Pems {
|
||||||
try {
|
try {
|
||||||
return privateKeySpec(InputSuppliers.of(pem));
|
return privateKeySpec(InputSuppliers.of(pem));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,8 +91,7 @@ public class SSLModule extends AbstractModule {
|
||||||
sc.init(null, new TrustManager[] { trustAllCerts }, new SecureRandom());
|
sc.init(null, new TrustManager[] { trustAllCerts }, new SecureRandom());
|
||||||
return sc;
|
return sc;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,8 +131,7 @@ public class Payloads {
|
||||||
try {
|
try {
|
||||||
return calculateMD5(payload, MessageDigest.getInstance("MD5"));
|
return calculateMD5(payload, MessageDigest.getInstance("MD5"));
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,8 +159,7 @@ public class Payloads {
|
||||||
try {
|
try {
|
||||||
return calculateMD5(payloadEnclosing, MessageDigest.getInstance("MD5"));
|
return calculateMD5(payloadEnclosing, MessageDigest.getInstance("MD5"));
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,8 +76,7 @@ public class BasePayloadSlicer implements PayloadSlicer {
|
||||||
try {
|
try {
|
||||||
return doSlice(new FileInputStream(content), offset, length);
|
return doSlice(new FileInputStream(content), offset, length);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,7 @@ public class FilePayload extends BasePayload<File> {
|
||||||
try {
|
try {
|
||||||
return new FileInputStream(content);
|
return new FileInputStream(content);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,7 @@ public class InputStreamSupplierPayload extends BasePayload<InputSupplier<? exte
|
||||||
toClose.add(returnVal);
|
toClose.add(returnVal);
|
||||||
return returnVal;
|
return returnVal;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -550,8 +550,7 @@ public class RestAnnotationProcessor<T> {
|
||||||
utils.checkRequestHasRequiredProperties(request);
|
utils.checkRequestHasRequiredProperties(request);
|
||||||
return request;
|
return request;
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,8 +58,7 @@ public abstract class BaseParserTest<T, G> {
|
||||||
return (Function<HttpResponse, T>) RestAnnotationProcessor.getTransformerForMethod(getClass()
|
return (Function<HttpResponse, T>) RestAnnotationProcessor.getTransformerForMethod(getClass()
|
||||||
.getMethod("expected"), i);
|
.getMethod("expected"), i);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,8 +90,7 @@ public class AsyncGaeHttpCommandExecutorServiceIntegrationTest extends BaseHttpC
|
||||||
try {
|
try {
|
||||||
return Futures.makeListenable(service.fetchAsync(fetch.toURL()), MoreExecutors.sameThreadExecutor());
|
return Futures.makeListenable(service.fetchAsync(fetch.toURL()), MoreExecutors.sameThreadExecutor());
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,8 +74,7 @@ public abstract class BaseBindVMSpecToXmlPayload<T> extends BindToStringPayload
|
||||||
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||||
return rootBuilder.asString(outputProperties);
|
return rootBuilder.asString(outputProperties);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,7 @@ public class FileDownloadFromURI implements Function<URI, File> {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,8 +201,7 @@ public class AdminAccess implements Statement {
|
||||||
grantSudoToAdminUser, authorizeAdminPublicKey, installAdminPrivateKey, resetLoginPassword,
|
grantSudoToAdminUser, authorizeAdminPublicKey, installAdminPrivateKey, resetLoginPassword,
|
||||||
cryptFunction);
|
cryptFunction);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue