Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
taowen committed Oct 12, 2017
1 parent b5be533 commit a3e4cc1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/main/java/com/jsoniter/spi/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/test/java/com/jsoniter/TestAnnotationJsonProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit a3e4cc1

Please sign in to comment.