Skip to content

Commit

Permalink
[Java] register common exception (#879)
Browse files Browse the repository at this point in the history
register common exception
  • Loading branch information
chaokunyang authored Aug 18, 2023
1 parent 8e4a84d commit b889a78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
import io.fury.util.StringUtils;
import io.fury.util.function.Functions;
import java.io.Externalizable;
import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -371,6 +372,12 @@ private void registerDefaultClasses() {
register(EnumSet.allOf(Language.class).getClass());
register(EnumSet.of(Language.JAVA).getClass());
register(UnexistedMetaSharedClass.class, UnexistedSkipClass.class);
register(Throwable.class, StackTraceElement.class, Exception.class, RuntimeException.class);
register(NullPointerException.class);
register(IOException.class);
register(IllegalArgumentException.class);
register(IllegalStateException.class);
register(IndexOutOfBoundsException.class, ArrayIndexOutOfBoundsException.class);
}

/** register class. */
Expand Down
6 changes: 6 additions & 0 deletions java/fury-core/src/test/java/io/fury/FuryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ public void serializeBeanTest(boolean referenceTracking) {
assertEquals(beanA, o);
}

@Test
public void testSerializeException() {
Fury fury = Fury.builder().withLanguage(Language.JAVA).withRefTracking(true).build();
fury.serialize(new Exception());
}

@Test(dataProvider = "referenceTrackingConfig")
public void registerTest(boolean referenceTracking) {
Fury fury =
Expand Down

0 comments on commit b889a78

Please sign in to comment.