Skip to content

Commit a3e4cc1

Browse files
committed
fix test
1 parent b5be533 commit a3e4cc1

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Diff for: src/main/java/com/jsoniter/spi/Config.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,11 @@ private void updateBindings(ClassDescriptor desc) {
418418
desc.onExtraProperties = binding;
419419
}
420420
if (annotated && binding.field != null) {
421-
for (Binding setter : desc.setters) {
422-
if (binding.name.equals(setter.name)) {
423-
throw new JsonException("annotation should be marked on getter/setter for field: " + binding.name);
421+
if (desc.setters != null) {
422+
for (Binding setter : desc.setters) {
423+
if (binding.name.equals(setter.name)) {
424+
throw new JsonException("annotation should be marked on getter/setter for field: " + binding.name);
425+
}
424426
}
425427
}
426428
}

Diff for: src/test/java/com/jsoniter/TestAnnotationJsonProperty.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.jsoniter.annotation.JsonProperty;
66
import com.jsoniter.fuzzy.StringIntDecoder;
77
import com.jsoniter.output.JsonStream;
8+
import com.jsoniter.spi.DecodingMode;
89
import com.jsoniter.spi.JsonException;
910
import junit.framework.TestCase;
1011

@@ -145,12 +146,16 @@ public void test_getter_and_setter() throws IOException {
145146
}
146147

147148
public static class TestObject10 {
148-
public int field;
149+
private int field;
149150

150151
@JsonCreator
151152
public TestObject10(@JsonProperty("hello") int field) {
152153
this.field = field;
153154
}
155+
156+
public int getField() {
157+
return field;
158+
}
154159
}
155160

156161
public void test_creator_with_json_property() {

0 commit comments

Comments
 (0)