Merge pull request #601 from andrewgaul/throwables-propagate

Improve use of Throwables.propagate
This commit is contained in:
Adrian Cole 2012-05-02 15:08:32 -07:00
commit 079b39a235
11 changed files with 27 additions and 67 deletions

View File

@ -262,9 +262,7 @@ public class FilesystemAsyncBlobStore extends BaseAsyncBlobStore {
.build()));
return metadata;
} catch (Exception e) {
propagate(e);
assert false : "exception should have propagated: " + e;
return null;
throw propagate(e);
}
}

View File

@ -122,9 +122,7 @@ public abstract class BindCloneParamsToXmlPayload<O extends CloneOptions> implem
try {
return getOptionClass().newInstance();
} catch (Exception e) {
Throwables.propagate(e);
assert false : "unreachable code";
return null;
throw Throwables.propagate(e);
}
}

View File

@ -251,9 +251,7 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore {
HttpUtils.copy(in.getContentMetadata(), out.getContentMetadata());
return out;
} catch (Exception e) {
propagate(e);
assert false : "exception should have propagated: " + e;
return null;
throw propagate(e);
}
}

View File

@ -48,9 +48,7 @@ public class RetryOnTimeOutExceptionSupplier<T> implements Supplier<T> {
} catch (Exception e) {
if ((ex = Throwables2.getFirstThrowableOfType(e, TimeoutException.class)) != null)
continue;
propagate(e);
assert false;
return null;
throw propagate(e);
}
}
if (ex != null)

View File

@ -115,8 +115,7 @@ public class JavaUrlHttpCommandExecutorService extends BaseHttpCommandExecutorSe
in = bufferAndCloseStream(connection.getErrorStream());
} catch (RuntimeException e) {
closeQuietly(in);
propagate(e);
assert false : "should have propagated exception";
throw propagate(e);
}
int responseCode = connection.getResponseCode();

View File

@ -56,9 +56,7 @@ public class SetAndThrowAuthorizationExceptionSupplier<T> implements Supplier<T>
authException.set(aex);
throw aex;
}
propagate(e);
assert false : e;
return null;
throw propagate(e);
}
}

View File

@ -84,8 +84,7 @@ public class RetrieveActiveBridgedInterfaces implements Function<NodeMetadata, L
}
} catch (SocketException e) {
logger.error(e, "Problem in listing network interfaces.");
Throwables.propagate(e);
assert false;
throw Throwables.propagate(e);
}
return activeNetworkInterfaces;
}
@ -117,10 +116,8 @@ public class RetrieveActiveBridgedInterfaces implements Function<NodeMetadata, L
!networkInterface.isLoopback());
} catch (SocketException e) {
logger.error(e, "Problem in listing network interfaces.");
Throwables.propagate(e);
assert false;
}
return false;
throw Throwables.propagate(e);
}
}
}
}

View File

@ -115,14 +115,7 @@ public class LibvirtComputeService extends BaseComputeService {
storageVol.delete(0);
client.domainLookupByUUIDString(id).undefine();
} catch (Exception e) {
propogate(e);
}
}
protected <T> T propogate(Exception e) {
Throwables.propagate(e);
assert false;
return null;
}
}
}

View File

@ -83,22 +83,16 @@ public class DomainToHardware implements Function<Domain, Hardware> {
}
builder.volumes((List<Volume>) volumes);
} catch (LibvirtException e) {
propagate(e);
Throwables.propagate(e);
} catch (XPathExpressionException e) {
propagate(e);
Throwables.propagate(e);
} catch (ParserConfigurationException e) {
propagate(e);
Throwables.propagate(e);
} catch (SAXException e) {
propagate(e);
Throwables.propagate(e);
} catch (IOException e) {
propagate(e);
Throwables.propagate(e);
}
return builder.build();
}
protected <T> T propagate(Exception e) {
Throwables.propagate(e);
assert false;
return null;
}
}

View File

@ -116,9 +116,9 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
credentialStore.put(domain.getUUIDString() + "", new Credentials("identity", "credential"));
return newDomain;
} catch (LibvirtException e) {
return propogate(e);
throw Throwables.propagate(e);
} catch (Exception e) {
return propogate(e);
throw Throwables.propagate(e);
}
}
@ -138,7 +138,7 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
}
return images;
} catch (Exception e) {
return propogate(e);
throw Throwables.propagate(e);
}
}
@ -151,7 +151,7 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
}
return domains;
} catch (LibvirtException e) {
return propogate(e);
throw Throwables.propagate(e);
}
}
@ -168,7 +168,7 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
} catch (LibvirtException e) {
if (e.getMessage().indexOf("Domain not found: no domain with matching uuid") != -1)
return null;
propogate(e);
Throwables.propagate(e);
}
return d;
}
@ -187,9 +187,9 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
client.domainLookupByUUIDString(id).undefine();
} catch (LibvirtException e) {
propogate(e);
Throwables.propagate(e);
} catch (Exception e) {
propogate(e);
Throwables.propagate(e);
}
}
@ -198,20 +198,8 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
try {
client.domainLookupByUUIDString(id).reboot(0);
} catch (LibvirtException e) {
propogate(e);
}
}
protected <T> T propogate(LibvirtException e) {
Throwables.propagate(e);
assert false;
return null;
}
protected <T> T propogate(Exception e) {
Throwables.propagate(e);
assert false;
return null;
}
private static StorageVol cloneVolume(StoragePool storagePool, StorageVol from) throws LibvirtException,
@ -224,7 +212,7 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
try {
client.domainLookupByUUIDString(id).resume();
} catch (LibvirtException e) {
propogate(e);
Throwables.propagate(e);
}
}
@ -233,7 +221,7 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
try {
client.domainLookupByUUIDString(id).suspend();
} catch (LibvirtException e) {
propogate(e);
Throwables.propagate(e);
}
}

View File

@ -192,8 +192,7 @@ public class NingHttpCommandExecutorService implements HttpCommandExecutorServic
in = BaseHttpCommandExecutorService.consumeOnClose(nativeResponse.getResponseBodyAsStream());
} catch (IOException e) {
Closeables.closeQuietly(in);
propagate(e);
assert false : "should have propagated exception";
throw propagate(e);
}
Payload payload = in != null ? Payloads.newInputStreamPayload(in) : null;