File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
src/com/esotericsoftware/kryo/serializers
test/com/esotericsoftware/kryo/serializers Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -84,8 +84,13 @@ private static class ObjectInputStreamWithKryoClassLoader extends ObjectInputStr
84
84
protected Class resolveClass (ObjectStreamClass type ) {
85
85
try {
86
86
return Class .forName (type .getName (), false , kryo .getClassLoader ());
87
+ } catch (ClassNotFoundException ignored ) {}
88
+ try {
89
+ return super .resolveClass (type );
87
90
} catch (ClassNotFoundException ex ) {
88
91
throw new KryoException ("Class not found: " + type .getName (), ex );
92
+ } catch (IOException ex ) {
93
+ throw new KryoException ("Could not load class: " + type .getName (), ex );
89
94
}
90
95
}
91
96
}
Original file line number Diff line number Diff line change 22
22
import com .esotericsoftware .kryo .KryoTestCase ;
23
23
24
24
import java .io .Serializable ;
25
+ import java .net .URL ;
26
+ import java .net .URLClassLoader ;
25
27
26
28
import org .junit .jupiter .api .Test ;
27
29
@@ -42,6 +44,17 @@ void testJavaSerializer () {
42
44
roundTrip (146 , test );
43
45
}
44
46
47
+ @ Test
48
+ void testJavaSerializerFallbackToDefaultClassLoader () {
49
+ kryo .setClassLoader (new URLClassLoader (new URL []{}, null ));
50
+
51
+ kryo .register (TestClass .class , new JavaSerializer ());
52
+
53
+ TestClass test = new TestClass ();
54
+ test .intField = 54321 ;
55
+ roundTrip (139 , test );
56
+ }
57
+
45
58
public static class TestClass implements Serializable {
46
59
String stringField ;
47
60
int intField ;
You can’t perform that action at this time.
0 commit comments