Please sign in to comment.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix of #1400 - race in DriverDataSource.init
Used double checked locking for `initialized` flag in order to avoid the initialization race. Also removed the initial setting of initialized = true since it shouldn't be done until after initialization is complete, which already happens in the finally block. There should be zero performance penalty since the synchronized block is only reached when uninitialized. Also made the `driver` and `connectionProps` variables volatile since I can't see how the writes to them will be guaranteed to be visible to other threads otherwise. The performance penalty should be almost zero in practice since the `initialized` variable was already volatile and the read of `initialized`, which happens at every getConnection() call, would've already triggered a read through from main memory and a second one shouldn't be noticeable.
- Loading branch information
Showing with 32 additions and 29 deletions.