-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Labels
agentLanguage agent related.Language agent related.bugSomething isn't working and you are sure it's a bug!Something isn't working and you are sure it's a bug!enhancementEnhancement on performance or codesEnhancement on performance or codesjavaJava agent relatedJava agent related
Milestone
Description
Search before asking
- I had searched in the issues and found no similar issues.
Apache SkyWalking Component
Java Agent (apache/skywalking-java)
What happened
If StreamObserver#onNext is called in another thread, we will see exception: IllegalArgumentException("ContextSnapshot can't be null.")
After apache/skywalking-java#457, we use a io.grpc.Context to pass the ContextSnapshot. But by default, io.grpc.Context uses ThreadLocal as storage. So it won't work across threads. Then the contextSnapshot will be null, which causes the exception above.
I think we should partially revert the PR. Using the constructor to pass contexts is good.
What you expected to happen
It should work normally
How to reproduce
the simplest way is write a handler like this:
public StreamObserver<Request> connect(StreamObserver<Response> responseObserver) {
new Thread(()-> {
responseObserver.onNext(Response.newBuilder().build());
}).start();
return new StreamObserver<>() {
@Override
public void onNext(Request value) {
}
@Override
public void onError(Throwable t) {
}
@Override
public void onCompleted() {
}
}Then call it with a client, such as grpcurl.
Anything else
No response
Are you willing to submit a pull request to fix on your own?
- Yes I am willing to submit a pull request on my own!
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
agentLanguage agent related.Language agent related.bugSomething isn't working and you are sure it's a bug!Something isn't working and you are sure it's a bug!enhancementEnhancement on performance or codesEnhancement on performance or codesjavaJava agent relatedJava agent related