Skip to content

Commit 619072d

Browse files
committed
Add a null check in the equals method
Signed-off-by: Clement Escoffier <[email protected]>
1 parent 16422be commit 619072d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

framework/resource-controller/src/main/java/org/wisdom/resources/WebJarDeployer.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public synchronized void stop() {
244244
* A structure holding a webjar found in a jar file.
245245
* Don't forget that a single jar file can contain any number of libraries.
246246
*/
247-
private static class DetectedWebJar {
247+
private static final class DetectedWebJar {
248248

249249
/**
250250
* The id computed as follows: {@code name-version}.
@@ -291,7 +291,10 @@ private DetectedWebJar(String name, String version, String path, File file) {
291291
*/
292292
@Override
293293
public boolean equals(Object obj) {
294-
return obj.getClass().equals(DetectedWebJar.class) && id.equals(((DetectedWebJar) obj).id);
294+
// We don't use instanceOf because we don't need inheritance (the class if final).
295+
return obj != null // Check not null
296+
&& obj.getClass().equals(DetectedWebJar.class) // Check it's the right class
297+
&& id.equals(((DetectedWebJar) obj).id); // Check id
295298
}
296299

297300
/**

0 commit comments

Comments
 (0)