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

NPE in ScaleTransformationService #8011

Closed
DerOetzi opened this issue Jun 25, 2020 · 4 comments · Fixed by #8124
Closed

NPE in ScaleTransformationService #8011

DerOetzi opened this issue Jun 25, 2020 · 4 comments · Fixed by #8124
Labels
bug An unexpected problem or unintended behavior of an add-on

Comments

@DerOetzi
Copy link
Contributor

Expected Behavior

Tried to load Control Page in PaperUI

Current Behavior

Page is empty and the is as NPE Stacktrace caused by ScaleTransformationService:

20:12:00.968 [ERROR] [jersey.server.ServerRuntime$Responder] - An I/O error has occurred while writing a response message entity to the container output stream.
org.glassfish.jersey.server.internal.process.MappableException: java.lang.NullPointerException
        at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:92) ~[?:?]
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[bundleFile:?]
        at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1130) ~[bundleFile:?]
        at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:711) [bundleFile:?]
        at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:444) [bundleFile:?]
        at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:434) [bundleFile:?]
        at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:329) [bundleFile:?]
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [bundleFile:?]
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [bundleFile:?]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [bundleFile:?]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [bundleFile:?]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [bundleFile:?]
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [bundleFile:?]
        at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [bundleFile:?]
        at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [bundleFile:?]
        at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473) [bundleFile:?]
        at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427) [bundleFile:?]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388) [bundleFile:?]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341) [bundleFile:?]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228) [bundleFile:?]
        at com.eclipsesource.jaxrs.publisher.internal.ServletContainerBridge.service(ServletContainerBridge.java:76) [bundleFile:?]
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:544) [bundleFile:9.4.20.v20190813]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) [bundleFile:?]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307) [bundleFile:9.4.20.v20190813]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293) [bundleFile:?]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [bundleFile:9.4.20.v20190813]
        at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) [bundleFile:?]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.Server.handle(Server.java:494) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:367) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918) [bundleFile:9.4.20.v20190813]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_232]

