Skip to content

Commit

Permalink
Fix #3938 to repro actual issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 18, 2023
1 parent 04d7ae4 commit c524e6b
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.fasterxml.jackson.databind.records;

import com.fasterxml.jackson.annotation.JsonProperty;

import com.fasterxml.jackson.databind.*;

public class RecordFailingSetter3938Test extends BaseMapTest
Expand All @@ -19,8 +18,7 @@ default void setOptions(JsonNode value) {
}
}

public record Command3938(int id, String filter) implements NoOptionsCommand {
}
public record Command3938(int id, String filter) implements NoOptionsCommand { }

private final ObjectMapper MAPPER = newJsonMapper();

Expand All @@ -29,13 +27,13 @@ public void testFailingSetter3939() throws Exception
{
final ObjectReader R = MAPPER.readerFor(Command3938.class);

// First, missing value and `null` are fine
// First, missing value and `null` are fine, as long as we have all fields
assertNotNull(R.readValue(a2q("{'id':1, 'filter':'abc'}")));
assertNotNull(R.readValue(a2q("{'id':2, 'filter':'def', 'options':null}")));
assertNotNull(R.readValue(a2q("{'id':2, 'filter':'abc', 'options':null}")));

// But then failure for non-empty Array (f.ex)
try {
R.readValue(a2q("{'id':3, 'filter':'xyz', 'options':[ 123 ]}"));
R.readValue(a2q("{'id':2,'options':[123]}}"));
fail("Should not pass");
} catch (DatabindException e) {
verifyException(e, ERROR_3938_PREFIX);
Expand Down

0 comments on commit c524e6b

Please sign in to comment.