Skip to content

Add failing test for Record class deserialization with single field annotated with JsonProperty.Access.WRITE_ONLY #3899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.fasterxml.jackson.databind.failing;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.BaseMapTest;

// [databinding#3897] This is failing test for `Record` class deserialization with single field annotated with
// `JsonProperty.Access.WRITE_ONLY`. Regression from Jackson 2.14.2
public class RecordDeserialization3897Test extends BaseMapTest {

record Example(
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
String value
) {}

// Passes in 2.14.2, but does not in 2.15.0
public void testRecordWithWriteOnly() throws Exception {
final String JSON = a2q("{'value':'foo'}");

Example result = newJsonMapper().readValue(JSON, Example.class);

assertEquals("foo", result.value());
}
}