Skip to content

Commit 2b15132

Browse files
committed
[GR-62989] Remove NEGATIVE_QUERY from registeredResources in Build Report data when it was replaced with an actual resource
PullRequest: graal/20554
2 parents 33123de + 98da29f commit 2b15132

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/EmbeddedResourcesInfo.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ public void declareResourceAsRegistered(Module module, String resource, String s
5656
}
5757

5858
Resources.ModuleResourceKey key = Resources.createStorageKey(module, resource);
59+
60+
/*
61+
* If we already have an entry with this key, and it was a NEGATIVE_QUERY, the new resource
62+
* would either be ignored if it was another NEGATIVE_QUERY or it will override existing
63+
* NEGATIVE_QUERY for that key. In both cases we can remove previous NEGATIVE_QUERY since it
64+
* will be replaced with either new NEGATIVE_QUERY or with resource that exists.
65+
*/
66+
List<SourceAndOrigin> existingEntries = registeredResources.get(key);
67+
if (existingEntries != null && existingEntries.size() == 1 && isNegativeQuery(existingEntries.get(0))) {
68+
registeredResources.remove(key);
69+
}
70+
5971
registeredResources.compute(key, (k, v) -> {
6072
if (v == null) {
6173
ArrayList<SourceAndOrigin> newValue = new ArrayList<>();
@@ -83,4 +95,8 @@ public void declareResourceAsRegistered(Module module, String resource, String s
8395
return v;
8496
});
8597
}
98+
99+
private static boolean isNegativeQuery(SourceAndOrigin entry) {
100+
return entry.source().equalsIgnoreCase("") && ((String) entry.origin()).equalsIgnoreCase("");
101+
}
86102
}

0 commit comments

Comments
 (0)