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 8a4bfcdda4a50b78a57fb3fd7150b37e39340173
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Mon May 26 09:51:56 2025 -0400

    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
---
 src/changes/changes.xml                                          | 1 +
 src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 7059bf33..1ee7f6bd 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -78,6 +78,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 "isSharedConnection" in one thread 
may not yield the value of the most recent write from another thread 
[org.apache.commons.dbcp2.managed.ManagedConnection] 
AT_STALE_THREAD_WRITE_OF_PRIMITIVE.</action>
       <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.cpdsadapter.PooledConnectionImpl] 
AT_STALE_THREAD_WRITE_OF_PRIMITIVE.</action>
       <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>
       <!-- 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/DelegatingConnection.java 
b/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
index 2304b325..08dfacca 100644
--- a/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
+++ b/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
@@ -69,8 +69,7 @@ public class DelegatingConnection<C extends Connection> 
extends AbandonedTrace i
     private volatile C connection;
 
     private volatile boolean closed;
-
-    private boolean cacheState = true;
+    private volatile boolean cacheState = true;
     private Boolean cachedAutoCommit;
     private Boolean cachedReadOnly;
     private String cachedCatalog;

Reply via email to