mirror of https://github.com/grpc/grpc-java.git
Handle exceptions in after
This commit is contained in:
parent
778804f4c5
commit
f8d30afb20
|
|
@ -21,6 +21,7 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.ManagedChannelBuilder;
|
||||
import io.grpc.internal.MoreThrowables;
|
||||
import io.grpc.okhttp.OkHttpChannelBuilder;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
|
@ -181,8 +182,21 @@ public final class OkHttpClientInteropServlet extends HttpServlet {
|
|||
return new AutoCloseable() {
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
Throwable failure = null;
|
||||
for (Method method : methods) {
|
||||
try {
|
||||
method.invoke(o);
|
||||
} catch (Throwable t) {
|
||||
if (failure == null) {
|
||||
failure = t;
|
||||
} else {
|
||||
failure.addSuppressed(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (failure != null) {
|
||||
MoreThrowables.throwIfUnchecked(failure);
|
||||
throw new Exception(failure);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue