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