diff --git a/gcloud-java-compute/src/main/java/com/google/gcloud/compute/ComputeException.java b/gcloud-java-compute/src/main/java/com/google/gcloud/compute/ComputeException.java index e63d61f2792d..c6e7ef734442 100644 --- a/gcloud-java-compute/src/main/java/com/google/gcloud/compute/ComputeException.java +++ b/gcloud-java-compute/src/main/java/com/google/gcloud/compute/ComputeException.java @@ -32,11 +32,11 @@ public class ComputeException extends BaseServiceException { private static final Set RETRYABLE_ERRORS = ImmutableSet.of(new Error(500, null)); private static final long serialVersionUID = -8039359778707845810L; - public ComputeException(int code, String message) { + ComputeException(int code, String message) { super(code, message, null, true, null); } - private ComputeException(int code, String message, Throwable cause) { + ComputeException(int code, String message, Throwable cause) { super(code, message, null, true, cause); } diff --git a/gcloud-java-compute/src/test/java/com/google/gcloud/compute/ComputeExceptionTest.java b/gcloud-java-compute/src/test/java/com/google/gcloud/compute/ComputeExceptionTest.java index 995be7841624..f98bfa150d8c 100644 --- a/gcloud-java-compute/src/test/java/com/google/gcloud/compute/ComputeExceptionTest.java +++ b/gcloud-java-compute/src/test/java/com/google/gcloud/compute/ComputeExceptionTest.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import com.google.gcloud.BaseServiceException; @@ -57,7 +58,15 @@ public void testResourceManagerException() { assertNull(exception.getMessage()); assertTrue(exception.retryable()); assertTrue(exception.idempotent()); - assertEquals(cause, exception.getCause()); + assertSame(cause, exception.getCause()); + + exception = new ComputeException(403, "message", cause); + assertEquals(403, exception.code()); + assertEquals("message", exception.getMessage()); + assertNull(exception.reason()); + assertFalse(exception.retryable()); + assertTrue(exception.idempotent()); + assertSame(cause, exception.getCause()); } @Test @@ -88,7 +97,7 @@ public void testTranslateAndThrow() throws Exception { assertEquals("message", ex.getMessage()); assertFalse(ex.retryable()); assertTrue(ex.idempotent()); - assertEquals(cause, ex.getCause()); + assertSame(cause, ex.getCause()); } finally { verify(exceptionMock); }