Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method LicenseInfoFactory::getListedLicenseById never returns null #238

Closed
dwalluck opened this issue May 2, 2024 · 1 comment · Fixed by #239
Closed

Method LicenseInfoFactory::getListedLicenseById never returns null #238

dwalluck opened this issue May 2, 2024 · 1 comment · Fixed by #239

Comments

@dwalluck
Copy link
Contributor

dwalluck commented May 2, 2024

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.

@goneall
Copy link
Member

goneall commented May 3, 2024

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.

dwalluck added a commit to dwalluck/Spdx-Java-Library that referenced this issue May 16, 2024
`ListedLicenses::getListedLicenseById` and
`ListedLicenses::getListedExceptionById` should return `null` if ID
does not exist.

Resolves spdxGH-238

Signed-off-by: David Walluck <dwalluck@redhat.com>
dwalluck added a commit to dwalluck/Spdx-Java-Library that referenced this issue May 16, 2024
`ListedLicenses::getListedLicenseById` and
`ListedLicenses::getListedExceptionById` should return `null` if ID
does not exist.

Resolves spdxGH-238

Signed-off-by: David Walluck <dwalluck@redhat.com>
dwalluck added a commit to dwalluck/Spdx-Java-Library that referenced this issue May 16, 2024
`ListedLicenses::getListedLicenseById` and `ListedLicenses::getListedExceptionById` should return `null` if ID does not exist.

Resolves spdxGH-238

Signed-off-by: David Walluck <dwalluck@redhat.com>
dwalluck added a commit to dwalluck/Spdx-Java-Library that referenced this issue May 16, 2024
`ListedLicenses::getListedLicenseById` and `ListedLicenses::getListedExceptionById` should return `null` if ID does not exist.

Resolves spdxGH-238

Signed-off-by: David Walluck <dwalluck@redhat.com>
goneall pushed a commit that referenced this issue May 16, 2024
`ListedLicenses::getListedLicenseById` and `ListedLicenses::getListedExceptionById` should return `null` if ID does not exist.

Resolves GH-238

Signed-off-by: David Walluck <dwalluck@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants