Open source software supply chain lighting plan, waiting for you>>>
Background of error reporting
Java code occasionally reports an error, but it will not report an error under normal operation
Error reporting
exception: java.lang.reflect.InvocationTargetException: null
2020-05-11 at 15:17:39 CST traceId:[] ERROR io.netty.util.internal.logging.AbstractInternalLogger 91 error - Unexpected exception: java.lang.reflect.InvocationTargetException: null
at sun.reflect.GeneratedMethodAccessor214.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_192]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_192]
at org.yeauty.pojo.PojoEndpointServer.doOnClose(PojoEndpointServer.java:121) [netty-websocket-spring-boot-starter-0.8.0.jar!/:?]
at org.yeauty.standard.WebSocketServerHandler.channelInactive(WebSocketServerHandler.java:29) [netty-websocket-spring-boot-starter-0.8.0.jar!/:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:257) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:243) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:236) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:393) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:358) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:257) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:243) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:236) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1416) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:257) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:243) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:912) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.channel.AbstractChannel$AbstractUnsafe$8.run(AbstractChannel.java:816) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:416) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:515) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-all-4.1.38.Final.jar!/:4.1.38.Final]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_192]
Caused by: java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextNode(HashMap.java:1445) ~[?:1.8.0_192]
at java.util.HashMap$EntryIterator.next(HashMap.java:1479) ~[?:1.8.0_192]
at java.util.HashMap$EntryIterator.next(HashMap.java:1477) ~[?:1.8.0_192]
at com.jcdz.hbdservice.websocket.ServerWebSocket1.onClose(ServerWebSocket1.java:38) ~[coalminehbdservice-1.0.jar!/:1.0]
... 25 more
Cause of error
There are many reasons for reporting errors. I will just say the reason I came into contact with:
(1) If (= =) judgment statement error
if(devMap.get(“locationcode”) == null)
Devmap. Get (“locationcode”): it is possible to pass a null, and then a null pointer will appear
(2) If (equals) judgment statement error
if(! time.equals(“1900-01-01 00:00:00”))
Time: it is possible that a null will be passed, and then a null pointer will appear
in this case
Error report solution
Modify the sequence of judgment sentences as follows:
if(null == devMap.get(“locationcode”))
if(!” 1900-01-01 00:00:00″.equals(time))