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

NullPointerException on connection disposal #914

Closed
SerCeMan opened this issue Aug 11, 2020 · 8 comments · Fixed by #941
Closed

NullPointerException on connection disposal #914

SerCeMan opened this issue Aug 11, 2020 · 8 comments · Fixed by #941
Assignees
Labels
bug superseded Issue is superseded by another
Milestone

Comments

@SerCeMan
Copy link
Member

Hey, folks!

We've noticed the following error periodically when the connections are being disposed. If I'm reading the exception correctly, it seems like the collection stores null at some point.

java.lang.NullPointerException: null
    at java.lang.Iterable.forEach(Iterable.java:75)
    at io.rsocket.core.RSocketResponder.cleanUpSendingSubscriptions(RSocketResponder.java:274)
    at io.rsocket.core.RSocketResponder.cleanup(RSocketResponder.java:264)
    at io.rsocket.core.RSocketResponder.tryTerminate(RSocketResponder.java:166)
    at io.rsocket.core.RSocketResponder.tryTerminateOnConnectionClose(RSocketResponder.java:159)
    at reactor.core.publisher.LambdaMonoSubscriber.onComplete(LambdaMonoSubscriber.java:132)
    at reactor.core.publisher.MonoProcessor$NextInner.onComplete(MonoProcessor.java:518)
    at reactor.core.publisher.MonoProcessor.onNext(MonoProcessor.java:308)
    at reactor.core.publisher.MonoProcessor.onComplete(MonoProcessor.java:265)
    at io.rsocket.internal.BaseDuplexConnection.dispose(BaseDuplexConnection.java:23)
    at ...

Steps to Reproduce

It seems that the error isn't easily reproducible. We're only seeing very rarely, once or twice a day.

Your Environment

  • RSocket version(s) used: 1.0.1
  • Other relevant libraries versions (eg. netty, ...): none
  • Platform (eg. JVM version (javar -version) or Node version (node --version)): 13
  • OS and version (eg uname -a): ubuntu 20.04
@OlegDokuka
Copy link
Member

OlegDokuka commented Aug 11, 2020

Hey @SerCeMan!

Thank you for reporting that!
I will have a look.

On the root-cause... Not sure we put null somewhere, it is more likely a racing between cleanup during disposal and a stream that does self-removal from the same collection when it is terminated.

So it may be that the iterator has seen an element but a collection has already been shrunken so once a next is called, the element being observed is null, hence we see NPE.

@OlegDokuka OlegDokuka added the bug label Aug 11, 2020
@OlegDokuka OlegDokuka added this to the 1.0.3 milestone Aug 12, 2020
rstoyanchev added a commit to rstoyanchev/rsocket-java that referenced this issue Oct 6, 2020
Closes rsocketgh-914

Signed-off-by: Rossen Stoyanchev <rstoyanchev@vmware.com>
@rstoyanchev rstoyanchev linked a pull request Oct 6, 2020 that will close this issue
rstoyanchev added a commit to rstoyanchev/rsocket-java that referenced this issue Oct 6, 2020
Closes rsocketgh-914

Signed-off-by: Rossen Stoyanchev <rstoyanchev@vmware.com>
rstoyanchev added a commit to rstoyanchev/rsocket-java that referenced this issue Oct 6, 2020
A follow-up fix that extends the changes in
1ca3b99

See rsocketgh-914

Signed-off-by: Rossen Stoyanchev <rstoyanchev@vmware.com>
@rstoyanchev rstoyanchev added the superseded Issue is superseded by another label Oct 6, 2020
@rstoyanchev rstoyanchev self-assigned this Oct 6, 2020
@rstoyanchev rstoyanchev removed this from the 1.0.3 milestone Oct 6, 2020
@rstoyanchev
Copy link
Contributor

This should be resolved now.

@Cesarla
Copy link

Cesarla commented Mar 11, 2021

Hi @OlegDokuka, @rstoyanchev can these improvements be back-ported to rsocket 1.1.X? I am facing the same problems with the version 1.1.0

@OlegDokuka
Copy link
Member

@Cesarla any reproducer to share?

@Cesarla
Copy link

Cesarla commented Mar 11, 2021

It happens while cleaning channel-based communication:

java.lang.NullPointerException: null
at java.lang.Iterable.forEach (Iterable.java:75)
at io.rsocket.core.RSocketResponder.cleanUpSendingSubscriptions (RSocketResponder.java:186)
at io.rsocket.core.RSocketResponder.doOnDispose (RSocketResponder.java:174)
at io.rsocket.core.RSocketResponder.tryTerminate (RSocketResponder.java:108)
at io.rsocket.core.RSocketResponder.tryTerminateOnConnectionClose (RSocketResponder.java:101)
at reactor.core.publisher.LambdaMonoSubscriber.onComplete (LambdaMonoSubscriber.java:135)
at reactor.core.publisher.NextProcessor$NextInner.onComplete (NextProcessor.java:403)
at reactor.core.publisher.NextProcessor.tryEmitValue (NextProcessor.java:185)
at reactor.core.publisher.NextProcessor.tryEmitEmpty (NextProcessor.java:137)
at reactor.core.publisher.NextProcessor.onComplete (NextProcessor.java:132)
at io.rsocket.resume.ResumableDuplexConnection.dispose (ResumableDuplexConnection.java:213)
at io.rsocket.resume.ServerRSocketSession.onNext (ServerRSocketSession.java:215)
at io.rsocket.resume.ServerRSocketSession.onNext (ServerRSocketSession.java:40)
at com.XXXX.eventstream.MdcContextLifter.onNext (MdcContextLifter.java:29)
at reactor.core.publisher.MonoDelay$MonoDelayRunnable.run (MonoDelay.java:119)
at reactor.core.scheduler.SchedulerTask.call (SchedulerTask.java:68)
at reactor.core.scheduler.SchedulerTask.call (SchedulerTask.java:28)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run (ScheduledThreadPoolExecutor.java:304)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
at java.lang.Thread.run (Thread.java:834)

@OlegDokuka
Copy link
Member

yeah. It is actually IntObjectMap bug that may send unused values so they are null which endups with NPE

@OlegDokuka OlegDokuka reopened this Mar 12, 2021
@OlegDokuka OlegDokuka added this to the 1.1.1 milestone Mar 16, 2021
@yschimke
Copy link
Member

Is this still happening?

rstoyanchev added a commit to rstoyanchev/rsocket-java that referenced this issue Apr 27, 2021
Closes rsocketgh-914

Signed-off-by: Rossen Stoyanchev <rstoyanchev@vmware.com>
@rstoyanchev
Copy link
Contributor

@Cesarla this should be fixed in 1.1.1 snapshots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug superseded Issue is superseded by another
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants