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

Erik Joelsson erikj at openjdk.java.net
Thu Dec 16 22:41:04 UTC 2021

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.


Commit messages:
 - SKARA-1291

Changes: https://git.openjdk.java.net/skara/pull/1264/files
 Webrev: https://webrevs.openjdk.java.net/?repo=skara&pr=1264&range=00
  Issue: https://bugs.openjdk.java.net/browse/SKARA-1291
  Stats: 24 lines in 1 file changed: 17 ins; 4 del; 3 mod
  Patch: https://git.openjdk.java.net/skara/pull/1264.diff
  Fetch: git fetch https://git.openjdk.java.net/skara pull/1264/head:pull/1264

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

More information about the skara-dev mailing list