From a3e4cc1582f7ea06764eea0e2901965a87c7b854 Mon Sep 17 00:00:00 2001 From: Tao Wen Date: Thu, 12 Oct 2017 16:21:27 +0800 Subject: [PATCH] fix test --- src/main/java/com/jsoniter/spi/Config.java | 8 +++++--- .../java/com/jsoniter/TestAnnotationJsonProperty.java | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/jsoniter/spi/Config.java b/src/main/java/com/jsoniter/spi/Config.java index 71586627..32c95184 100644 --- a/src/main/java/com/jsoniter/spi/Config.java +++ b/src/main/java/com/jsoniter/spi/Config.java @@ -418,9 +418,11 @@ private void updateBindings(ClassDescriptor desc) { desc.onExtraProperties = binding; } if (annotated && binding.field != null) { - for (Binding setter : desc.setters) { - if (binding.name.equals(setter.name)) { - throw new JsonException("annotation should be marked on getter/setter for field: " + binding.name); + if (desc.setters != null) { + for (Binding setter : desc.setters) { + if (binding.name.equals(setter.name)) { + throw new JsonException("annotation should be marked on getter/setter for field: " + binding.name); + } } } } diff --git a/src/test/java/com/jsoniter/TestAnnotationJsonProperty.java b/src/test/java/com/jsoniter/TestAnnotationJsonProperty.java index aca31f7e..2bdcbb16 100644 --- a/src/test/java/com/jsoniter/TestAnnotationJsonProperty.java +++ b/src/test/java/com/jsoniter/TestAnnotationJsonProperty.java @@ -5,6 +5,7 @@ import com.jsoniter.annotation.JsonProperty; import com.jsoniter.fuzzy.StringIntDecoder; import com.jsoniter.output.JsonStream; +import com.jsoniter.spi.DecodingMode; import com.jsoniter.spi.JsonException; import junit.framework.TestCase; @@ -145,12 +146,16 @@ public void test_getter_and_setter() throws IOException { } public static class TestObject10 { - public int field; + private int field; @JsonCreator public TestObject10(@JsonProperty("hello") int field) { this.field = field; } + + public int getField() { + return field; + } } public void test_creator_with_json_property() {