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

fix(plc4j/drivers/s7): fix NoSuchElementException when watchdog ChannelHandler was not added yet & fix exception "MessageToMessageCodec$1 must produce at least one message." & fix some typos #1873

Merged
merged 4 commits into from
Nov 11, 2024

Conversation

jmeierhofer
Copy link
Contributor

Fixes 2 exceptions and some typos in log messages.

Fixes an exception when the "watchdog" is tried to be removed but was not added yet.

This produced an unnecessary INFO log:

DefaultChannelPipeline.getContextOrDie(String) line: 1022	
DefaultChannelPipeline.remove(String) line: 372	
S7HMuxImpl.userEventTriggered(ChannelHandlerContext, Object) line: 180	
DefaultChannelHandlerContext(AbstractChannelHandlerContext).invokeUserEventTriggered(Object) line: 398	
AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext, Object) line: 376	
DefaultChannelPipeline$HeadContext(AbstractChannelHandlerContext).fireUserEventTriggered(Object) line: 368	
DefaultChannelPipeline$HeadContext.userEventTriggered(ChannelHandlerContext, Object) line: 1375	
DefaultChannelPipeline$HeadContext(AbstractChannelHandlerContext).invokeUserEventTriggered(Object) line: 396	
AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext, Object) line: 376	
EmbeddedChannel$EmbeddedChannelPipeline(DefaultChannelPipeline).fireUserEventTriggered(Object) line: 862	
DefaultConversationContext<T1>.fireConnected() line: 76	
S7ProtocolLogic.lambda$8(ConversationContext, S7ParameterSetupCommunication) line: 212	
0x000001e0814f4fc0.accept(Object) line: not available	
NettyHashTimerTimeoutManager$TimeoutCompletionCallback<T>(Consumer<T>).lambda$andThen$0(Consumer, Object) line: 65	
0x000001e081458960.accept(Object) line: not available	
Plc4xNettyWrapper<T>.decode(ChannelHandlerContext, T, List<Object>) line: 183	
MessageToMessageCodec$2.decode(ChannelHandlerContext, Object, List<Object>) line: 81	
MessageToMessageCodec$2(MessageToMessageDecoder<I>).channelRead(ChannelHandlerContext, Object) line: 88	
Plc4xNettyWrapper<T>(MessageToMessageCodec<INBOUND_IN,OUTBOUND_IN>).channelRead(ChannelHandlerContext, Object) line: 111	
DefaultChannelHandlerContext(AbstractChannelHandlerContext).invokeChannelRead(Object) line: 442	
AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext, Object) line: 420	
DefaultChannelHandlerContext(AbstractChannelHandlerContext).fireChannelRead(Object) line: 412	
MessageToMessageCodec$2(MessageToMessageDecoder<I>).channelRead(ChannelHandlerContext, Object) line: 103	
EventListenerMessageCodec(MessageToMessageCodec<INBOUND_IN,OUTBOUND_IN>).channelRead(ChannelHandlerContext, Object) line: 111	
DefaultChannelHandlerContext(AbstractChannelHandlerContext).invokeChannelRead(Object) line: 442	
AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext, Object) line: 420	
DefaultChannelHandlerContext(AbstractChannelHandlerContext).fireChannelRead(Object) line: 412	
ByteToMessageDecoder.fireChannelRead(ChannelHandlerContext, CodecOutputList, int) line: 346	
ByteToMessageCodec$1(ByteToMessageDecoder).channelRead(ChannelHandlerContext, Object) line: 318	
GeneratedProtocolMessageCodec<BASE_PACKET_CLASS>(ByteToMessageCodec<I>).channelRead(ChannelHandlerContext, Object) line: 103	
DefaultChannelHandlerContext(AbstractChannelHandlerContext).invokeChannelRead(Object) line: 442	
AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext, Object) line: 420	
DefaultChannelHandlerContext(AbstractChannelHandlerContext).fireChannelRead(Object) line: 412	
LoggingHandler.channelRead(ChannelHandlerContext, Object) line: 280	
DefaultChannelHandlerContext(AbstractChannelHandlerContext).invokeChannelRead(Object) line: 442	
AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext, Object) line: 420	
DefaultChannelHandlerContext(AbstractChannelHandlerContext).fireChannelRead(Object) line: 412	
S7HMuxImpl.decode(ChannelHandlerContext, ByteBuf, List<Object>) line: 145	
S7HMuxImpl.decode(ChannelHandlerContext, Object, List) line: 1	
MessageToMessageCodec$2.decode(ChannelHandlerContext, Object, List<Object>) line: 81	
MessageToMessageCodec$2(MessageToMessageDecoder<I>).channelRead(ChannelHandlerContext, Object) line: 88	
S7HMuxImpl(MessageToMessageCodec<INBOUND_IN,OUTBOUND_IN>).channelRead(ChannelHandlerContext, Object) line: 111	
DefaultChannelHandlerContext(AbstractChannelHandlerContext).invokeChannelRead(Object) line: 442	
AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext, Object) line: 420	
DefaultChannelPipeline$HeadContext(AbstractChannelHandlerContext).fireChannelRead(Object) line: 412	
DefaultChannelPipeline$HeadContext.channelRead(ChannelHandlerContext, Object) line: 1357	
DefaultChannelPipeline$HeadContext(AbstractChannelHandlerContext).invokeChannelRead(Object) line: 440	
AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext, Object) line: 420	
DefaultChannelPipeline.fireChannelRead(Object) line: 868	
NioSocketChannel$NioSocketChannelUnsafe(AbstractNioByteChannel$NioByteUnsafe).read() line: 166	
NioEventLoop.processSelectedKey(SelectionKey, AbstractNioChannel) line: 788	
NioEventLoop.processSelectedKeysOptimized() line: 724	
NioEventLoop.processSelectedKeys() line: 650	
NioEventLoop.run() line: 562	
SingleThreadEventExecutor$4.run() line: 997	
ThreadExecutorMap$2.run() line: 74	
FastThreadLocalRunnable.run() line: 30	
FastThreadLocalThread(Thread).runWith(Object, Runnable) line: 1596	
FastThreadLocalThread(Thread).run() line: 1583	

