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

ExceptionMapper not thread safe #318

Open
DanyalBurke opened this issue Aug 4, 2015 · 1 comment
Open

ExceptionMapper not thread safe #318

DanyalBurke opened this issue Aug 4, 2015 · 1 comment

Comments

@DanyalBurke
Copy link

ExceptionMapper is accessed from multiple request threads but the underlying Map is a HashMap; could be refactored to use a ConcurrentHashMap or methods could be made synchronized

@jakaarl
Copy link
Contributor

jakaarl commented Jan 5, 2016

I can't claim to be very knowledgeable about the inner workings of Spark, but from a quick read of the sources, I think this is not necessarily a big problem. The exception mappings are done in SparkInstance.exception(), which is synchronized (and AFAIK, multiple instances are not intended to be used). MatcherFilter accesses the mappings without synchronization, but in a read-only fashion. As long as exceptions are mapped before SparkInstance.init()is called, we're good - of course, nothing prevents users from adding routes or filters before exception mappings, which could cause a race condition. I guess the solution would be to either synchronize access (or use a concurrent map) or require that exceptions are not mapped after initialization.

Lloyd-Pottiger added a commit to Lloyd-Pottiger/spark that referenced this issue Apr 20, 2021
lepe added a commit to Intellisrc/spark that referenced this issue Jul 4, 2022
fix issue perwendel#318 change HashMap to ConcurrentHashMap
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

3 participants