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

ConcurrentModificationException on atmosphere websocket connection #1908

Closed
albertdabrowski opened this issue Mar 25, 2015 · 13 comments
Closed

Comments

@albertdabrowski
Copy link

I'm using atmosphere-runtime version 2.3.0-RC3 and the following exception occurs after exchanging few frames over websocket. BTW, it's setup to send it in binary mode.

Message received! 1817199655410146
2015-03-23 14:51:32 WARN  TrackMessageSizeInterceptor:135 - Cannot use TrackMessageSizeInterceptor with binary write. Writing the message as it is.
2015-03-23 14:51:32 WARN  TrackMessageSizeInterceptor:135 - Cannot use TrackMessageSizeInterceptor with binary write. Writing the message as it is.
Message received! 1817199655410147
2015-03-23 14:51:32 WARN  TrackMessageSizeInterceptor:135 - Cannot use TrackMessageSizeInterceptor with binary write. Writing the message as it is.
Message received! 1817199655410148
2015-03-23 14:51:32 WARN  TrackMessageSizeInterceptor:135 - Cannot use TrackMessageSizeInterceptor with binary write. Writing the message as it is.
Message received! 1817199655410149
2015-03-23 14:51:32 WARN  TrackMessageSizeInterceptor:135 - Cannot use TrackMessageSizeInterceptor with binary write. Writing the message as it is.
Message received! 1817199655410150
2015-03-23 14:51:32 WARN  TrackMessageSizeInterceptor:135 - Cannot use TrackMessageSizeInterceptor with binary write. Writing the message as it is.
Message received! 1817199655410151
2015-03-23 14:51:32 WARN  TrackMessageSizeInterceptor:135 - Cannot use TrackMessageSizeInterceptor with binary write. Writing the message as it is.
Message received! 1817199655410152
2015-03-23 14:51:32 WARN  TrackMessageSizeInterceptor:135 - Cannot use TrackMessageSizeInterceptor with binary write. Writing the message as it is.
Message received! 1817199655410153
2015-03-23 14:51:32 WARN  TrackMessageSizeInterceptor:135 - Cannot use TrackMessageSizeInterceptor with binary write. Writing the message as it is.
Message received! 1817199655410154
2015-03-23 14:51:32 WARN  TrackMessageSizeInterceptor:135 - Cannot use TrackMessageSizeInterceptor with binary write. Writing the message as it is.
2015-03-23 14:51:32 DEBUG BridgeRuntime:682 - Exception
java.util.ConcurrentModificationException
       at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429)
       at java.util.HashMap$EntryIterator.next(HashMap.java:1463)
       at java.util.HashMap$EntryIterator.next(HashMap.java:1461)
       at org.atmosphere.websocket.protocol.ProtocolUtil.attributes(ProtocolUtil.java:57)
       at org.atmosphere.websocket.protocol.ProtocolUtil.constructRequest(ProtocolUtil.java:35)
       at org.atmosphere.websocket.protocol.SimpleHttpProtocol.onMessage(SimpleHttpProtocol.java:136)
       at org.atmosphere.websocket.DefaultWebSocketProcessor.invokeWebSocketProtocol(DefaultWebSocketProcessor.java:464)
       at org.atmosphere.nettosphere.BridgeRuntime.handleWebSocketFrame(BridgeRuntime.java:347)
       at org.atmosphere.nettosphere.BridgeRuntime.messageReceived(BridgeRuntime.java:270)
       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
       at org.jboss.netty.handler.stream.ChunkedWriteHandler.handleUpstream(ChunkedWriteHandler.java:142)
       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
       at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
       at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462)
       at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:536)
       at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:435)
       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
       at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
       at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
       at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
       at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
       at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)
       at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
       at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
       at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
       at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
       at java.lang.Thread.run(Thread.java:745)
