Spdx-Java-Library
Spdx-Java-Library copied to clipboard
Method `LicenseInfoFactory::getListedLicenseById` never returns `null`
The javadoc for LicenseInfoFactory::getListedLicenseById
states that it returns the "SPDX listed license or null
if the ID is not in the SPDX license list". But, it looks like that for any value I pass in, it seems to return a SpdxListedLicense
with the id
set to that value (licenseId
).
Therefore, instead of simply calling this method, I must check whether licenseId
is contained in LicenseInfoFactory::getSpdxListedLicenseIds
before calling the method.
Thanks @dwalluck for pointing this out. I looked at the code, and it looks like it will create the license if it doesn't exist based on this method which defaults to creating the class.
There are a couple possible solutions - check before return or catch the error with create=false (a higher performance solution).
I can take a look at a solution after implementing the SPDX 3.0 support - or if you'd like to create a PR, I can review / merge.