diff --git a/src/main/java/sbt/testing/OptionalThrowable.java b/src/main/java/sbt/testing/OptionalThrowable.java index fa3f16e..b637762 100644 --- a/src/main/java/sbt/testing/OptionalThrowable.java +++ b/src/main/java/sbt/testing/OptionalThrowable.java @@ -11,11 +11,10 @@ public final class OptionalThrowable implements Serializable { /** * Constructs an OptionalThrowable containing a Throwable. + * @param exception if null an empty OptionalThrowable will be created + * @see sbt.testing.OptionalThrowable#isEmpty() */ public OptionalThrowable(Throwable exception) { - if (exception == null) { - throw new NullPointerException("Cannot pass a null exception to OptionalThrowable's constructor."); - } this.exception = exception; } diff --git a/src/test/scala/sbt/testing/OptionalThrowableSpec.scala b/src/test/scala/sbt/testing/OptionalThrowableSpec.scala index dbb288c..6929502 100644 --- a/src/test/scala/sbt/testing/OptionalThrowableSpec.scala +++ b/src/test/scala/sbt/testing/OptionalThrowableSpec.scala @@ -37,10 +37,9 @@ class OptionalThrowableSpec extends UnitSpec { } } } - def `should throw NPE from constructor if null passed` { - a [NullPointerException] should be thrownBy { - new OptionalThrowable(null) - } + def `should be empty and not-defined if constructed with null` { + new OptionalThrowable(null).isEmpty shouldBe true + new OptionalThrowable(null).isDefined shouldBe false } def `should have a properly behaving equals method` { def1 shouldEqual def1