Skip to content

Commit 32bc947

Browse files
committed
Add @SuppressWarnings and comments
Format
1 parent 08e842c commit 32bc947

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,9 +552,9 @@ public CSVParser(final Reader reader, final CSVFormat format, final long charact
552552
* If there is a problem reading the header or skipping the first record.
553553
* @throws CSVException Thrown on invalid CSV input data.
554554
*/
555-
private CSVParser(final Reader reader, final CSVFormat format, final long characterOffset, final long recordNumber,
556-
final Charset charset, final boolean trackBytes)
557-
throws IOException {
555+
@SuppressWarnings("resource") // reader is managed by lexer.
556+
private CSVParser(final Reader reader, final CSVFormat format, final long characterOffset, final long recordNumber, final Charset charset,
557+
final boolean trackBytes) throws IOException {
558558
Objects.requireNonNull(reader, "reader");
559559
Objects.requireNonNull(format, "format");
560560
this.format = format.copy();

src/test/java/org/apache/commons/csv/JiraCsv196Test.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ private Reader getTestInput(final String path) {
3838
public void testParseFourBytes() throws IOException {
3939
final CSVFormat format = CSVFormat.Builder.create().setDelimiter(',').setQuote('\'').get();
4040
// @formatter:off
41-
try (CSVParser parser = new CSVParser.Builder()
41+
try (@SuppressWarnings("resource") // parser closes the reader.
42+
CSVParser parser = new CSVParser.Builder()
4243
.setFormat(format)
4344
.setReader(getTestInput("org/apache/commons/csv/CSV-196/emoji.csv"))
4445
.setCharset(StandardCharsets.UTF_8)
45-
.setTrackBytes(true).get()) {
46+
.setTrackBytes(true)
47+
.get()) {
4648
// @formatter:on
4749
final long[] charByteKey = { 0, 84, 701, 1318, 1935 };
4850
int idx = 0;
@@ -56,11 +58,13 @@ public void testParseFourBytes() throws IOException {
5658
public void testParseThreeBytes() throws IOException {
5759
final CSVFormat format = CSVFormat.Builder.create().setDelimiter(',').setQuote('\'').get();
5860
// @formatter:off
59-
try (CSVParser parser = new CSVParser.Builder()
61+
try (@SuppressWarnings("resource") // parser closes the reader.
62+
CSVParser parser = new CSVParser.Builder()
6063
.setFormat(format)
6164
.setReader(getTestInput("org/apache/commons/csv/CSV-196/japanese.csv"))
6265
.setCharset(StandardCharsets.UTF_8)
63-
.setTrackBytes(true).get()) {
66+
.setTrackBytes(true)
67+
.get()) {
6468
// @formatter:on
6569
final long[] charByteKey = { 0, 89, 242, 395 };
6670
int idx = 0;

0 commit comments

Comments
 (0)