NullPointerException calling `getQualifiers()` if the PURL has no qualifiers
matt-phylum opened this issue · comments
If you parse a PURL with no qualifiers, for example pkg:maven/org.apache.commons/io@1.3.4
from test-suite-data.json
, and then try to check what the qualifiers were, a NullPointerException is thrown.
PackageURLTest.java
currently skips verifying the qualifiers if none are expected to be present. It should check that it can retrieve the qualifiers and that there are none.
if (qualifiers != null) {
Assert.assertNotNull(purl.getQualifiers());
Assert.assertEquals(qualifiers.length(), purl.getQualifiers().size());
qualifiers.keySet().forEach((key) -> {
String value = qualifiers.getString(key);
Assert.assertTrue(purl.getQualifiers().containsKey(key));
Assert.assertEquals(value, purl.getQualifiers().get(key));
});
// New else case:
} else {
Assert.assertEquals(0, purl.getQualifiers().size());
}
Thanks for reporting the issue