diff --git a/src/main/java/net/openhft/chronicle/wire/WireMarshaller.java b/src/main/java/net/openhft/chronicle/wire/WireMarshaller.java index 8822626a4..ec288656a 100644 --- a/src/main/java/net/openhft/chronicle/wire/WireMarshaller.java +++ b/src/main/java/net/openhft/chronicle/wire/WireMarshaller.java @@ -1433,7 +1433,7 @@ protected void setValue(Object o, @NotNull ValueIn read, boolean overwrite) thro Object object = null; try { object = read.object(using, type, false); - } catch (Exception e) { + } catch (ClassNotFoundRuntimeException e) { // "Unhandled" Abstract classes that are not types should be null (Enums are abstract classes in Java but should not be null here) if (using == null && Modifier.isAbstract(type.getModifiers()) && @@ -1441,6 +1441,7 @@ protected void setValue(Object o, @NotNull ValueIn read, boolean overwrite) thro !type.isEnum() && !read.isTyped()) { // retain the null value of object + read.wireIn().bytes().readPosition(pos); Jvm.warn().on(getClass(), "Ignoring exception and setting field '" + field.getName() + "' to null", e); } else { Jvm.rethrow(e); diff --git a/src/test/java/net/openhft/chronicle/wire/AbstractUntypedFieldTest.java b/src/test/java/net/openhft/chronicle/wire/AbstractUntypedFieldTest.java index 3806916b6..36ab759da 100644 --- a/src/test/java/net/openhft/chronicle/wire/AbstractUntypedFieldTest.java +++ b/src/test/java/net/openhft/chronicle/wire/AbstractUntypedFieldTest.java @@ -53,8 +53,9 @@ void beforeEach() { void typedFieldsShouldBeNonNull(Function, Wire> wireConstruction) { final Bytes bytes = Bytes.from("" + "!net.openhft.chronicle.wire.AbstractUntypedFieldShouldBeNull$Holder {\n" + - " a: !AImpl {\n" + - " }\n" + + " \"a\": !AImpl {\n" + + " }," + + " \"b\": \"Impl\",\n" + "}"); final Wire textWire = wireConstruction.apply(bytes); @@ -71,8 +72,9 @@ void typedFieldsShouldBeNonNull(Function, Wire> wireConstruction) @MethodSource("provideWire") void untypedFieldsShouldBeNull(Function, Wire> wireConstruction) { final Bytes bytes = Bytes.from("!net.openhft.chronicle.wire.AbstractUntypedFieldShouldBeNull$Holder {\n" + - " a: {\n" + - " }\n" + + " \"a\": {\n" + + " }," + + " \"b\": \"Abstract\",\n" + "}"); final Wire textWire = wireConstruction.apply(bytes); @@ -112,6 +114,7 @@ private static final class AImpl extends A { // Holder class to hold instances of type A private static final class Holder { A a; + String b; } }