Commit 9992dca
committed
ConversionUtils: avoid NPEs in canCast methods
The following calls now return true:
* canCast((Class) null, Foo.class) -- previously threw NPE
* canCast((Object) null, Foo.class) -- already did
The following calls now return false:
* canCast((Class) null, null) -- previously threw NPE
* canCast((Object) null, null) -- previously threw NPE
* canCast(new Foo(), null) -- previously threw NPE
* canCast(Foo.class, null) -- previously threw NPE
This commit also adds tests to ensure these calls continue to work.1 parent b509f5c commit 9992dca
File tree
2 files changed
+17
-1
lines changed- src
- main/java/org/scijava/util
- test/java/org/scijava/util
2 files changed
+17
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
106 | | - | |
| 108 | + | |
| 109 | + | |
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
110 | 113 | | |
111 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
112 | 118 | | |
113 | 119 | | |
114 | 120 | | |
| 121 | + | |
115 | 122 | | |
116 | 123 | | |
117 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
81 | 84 | | |
82 | 85 | | |
83 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
84 | 93 | | |
85 | 94 | | |
86 | 95 | | |
| |||
0 commit comments