From d45404a338e638035c636063a9144b6ad19ed09f Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Thu, 3 May 2012 15:32:33 -0700 Subject: [PATCH] Throw exceptions in static blocks This reports any errors instead of silently ignoring them. --- .../cloudsigma/binders/BindServerToPlainTextStringTest.java | 5 +++-- .../binders/BindServerToPlainTextStringTest.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextStringTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextStringTest.java index 14b0a4e457..463e172ff1 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextStringTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextStringTest.java @@ -39,6 +39,7 @@ import org.testng.annotations.Test; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.base.Throwables; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.TypeLiteral; @@ -50,13 +51,13 @@ import com.google.inject.TypeLiteral; @Test(groups = { "unit" }) public class BindServerToPlainTextStringTest { - public static String CREATED_SERVER; + public static final String CREATED_SERVER; static { try { CREATED_SERVER = Strings2.toStringAndClose(BindServerToPlainTextStringTest.class .getResourceAsStream("/create_server.txt")); } catch (IOException e) { - CREATED_SERVER = null; + throw Throwables.propagate(e); } } public static final Server SERVER = new Server.Builder() diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/binders/BindServerToPlainTextStringTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/binders/BindServerToPlainTextStringTest.java index d4972ecf00..818eefd2e2 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/binders/BindServerToPlainTextStringTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/binders/BindServerToPlainTextStringTest.java @@ -40,6 +40,7 @@ import org.testng.annotations.Test; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.base.Throwables; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; @@ -52,13 +53,13 @@ import com.google.inject.TypeLiteral; @Test(groups = { "unit" }) public class BindServerToPlainTextStringTest { - public static String CREATED_SERVER; + public static final String CREATED_SERVER; static { try { CREATED_SERVER = Strings2.toStringAndClose(BindServerToPlainTextStringTest.class .getResourceAsStream("/create_server.txt")); } catch (IOException e) { - CREATED_SERVER = null; + throw Throwables.propagate(e); } } public static final Server SERVER = new Server.Builder()