Skip to content

Commit 80c3993

Browse files
author
Andre Bonna
committed
Fix setter of null value for nonPrimitive and byte value for Primitive types.
1 parent 24aa4eb commit 80c3993

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Add to your pom.xml dependencies section:
2828
<dependency>
2929
<groupId>io.github.json-snapshot</groupId>
3030
<artifactId>json-snapshot</artifactId>
31-
<version>1.0.6</version>
31+
<version>1.0.7</version>
3232
</dependency>
3333
```
3434

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>io.github.json-snapshot</groupId>
77
<artifactId>json-snapshot</artifactId>
8-
<version>1.0.6</version>
8+
<version>1.0.7</version>
99
<packaging>jar</packaging>
1010

1111
<name>json-snapshot</name>

src/main/java/io/github/jsonSnapshot/SnapshotCaptor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ public Object removeIgnored(Object value) {
3434
try {
3535
Field field = this.argumentClass.getDeclaredField(each);
3636
field.setAccessible(true);
37-
field.set(newValue, null);
37+
if (field.getType().isPrimitive()) {
38+
field.setByte(newValue, Integer.valueOf(0).byteValue());
39+
}
40+
else {
41+
field.set(newValue, null);
42+
}
3843
} catch (IllegalAccessException | NoSuchFieldException e) {
3944
throw new SnapshotMatchException("Invalid Ignore value " + each, e.getCause());
4045
}

0 commit comments

Comments
 (0)