Skip to content

Commit 7c089c9

Browse files
committed
Fixed NPE in some rare combinations of JSON files
The error triggered inside ContributioIndexer.mergeContributions() while trying to remove a platform: if (platform != null) { targetPackage.getPlatforms().remove(platform); } remove() method calls ContributedPlatform.equals() to find the element to remove but since the parentPackage fields are resolved *after* merging contributions, the equls() method will fail with a NullPointerException.
1 parent fa4876b commit 7c089c9

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

arduino-core/src/cc/arduino/contributions/packages/ContributedPlatform.java

+19-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,24 @@ public boolean equals(Object obj) {
108108
}
109109

110110
ContributedPlatform obj1 = (ContributedPlatform) obj;
111-
return getParentPackage().getName().equals(obj1.getParentPackage().getName()) && getArchitecture().equals(obj1.getArchitecture()) && getVersion().equals(obj1.getVersion()) && getName().equals(obj1.getName());
111+
112+
ContributedPackage parentPackage = getParentPackage();
113+
ContributedPackage parentPackage1 = obj1.getParentPackage();
114+
if (parentPackage == null) {
115+
if (parentPackage1 != null)
116+
return false;
117+
} else {
118+
if (parentPackage1 == null)
119+
return false;
120+
if (!parentPackage.getName().equals(parentPackage1.getName()))
121+
return false;
122+
}
123+
if (!getArchitecture().equals(obj1.getArchitecture())) {
124+
return false;
125+
}
126+
if (!getVersion().equals(obj1.getVersion())) {
127+
return false;
128+
}
129+
return getName().equals(obj1.getName());
112130
}
113131
}

0 commit comments

Comments
 (0)