Fixes an unnecessary log message about an invalid encode() call which does not add any output to the given list.

This behavior was already mentioned here: #1257

io.netty.handler.codec.DecoderException: io.netty.handler.codec.EncoderException: MessageToMessageCodec$1 must produce at least one message.
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:98)
	at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
	at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
	at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:103)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:280)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at org.apache.plc4x.java.s7.readwrite.protocol.S7HMuxImpl.decode(S7HMuxImpl.java:145)
	at org.apache.plc4x.java.s7.readwrite.protocol.S7HMuxImpl.decode(S7HMuxImpl.java:1)
	at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81)
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88)
	at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1357)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:868)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: io.netty.handler.codec.EncoderException: MessageToMessageCodec$1 must produce at least one message.
	at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:99)
	at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:891)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:875)
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:984)
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:868)
	at io.netty.handler.logging.LoggingHandler.write(LoggingHandler.java:288)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:891)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:875)
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:984)
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:868)
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:113)
	at io.netty.handler.codec.ByteToMessageCodec.write(ByteToMessageCodec.java:108)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:891)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:875)
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:984)
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:868)
	at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:113)
	at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:891)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:875)
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:984)
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:868)
	at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:113)
	at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:891)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:956)
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:982)
	at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:950)
	at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:1000)
	at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:974)
	at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:305)
	at io.netty.channel.embedded.EmbeddedChannel.writeAndFlush(EmbeddedChannel.java:776)
	at org.apache.plc4x.java.spi.internal.DefaultConversationContext.sendToWire(DefaultConversationContext.java:70)
	at org.apache.plc4x.java.spi.internal.DefaultSendRequestContext.handle(DefaultSendRequestContext.java:107)
	at org.apache.plc4x.java.spi.internal.DefaultSendRequestContext.handle(DefaultSendRequestContext.java:1)
	at org.apache.plc4x.java.s7.readwrite.protocol.S7ProtocolLogic.lambda$3(S7ProtocolLogic.java:194)
	at java.base/java.util.function.Consumer.lambda$andThen$0(Consumer.java:65)
	at org.apache.plc4x.java.spi.Plc4xNettyWrapper.decode(Plc4xNettyWrapper.java:183)
	at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81)
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88)
	... 40 common frames omitted

Jochen Meierhofer added 4 commits November 7, 2024 17:45
…elHandler was not added yet & fix unnecessary warning in logfile/console due to exception "MessageToMessageCodec$1 must produce at least one message."
…located in org.apache.plc4x.java.s7.readwrite.protocol
…nes are located in org.apache.plc4x.java.s7.readwrite.protocol"

This reverts commit 5b1cc09.
@sruehl sruehl requested a review from glcj November 8, 2024 12:21
@jmeierhofer
Copy link
Contributor Author

@sruehl could you please trigger the failed Github action "test (17, ubuntu-latest)" again? Seems like it failed due to something unrelated to this PR.

@sruehl
Copy link
Contributor

sruehl commented Nov 11, 2024

LGTM ty for the PR

@sruehl sruehl merged commit 9856bb7 into apache:develop Nov 11, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants