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

[persistence] Handle null value for relative & inverted props of filters #3727

Merged
merged 1 commit into from
Jul 25, 2023
Merged

[persistence] Handle null value for relative & inverted props of filters #3727

merged 1 commit into from
Jul 25, 2023

Conversation

florian-h05
Copy link
Contributor

This allows the UI to remove some specific checks that are performed on every save, and simplifies usage of the API for external applications.

@florian-h05
Copy link
Contributor Author

florian-h05 commented Jul 24, 2023

@J-N-K This is what you proposed in #3681 (comment), right?

I've tried this, but I get a NPE:

11:30:17.976 [ERROR] [.internal.JSONResponseExceptionMapper] - Unexpected exception occurred while processing REST request.
java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because "f.relative" is null
        at org.openhab.core.persistence.registry.PersistenceServiceConfigurationDTOMapper.lambda$9(PersistenceServiceConfigurationDTOMapper.java:84) ~[?:?]
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?]
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) ~[?:?]
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]
        at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?]
        at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?]
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
        at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?]
        at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276) ~[?:?]
        at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) ~[?:?]
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) ~[?:?]
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[?:?]
        at org.openhab.core.persistence.registry.PersistenceServiceConfigurationDTOMapper.map(PersistenceServiceConfigurationDTOMapper.java:89) ~[?:?]
        at org.openhab.core.io.rest.core.internal.persistence.PersistenceResource.httpPutPersistenceServiceConfiguration(PersistenceResource.java:204) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179) ~[bundleFile:3.4.5]
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) ~[bundleFile:3.4.5]
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:201) ~[bundleFile:3.4.5]
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:104) ~[bundleFile:3.4.5]
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) ~[bundleFile:3.4.5]
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96) ~[bundleFile:3.4.5]
...

Any idea?

@J-N-K
Copy link
Member

J-N-K commented Jul 24, 2023

I just tried the exact same (except this.inverted == inverted != null && inverted instead of this.inverted == inverted == null ? false : inverted) and it works perfectly fine when I omit the inverted field in the include filter or relative in the threshold filter. What exactly did you try?

@florian-h05
Copy link
Contributor Author

florian-h05 commented Jul 25, 2023

I have tried exactly the code as in this PR, and it did not work.
I just re-tried it (fresh compile, bundle:update, restart the runtime) and now it works fine.

So this is ready for review now.

@florian-h05 florian-h05 marked this pull request as ready for review July 25, 2023 18:36
@florian-h05 florian-h05 requested a review from a team as a code owner July 25, 2023 18:36
@J-N-K J-N-K added rebuild Triggers the Jenkins PR build and removed rebuild Triggers the Jenkins PR build labels Jul 25, 2023
Copy link
Member

@J-N-K J-N-K left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@J-N-K J-N-K added the bug An unexpected problem or unintended behavior of the Core label Jul 25, 2023
@J-N-K J-N-K added this to the 4.1 milestone Jul 25, 2023
@J-N-K J-N-K merged commit f5a0b37 into openhab:main Jul 25, 2023
@florian-h05 florian-h05 deleted the persistence-filters branch July 25, 2023 19:07
florian-h05 added a commit to florian-h05/openhab-webui that referenced this pull request Jul 25, 2023
openhab/openhab-core#3727 made core accept null as values for `relative` and `inverted` fields of persistence filters and set defaults for those.
Therefore, UI does not need to ensure they are set anymore.

Signed-off-by: Florian Hotze <[email protected]>
ghys pushed a commit to openhab/openhab-webui that referenced this pull request Jul 26, 2023
)

openhab/openhab-core#3727 made core handle
`null` as values for `relative` and `inverted` fields of persistence
filters and set defaults for those. Therefore, UI does not need to
ensure they are set anymore.

Signed-off-by: Florian Hotze <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants