diff --git a/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/SubTypeValidator.java b/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/SubTypeValidator.java index 958e497a7b..b6f751412e 100644 --- a/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/SubTypeValidator.java +++ b/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/SubTypeValidator.java @@ -73,6 +73,7 @@ public void validateSubType(DeserializationContext ctxt, JavaType type, final Class raw = type.getRawClass(); String full = raw.getName(); + main_check: do { if (_cfgIllegalClassNames.contains(full)) { break; @@ -86,8 +87,8 @@ public void validateSubType(DeserializationContext ctxt, JavaType type, // looking for "AbstractBeanFactoryPointcutAdvisor" but no point to allow any is there? if ("AbstractPointcutAdvisor".equals(name) // ditto for "FileSystemXmlApplicationContext": block all ApplicationContexts - || "AbstractApplicationContext.equals".equals(name)) { - break; + || "AbstractApplicationContext".equals(name)) { + break main_check; } } } diff --git a/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java b/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java index b5002dcfe9..629a9adbe2 100644 --- a/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java @@ -1,5 +1,8 @@ package com.fasterxml.jackson.databind.interop; +import org.springframework.jacksontest.BogusApplicationContext; +import org.springframework.jacksontest.BogusPointcutAdvisor; + import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.exc.InvalidDefinitionException; @@ -68,6 +71,10 @@ public void testJDKTypes1855() throws Exception { // apparently included by JDK? _testIllegalType("com.sun.org.apache.bcel.internal.util.ClassLoader"); + + // also: we can try some form of testing, even if bit contrived... + _testIllegalType(BogusPointcutAdvisor.class); + _testIllegalType(BogusApplicationContext.class); } // 17-Aug-2017, tatu: Ideally would test handling of 3rd party types, too, diff --git a/src/test/java/org/springframework/jacksontest/AbstractApplicationContext.java b/src/test/java/org/springframework/jacksontest/AbstractApplicationContext.java new file mode 100644 index 0000000000..e537782fae --- /dev/null +++ b/src/test/java/org/springframework/jacksontest/AbstractApplicationContext.java @@ -0,0 +1,5 @@ +package org.springframework.jacksontest; + +public class AbstractApplicationContext { + +} diff --git a/src/test/java/org/springframework/jacksontest/AbstractPointcutAdvisor.java b/src/test/java/org/springframework/jacksontest/AbstractPointcutAdvisor.java new file mode 100644 index 0000000000..0ee87e0416 --- /dev/null +++ b/src/test/java/org/springframework/jacksontest/AbstractPointcutAdvisor.java @@ -0,0 +1,5 @@ +package org.springframework.jacksontest; + +public class AbstractPointcutAdvisor { + +} diff --git a/src/test/java/org/springframework/jacksontest/BogusApplicationContext.java b/src/test/java/org/springframework/jacksontest/BogusApplicationContext.java new file mode 100644 index 0000000000..55dba37f0b --- /dev/null +++ b/src/test/java/org/springframework/jacksontest/BogusApplicationContext.java @@ -0,0 +1,9 @@ +package org.springframework.jacksontest; + +//Made-up test class that should trigger checks for [databind#1855] +public class BogusApplicationContext extends AbstractApplicationContext { + public BogusApplicationContext(String s) { + super(); + throw new Error("Wrong!"); + } +} diff --git a/src/test/java/org/springframework/jacksontest/BogusPointcutAdvisor.java b/src/test/java/org/springframework/jacksontest/BogusPointcutAdvisor.java new file mode 100644 index 0000000000..c21d92399a --- /dev/null +++ b/src/test/java/org/springframework/jacksontest/BogusPointcutAdvisor.java @@ -0,0 +1,9 @@ +package org.springframework.jacksontest; + +// Made-up test class that should trigger checks for [databind#1855] +public class BogusPointcutAdvisor extends AbstractPointcutAdvisor { + public BogusPointcutAdvisor(String s) { + super(); + throw new Error("Wrong!"); + } +}