This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git

commit e57fcdb341cf37586d4a804d61b806e7dd7e4538
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Mon May 26 10:08:16 2025 -0400

    Fix SpotBugs [ERROR] Medium: Shared primitive variable
    "clearStatementPoolOnReturn" in one thread may not yield the value of
    the most recent write from another thread
    [org.apache.commons.dbcp2.PoolingConnection]
    AT_STALE_THREAD_WRITE_OF_PRIMITIVE
---
 src/changes/changes.xml                                       | 1 +
 src/main/java/org/apache/commons/dbcp2/PoolingConnection.java | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 43546b93..066df3f9 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -80,6 +80,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix SpotBugs 
[ERROR] Medium: Shared primitive variable "closed" in one thread may not yield 
the value of the most recent write from another thread 
[org.apache.commons.dbcp2.DelegatingStatement] 
AT_STALE_THREAD_WRITE_OF_PRIMITIVE.</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix SpotBugs 
[ERROR] Medium: Shared primitive variable "cacheState" in one thread may not 
yield the value of the most recent write from another thread 
[org.apache.commons.dbcp2.DelegatingConnection] 
AT_STALE_THREAD_WRITE_OF_PRIMITIVE.</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix SpotBugs 
[ERROR] Medium: Operation on the "fatalSqlExceptionThrown" shared variable in 
"PoolableConnection" class is not atomic 
[org.apache.commons.dbcp2.PoolableConnection] 
AT_NONATOMIC_OPERATIONS_ON_SHARED_VARIABLE.</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix SpotBugs 
[ERROR] Medium: Shared primitive variable "clearStatementPoolOnReturn" in one 
thread may not yield the value of the most recent write from another thread 
[org.apache.commons.dbcp2.PoolingConnection] 
AT_STALE_THREAD_WRITE_OF_PRIMITIVE.</action>
       <!-- ADD -->
       <!-- UPDATE -->
       <action type="update" dev="ggregory" due-to="Gary Gregory">Bump 
org.apache.commons:commons-parent from 78 to 81.</action>
diff --git a/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java 
b/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
index 57720e2e..89d99055 100644
--- a/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
+++ b/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
@@ -76,7 +76,7 @@ public class PoolingConnection extends 
DelegatingConnection<Connection>
     /** Pool of {@link PreparedStatement}s. and {@link CallableStatement}s */
     private KeyedObjectPool<PStmtKey, DelegatingPreparedStatement> stmtPool;
 
-    private boolean clearStatementPoolOnReturn;
+    private volatile boolean clearStatementPoolOnReturn;
 
     /**
      * Constructs a new instance.

Reply via email to