Skip to content

Commit 97292be

Browse files
author
jan
committed
Added test to avoid null pointers for malformed json files #1681
1 parent 22d1066 commit 97292be

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

io.sloeber.ui/src/io/sloeber/ui/preferences/PlatformSelectionPage.java

+12
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ private boolean mustBeInstalled(IArduinoPlatform platform) {
5858
IArduinoPlatformPackageIndex parentIndex = parentPkg.getPackageIndex();
5959
InstallableVersion[] inScopeVersions = myShownPlatforms.get(parentIndex.getID()).get(parentPkg.getID())
6060
.get(platform.getID());
61+
if(inScopeVersions==null) {
62+
//in case there are no versions
63+
return false;
64+
}
6165
for (InstallableVersion version : inScopeVersions) {
6266
if (version.mustBeInstalled()) {
6367
return true;
@@ -69,6 +73,10 @@ private boolean mustBeInstalled(IArduinoPlatform platform) {
6973
private boolean mustBeInstalled(IArduinoPlatformPackageIndex packageIndex) {
7074
TreeMap<String, TreeMap<String, InstallableVersion[]>> inScopeVersions = myShownPlatforms
7175
.get(packageIndex.getID());
76+
if(inScopeVersions==null) {
77+
//in case there are no versions
78+
return false;
79+
}
7280
for (TreeMap<String, InstallableVersion[]> platform : inScopeVersions.values()) {
7381
for (InstallableVersion[] versions : platform.values()) {
7482
for (InstallableVersion version : versions) {
@@ -85,6 +93,10 @@ private boolean mustBeInstalled(IArduinoPackage pkg) {
8593
IArduinoPlatformPackageIndex parentIndex = pkg.getPackageIndex();
8694
TreeMap<String, InstallableVersion[]> inScopeVersions = myShownPlatforms.get(parentIndex.getID())
8795
.get(pkg.getID());
96+
if(inScopeVersions==null) {
97+
//in case there are no versions
98+
return false;
99+
}
88100
for (InstallableVersion[] versions : inScopeVersions.values()) {
89101
for (InstallableVersion version : versions) {
90102
if (version.mustBeInstalled()) {

0 commit comments

Comments
 (0)