Moves classes to brooklyn.util.exceptions - Moves RuntimeInterruptedException and Exceptions, from brooklyn.util to brooklyn.util.exceptions
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/f3243177 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/f3243177 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/f3243177 Branch: refs/heads/0.4.0 Commit: f324317764f14078220965d8cd51d93555ed87e2 Parents: 5e34360 Author: Aled Sage <[email protected]> Authored: Sat Oct 20 20:52:59 2012 +0100 Committer: Aled Sage <[email protected]> Committed: Sat Oct 20 20:52:59 2012 +0100 ---------------------------------------------------------------------- .../java/brooklyn/event/adapter/JmxHelper.java | 2 +- .../location/geo/UtraceHostGeoLookup.java | 4 ++-- .../src/main/java/brooklyn/util/Exceptions.java | 16 ------------- .../util/RuntimeInterruptedException.java | 25 -------------------- core/src/main/java/brooklyn/util/Time.java | 1 + .../brooklyn/util/exceptions/Exceptions.java | 16 +++++++++++++ .../exceptions/RuntimeInterruptedException.java | 25 ++++++++++++++++++++ .../entity/basic/lifecycle/ScriptHelper.java | 2 +- 8 files changed, 46 insertions(+), 45 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f3243177/core/src/main/java/brooklyn/event/adapter/JmxHelper.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/event/adapter/JmxHelper.java b/core/src/main/java/brooklyn/event/adapter/JmxHelper.java index 9664c4f..2b80f09 100644 --- a/core/src/main/java/brooklyn/event/adapter/JmxHelper.java +++ b/core/src/main/java/brooklyn/event/adapter/JmxHelper.java @@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory; import brooklyn.entity.basic.Attributes; import brooklyn.entity.basic.EntityLocal; import brooklyn.util.MutableMap; -import brooklyn.util.RuntimeInterruptedException; +import brooklyn.util.exceptions.RuntimeInterruptedException; import brooklyn.util.internal.LanguageUtils; import brooklyn.util.internal.TimeExtras; http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f3243177/core/src/main/java/brooklyn/location/geo/UtraceHostGeoLookup.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/location/geo/UtraceHostGeoLookup.java b/core/src/main/java/brooklyn/location/geo/UtraceHostGeoLookup.java index 7fb7cf8..c4829cb 100644 --- a/core/src/main/java/brooklyn/location/geo/UtraceHostGeoLookup.java +++ b/core/src/main/java/brooklyn/location/geo/UtraceHostGeoLookup.java @@ -14,10 +14,10 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import brooklyn.util.Exceptions; import brooklyn.util.NetworkUtils; import brooklyn.util.ResourceUtils; -import brooklyn.util.RuntimeInterruptedException; +import brooklyn.util.exceptions.Exceptions; +import brooklyn.util.exceptions.RuntimeInterruptedException; import com.google.common.base.Throwables; http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f3243177/core/src/main/java/brooklyn/util/Exceptions.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/util/Exceptions.java b/core/src/main/java/brooklyn/util/Exceptions.java deleted file mode 100644 index efda008..0000000 --- a/core/src/main/java/brooklyn/util/Exceptions.java +++ /dev/null @@ -1,16 +0,0 @@ -package brooklyn.util; - -import com.google.common.base.Throwables; - -public class Exceptions { - - /** like guava {@link Throwables#propagate(Throwable)}, - * but set interrupted if interrupted exception (why doesn't guava do this?!), - * and throw {@link RuntimeInterruptedException} */ - public static RuntimeException propagate(Throwable throwable) { - if (throwable instanceof InterruptedException) - throw new RuntimeInterruptedException((InterruptedException)throwable); - return Throwables.propagate(throwable); - } - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f3243177/core/src/main/java/brooklyn/util/RuntimeInterruptedException.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/util/RuntimeInterruptedException.java b/core/src/main/java/brooklyn/util/RuntimeInterruptedException.java deleted file mode 100644 index a125db4..0000000 --- a/core/src/main/java/brooklyn/util/RuntimeInterruptedException.java +++ /dev/null @@ -1,25 +0,0 @@ -package brooklyn.util; - -/** - * A {@link RuntimeException} that is thrown when a Thread is interrupted. - * - * This exception is useful if a Thread needs to be interrupted, but the {@link InterruptedException} can't be thrown - * because it is checked. - * - * When the RuntimeInterruptedException is created, it will automatically set the interrupt status on the calling - * thread. - * - * @author Peter Veentjer. - */ -public class RuntimeInterruptedException extends RuntimeException { - - public RuntimeInterruptedException(InterruptedException cause) { - super(cause); - Thread.currentThread().interrupt(); - } - - @Override - public InterruptedException getCause() { - return (InterruptedException) super.getCause(); - } -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f3243177/core/src/main/java/brooklyn/util/Time.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/util/Time.java b/core/src/main/java/brooklyn/util/Time.java index f49eccd..79c96d4 100644 --- a/core/src/main/java/brooklyn/util/Time.java +++ b/core/src/main/java/brooklyn/util/Time.java @@ -12,6 +12,7 @@ import java.util.GregorianCalendar; import java.util.TimeZone; import java.util.concurrent.TimeUnit; +import brooklyn.util.exceptions.Exceptions; import brooklyn.util.text.Strings; public class Time { http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f3243177/core/src/main/java/brooklyn/util/exceptions/Exceptions.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/util/exceptions/Exceptions.java b/core/src/main/java/brooklyn/util/exceptions/Exceptions.java new file mode 100644 index 0000000..dad464e --- /dev/null +++ b/core/src/main/java/brooklyn/util/exceptions/Exceptions.java @@ -0,0 +1,16 @@ +package brooklyn.util.exceptions; + +import com.google.common.base.Throwables; + +public class Exceptions { + + /** like guava {@link Throwables#propagate(Throwable)}, + * but set interrupted if interrupted exception (why doesn't guava do this?!), + * and throw {@link RuntimeInterruptedException} */ + public static RuntimeException propagate(Throwable throwable) { + if (throwable instanceof InterruptedException) + throw new RuntimeInterruptedException((InterruptedException)throwable); + return Throwables.propagate(throwable); + } + +} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f3243177/core/src/main/java/brooklyn/util/exceptions/RuntimeInterruptedException.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/util/exceptions/RuntimeInterruptedException.java b/core/src/main/java/brooklyn/util/exceptions/RuntimeInterruptedException.java new file mode 100644 index 0000000..dba5e2f --- /dev/null +++ b/core/src/main/java/brooklyn/util/exceptions/RuntimeInterruptedException.java @@ -0,0 +1,25 @@ +package brooklyn.util.exceptions; + +/** + * A {@link RuntimeException} that is thrown when a Thread is interrupted. + * + * This exception is useful if a Thread needs to be interrupted, but the {@link InterruptedException} can't be thrown + * because it is checked. + * + * When the RuntimeInterruptedException is created, it will automatically set the interrupt status on the calling + * thread. + * + * @author Peter Veentjer. + */ +public class RuntimeInterruptedException extends RuntimeException { + + public RuntimeInterruptedException(InterruptedException cause) { + super(cause); + Thread.currentThread().interrupt(); + } + + @Override + public InterruptedException getCause() { + return (InterruptedException) super.getCause(); + } +} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f3243177/software/base/src/main/java/brooklyn/entity/basic/lifecycle/ScriptHelper.java ---------------------------------------------------------------------- diff --git a/software/base/src/main/java/brooklyn/entity/basic/lifecycle/ScriptHelper.java b/software/base/src/main/java/brooklyn/entity/basic/lifecycle/ScriptHelper.java index a1263e7..ba14942 100644 --- a/software/base/src/main/java/brooklyn/entity/basic/lifecycle/ScriptHelper.java +++ b/software/base/src/main/java/brooklyn/entity/basic/lifecycle/ScriptHelper.java @@ -15,7 +15,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import brooklyn.util.GroovyJavaMethods; -import brooklyn.util.RuntimeInterruptedException; +import brooklyn.util.exceptions.RuntimeInterruptedException; import brooklyn.util.mutex.WithMutexes; import brooklyn.util.task.Tasks;
