steveloughran commented on code in PR #5863:
URL: https://github.com/apache/hadoop/pull/5863#discussion_r1269222686
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RemoteException.java:
##########
@@ -47,12 +50,23 @@ public RemoteException(String className, String msg) {
* @param erCode may be null
*/
public RemoteException(String className, String msg, RpcErrorCodeProto
erCode) {
+ this(className, msg, erCode, null);
+ }
+
+ /**
+ * @param className wrapped exception, may be null
Review Comment:
nit: add a . here and in other javadocs, to keep the compilers happy
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestProtoBufRpc.java:
##########
@@ -329,7 +331,30 @@ public void testProtoBufRandomException() throws Exception
{
.isEqualTo(RpcErrorCodeProto.ERROR_APPLICATION);
}
}
-
+
+ @Test (timeout=5000)
+ public void testProtoBufReconstructableException() throws Exception {
+ //No test with legacy
+ assumeFalse(testWithLegacy);
+ TestRpcService client = getClient(addr, conf);
+
+ try {
+ client.error3(null, newEmptyRequest());
+ } catch (ServiceException se) {
+ assertThat(se.getCause()).isInstanceOf(RemoteException.class);
Review Comment:
if you use the AssertJ assertThat() (which a lot of new code does) you can
explictily use an .isInstanceOf() assert and get more detail on the error
##########
hadoop-common-project/hadoop-common/src/main/proto/RpcHeader.proto:
##########
@@ -165,6 +165,7 @@ message RpcResponseHeaderProto {
// The client should not interpret these bytes, but only
// forward them to the router using
RpcRequestHeaderProto.routerFederatedState.
optional bytes routerFederatedState = 10;
+ optional ExceptionReconstructParamsProto exceptionReconstructParams = 11;
Review Comment:
add a comment above to ensure no confusion with the comment at L165
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/protocolPB/PBHelper.java:
##########
@@ -134,4 +136,14 @@ public static FileStatusProto convert(FileStatus stat)
throws IOException {
return bld.build();
}
+ public static ExceptionReconstructParamsProto getReconstructParams(Throwable
t) {
+ if (t instanceof ReconstructableException) {
Review Comment:
and instance of IOException?
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestReconstructableException.java:
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ipc;
+
+import java.io.IOException;
+
+/**
+ * Test class of ReconstructableException.
+ */
+public class TestReconstructableException extends IOException
Review Comment:
as all unit tests begin with Test, I'd prefer a different classname to aviod
confusion
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestReconstructableException.java:
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ipc;
+
+import java.io.IOException;
+
+/**
+ * Test class of ReconstructableException.
+ */
+public class TestReconstructableException extends IOException
+ implements ReconstructableException<TestReconstructableException> {
+
+ private String field1;
+ private String field2;
Review Comment:
make one final, to see what happens
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RemoteException.java:
##########
@@ -47,12 +50,23 @@ public RemoteException(String className, String msg) {
* @param erCode may be null
*/
public RemoteException(String className, String msg, RpcErrorCodeProto
erCode) {
+ this(className, msg, erCode, null);
+ }
+
+ /**
+ * @param className wrapped exception, may be null
+ * @param msg may be null
+ * @param erCode may be null
+ */
+ public RemoteException(String className, String msg, RpcErrorCodeProto
erCode,
+ ExceptionReconstructParamsProto paramsProto) {
super(msg);
this.className = className;
if (erCode != null)
Review Comment:
good time to add {} here, or move to ? : instead. I know its old code, but
it is adjacent to your work
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]