From b7822e8f88efbcda68f820e80dbcebf8b0f28b66 Mon Sep 17 00:00:00 2001 From: Carl Mastrangelo Date: Thu, 6 Aug 2015 11:21:14 -0700 Subject: [PATCH] Fix javadoc, and remove deprecated classes --- core/src/main/java/io/grpc/Status.java | 54 +++---------------- .../main/java/io/grpc/StatusException.java | 15 ++++-- .../java/io/grpc/StatusRuntimeException.java | 14 +++-- 3 files changed, 30 insertions(+), 53 deletions(-) diff --git a/core/src/main/java/io/grpc/Status.java b/core/src/main/java/io/grpc/Status.java index 0b994e7c0e..37208fbbd5 100644 --- a/core/src/main/java/io/grpc/Status.java +++ b/core/src/main/java/io/grpc/Status.java @@ -324,17 +324,17 @@ public final class Status { */ public static Status fromThrowable(Throwable t) { for (Throwable cause : Throwables.getCausalChain(t)) { - if (cause instanceof OperationException) { - return ((Status.OperationException) cause).getStatus(); - } else if (cause instanceof OperationRuntimeException) { - return ((Status.OperationRuntimeException) cause).getStatus(); + if (cause instanceof StatusException) { + return ((StatusException) cause).getStatus(); + } else if (cause instanceof StatusRuntimeException) { + return ((StatusRuntimeException) cause).getStatus(); } } // Couldn't find a cause with a Status return UNKNOWN.withCause(t); } - private static String formatThrowableMessage(Status status) { + static String formatThrowableMessage(Status status) { if (status.description == null) { return status.code.toString(); } else { @@ -421,7 +421,7 @@ public final class Status { } /** - * Convert this {@link Status} to a {@link RuntimeException}. Use {@code #fromThrowable} + * Convert this {@link Status} to a {@link RuntimeException}. Use {@link #fromThrowable} * to recover this {@link Status} instance when the returned exception is in the causal chain. */ public StatusRuntimeException asRuntimeException() { @@ -429,7 +429,7 @@ public final class Status { } /** - * Convert this {@link Status} to an {@link Exception}. Use {@code #fromThrowable} + * Convert this {@link Status} to an {@link Exception}. Use {@link #fromThrowable} * to recover this {@link Status} instance when the returned exception is in the causal chain. */ public StatusException asException() { @@ -448,46 +448,6 @@ public final class Status { .toString(); } - /** - * Exception thrown by implementations while managing an operation. - * - * @deprecated Use {@link StatusException} instead - */ - @Deprecated - public static class OperationException extends Exception { - private static final long serialVersionUID = -660954903976144640L; - private final Status status; - - public OperationException(Status status) { - super(formatThrowableMessage(status), status.getCause()); - this.status = status; - } - - public Status getStatus() { - return status; - } - } - - /** - * Runtime exception thrown by implementations while managing an operation. - * - * @deprecated Use {@link StatusRuntimeException} instead - */ - @Deprecated - public static class OperationRuntimeException extends RuntimeException { - private static final long serialVersionUID = 1950934672280720624L; - private final Status status; - - public OperationRuntimeException(Status status) { - super(formatThrowableMessage(status), status.getCause()); - this.status = status; - } - - public Status getStatus() { - return status; - } - } - private static class StatusCodeMarshaller implements Metadata.AsciiMarshaller { @Override public String toAsciiString(Status status) { diff --git a/core/src/main/java/io/grpc/StatusException.java b/core/src/main/java/io/grpc/StatusException.java index ccb7bc3f79..d4b2b032d3 100644 --- a/core/src/main/java/io/grpc/StatusException.java +++ b/core/src/main/java/io/grpc/StatusException.java @@ -31,14 +31,23 @@ package io.grpc; +import static io.grpc.Status.formatThrowableMessage; + /** * {@link Status} in Exception form, for propagating Status information via exceptions. * * @see StatusRuntimeException */ -@SuppressWarnings("deprecation") -public class StatusException extends Status.OperationException { +public class StatusException extends Exception { + private static final long serialVersionUID = -660954903976144640L; + private final Status status; + public StatusException(Status status) { - super(status); + super(formatThrowableMessage(status), status.getCause()); + this.status = status; + } + + public Status getStatus() { + return status; } } diff --git a/core/src/main/java/io/grpc/StatusRuntimeException.java b/core/src/main/java/io/grpc/StatusRuntimeException.java index 04bbbecce3..f7623de296 100644 --- a/core/src/main/java/io/grpc/StatusRuntimeException.java +++ b/core/src/main/java/io/grpc/StatusRuntimeException.java @@ -36,9 +36,17 @@ package io.grpc; * * @see StatusException */ -@SuppressWarnings("deprecation") -public class StatusRuntimeException extends Status.OperationRuntimeException { +public class StatusRuntimeException extends RuntimeException { + + private static final long serialVersionUID = 1950934672280720624L; + private final Status status; + public StatusRuntimeException(Status status) { - super(status); + super(Status.formatThrowableMessage(status), status.getCause()); + this.status = status; + } + + public Status getStatus() { + return status; } }