2015-03-23 14:51:32 DEBUG BridgeRuntime:620 - Error 500 Internal Server Error for null
Message received! 1817199655410156
Connection established!
User {89eaa38e-c3c0-4ba1-9c5f-13d2f3f6ab6e} connected.
2015-03-23 14:51:32 WARN  TrackMessageSizeInterceptor:135 - Cannot use TrackMessageSizeInterceptor with binary write. Writing the message as it is.
Message received! 1817199655410157
2015-03-23 14:51:32 WARN  TrackMessageSizeInterceptor:135 - Cannot use TrackMessageSizeInterceptor with binary write. Writing the message as it is.
2015-03-23 14:51:48 DEBUG IdleResourceInterceptor:91 - IdleResourceInterceptor disconnecting AtmosphereResource{
       uuid=89eaa38e-c3c0-4ba1-9c5f-13d2f3f6ab6e,
       transport=WEBSOCKET,
       isInScope=true,
       isResumed=false,
       isCancelled=false,
       isSuspended=true,
       broadcaster=/atmosphere size: 1,
       isClosedByClient=false,
       isClosedByApplication=false,
       action=Action{timeout=-1, type=SUSPEND}}
User {89eaa38e-c3c0-4ba1-9c5f-13d2f3f6ab6e} unexpectedly disconnected
@jfarcand
Copy link
Member

@albertdabrowski Please test with 2.3.0-SNAPSHOT https://github.com/Atmosphere/atmosphere/wiki/Downloading-Atmosphere's-SNAPSHOT and let me know if you still experiencing the issue.

@albertdabrowski
Copy link
Author

I experience the same effect on that snapshot version. Did test on stable 2.2.6 but was the same effect.

@jfarcand
Copy link
Member

@albertdabrowski Please share the stack trace obtained with 2.3.0-SNAPSHOT.

@albertdabrowski
Copy link
Author

Regarding Unit Test I'm doing here, it sent random binary data to the server which in response send back the status. I switched that into binary mode. Anyway I do the test without waiting for response from the server. It simply fires next message once the previous one is already sent (not waiting for response to receive on Function)

2015-03-26 15:58:44 WARN  TrackMessageSizeInterceptor:135 - Cannot use TrackMessageSizeInterceptor with binary write. Writing the message as it is.
2015-03-26 15:58:44 DEBUG BridgeRuntime:682 - Exception
java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429)
    at java.util.HashMap$EntryIterator.next(HashMap.java:1463)
    at java.util.HashMap$EntryIterator.next(HashMap.java:1461)
    at org.atmosphere.websocket.protocol.ProtocolUtil.attributes(ProtocolUtil.java:57)
    at org.atmosphere.websocket.protocol.ProtocolUtil.constructRequest(ProtocolUtil.java:35)
    at org.atmosphere.websocket.protocol.SimpleHttpProtocol.onMessage(SimpleHttpProtocol.java:136)
    at org.atmosphere.websocket.DefaultWebSocketProcessor.invokeWebSocketProtocol(DefaultWebSocketProcessor.java:464)
    at org.atmosphere.nettosphere.BridgeRuntime.handleWebSocketFrame(BridgeRuntime.java:347)
    at org.atmosphere.nettosphere.BridgeRuntime.messageReceived(BridgeRuntime.java:270)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.handler.stream.ChunkedWriteHandler.handleUpstream(ChunkedWriteHandler.java:142)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462)
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:536)
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:435)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
    at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
    at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
    at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
    at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
    at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
