Skip to content

Commit decbfb3

Browse files
committed
2 parents dae9b1f + e9d466e commit decbfb3

7 files changed

Lines changed: 91 additions & 85 deletions

File tree

.github/workflows/maven.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,26 @@ jobs:
2727
continue-on-error: ${{ matrix.experimental }}
2828
strategy:
2929
matrix:
30-
java: [ 8, 11, 17, 21, 22 ]
30+
java: [ 8, 11, 17, 21 ]
3131
experimental: [false]
3232
include:
33-
- java: 23-ea
33+
- java: 23
3434
experimental: true
3535
- java: 24-ea
3636
experimental: true
3737

3838
steps:
39-
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7
39+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7
4040
with:
4141
persist-credentials: false
42-
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
42+
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
4343
with:
4444
path: ~/.m2/repository
4545
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
4646
restore-keys: |
4747
${{ runner.os }}-maven-
4848
- name: Set up JDK ${{ matrix.java }}
49-
uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0
49+
uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0
5050
with:
5151
distribution: 'temurin'
5252
java-version: ${{ matrix.java }}

pom.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<groupId>org.apache.commons</groupId>
2222
<artifactId>commons-parent</artifactId>
23-
<version>74</version>
23+
<version>75</version>
2424
</parent>
2525
<artifactId>commons-csv</artifactId>
2626
<version>1.12.0-SNAPSHOT</version>
@@ -50,7 +50,7 @@
5050
<dependency>
5151
<groupId>commons-io</groupId>
5252
<artifactId>commons-io</artifactId>
53-
<version>2.16.1</version>
53+
<version>2.17.0</version>
5454
</dependency>
5555
<dependency>
5656
<groupId>commons-codec</groupId>
@@ -173,7 +173,6 @@
173173
<commons.jira.pid>12313222</commons.jira.pid>
174174
<maven.compiler.source>1.8</maven.compiler.source>
175175
<maven.compiler.target>1.8</maven.compiler.target>
176-
<commons.javadoc.java.link>http://docs.oracle.com/javase/8/docs/api/</commons.javadoc.java.link>
177176
<!-- Ensure copies work OK (can be removed later when this is in parent POM) -->
178177
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
179178
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

src/changes/changes.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,15 @@
5151
<action type="fix" dev="ggregory" due-to="Dávid Szigecsán">Fix documentation for CSVFormat private constructor #466.</action>
5252
<action type="fix" issue="CSV-294" dev="ggregory" due-to="Joern Huxhorn, Gary Gregory">CSVFormat does not support explicit " as escape char.</action>
5353
<action type="fix" issue="CSV-150" dev="ggregory" due-to="dota17, Gary Gregory, Jörn Huxhorn">Escaping is not disableable.</action>
54+
<action type="fix" dev="ggregory" due-to="Gary Gregory">Fix Javadoc warnings on Java 23.</action>
55+
<action type="fix" dev="ggregory" due-to="Gary Gregory">Improve parser performance by up to 20%, YMMV.</action>
5456
<!-- UPDATE -->
5557
<action type="update" dev="ggregory" due-to="Dependabot">Bump commons-codec:commons-codec from 1.16.1 to 1.17.1 #422, #449.</action>
56-
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump org.apache.commons:commons-parent from 69 to 74 #435, #452, #465, #468.</action>
58+
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump org.apache.commons:commons-parent from 69 to 75 #435, #452, #465, #468, #475.</action>
5759
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump org.codehaus.mojo:taglist-maven-plugin from 3.0.0 to 3.1.0 #441.</action>
5860
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump org.apache.commons:commons-lang3 from 3.14.0 to 3.17.0 #450, #459, #470.</action>
5961
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump org.hamcrest:hamcrest from 2.2 to 3.0 #455.</action>
62+
<action type="update" dev="ggregory" due-to="Gary Gregory, Dependabot">Bump commons-io:commons-io from 2.16.1 to 2.17.0 #476.</action>
6063
</release>
6164
<release version="1.11.0" date="2024-04-28" description="Feature and bug fix release (Java 8 or above)">
6265
<!-- ADD -->

