Skip to content

Commit 8ef96f1

Browse files
fedejeannemerks
authored andcommitted
Prevents NPE when using the result of TargetDefinition.getBundles()
Extract the logic to a new private method and add null-check.
1 parent 95f5efc commit 8ef96f1

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetContentsGroup.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,14 +1166,7 @@ public Object[] getElements(Object inputElement) {
11661166
if (fMissing == null || fMissing.isEmpty()) {
11671167
fMissing = new HashSet<>(); // A set is used to remove copies of problem bundles
11681168
TargetBundle[] bundles = fTargetDefinition.getBundles();
1169-
for (int i = 0; i < bundles.length; i++) {
1170-
if (!bundles[i].getStatus().isOK()) {
1171-
// We only display error bundles that have symbolic names
1172-
if (bundles[i].getBundleInfo().getSymbolicName() != null) {
1173-
fMissing.add(bundles[i]);
1174-
}
1175-
}
1176-
}
1169+
addMissing(bundles);
11771170
result.addAll(fMissing);
11781171
} else {
11791172
// As missing bundles are unchecked, we want to keep them in the table, only if locations change does fMissing become null
@@ -1208,6 +1201,20 @@ public Object[] getElements(Object inputElement) {
12081201
return new Object[] {inputElement};
12091202
}
12101203

1204+
private void addMissing(TargetBundle[] bundles) {
1205+
if (bundles == null)
1206+
return;
1207+
1208+
for (TargetBundle bundle : bundles) {
1209+
if (!bundle.getStatus().isOK()) {
1210+
// We only display error bundles that have symbolic names
1211+
if (bundle.getBundleInfo().getSymbolicName() != null) {
1212+
fMissing.add(bundle);
1213+
}
1214+
}
1215+
}
1216+
}
1217+
12111218
}
12121219

12131220
}

0 commit comments

Comments
 (0)