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-csv.git
The following commit(s) were added to refs/heads/master by this push:
new 32bc9474 Add @SuppressWarnings and comments
32bc9474 is described below
commit 32bc94743541234e70f7287a5a3c450d796d9d0b
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Jun 6 09:35:03 2025 -0400
Add @SuppressWarnings and comments
Format
---
src/main/java/org/apache/commons/csv/CSVParser.java | 6 +++---
src/test/java/org/apache/commons/csv/JiraCsv196Test.java | 12 ++++++++----
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/commons/csv/CSVParser.java
b/src/main/java/org/apache/commons/csv/CSVParser.java
index 4d74bc96..9b96f7c7 100644
--- a/src/main/java/org/apache/commons/csv/CSVParser.java
+++ b/src/main/java/org/apache/commons/csv/CSVParser.java
@@ -552,9 +552,9 @@ public final class CSVParser implements
Iterable<CSVRecord>, Closeable {
* If there is a problem reading the header or skipping the
first record.
* @throws CSVException Thrown on invalid CSV input data.
*/
- private CSVParser(final Reader reader, final CSVFormat format, final long
characterOffset, final long recordNumber,
- final Charset charset, final boolean trackBytes)
- throws IOException {
+ @SuppressWarnings("resource") // reader is managed by lexer.
+ private CSVParser(final Reader reader, final CSVFormat format, final long
characterOffset, final long recordNumber, final Charset charset,
+ final boolean trackBytes) throws IOException {
Objects.requireNonNull(reader, "reader");
Objects.requireNonNull(format, "format");
this.format = format.copy();
diff --git a/src/test/java/org/apache/commons/csv/JiraCsv196Test.java
b/src/test/java/org/apache/commons/csv/JiraCsv196Test.java
index 3b6c7401..90261f2b 100644
--- a/src/test/java/org/apache/commons/csv/JiraCsv196Test.java
+++ b/src/test/java/org/apache/commons/csv/JiraCsv196Test.java
@@ -38,11 +38,13 @@ public class JiraCsv196Test {
public void testParseFourBytes() throws IOException {
final CSVFormat format =
CSVFormat.Builder.create().setDelimiter(',').setQuote('\'').get();
// @formatter:off
- try (CSVParser parser = new CSVParser.Builder()
+ try (@SuppressWarnings("resource") // parser closes the reader.
+ CSVParser parser = new CSVParser.Builder()
.setFormat(format)
.setReader(getTestInput("org/apache/commons/csv/CSV-196/emoji.csv"))
.setCharset(StandardCharsets.UTF_8)
- .setTrackBytes(true).get()) {
+ .setTrackBytes(true)
+ .get()) {
// @formatter:on
final long[] charByteKey = { 0, 84, 701, 1318, 1935 };
int idx = 0;
@@ -56,11 +58,13 @@ public class JiraCsv196Test {
public void testParseThreeBytes() throws IOException {
final CSVFormat format =
CSVFormat.Builder.create().setDelimiter(',').setQuote('\'').get();
// @formatter:off
- try (CSVParser parser = new CSVParser.Builder()
+ try (@SuppressWarnings("resource") // parser closes the reader.
+ CSVParser parser = new CSVParser.Builder()
.setFormat(format)
.setReader(getTestInput("org/apache/commons/csv/CSV-196/japanese.csv"))
.setCharset(StandardCharsets.UTF_8)
- .setTrackBytes(true).get()) {
+ .setTrackBytes(true)
+ .get()) {
// @formatter:on
final long[] charByteKey = { 0, 89, 242, 395 };
int idx = 0;