Caused by: java.lang.NullPointerException
        at org.openhab.transform.scale.internal.ScaleTransformationService.lambda$0(ScaleTransformationService.java:132) ~[?:?]
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174) ~[?:1.8.0_232]
        at java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1812) ~[?:1.8.0_232]
        at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) ~[?:1.8.0_232]
        at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499) ~[?:1.8.0_232]
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486) ~[?:1.8.0_232]
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_232]
        at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152) ~[?:1.8.0_232]
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_232]
        at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:531) ~[?:1.8.0_232]
        at org.openhab.transform.scale.internal.ScaleTransformationService.getScaleResult(ScaleTransformationService.java:132) ~[?:?]
        at org.openhab.transform.scale.internal.ScaleTransformationService.formatResult(ScaleTransformationService.java:126) ~[?:?]
        at org.openhab.transform.scale.internal.ScaleTransformationService.internalTransform(ScaleTransformationService.java:105) ~[?:?]
        at org.openhab.transform.scale.internal.ScaleTransformationService.internalTransform(ScaleTransformationService.java:1) ~[?:?]
        at org.eclipse.smarthome.core.transform.AbstractFileTransformationService.transform(AbstractFileTransformationService.java:138) ~[?:?]
        at org.eclipse.smarthome.core.transform.TransformationHelper.transform(TransformationHelper.java:125) ~[?:?]
        at org.eclipse.smarthome.core.transform.TransformationHelper.transform(TransformationHelper.java:100) ~[?:?]
        at org.eclipse.smarthome.io.rest.core.item.EnrichedItemDTOMapper.considerTransformation(EnrichedItemDTOMapper.java:124) ~[?:?]
        at org.eclipse.smarthome.io.rest.core.item.EnrichedItemDTOMapper.map(EnrichedItemDTOMapper.java:67) ~[?:?]
        at org.eclipse.smarthome.io.rest.core.item.EnrichedItemDTOMapper.map(EnrichedItemDTOMapper.java:61) ~[?:?]
        at org.eclipse.smarthome.io.rest.core.internal.item.ItemResource.lambda$0(ItemResource.java:230) ~[?:?]
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_232]
        at java.util.HashMap$KeySpliterator.tryAdvance(HashMap.java:1577) ~[?:1.8.0_232]
        at java.util.stream.StreamSpliterators$WrappingSpliterator.lambda$initPartialTraversalState$0(StreamSpliterators.java:295) ~[?:1.8.0_232]
        at java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.fillBuffer(StreamSpliterators.java:207) ~[?:1.8.0_232]
        at java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.doAdvance(StreamSpliterators.java:170) ~[?:1.8.0_232]
        at java.util.stream.StreamSpliterators$WrappingSpliterator.tryAdvance(StreamSpliterators.java:301) ~[?:1.8.0_232]
        at java.util.Spliterators$1Adapter.hasNext(Spliterators.java:681) ~[?:1.8.0_232]
        at org.eclipse.smarthome.io.rest.Stream2JSONInputStream.fillBuffer(Stream2JSONInputStream.java:93) ~[?:?]
        at org.eclipse.smarthome.io.rest.Stream2JSONInputStream.read(Stream2JSONInputStream.java:69) ~[?:?]
        at java.io.InputStream.read(InputStream.java:179) ~[?:1.8.0_232]
        at java.io.InputStream.read(InputStream.java:101) ~[?:1.8.0_232]
        at org.glassfish.jersey.message.internal.ReaderWriter.writeTo(ReaderWriter.java:115) ~[bundleFile:?]
        at org.glassfish.jersey.message.internal.AbstractMessageReaderWriterProvider.writeTo(AbstractMessageReaderWriterProvider.java:79) ~[bundleFile:?]
        at org.glassfish.jersey.message.internal.InputStreamProvider.writeTo(InputStreamProvider.java:105) ~[bundleFile:?]
        at org.glassfish.jersey.message.internal.InputStreamProvider.writeTo(InputStreamProvider.java:60) ~[bundleFile:?]
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265) ~[bundleFile:?]
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250) ~[bundleFile:?]
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[bundleFile:?]
        at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:106) ~[?:?]
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[bundleFile:?]
        at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:86) ~[?:?]
        ... 53 more

Your Environment

  • Version used: 2.5.6
  • Operating System and version: docker on raspi
@DerOetzi DerOetzi added the bug An unexpected problem or unintended behavior of an add-on label Jun 25, 2020
@DerOetzi
Copy link
Contributor Author

Did some further investigation and found the defect items:

Example item:

Number colorTempFlurEGVorne1
    "Flur EG Vorne 1 [SCALE(spektrum.scale):%s]"
    <light>
    (colorTempFlurEGVorne)
    ["db|light|tag:group=FlurEGVorne|tag:typ=color"]
    {channel="deconz:colortemperaturelight:homeserver:XXXXXXXXXXXXXXX:color_temperature"}

spektrum.scale:

[..10]=Kaltweiß
]10..90[=Gemischt
[90..100]=Warmweiß
NaN=Unbekannt

The item was used with hue-binding before and was type dimmer. Now with deconz binding this is type Number and has a value 2095, which is outside of all ranges. Maybe this is causing the problem

@J-N-K
Copy link
Member

J-N-K commented Jun 25, 2020

The deconz binding uses the color temperature in Kelvin. But that should not result in an NPE.

@J-N-K J-N-K mentioned this issue Jun 25, 2020
@DerOetzi
Copy link
Contributor Author

@J-N-K I tried to reproduce your fix and started with introducing your additional Unit-Testcase but used existing humidex.scale file with range up to 100 with a value of 200 and the test case passed fine. So I had a closer look on it and noticed the test-case failed with a NPE only when I introduced the last line to humidex,scale file

NaN=Unknown

So it seems that line is the real problem and I'm not sure whether your fix is still neccessary or whether this line is invalid configuration on my side?

@J-N-K
Copy link
Member

J-N-K commented Jun 29, 2020

IMO NaN is perfectly valid here. It‘s the implementation that‘s flawed.

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 an add-on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants