Throw exceptions in static blocks

This reports any errors instead of silently ignoring them.
This commit is contained in:
Andrew Gaul 2012-05-03 15:32:33 -07:00 committed by Andrew Gaul
parent a895869e6f
commit d45404a338
2 changed files with 6 additions and 4 deletions

View File

@ -39,6 +39,7 @@ import org.testng.annotations.Test;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.base.Throwables;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Guice; import com.google.inject.Guice;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
@ -50,13 +51,13 @@ import com.google.inject.TypeLiteral;
@Test(groups = { "unit" }) @Test(groups = { "unit" })
public class BindServerToPlainTextStringTest { public class BindServerToPlainTextStringTest {
public static String CREATED_SERVER; public static final String CREATED_SERVER;
static { static {
try { try {
CREATED_SERVER = Strings2.toStringAndClose(BindServerToPlainTextStringTest.class CREATED_SERVER = Strings2.toStringAndClose(BindServerToPlainTextStringTest.class
.getResourceAsStream("/create_server.txt")); .getResourceAsStream("/create_server.txt"));
} catch (IOException e) { } catch (IOException e) {
CREATED_SERVER = null; throw Throwables.propagate(e);
} }
} }
public static final Server SERVER = new Server.Builder() public static final Server SERVER = new Server.Builder()

View File

@ -40,6 +40,7 @@ import org.testng.annotations.Test;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.base.Throwables;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Guice; import com.google.inject.Guice;
import com.google.inject.Injector; import com.google.inject.Injector;
@ -52,13 +53,13 @@ import com.google.inject.TypeLiteral;
@Test(groups = { "unit" }) @Test(groups = { "unit" })
public class BindServerToPlainTextStringTest { public class BindServerToPlainTextStringTest {
public static String CREATED_SERVER; public static final String CREATED_SERVER;
static { static {
try { try {
CREATED_SERVER = Strings2.toStringAndClose(BindServerToPlainTextStringTest.class CREATED_SERVER = Strings2.toStringAndClose(BindServerToPlainTextStringTest.class
.getResourceAsStream("/create_server.txt")); .getResourceAsStream("/create_server.txt"));
} catch (IOException e) { } catch (IOException e) {
CREATED_SERVER = null; throw Throwables.propagate(e);
} }
} }
public static final Server SERVER = new Server.Builder() public static final Server SERVER = new Server.Builder()