Repository: reef Updated Branches: refs/heads/master d33717097 -> a67bdbaa6
[REEF-1104] Enable AvoidHidingCauseExceptionCheck from sevntu-checkstyle This patch: * Adds the AvoidHidingCauseException check to checkstyle.xml and checkstyle-strict.xml * Fixes the violations of the check in the REEF Java codebase JIRA: [REEF-1104](https://issues.apache.org/jira/browse/REEF-1104) Pull Request: This closes #765 Project: http://git-wip-us.apache.org/repos/asf/reef/repo Commit: http://git-wip-us.apache.org/repos/asf/reef/commit/a67bdbaa Tree: http://git-wip-us.apache.org/repos/asf/reef/tree/a67bdbaa Diff: http://git-wip-us.apache.org/repos/asf/reef/diff/a67bdbaa Branch: refs/heads/master Commit: a67bdbaa6c0ae4d6b1726c8fb86f7f77f8917553 Parents: d337170 Author: [email protected] <[email protected]> Authored: Wed Jan 13 14:51:41 2016 +0100 Committer: Markus Weimer <[email protected]> Committed: Thu Jan 28 14:21:08 2016 -0800 ---------------------------------------------------------------------- .../reef/javabridge/generic/JobClient.java | 2 +- .../src/main/resources/checkstyle-strict.xml | 3 +++ .../src/main/resources/checkstyle.xml | 2 ++ .../examples/group/utils/math/VectorCodec.java | 4 ++-- .../network/naming/LocalNameResolverImpl.java | 2 +- .../reef/io/storage/FramingOutputStream.java | 22 +++++++------------- .../reef/io/storage/FramingTupleSerializer.java | 14 ++++++++----- .../formats/AvroConfigurationSerializer.java | 2 +- .../apache/reef/tang/formats/CommandLine.java | 3 +++ .../ConfigurationBuilderImpl.java | 6 +++--- .../implementation/avro/AvroClassHierarchy.java | 2 +- .../implementation/java/ClassHierarchyImpl.java | 4 ++-- .../tang/implementation/java/InjectorImpl.java | 10 ++++----- .../protobuf/ProtocolBufferClassHierarchy.java | 4 ++-- .../tang/formats/TestConfigurationModule.java | 4 ++++ .../TaskletCancellationTestStart.java | 2 +- .../address/LegacyLocalAddressProvider.java | 3 +-- .../netty/NettyMessagingTransport.java | 4 ++-- 18 files changed, 50 insertions(+), 43 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-bridge-java/src/main/java/org/apache/reef/javabridge/generic/JobClient.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-bridge-java/src/main/java/org/apache/reef/javabridge/generic/JobClient.java b/lang/java/reef-bridge-java/src/main/java/org/apache/reef/javabridge/generic/JobClient.java index f56156e..8ec68ae 100644 --- a/lang/java/reef-bridge-java/src/main/java/org/apache/reef/javabridge/generic/JobClient.java +++ b/lang/java/reef-bridge-java/src/main/java/org/apache/reef/javabridge/generic/JobClient.java @@ -230,7 +230,7 @@ public class JobClient { driverConfig); LOG.log(Level.INFO, "Driver configuration file created at " + driverConfig.getAbsolutePath()); } catch (final IOException e) { - throw new RuntimeException("Cannot create driver configuration file at " + driverConfig.getAbsolutePath()); + throw new RuntimeException("Cannot create driver configuration file at " + driverConfig.getAbsolutePath(), e); } } } http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-common/src/main/resources/checkstyle-strict.xml ---------------------------------------------------------------------- diff --git a/lang/java/reef-common/src/main/resources/checkstyle-strict.xml b/lang/java/reef-common/src/main/resources/checkstyle-strict.xml index ce75ec3..df5f871 100644 --- a/lang/java/reef-common/src/main/resources/checkstyle-strict.xml +++ b/lang/java/reef-common/src/main/resources/checkstyle-strict.xml @@ -227,6 +227,7 @@ <module name="ForbidReturnInFinallyBlockCheck"/> <module name="ForbidThrowAnonymousExceptionsCheck"/> <module name="UselessSingleCatchCheck"/> + <module name="EmptyCatchBlock"> <property name="commentFormat" value="This is expected"/> <property name="exceptionVariableName" value="expected|ignored"/> @@ -246,6 +247,8 @@ <property name="classes" value="java.lang.Throwable, java.lang.Error"/> </module> + <module name="AvoidHidingCauseExceptionCheck" /> + </module> </module> http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-common/src/main/resources/checkstyle.xml ---------------------------------------------------------------------- diff --git a/lang/java/reef-common/src/main/resources/checkstyle.xml b/lang/java/reef-common/src/main/resources/checkstyle.xml index af0b527..aba3651 100644 --- a/lang/java/reef-common/src/main/resources/checkstyle.xml +++ b/lang/java/reef-common/src/main/resources/checkstyle.xml @@ -248,6 +248,8 @@ <property name="classes" value="java.lang.Throwable, java.lang.Error"/> </module> + <module name="AvoidHidingCauseExceptionCheck" /> + </module> </module> http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-examples/src/main/java/org/apache/reef/examples/group/utils/math/VectorCodec.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-examples/src/main/java/org/apache/reef/examples/group/utils/math/VectorCodec.java b/lang/java/reef-examples/src/main/java/org/apache/reef/examples/group/utils/math/VectorCodec.java index b44ed75..c91442c 100644 --- a/lang/java/reef-examples/src/main/java/org/apache/reef/examples/group/utils/math/VectorCodec.java +++ b/lang/java/reef-examples/src/main/java/org/apache/reef/examples/group/utils/math/VectorCodec.java @@ -48,7 +48,7 @@ public class VectorCodec implements Codec<Vector> { result.set(i, dais.readDouble()); } } catch (final IOException e) { - throw new RuntimeException(e.getCause()); + throw new RuntimeException(e); } return result; } @@ -63,7 +63,7 @@ public class VectorCodec implements Codec<Vector> { daos.writeDouble(vec.get(i)); } } catch (final IOException e) { - throw new RuntimeException(e.getCause()); + throw new RuntimeException(e); } return baos.toByteArray(); } http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-io/src/main/java/org/apache/reef/io/network/naming/LocalNameResolverImpl.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-io/src/main/java/org/apache/reef/io/network/naming/LocalNameResolverImpl.java b/lang/java/reef-io/src/main/java/org/apache/reef/io/network/naming/LocalNameResolverImpl.java index 82b99c1..2b8e8fe 100644 --- a/lang/java/reef-io/src/main/java/org/apache/reef/io/network/naming/LocalNameResolverImpl.java +++ b/lang/java/reef-io/src/main/java/org/apache/reef/io/network/naming/LocalNameResolverImpl.java @@ -104,7 +104,7 @@ public final class LocalNameResolverImpl implements NameResolver { } } catch (final NullPointerException e) { if (retriesLeft <= 0) { - throw new NamingException("Cannot find " + id + " from the name server"); + throw new NamingException("Cannot find " + id + " from the name server", e); } else { final int retTimeout = LocalNameResolverImpl.this.retryTimeout * (origRetryCount - retriesLeft + 1); http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-io/src/main/java/org/apache/reef/io/storage/FramingOutputStream.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-io/src/main/java/org/apache/reef/io/storage/FramingOutputStream.java b/lang/java/reef-io/src/main/java/org/apache/reef/io/storage/FramingOutputStream.java index 28f6916..b520e0c 100644 --- a/lang/java/reef-io/src/main/java/org/apache/reef/io/storage/FramingOutputStream.java +++ b/lang/java/reef-io/src/main/java/org/apache/reef/io/storage/FramingOutputStream.java @@ -44,15 +44,11 @@ public class FramingOutputStream extends OutputStream implements Accumulable<byt this.baos = new ByteArrayOutputStream(); } - public void nextFrame() throws StorageException { - try { - o.writeInt(baos.size()); - offset += 4; - baos.writeTo(o); - baos.reset(); - } catch (final IOException e) { - throw new StorageException(e); - } + public void nextFrame() throws IOException { + o.writeInt(baos.size()); + offset += 4; + baos.writeTo(o); + baos.reset(); } public long getCurrentOffset() { @@ -85,12 +81,8 @@ public class FramingOutputStream extends OutputStream implements Accumulable<byt @Override public void close() throws IOException { if (!closed) { - try { - if (this.offset > 0) { - nextFrame(); - } - } catch (final StorageException e) { - throw (IOException) e.getCause(); + if (this.offset > 0) { + nextFrame(); } o.writeInt(-1); o.close(); http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-io/src/main/java/org/apache/reef/io/storage/FramingTupleSerializer.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-io/src/main/java/org/apache/reef/io/storage/FramingTupleSerializer.java b/lang/java/reef-io/src/main/java/org/apache/reef/io/storage/FramingTupleSerializer.java index 5da8e3b..20cbf3b 100644 --- a/lang/java/reef-io/src/main/java/org/apache/reef/io/storage/FramingTupleSerializer.java +++ b/lang/java/reef-io/src/main/java/org/apache/reef/io/storage/FramingTupleSerializer.java @@ -59,13 +59,17 @@ public class FramingTupleSerializer<K, V> implements @Override public void add(final Tuple<K, V> datum) throws ServiceException { - if (!first) { + try { + if (!first) { + faos.nextFrame(); + } + first = false; + keyAccumulator.add(datum.getKey()); faos.nextFrame(); + valAccumulator.add(datum.getValue()); + } catch (final IOException e) { + throw new ServiceException(e); } - first = false; - keyAccumulator.add(datum.getKey()); - faos.nextFrame(); - valAccumulator.add(datum.getValue()); } @Override http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/formats/AvroConfigurationSerializer.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/formats/AvroConfigurationSerializer.java b/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/formats/AvroConfigurationSerializer.java index 010bbbb..0c0b976 100644 --- a/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/formats/AvroConfigurationSerializer.java +++ b/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/formats/AvroConfigurationSerializer.java @@ -97,7 +97,7 @@ public final class AvroConfigurationSerializer implements ConfigurationSerialize final String oldValue = importedNames.put(lastTok, value); if (oldValue != null) { throw new IllegalArgumentException("Name conflict: " - + lastTok + " maps to " + oldValue + " and " + value); + + lastTok + " maps to " + oldValue + " and " + value, e); } } } else if (value.startsWith(ConfigurationBuilderImpl.INIT)) { http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/formats/CommandLine.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/formats/CommandLine.java b/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/formats/CommandLine.java index 56f073f..eebd02a 100644 --- a/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/formats/CommandLine.java +++ b/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/formats/CommandLine.java @@ -197,6 +197,9 @@ public final class CommandLine { * @return a ConfigurationBuilder with the parsed parameters * @throws ParseException if the parsing of the commandline fails. */ + + // ParseException constructor does not accept a cause Exception, hence + @SuppressWarnings("checkstyle:avoidhidingcauseexception") public static ConfigurationBuilder parseToConfigurationBuilder(final String[] args, final Class<? extends Name<?>>... argClasses) throws ParseException { http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/ConfigurationBuilderImpl.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/ConfigurationBuilderImpl.java b/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/ConfigurationBuilderImpl.java index ca15e04..2173904 100644 --- a/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/ConfigurationBuilderImpl.java +++ b/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/ConfigurationBuilderImpl.java @@ -248,7 +248,7 @@ public class ConfigurationBuilderImpl implements ConfigurationBuilder { try { javanamespace.parse(iface, impl); } catch (final ParseException e) { - throw new IllegalStateException("Could not parse " + impl + " which was passed to " + iface); + throw new IllegalStateException("Could not parse " + impl + " which was passed to " + iface, e); } } boundSetEntries.put((NamedParameterNode<Set<?>>) (NamedParameterNode<?>) iface, impl); @@ -272,7 +272,7 @@ public class ConfigurationBuilderImpl implements ConfigurationBuilder { // Just for parsability checking. javanamespace.parse(iface, (String) item); } catch (final ParseException e) { - throw new IllegalStateException("Could not parse " + item + " which was passed to " + iface); + throw new IllegalStateException("Could not parse " + item + " which was passed to " + iface, e); } } } @@ -291,7 +291,7 @@ public class ConfigurationBuilderImpl implements ConfigurationBuilder { // Just for parsability checking. javanamespace.parse(ifaceNode, (String) item); } catch (final ParseException e) { - throw new IllegalStateException("Could not parse " + item + " which was passed to " + iface); + throw new IllegalStateException("Could not parse " + item + " which was passed to " + iface, e); } } } http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/avro/AvroClassHierarchy.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/avro/AvroClassHierarchy.java b/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/avro/AvroClassHierarchy.java index a120214..81a9dfc 100644 --- a/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/avro/AvroClassHierarchy.java +++ b/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/avro/AvroClassHierarchy.java @@ -153,7 +153,7 @@ final class AvroClassHierarchy implements ClassHierarchy { final String errorMessage = new StringBuilder() .append("Got 'cant happen' exception when producing error message for ") .append(e).toString(); - throw new IllegalStateException(errorMessage); + throw new IllegalStateException(errorMessage, e2); } } } http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/java/ClassHierarchyImpl.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/java/ClassHierarchyImpl.java b/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/java/ClassHierarchyImpl.java index f2d683f..ebca0a2 100644 --- a/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/java/ClassHierarchyImpl.java +++ b/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/java/ClassHierarchyImpl.java @@ -149,7 +149,7 @@ public class ClassHierarchyImpl implements JavaClassHierarchy { iface = (ClassNode<T>) getNode(np.getFullArgName()); } catch (final NameResolutionException e) { throw new IllegalStateException("Could not parse validated named parameter argument type. NamedParameter is " + - np.getFullName() + " argument type is " + np.getFullArgName()); + np.getFullName() + " argument type is " + np.getFullArgName(), e); } Class<?> clazz; String fullName; @@ -176,7 +176,7 @@ public class ClassHierarchyImpl implements JavaClassHierarchy { " cannot take non-subclass " + impl.getFullName(), e); } catch (final NameResolutionException e2) { throw new ParseException("Name<" + iface.getFullName() + "> " + np.getFullName() + - " cannot take non-class " + value, e); + " cannot take non-class " + value, e2); } } } http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/java/InjectorImpl.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/java/InjectorImpl.java b/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/java/InjectorImpl.java index d24fa5d..1e976f9 100644 --- a/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/java/InjectorImpl.java +++ b/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/java/InjectorImpl.java @@ -114,7 +114,7 @@ public class InjectorImpl implements Injector { i.instances.put(newCn, old.instances.get(cn)); } catch (final BindException e) { throw new IllegalStateException("Could not resolve name " - + cn.getFullName() + " when copying injector"); + + cn.getFullName() + " when copying injector", e); } } // Copy references to the remaining (which must have been set with @@ -318,7 +318,7 @@ public class InjectorImpl implements Injector { } catch (final ParseException e) { // Parsability is now pre-checked in bindSet, so it should not be reached! throw new IllegalStateException("Could not parse " + o + " which was passed into " + np + - " FIXME: Parsability is not currently checked by bindSetEntry(Node,String)"); + " FIXME: Parsability is not currently checked by bindSetEntry(Node,String)", e); } } else if (o instanceof Node) { ret2.add((T) o); @@ -339,7 +339,7 @@ public class InjectorImpl implements Injector { } catch (final ParseException e) { // Parsability is now pre-checked in bindList, so it should not be reached! throw new IllegalStateException("Could not parse " + o + " which was passed into " + np + " FIXME: " + - "Parsability is not currently checked by bindList(Node,List)"); + "Parsability is not currently checked by bindList(Node,List)", e); } } else if (o instanceof Node) { ret2.add((T) o); @@ -608,7 +608,7 @@ public class InjectorImpl implements Injector { pendingFutures.add(ret); return (T) ret; } catch (final ClassNotFoundException e) { - throw new InjectionException("Could not get class for " + key); + throw new InjectionException("Could not get class for " + key, e); } } else if (plan.getNode() instanceof ClassNode && null != getCachedInstance((ClassNode<T>) plan.getNode())) { return getCachedInstance((ClassNode<T>) plan.getNode()); @@ -723,7 +723,7 @@ public class InjectorImpl implements Injector { } catch (final IllegalArgumentException e) { throw new BindException( "Attempt to bind named parameter " + ReflectionUtilities.getFullName(cl) + " failed. " - + "Value is [" + o + "]"); + + "Value is [" + o + "]", e); } } else { http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/protobuf/ProtocolBufferClassHierarchy.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/protobuf/ProtocolBufferClassHierarchy.java b/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/protobuf/ProtocolBufferClassHierarchy.java index 7a8c46b..8898340 100644 --- a/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/protobuf/ProtocolBufferClassHierarchy.java +++ b/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/implementation/protobuf/ProtocolBufferClassHierarchy.java @@ -337,7 +337,7 @@ public class ProtocolBufferClassHierarchy implements ClassHierarchy { iface.putImpl((ClassNode) getNode(impl)); } catch (final NameResolutionException e) { throw new IllegalStateException("When reading protocol buffer node " - + n + " refers to non-existent implementation:" + impl); + + n + " refers to non-existent implementation:" + impl, e); } catch (final ClassCastException e) { try { throw new IllegalStateException( @@ -347,7 +347,7 @@ public class ProtocolBufferClassHierarchy implements ClassHierarchy { } catch (final NameResolutionException e2) { throw new IllegalStateException( "Got 'cant happen' exception when producing error message for " - + e); + + e, e2); } } } http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-tang/tang/src/test/java/org/apache/reef/tang/formats/TestConfigurationModule.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-tang/tang/src/test/java/org/apache/reef/tang/formats/TestConfigurationModule.java b/lang/java/reef-tang/tang/src/test/java/org/apache/reef/tang/formats/TestConfigurationModule.java index d03a237..ce064ba 100644 --- a/lang/java/reef-tang/tang/src/test/java/org/apache/reef/tang/formats/TestConfigurationModule.java +++ b/lang/java/reef-tang/tang/src/test/java/org/apache/reef/tang/formats/TestConfigurationModule.java @@ -174,6 +174,7 @@ public class TestConfigurationModule { } @Test + @SuppressWarnings("checkstyle:avoidhidingcauseexception") public void omitRequiredTest() throws Throwable { thrown.expect(BindException.class); thrown.expectMessage("Attempt to build configuration before setting required option(s): { THE_FOO }"); @@ -212,6 +213,7 @@ public class TestConfigurationModule { } @Test + @SuppressWarnings("checkstyle:avoidhidingcauseexception") public void badConfTest() throws Throwable { thrown.expect(ClassHierarchyException.class); thrown.expectMessage("Found declared options that were not used in binds: { FOO_NESS }"); @@ -254,6 +256,7 @@ public class TestConfigurationModule { } @Test + @SuppressWarnings("checkstyle:avoidhidingcauseexception") public void foreignSetTest() throws Throwable { thrown.expect(ClassHierarchyException.class); thrown.expectMessage("Unknown Impl/Param when setting RequiredImpl. " + @@ -267,6 +270,7 @@ public class TestConfigurationModule { } @Test + @SuppressWarnings("checkstyle:avoidhidingcauseexception") public void foreignBindTest() throws Throwable { thrown.expect(ClassHierarchyException.class); thrown.expectMessage("Unknown Impl/Param when binding RequiredImpl. " + http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-tests/src/test/java/org/apache/reef/tests/applications/vortex/cancellation/TaskletCancellationTestStart.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/applications/vortex/cancellation/TaskletCancellationTestStart.java b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/applications/vortex/cancellation/TaskletCancellationTestStart.java index 3a53b1f..52a7dd7 100644 --- a/lang/java/reef-tests/src/test/java/org/apache/reef/tests/applications/vortex/cancellation/TaskletCancellationTestStart.java +++ b/lang/java/reef-tests/src/test/java/org/apache/reef/tests/applications/vortex/cancellation/TaskletCancellationTestStart.java @@ -52,7 +52,7 @@ public final class TaskletCancellationTestStart implements VortexStart { // Harmless. } catch (final Exception e) { e.printStackTrace(); - throw new RuntimeException("Unexpected exception."); + throw new RuntimeException("Unexpected exception.", e); } Assert.assertTrue(future.cancel(true)); http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-wake/wake/src/main/java/org/apache/reef/wake/remote/address/LegacyLocalAddressProvider.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-wake/wake/src/main/java/org/apache/reef/wake/remote/address/LegacyLocalAddressProvider.java b/lang/java/reef-wake/wake/src/main/java/org/apache/reef/wake/remote/address/LegacyLocalAddressProvider.java index 50c5e5b..140c337 100644 --- a/lang/java/reef-wake/wake/src/main/java/org/apache/reef/wake/remote/address/LegacyLocalAddressProvider.java +++ b/lang/java/reef-wake/wake/src/main/java/org/apache/reef/wake/remote/address/LegacyLocalAddressProvider.java @@ -83,8 +83,7 @@ public final class LegacyLocalAddressProvider implements LocalAddressProvider { cached.set(sortedAddrs.pollFirst().getHostAddress()); LOG.log(Level.FINE, "Local address is {0}", cached.get()); } catch (final SocketException e) { - throw new WakeRuntimeException("Unable to get local host address", - e.getCause()); + throw new WakeRuntimeException("Unable to get local host address", e); } } return cached.get(); http://git-wip-us.apache.org/repos/asf/reef/blob/a67bdbaa/lang/java/reef-wake/wake/src/main/java/org/apache/reef/wake/remote/transport/netty/NettyMessagingTransport.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-wake/wake/src/main/java/org/apache/reef/wake/remote/transport/netty/NettyMessagingTransport.java b/lang/java/reef-wake/wake/src/main/java/org/apache/reef/wake/remote/transport/netty/NettyMessagingTransport.java index 22d0c49..c37e556 100644 --- a/lang/java/reef-wake/wake/src/main/java/org/apache/reef/wake/remote/transport/netty/NettyMessagingTransport.java +++ b/lang/java/reef-wake/wake/src/main/java/org/apache/reef/wake/remote/transport/netty/NettyMessagingTransport.java @@ -181,7 +181,7 @@ public class NettyMessagingTransport implements Transport { } } catch (final IllegalStateException ex) { final RuntimeException transportException = - new TransportRuntimeException("tcpPortProvider failed to return free ports."); + new TransportRuntimeException("tcpPortProvider failed to return free ports.", ex); LOG.log(Level.SEVERE, "Cannot find a free port with " + tcpPortProvider, transportException); this.clientWorkerGroup.shutdownGracefully(); @@ -191,7 +191,7 @@ public class NettyMessagingTransport implements Transport { } catch (final Exception ex) { final RuntimeException transportException = - new TransportRuntimeException("Cannot bind to port " + p); + new TransportRuntimeException("Cannot bind to port " + p, ex); LOG.log(Level.SEVERE, "Cannot bind to port " + p, ex); this.clientWorkerGroup.shutdownGracefully();
