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
Persistence extensions: allow null serviceId #4213
Conversation
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise a nice addition.
@@ -80,7 +80,7 @@ public PersistenceExtensions(@Reference PersistenceServiceRegistry registry, | |||
* @param item the item to store | |||
*/ | |||
public static void persist(Item item) { | |||
internalPersist(item); | |||
internalPersist(item, (String) null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need a cast to String
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was needed when I only half changed the file (version with signature internalPersist(Item, TimeSeries)
), but no longer needed, so removed.
String serviceId = getDefaultServiceId(); | ||
if (serviceId == null) { | ||
private static void internalPersist(Item item, @Nullable String serviceId) { | ||
String sId = serviceId == null ? getDefaultServiceId() : serviceId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String sId = serviceId == null ? getDefaultServiceId() : serviceId; | |
String effectiveServiceId = Objects.requireNonNullElse(serviceId, getDefaultServiceId()); |
Also below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Perhaps label this as regression? |
Also to ensure that this is honored in the future, could we please add some tests to check? |
I don't think it's a regression. It didn't work before, right? |
It worked like this before #3736: #3736 removed this and instead, it actually looks up |
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
True, it would, but relying on it was dangerous. For some actions it did not work, and for others it gave wrong result as it was never meant to be used like that. For some, you got lucky and it actually did end up giving the right result. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
See #3736 (comment)