Skip to content

Commit

Permalink
Merge pull request eclipse#163 from tbitonti/162-npe-no-text-properties
Browse files Browse the repository at this point in the history
Tolerate a null (unset) text substitutions table.
  • Loading branch information
bjhargrave committed Sep 17, 2021
2 parents 94e8766 + e3a681f commit b7419fa
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ public BundleData getBundleUpdate(String symbolicName) {
private final Map<Pattern, Map<String, String>> wildCardTextUpdates;

public Map<String, Map<String, String>> getSpecificTextUpdates() {
return specificTextUpdates;
return ((specificTextUpdates == null) ? Collections.emptyMap() : specificTextUpdates);
}

public Map<Pattern, Map<String, String>> getWildCardTextUpdates() {
return wildCardTextUpdates;
return ((wildCardTextUpdates == null) ? Collections.emptyMap() : wildCardTextUpdates);
}

//
Expand Down Expand Up @@ -441,12 +441,14 @@ public static boolean matches(Pattern p, CharSequence input) {
public Map<String, String> getTextSubstitutions(String inputFileName) {
String simpleFileName = FileUtils.getFileNameFromFullyQualifiedFileName(inputFileName);

Map<String, String> specificUpdates = getSpecificTextUpdates().get(simpleFileName);
if (specificUpdates != null) {
return specificUpdates;
Map<String, Map<String, String>> specificUpdates = getSpecificTextUpdates();
Map<String, String> updates = specificUpdates.get(simpleFileName);
if (updates != null) {
return updates;
}

for (Map.Entry<Pattern, Map<String, String>> wildcardEntry : getWildCardTextUpdates().entrySet()) {
Map<Pattern, Map<String, String>> wildcardUpdates = getWildCardTextUpdates();
for (Map.Entry<Pattern, Map<String, String>> wildcardEntry : wildcardUpdates.entrySet()) {
if (matches(wildcardEntry.getKey(), simpleFileName)) {
return wildcardEntry.getValue();
}
Expand Down

0 comments on commit b7419fa

Please sign in to comment.