fix(plc4j/eip): NullPointerException on decodeSingleReadResponse.#2471
Open
andvasp wants to merge 1 commit intoapache:developfrom
Open
fix(plc4j/eip): NullPointerException on decodeSingleReadResponse.#2471andvasp wants to merge 1 commit intoapache:developfrom
andvasp wants to merge 1 commit intoapache:developfrom
Conversation
Instead of throwing an exception, the system will report the response code INTERNAL_ERROR and plcValue will be null.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi everybody!
I am facing NPE at EipProtocolLogic:::decodeSingleReadResponse because the PlcResponseCode == "INTERNAL_ERROR
Caused by: java.lang.NullPointerException: Cannot invoke "org.apache.plc4x.java.eip.readwrite.CIPData.getDataType()" because the return value of "org.apache.plc4x.java.eip.readwrite.CipReadResponse.getData()" is null
at org.apache.plc4x.java.eip.base.protocol.EipProtocolLogic.decodeSingleReadResponse(EipProtocolLogic.java:814)
at org.apache.plc4x.java.eip.base.protocol.EipProtocolLogic.lambda$readWithoutMessageRouter$5(EipProtocolLogic.java:509)
at java.base/java.util.function.Consumer.lambda$andThen$0(Consumer.java:65)
at org.apache.plc4x.java.spi.Plc4xNettyWrapper.decode(Plc4xNettyWrapper.java:194)
at io.netty.handler.codec.MessageToMessageCodec$1.decode(MessageToMessageCodec.java:67)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:91)
at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:120)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
This pull request just move the type and data to inside the "if" where PlcResponseCode is OK. The data moved is just necessary inside the if to create the plcValue. So it is ok to move the code.
Instead of throwing an exception, the system will report the response code INTERNAL_ERROR and plcValue will be null.
PlcValue null value already can happen on parsePlcValue. So not prejuize to the current logic.
Best regards,
Anderson.