Skip to content

Commit b565065

Browse files
committed
Add synchronization to IndefiniteStatementCache.cache
The access to the backing Map of IndefiniteStatementCache is now synchronized. [resolves #232]
1 parent 8e32add commit b565065

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/io/r2dbc/postgresql/IndefiniteStatementCache.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ public Mono<String> getName(Binding binding, String sql) {
4646
Assert.requireNonNull(binding, "binding must not be null");
4747
Assert.requireNonNull(sql, "sql must not be null");
4848

49-
return this.cache.computeIfAbsent(Tuples.of(sql, binding.getParameterTypes()),
50-
tuple -> this.parse(tuple.getT1(), tuple.getT2()));
49+
synchronized (this.cache) {
50+
return this.cache.computeIfAbsent(Tuples.of(sql, binding.getParameterTypes()),
51+
tuple -> this.parse(tuple.getT1(), tuple.getT2()));
52+
}
5153
}
5254

5355
@Override

0 commit comments

Comments
 (0)