Skip to content

Commit 15af383

Browse files
committed
Avoid converting null values
In setValue calls we want to minimize the usage of the ConvertService, so if if the given value is null we should just cast.
1 parent cfbb1b3 commit 15af383

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/org/scijava/util/ClassUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ public static void setValue(final Field field, final Object instance,
431431
try {
432432
field.setAccessible(true);
433433
final Object compatibleValue;
434-
if (field.getType().isInstance(value)) {
434+
if (value == null || field.getType().isInstance(value)) {
435435
// the given value is compatible with the field
436436
compatibleValue = value;
437437
}

0 commit comments

Comments
 (0)