Skip to content

Commit

Permalink
Fix #1947
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Mar 6, 2018
1 parent 881f920 commit 13a7490
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
4 changes: 4 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -758,3 +758,7 @@ Aniruddha Maru (maroux@github)
* Reported #1940: `Float` values with integer value beyond `int` lose precision if
bound to `long`
(2.9.5)
Timur Shakurov (saladinkzn@github)
* Reported #1947: `MapperFeature.AUTO_DETECT_XXX` do not work if all disabled
(2.9.5)
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Project: jackson-databind
#1941: `TypeFactory.constructFromCanonical()` throws NPE for Unparameterized
generic canonical strings
(reported by ayushgp@github)
#1947: `MapperFeature.AUTO_DETECT_XXX` do not work if all disabled
(reported by Timur S)

2.9.4 (24-Jan-2018)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,8 @@ public final VisibilityChecker<?> getDefaultVisibilityChecker()
{
VisibilityChecker<?> vchecker = _configOverrides.getDefaultVisibility();
// then global overrides (disabling)
if ((_mapperFeatures & AUTO_DETECT_MASK) != 0) {
// 05-Mar-2018, tatu: As per [databind#1947], need to see if any disabled
if ((_mapperFeatures & AUTO_DETECT_MASK) != AUTO_DETECT_MASK) {
if (!isEnabled(MapperFeature.AUTO_DETECT_FIELDS)) {
vchecker = vchecker.withFieldVisibility(Visibility.NONE);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.fasterxml.jackson.databind.introspect;

import com.fasterxml.jackson.annotation.JsonProperty;

import com.fasterxml.jackson.databind.*;

// Test(s) for [databind#1947], regression for 2.9
public class AutoDetect1947Test extends BaseMapTest
{
static class Entity1947 {
public int shouldBeDetected;
public String shouldNotBeDetected;

@JsonProperty
public int getShouldBeDetected() {
return shouldBeDetected;
}

public void setShouldBeDetected(int shouldBeDetected) {
this.shouldBeDetected = shouldBeDetected;
}

public String getShouldNotBeDetected() {
return shouldNotBeDetected;
}

public void setShouldNotBeDetected(String shouldNotBeDetected) {
this.shouldNotBeDetected = shouldNotBeDetected;
}
}
public void testDisablingAll() throws Exception
{
ObjectMapper mapper = new ObjectMapper()
.disable(MapperFeature.AUTO_DETECT_SETTERS)
.disable(MapperFeature.AUTO_DETECT_FIELDS)
.disable(MapperFeature.AUTO_DETECT_GETTERS)
.disable(MapperFeature.AUTO_DETECT_CREATORS)
.disable(MapperFeature.AUTO_DETECT_IS_GETTERS);
String json = mapper.writeValueAsString(new Entity1947());
JsonNode n = mapper.readTree(json);
assertEquals(1, n.size());
assertTrue(n.has("shouldBeDetected"));
assertFalse(n.has("shouldNotBeDetected"));
}
}

0 comments on commit 13a7490

Please sign in to comment.