-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #3992: avoid too early/eager removal of accessors
- Loading branch information
1 parent
093d6da
commit e97afcf
Showing
3 changed files
with
59 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...t-jdk14/java/com/fasterxml/jackson/databind/records/RecordWithIgnoreOverride3992Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.fasterxml.jackson.databind.records; | ||
|
||
import java.util.*; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.databind.BaseMapTest; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
public class RecordWithIgnoreOverride3992Test extends BaseMapTest | ||
{ | ||
// [databind#3992] | ||
public record HelloRecord(String text, @JsonIgnore Recursion hidden) { | ||
// Before fix: works if this override is removed | ||
// After fix: works either way | ||
@Override | ||
public Recursion hidden() { | ||
return hidden; | ||
} | ||
} | ||
|
||
static class Recursion { | ||
public List<Recursion> all = new ArrayList<>(); | ||
|
||
void add(Recursion recursion) { | ||
all.add(recursion); | ||
} | ||
} | ||
|
||
private final ObjectMapper MAPPER = newJsonMapper(); | ||
|
||
/* | ||
/********************************************************************** | ||
/* Test methods | ||
/********************************************************************** | ||
*/ | ||
|
||
// [databind#3992] | ||
public void testHelloRecord() throws Exception { | ||
Recursion beanWithRecursion = new Recursion(); | ||
beanWithRecursion.add(beanWithRecursion); | ||
String json = MAPPER.writer() | ||
.writeValueAsString(new HelloRecord("hello", beanWithRecursion)); | ||
assertEquals(a2q("{'text':'hello'}"), json); | ||
} | ||
} |