src/main/java/org/apache/commons/csv/CSVFormat.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,66 +835,90 @@ public Builder setTrim(final boolean trim) {
835835
public enum Predefined {
836836

837837
/**
838+
* The DEFAULT predefined format.
839+
*
838840
* @see CSVFormat#DEFAULT
839841
*/
840842
Default(DEFAULT),
841843

842844
/**
845+
* The EXCEL predefined format.
846+
*
843847
* @see CSVFormat#EXCEL
844848
*/
845849
Excel(EXCEL),
846850

847851
/**
852+
* The INFORMIX_UNLOAD predefined format.
853+
*
848854
* @see CSVFormat#INFORMIX_UNLOAD
849855
* @since 1.3
850856
*/
851857
InformixUnload(INFORMIX_UNLOAD),
852858

853859
/**
860+
* The INFORMIX_UNLOAD_CSV predefined format.
861+
*
854862
* @see CSVFormat#INFORMIX_UNLOAD_CSV
855863
* @since 1.3
856864
*/
857865
InformixUnloadCsv(INFORMIX_UNLOAD_CSV),
858866

859867
/**
868+
* The MONGODB_CSV predefined format.
869+
*
860870
* @see CSVFormat#MONGODB_CSV
861871
* @since 1.7
862872
*/
863873
MongoDBCsv(MONGODB_CSV),
864874

865875
/**
876+
* The MONGODB_TSV predefined format.
877+
*
866878
* @see CSVFormat#MONGODB_TSV
867879
* @since 1.7
868880
*/
869881
MongoDBTsv(MONGODB_TSV),
870882

871883
/**
884+
* The MYSQL predefined format.
885+
*
872886
* @see CSVFormat#MYSQL
873887
*/
874888
MySQL(MYSQL),
875889

876890
/**
891+
* The ORACLE predefined format.
892+
*
877893
* @see CSVFormat#ORACLE
878894
*/
879895
Oracle(ORACLE),
880896

881897
/**
898+
* The POSTGRESQL_CSV predefined format.
899+
*
882900
* @see CSVFormat#POSTGRESQL_CSV
883901
* @since 1.5
884902
*/
885903
PostgreSQLCsv(POSTGRESQL_CSV),
886904

887905
/**
888-
* @see CSVFormat#POSTGRESQL_CSV
906+
* The POSTGRESQL_TEXT predefined format.
907+
*
908+
* @see CSVFormat#POSTGRESQL_TEXT
889909
*/
890910
PostgreSQLText(POSTGRESQL_TEXT),
891911

892912
/**
913+
* The RFC4180 predefined format.
914+
*
893915
* @see CSVFormat#RFC4180
894916
*/
895917
RFC4180(CSVFormat.RFC4180),
896918

897919
/**
920+
* The TDF predefined format.
921+
*
898922
* @see CSVFormat#TDF
899923
*/
900924
TDF(CSVFormat.TDF);

src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java

Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
import static org.apache.commons.csv.Constants.UNDEFINED;
2323
import static org.apache.commons.io.IOUtils.EOF;
2424

25-
import java.io.BufferedReader;
2625
import java.io.IOException;
2726
import java.io.Reader;
2827

2928
import org.apache.commons.io.IOUtils;
29+
import org.apache.commons.io.input.UnsynchronizedBufferedReader;
3030

3131
/**
3232
* A special buffered reader which supports sophisticated read access.
@@ -35,18 +35,19 @@
3535
* {@link #read()}. This reader also tracks how many characters have been read with {@link #getPosition()}.
3636
* </p>
3737
*/
38-
final class ExtendedBufferedReader extends BufferedReader {
38+
final class ExtendedBufferedReader extends UnsynchronizedBufferedReader {
3939

4040
/** The last char returned */
4141
private int lastChar = UNDEFINED;
42+
private int lastCharMark = UNDEFINED;
4243

4344
/** The count of EOLs (CR/LF/CRLF) seen so far */
4445
private long lineNumber;
46+
private long lineNumberMark;
4547

4648
/** The position, which is the number of characters read so far */
4749
private long position;
48-
49-
private boolean closed;
50+
private long positionMark;
5051

5152
/**
5253
* Constructs a new instance using the default buffer size.
@@ -55,6 +56,22 @@ final class ExtendedBufferedReader extends BufferedReader {
5556
super(reader);
5657
}
5758

59+
@Override
60+
public void mark(final int readAheadLimit) throws IOException {
61+
lineNumberMark = lineNumber;
62+
lastCharMark = lastChar;
63+
positionMark = position;
64+
super.mark(readAheadLimit);
65+
}
66+
67+
@Override
68+
public void reset() throws IOException {
69+
lineNumber = lineNumberMark;
70+
lastChar = lastCharMark;
71+
position = positionMark;
72+
super.reset();
73+
}
74+
5875
/**
5976
* Closes the stream.
6077
*
@@ -64,7 +81,6 @@ final class ExtendedBufferedReader extends BufferedReader {
6481
@Override
6582
public void close() throws IOException {
6683
// Set ivars before calling super close() in case close() throws an IOException.
67-
closed = true;
6884
lastChar = EOF;
6985
super.close();
7086
}
@@ -74,7 +90,7 @@ public void close() throws IOException {
7490
*
7591
* @return the current line number
7692
*/
77-
long getCurrentLineNumber() {
93+
long getLineNumber() {
7894
// Check if we are at EOL or EOF or just starting
7995
if (lastChar == CR || lastChar == LF || lastChar == UNDEFINED || lastChar == EOF) {
8096
return lineNumber; // counter is accurate
@@ -103,42 +119,6 @@ long getPosition() {
103119
return this.position;
104120
}
105121

106-
public boolean isClosed() {
107-
return closed;
108-
}
109-
110-
/**
111-
* Returns the next character in the current reader without consuming it. So the next call to {@link #read()} will
112-
* still return this value. Does not affect the line number or the last character.
113-
*
114-
* @return the next character
115-
*
116-
* @throws IOException
117-
* If an I/O error occurs
118-
*/
119-
int peek() throws IOException {
120-
super.mark(1);
121-
final int c = super.read();
122-
super.reset();
123-
return c;
124-
}
125-
126-
/**
127-
* Populates the buffer with the next {@code buf.length} characters in the current reader without consuming them. The next call to {@link #read()} will
128-
* still return the next value. This doesn't affect the line number or the last character.
129-
*
130-
* @param buf the buffer to fill for the look ahead.
131-
* @return The number of characters peeked, or -1 if the end of the stream has been reached.
132-
* @throws IOException If an I/O error occurs
133-
*/
134-
int peek(final char[] buf) throws IOException {
135-
final int n = buf.length;
136-
super.mark(n);
137-
final int c = super.read(buf, 0, n);
138-
super.reset();
139-
return c;
140-
}
141-
142122
@Override
143123
public int read() throws IOException {
144124
final int current = super.read();

src/main/java/org/apache/commons/csv/Lexer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ long getCharacterPosition() {
8989
* @return the current line number
9090
*/
9191
long getCurrentLineNumber() {
92-
return reader.getCurrentLineNumber();
92+
return reader.getLineNumber();
9393
}
9494

9595
String getFirstEol() {

0 commit comments

Comments
 (0)