-
-
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.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
daa0361
commit 035fba3
Showing
4 changed files
with
64 additions
and
8 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
49 changes: 49 additions & 0 deletions
49
...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,49 @@ | ||
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); | ||
|
||
// Let's check deserialization works too, just in case. | ||
HelloRecord result = MAPPER.readValue(json, HelloRecord.class); | ||
assertNotNull(result); | ||
} | ||
} |
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