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-io.git

commit 3f14d07461e80fe3c39223ba300751261537ad99
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Sun May 18 17:41:45 2025 -0400

    Fix SpotBugs AT_STALE_THREAD_WRITE_OF_PRIMITIVE
    
    - Fix SpotBugs [ERROR] Medium: Shared primitive variable "atSlashCr" in
    one thread may not yield the value of the most recent write from another
    thread [org.apache.commons.io.input.WindowsLineEndingInputStream,
    org.apache.commons.io.input.WindowsLineEndingInputStream] At
    WindowsLineEndingInputStream.java:[line 77]Another occurrence at
    WindowsLineEndingInputStream.java:[line 81]
    AT_STALE_THREAD_WRITE_OF_PRIMITIVE.
    - Fix SpotBugs [ERROR] Medium: Shared primitive variable "atSlashCr" in
    one thread may not yield the value of the most recent write from another
    thread [org.apache.commons.io.input.WindowsLineEndingInputStream] At
    WindowsLineEndingInputStream.java:[line 112]
    AT_STALE_THREAD_WRITE_OF_PRIMITIVE.
    - Fix SpotBugs [ERROR] Medium: Shared primitive variable "atSlashLf" in
    one thread may not yield the value of the most recent write from another
    thread [org.apache.commons.io.input.WindowsLineEndingInputStream] At
    WindowsLineEndingInputStream.java:[line 113]
    AT_STALE_THREAD_WRITE_OF_PRIMITIVE.
    - Tested locally using commons-parent 83 for the latest SpotBugs
---
 src/changes/changes.xml                                                | 3 +++
 .../java/org/apache/commons/io/input/WindowsLineEndingInputStream.java | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index ba3cb87d1..8e67f14d7 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -57,6 +57,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="fix"                due-to="Gary 
Gregory">org.apache.commons.io.build.AbstractOrigin.AbstractRandomAccessFileOrigin.getWriter(Charset)
 now maps a null Charset to the default Charset.</action>
       <action dev="ggregory" type="fix"                due-to="Gary 
Gregory">org.apache.commons.io.build.AbstractOrigin.OutputStreamOrigin.getWriter(Charset)
 now maps a null Charset to the default Charset.</action>
       <action dev="ggregory" type="fix"                due-to="Ryan Kurtz, 
Gary Gregory">FileUtils.readLines(File, Charset) now maps a null Charset to the 
default Charset #744.</action>
+      <action dev="ggregory" type="fix"                due-to="Gary 
Gregory">Fix SpotBugs [ERROR] Medium: Shared primitive variable "atSlashCr" in 
one thread may not yield the value of the most recent write from another thread 
[org.apache.commons.io.input.WindowsLineEndingInputStream, 
org.apache.commons.io.input.WindowsLineEndingInputStream] At 
WindowsLineEndingInputStream.java:[line 77]Another occurrence at 
WindowsLineEndingInputStream.java:[line 81] 
AT_STALE_THREAD_WRITE_OF_PRIMITIVE.< [...]
+      <action dev="ggregory" type="fix"                due-to="Gary 
Gregory">Fix SpotBugs [ERROR] Medium: Shared primitive variable "atSlashCr" in 
one thread may not yield the value of the most recent write from another thread 
[org.apache.commons.io.input.WindowsLineEndingInputStream] At 
WindowsLineEndingInputStream.java:[line 112] 
AT_STALE_THREAD_WRITE_OF_PRIMITIVE.</action>
+      <action dev="ggregory" type="fix"                due-to="Gary 
Gregory">Fix SpotBugs [ERROR] Medium: Shared primitive variable "atSlashLf" in 
one thread may not yield the value of the most recent write from another thread 
[org.apache.commons.io.input.WindowsLineEndingInputStream] At 
WindowsLineEndingInputStream.java:[line 113] 
AT_STALE_THREAD_WRITE_OF_PRIMITIVE.</action>
       <!-- ADD -->
       <action dev="ggregory" type="add" issue="IO-875" due-to="Pierre Baumard, 
Gary Gregory">Add and use 
org.apache.commons.io.file.CountingPathVisitor.accept(Path, 
BasicFileAttributes) #743.</action> 
       <!-- UPDATE -->
diff --git 
a/src/main/java/org/apache/commons/io/input/WindowsLineEndingInputStream.java 
b/src/main/java/org/apache/commons/io/input/WindowsLineEndingInputStream.java
index eb7534754..b179b5d59 100644
--- 
a/src/main/java/org/apache/commons/io/input/WindowsLineEndingInputStream.java
+++ 
b/src/main/java/org/apache/commons/io/input/WindowsLineEndingInputStream.java
@@ -97,7 +97,7 @@ public synchronized void mark(final int readLimit) {
      * {@inheritDoc}
      */
     @Override
-    public int read() throws IOException {
+    public synchronized int read() throws IOException {
         if (atEos) {
             return handleEos();
         }

Reply via email to