[JIRA] (JSSH-27) Implement an ensureId method to help with nullability annotation
Ian Young (Jira)
jira at shibboleth.atlassian.net
Tue Apr 18 16:16:17 UTC 2023
Ian Young ( https://shibboleth.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Ae127cb03-43ed-473d-b6ba-592949cb4be8 ) *created* an issue
Shibboleth Shared - Java ( https://shibboleth.atlassian.net/browse/JSSH?atlOrigin=eyJpIjoiYTcwM2ZkYTE0YWUxNGZiOTk5MmQ2MGVhOWM1Y2YyMWEiLCJwIjoiaiJ9 ) / New Feature ( https://shibboleth.atlassian.net/browse/JSSH-27?atlOrigin=eyJpIjoiYTcwM2ZkYTE0YWUxNGZiOTk5MmQ2MGVhOWM1Y2YyMWEiLCJwIjoiaiJ9 ) JSSH-27 ( https://shibboleth.atlassian.net/browse/JSSH-27?atlOrigin=eyJpIjoiYTcwM2ZkYTE0YWUxNGZiOTk5MmQ2MGVhOWM1Y2YyMWEiLCJwIjoiaiJ9 ) Implement an ensureId method to help with nullability annotation ( https://shibboleth.atlassian.net/browse/JSSH-27?atlOrigin=eyJpIjoiYTcwM2ZkYTE0YWUxNGZiOTk5MmQ2MGVhOWM1Y2YyMWEiLCJwIjoiaiJ9 )
Issue Type: New Feature Assignee: Unassigned Components: General Created: 18/Apr/23 12:16 PM Priority: Trivial Reporter: Ian Young ( https://shibboleth.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Ae127cb03-43ed-473d-b6ba-592949cb4be8 )
One of the things I’ve hit multiple times when trying to get code null-clean is that in our component system, getId}}is (correctly) labelled as {{@NonnullAfterInit but of course is always null in the normal course of execution where you want to pass it to a method which now requires @Nonnull. I've tried several bodges to work round this in various places, but I'm not fond of most of them.
My proposal is that we add the following method to AbstractIdentifiedInitializableComponent alongside getId :
protected @Nonnull String ensureId() {
final var id = getId();
if (id == null ) {
throw new IllegalStateException();
}
return id;
}
(Name suggested by Scott)
Note that I am suggesting that we add this to the implementation and not to the interface IdentifiedComponent where getId is declared. It would then be inherited by (hopefully) most or all of the code where we’re doing null checking without forcing any other places that implement IdentifiedComponent to be changed. I suppose an alternative would be to to add it as a default method to the interface, but I’m a little wary of that because I haven’t used that construct a lot.
I’m going to start by implementing this in a couple of places in the abstract class hierarchies in the MDA, but ideally we’d put this as high up as it can go, which means JSSE.
( https://shibboleth.atlassian.net/browse/JSSH-27#add-comment?atlOrigin=eyJpIjoiYTcwM2ZkYTE0YWUxNGZiOTk5MmQ2MGVhOWM1Y2YyMWEiLCJwIjoiaiJ9 ) Add Comment ( https://shibboleth.atlassian.net/browse/JSSH-27#add-comment?atlOrigin=eyJpIjoiYTcwM2ZkYTE0YWUxNGZiOTk5MmQ2MGVhOWM1Y2YyMWEiLCJwIjoiaiJ9 )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100222- sha1:c08beee )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/commits/attachments/20230418/061360d1/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-avatar-182d8c4b-4c39-4bab-a37b-792b6b27530c
Type: image/png
Size: 302 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20230418/061360d1/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-static-comment-icon-3e55929c-4084-43f0-8153-4b9924cc6fa2
Type: image/png
Size: 1084 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20230418/061360d1/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-static-trivial-90ea5980-53b5-4584-a1d8-84549135b940
Type: image/png
Size: 446 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20230418/061360d1/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jira-generated-image-static-footer-desktop-logo-f78a9af5-f2e0-49fe-b799-6a894505489b
Type: image/png
Size: 10805 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/commits/attachments/20230418/061360d1/attachment-0007.png>
More information about the commits
mailing list