RFR: 1291: NPE in org.openjdk.skara.issuetracker.Label.compareTo

Kevin Rushforth kcr at openjdk.java.net
Thu Dec 16 22:51:19 UTC 2021


On Thu, 16 Dec 2021 22:37:01 GMT, Erik Joelsson <erikj at openjdk.org> wrote:

> Recently, we have started seeing NPEs being thrown in org.openjdk.skara.issuetracker.Label::compareTo when called from GitLabMergeRequest::links. This seems to be caused by adding of labels while the GitLabMergeRequest object is active. The labelNameToLabel map is initiated in the constructor based on the repository labels. This may get outdated while the GitLabMergeRequest instance is still alive. 
> 
> This patch makes the initialization of the map lazy by wrapping all calls to the map in a private method. The map is re-initialized any time an element isn't found in it. I also added a filter on null labels before the sorting to avoid the NPE in case it still slips through.

Looks good.

-------------

Marked as reviewed by kcr (Reviewer).

PR: https://git.openjdk.java.net/skara/pull/1264


More information about the skara-dev mailing list