Skip to content

Commit 4672315

Browse files
committed
YARN-3770. SerializedException should also handle java.lang.Error on de-serialization. Contributed by Lavkesh Lahngir
1 parent 460e98f commit 4672315

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

hadoop-yarn-project/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,9 @@ Release 2.8.0 - UNRELEASED
571571
YARN-3695. ServerProxy (NMProxy, etc.) shouldn't retry forever for non
572572
network exception. (Raju Bairishetti via jianhe)
573573

574+
YARN-3770. SerializedException should also handle java.lang.Error on
575+
de-serialization. (Lavkesh Lahngir via jianhe)
576+
574577
Release 2.7.2 - UNRELEASED
575578

576579
INCOMPATIBLE CHANGES

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/SerializedExceptionPBImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public Throwable deSerialize() {
101101
} else if (RuntimeException.class.isAssignableFrom(realClass)) {
102102
classType = RuntimeException.class;
103103
} else {
104-
classType = Exception.class;
104+
classType = Throwable.class;
105105
}
106106
return instantiateException(realClass.asSubclass(classType), getMessage(),
107107
cause == null ? null : cause.deSerialize());

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/impl/pb/TestSerializedExceptionPBImpl.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020

2121
import java.nio.channels.ClosedChannelException;
2222

23-
import org.junit.Assert;
24-
import org.apache.hadoop.yarn.api.records.impl.pb.SerializedExceptionPBImpl;
2523
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
2624
import org.apache.hadoop.yarn.proto.YarnProtos.SerializedExceptionProto;
25+
import org.junit.Assert;
2726
import org.junit.Test;
2827

2928
public class TestSerializedExceptionPBImpl {
@@ -79,4 +78,13 @@ public void testBeforeInit() throws Exception {
7978
SerializedExceptionPBImpl pb3 = new SerializedExceptionPBImpl();
8079
Assert.assertEquals(defaultProto.getTrace(), pb3.getRemoteTrace());
8180
}
81+
82+
@Test
83+
public void testThrowableDeserialization() {
84+
// java.lang.Error should also be serializable
85+
Error ex = new Error();
86+
SerializedExceptionPBImpl pb = new SerializedExceptionPBImpl();
87+
pb.init(ex);
88+
Assert.assertEquals(ex.getClass(), pb.deSerialize().getClass());
89+
}
8290
}

0 commit comments

Comments
 (0)