Skip to content

Commit a2a45b3

Browse files
committed
Fix #1672
1 parent 88d12b4 commit a2a45b3

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

src/main/java/com/fasterxml/jackson/databind/AnnotationIntrospector.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ public PropertyName findNameForDeserialization(Annotated a) {
12211221
* @since 2.9
12221222
*/
12231223
public Boolean hasAnySetter(Annotated a) {
1224-
return false;
1224+
return null;
12251225
}
12261226

12271227
/**

src/test/java/com/fasterxml/jackson/databind/introspect/IgnoredCreatorProperty1572Test.java

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import com.fasterxml.jackson.databind.BaseMapTest;
66
import com.fasterxml.jackson.databind.ObjectMapper;
7-
import com.fasterxml.jackson.databind.introspect.*;
87

98
public class IgnoredCreatorProperty1572Test extends BaseMapTest
109
{

src/test/java/com/fasterxml/jackson/databind/introspect/IntrospectorPairTest.java

+39-4
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,17 @@ public String findTypeName(AnnotatedClass ac) {
197197
return (String) values.get("findTypeName");
198198
}
199199

200+
/*
201+
/******************************************************
202+
/* Deserialization introspection
203+
/******************************************************
204+
*/
205+
206+
@Override
207+
public Boolean hasAnySetter(Annotated a) {
208+
return (Boolean) values.get("hasAnySetter");
209+
}
210+
200211
/*
201212
/******************************************************
202213
/* Helper methods
@@ -215,7 +226,7 @@ private boolean _boolean(String key) {
215226
/**********************************************************
216227
*/
217228

218-
private final IntrospectorWithMap NO_ANNOTATIONS = new IntrospectorWithMap();
229+
private final AnnotationIntrospector NO_ANNOTATIONS = AnnotationIntrospector.nopInstance();
219230

220231
public void testVersion() throws Exception
221232
{
@@ -225,8 +236,9 @@ public void testVersion() throws Exception
225236
.version(v);
226237
assertEquals(v,
227238
new AnnotationIntrospectorPair(withVersion, NO_ANNOTATIONS).version());
239+
IntrospectorWithMap noVersion = new IntrospectorWithMap();
228240
assertEquals(Version.unknownVersion(),
229-
new AnnotationIntrospectorPair(NO_ANNOTATIONS, withVersion).version());
241+
new AnnotationIntrospectorPair(noVersion, withVersion).version());
230242
}
231243

232244
public void testAccess() throws Exception
@@ -395,7 +407,7 @@ public void testFindDeserializer() throws Exception
395407
/******************************************************
396408
/* Property auto-detection
397409
/******************************************************
398-
*/
410+
*/
399411

400412
public void testFindAutoDetectVisibility() throws Exception
401413
{
@@ -414,7 +426,7 @@ public void testFindAutoDetectVisibility() throws Exception
414426
/******************************************************
415427
/* Type handling
416428
/******************************************************
417-
*/
429+
*/
418430

419431
public void testFindTypeResolver() throws Exception
420432
{
@@ -445,6 +457,29 @@ public void testFindTypeName() {
445457
new AnnotationIntrospectorPair(intr2, intr1).findTypeName(null));
446458
}
447459

460+
/*
461+
/******************************************************
462+
/* Deserialization introspection
463+
/******************************************************
464+
*/
465+
466+
// for [databind#1672]
467+
public void testHasAnySetter() {
468+
IntrospectorWithMap intr1 = new IntrospectorWithMap()
469+
.add("hasAnySetter", Boolean.TRUE);
470+
IntrospectorWithMap intr2 = new IntrospectorWithMap()
471+
.add("hasAnySetter", Boolean.FALSE);
472+
assertNull(new AnnotationIntrospectorPair(NO_ANNOTATIONS, NO_ANNOTATIONS).hasAnySetter(null));
473+
assertEquals(Boolean.TRUE,
474+
new AnnotationIntrospectorPair(intr1, intr2).hasAnySetter(null));
475+
assertEquals(Boolean.TRUE,
476+
new AnnotationIntrospectorPair(NO_ANNOTATIONS, intr1).hasAnySetter(null));
477+
assertEquals(Boolean.FALSE,
478+
new AnnotationIntrospectorPair(intr2, intr1).hasAnySetter(null));
479+
assertEquals(Boolean.FALSE,
480+
new AnnotationIntrospectorPair(NO_ANNOTATIONS, intr2).hasAnySetter(null));
481+
}
482+
448483
/*
449484
/**********************************************************
450485
/* Test methods, others

0 commit comments

Comments
 (0)