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

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


The following commit(s) were added to refs/heads/master by this push:
     new 0633c989 Skip byte counting at EOF in ExtendedBufferedReader.read 
(#615).
0633c989 is described below

commit 0633c989c9ff892d99bacd3289a3ff8d4cb0fbd6
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Jun 20 15:11:11 2026 +0000

    Skip byte counting at EOF in ExtendedBufferedReader.read (#615).
    
    Sort members.
---
 src/changes/changes.xml                            |  1 +
 .../java/org/apache/commons/csv/CSVParserTest.java | 42 +++++++++++-----------
 2 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f172a96f..867a2050 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -60,6 +60,7 @@
       <action type="fix" dev="ggregory" due-to="Dexter.k, Gary Gregory">Escape 
quote char in printWithEscapes when QuoteMode is NONE (#609).</action>
       <action type="fix" dev="ggregory" due-to="Dexter.k, Gary Gregory">Quote 
value starting with comment marker in minimal quote mode (#610).</action>
       <action type="fix" dev="ggregory" due-to="Dexter.k, Gary Gregory">Escape 
leading comment marker in printWithEscapes (#614).</action>
+      <action type="fix" dev="ggregory" due-to="Dexter.k, Gary Gregory">Skip 
byte counting at EOF in ExtendedBufferedReader.read (#615).</action>
       <!-- ADD -->
       <action type="add" dev="ggregory" due-to="Gary Gregory, Indy, Sylvia van 
Os" issue="CSV-307">Add an "Android Compatibility" section to the web 
site.</action>
       <action type="add" dev="ggregory" due-to="Ruiqi Dong, Gary Gregory" 
issue="CSV-325">Add CSVParser.Builder.setByteOffset(long) (#604).</action>
diff --git a/src/test/java/org/apache/commons/csv/CSVParserTest.java 
b/src/test/java/org/apache/commons/csv/CSVParserTest.java
index 1332fa58..309a073c 100644
--- a/src/test/java/org/apache/commons/csv/CSVParserTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVParserTest.java
@@ -691,27 +691,6 @@ class CSVParserTest {
         }
     }
 
-    @Test
-    void testGetBytePositionWithSingleByteCharset() throws IOException {
-        // A single-byte charset cannot encode U+FFFF, the char value of the 
EOF sentinel.
-        // Byte counting must skip the EOF read so a valid file parses without 
throwing.
-        final String code = "a,b\nc,d\n";
-        try (CSVParser parser = CSVParser.builder()
-                .setReader(new StringReader(code))
-                .setFormat(CSVFormat.DEFAULT)
-                .setCharset(StandardCharsets.ISO_8859_1)
-                .setTrackBytes(true)
-                .get()) {
-            final CSVRecord first = parser.nextRecord();
-            final CSVRecord second = parser.nextRecord();
-            assertNotNull(first);
-            assertNotNull(second);
-            assertNull(parser.nextRecord());
-            assertEquals(0, first.getBytePosition());
-            assertEquals(4, second.getBytePosition());
-        }
-    }
-
     @Test
     void testGetBytePositionWithCharacterOffsetAndMultiBytePrefix() throws 
Exception {
         final String row0 = "é,x\n";
@@ -742,6 +721,27 @@ class CSVParserTest {
         }
     }
 
+    @Test
+    void testGetBytePositionWithSingleByteCharset() throws IOException {
+        // A single-byte charset cannot encode U+FFFF, the char value of the 
EOF sentinel.
+        // Byte counting must skip the EOF read so a valid file parses without 
throwing.
+        final String code = "a,b\nc,d\n";
+        try (CSVParser parser = CSVParser.builder()
+                .setReader(new StringReader(code))
+                .setFormat(CSVFormat.DEFAULT)
+                .setCharset(StandardCharsets.ISO_8859_1)
+                .setTrackBytes(true)
+                .get()) {
+            final CSVRecord first = parser.nextRecord();
+            final CSVRecord second = parser.nextRecord();
+            assertNotNull(first);
+            assertNotNull(second);
+            assertNull(parser.nextRecord());
+            assertEquals(0, first.getBytePosition());
+            assertEquals(4, second.getBytePosition());
+        }
+    }
+
     @Test
     void testGetHeaderComment_HeaderComment1() throws IOException {
         try (CSVParser parser = CSVParser.parse(CSV_INPUT_HEADER_COMMENT, 
FORMAT_AUTO_HEADER)) {

Reply via email to