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

The use of ArrayList in the Journey class is prone to thread concurrency issues #263

Open
nickp10 opened this issue Feb 24, 2023 · 3 comments

Comments

@nickp10
Copy link

nickp10 commented Feb 24, 2023

The ArrayList in the Journey class is causing thread concurrency issues. If you note the basic example from this Stack Overflow thread:

https://stackoverflow.com/questions/38531332/why-am-getting-null-value-from-arraylist-after-adding-value-using-thread

You'll note that null entries can mistakenly get added to the ArrayList. When this happens, the Journey's removeStepByName will throw a NullPointerException when it goes to iterate the list and comes across this null entry.

@dvayanu
Copy link
Member

dvayanu commented Feb 26, 2023

Hello, thank you for the issue and the pull request, we will review it shortly. Is it something you encountered in production?

@nickp10
Copy link
Author

nickp10 commented Feb 27, 2023

Yes this is a problem I'm currently experiencing. I have a simple GET request that has a tracer enabled on it. I'm using JMeter to send about 100 concurrent requests to this GET request and I'm getting a NullPointerException on average once each time I run my JMeter test.

image

@nickp10
Copy link
Author

nickp10 commented Feb 28, 2023

I did a little more research into this because I realized I was using an older version of the library (2.10.1). I updated to the latest version (3.2.2) and was unable to reproduce the issue anymore. The reason this is resolved in the latest version is because the Journey's addCall method is only called for a specific method, e.g. "Traced-Class.method" (from MonitorInterceptor). However, the Journey's removeStepByName method is only called for the general tracer, e.g. "Traced-Class.*" (from Tracer.addTrace). These resolve to two separate Journey instances so the traces are being added to one Journey and are attempted to being removed from a different Journey. This has resolved the concurrency issue, but likely has introduced other side effects since the one Journey never gets cleaned up.

EDIT; If I add a specific tracer for the specific method, this issue is still reproducible. Our configuration for tracers is only based on the * wildcard, so this issue is inadvertently resolved by the method specific tracing.

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

No branches or pull requests

2 participants