2015-03-26 15:58:44 DEBUG BridgeRuntime:620 - Error 500 Internal Server Error for null
User {494c4e48-ccf8-469b-98f9-6d16e083dd02} unexpectedly disconnected
2015-03-26 15:58:44 DEBUG Processor:114 - Channel Closed: [id: 0x1882c562, /127.0.0.1:57075 :> localhost/127.0.0.1:8080] with attribute NettyResponseFuture{currentRetry=5,
    isDone=true,
    isCancelled=false,
    asyncHandler=org.atmosphere.wasync.transport.WebSocketTransport@691a7e39,
    nettyRequest=com.ning.http.client.providers.netty.request.NettyRequest@3d408364,
    content=NettyWebSocket{channel=[id: 0x1882c562, /127.0.0.1:57075 :> localhost/127.0.0.1:8080]},
    uri=ws://localhost:8080/atmosphere,
    keepAlive=true,
    httpHeaders=org.jboss.netty.handler.codec.http.DefaultHttpHeaders@4dc16a2e,
    exEx=null,
    redirectCount=0,
    timeoutsHolder=null,
    inAuth=false,
    statusReceived=false,
    touch=1526381207}
2015-03-26 15:58:44 WARN  WebSocketTransport:169 - 
java.io.IOException: Invalid Socket Status CLOSE
    at org.atmosphere.wasync.impl.SocketRuntime.write(SocketRuntime.java:90)
    at org.atmosphere.wasync.impl.DefaultSocket.fire(DefaultSocket.java:82)
    at com.motorolasolutions.bigdata.ws2kafka.Ws2kafkaTest.testManyMessagesOverWebSocket(Ws2kafkaTest.java:91)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
    at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
2015-03-26 15:58:44 INFO  WebSocketTransport:297 - try reconnect : attempt [1/0]

@jfarcand
Copy link
Member

@albertdabrowski You aren't using the latest SNAPSHOT http://goo.gl/g3oH83

@albertdabrowski
Copy link
Author

I cannot get this snapshot through maven due to my proxy issue, so I downloaded it manually and put it into classpath. Please let me know if the version atmosphere-runtime-2.3.0-20150325.173055-217.jar is the right jar? I found that's the latest one from the repo You sent me.

@albertdabrowski
Copy link
Author

Ok, I see that You did a change on master, so I did a test and this time sometimes it works sometimes not (got the same ConcurrentModificationException. I think that problem is that in Your change You take a view, but this is not a copy of map, so if that map is modified somewhere else then the same exception occurs

catch (Exception ex) {
            ...
            Map<String, Object> dup = Collections.unmodifiableMap(request.localAttributes());
            ...

change to

catch (Exception ex) {
            ...
            Map<String, Object> dup = Collections.unmodifiableMap(new HashMap(request.localAttributes()));
            ...

albertdabrowski pushed a commit to albertdabrowski/atmosphere that referenced this issue Mar 30, 2015
jfarcand added a commit that referenced this issue Mar 31, 2015
jfarcand added a commit that referenced this issue Mar 31, 2015
@jfarcand jfarcand reopened this Apr 1, 2015
@albertdabrowski
Copy link
Author

Ok, here I created simple Unit Test with this and You may check that it
fails. BTW, I did a check on just sending info to the client and that
works. The problem arise when atmopshere send the message back to the
client. I think You still need that synchronization or I miss some other
knowledge from Your implementation.

Regards,
Albert

2015-04-01 14:49 GMT+02:00 Jeanfrancois Arcand notifications@github.com:

Reopened #1908 #1908.


Reply to this email directly or view it on GitHub
#1908 (comment).

@jfarcand
Copy link
Member

jfarcand commented Apr 1, 2015

@albertdabrowski Please share the test :-)

@albertdabrowski
Copy link
Author

I cannot add it here the zip file with small project having this test, I've sent to You in attachmment over mail, please have a look.

@jfarcand
Copy link
Member

@albertdabrowski Any update? I've never received your .zip

@jfarcand jfarcand reopened this Apr 16, 2015
@albertdabrowski
Copy link
Author

I've sent it once again to the jfarcand.oss@gmail.com

jfarcand added a commit that referenced this issue Apr 17, 2015
@jfarcand jfarcand added the 2.2.7 label Apr 17, 2015
jfarcand added a commit that referenced this issue Apr 17, 2015
@albertdabrowski
Copy link
Author

Let me know when the new version will be available. Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants