Skip to content

Commit 5e9216d

Browse files
committed
Remove unnecessary array creation for varargs.
1 parent 06dda31 commit 5e9216d

3 files changed

Lines changed: 11 additions & 12 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,12 @@ public void testDuplicateHeadersNotAllowed() {
296296
assertThrows(
297297
IllegalArgumentException.class,
298298
() -> CSVParser.parse("a,b,a\n1,2,3\nx,y,z",
299-
CSVFormat.DEFAULT.withHeader(new String[] {}).withAllowDuplicateHeaderNames(false)));
299+
CSVFormat.DEFAULT.withHeader().withAllowDuplicateHeaderNames(false)));
300300
}
301301

302302
@Test
303303
public void testDuplicateHeadersAllowedByDefault() throws Exception {
304-
CSVParser.parse("a,b,a\n1,2,3\nx,y,z", CSVFormat.DEFAULT.withHeader(new String[] {}));
304+
CSVParser.parse("a,b,a\n1,2,3\nx,y,z", CSVFormat.DEFAULT.withHeader());
305305
}
306306

307307
@Test

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ private static void testParseURL() throws Exception {
264264
private static Constructor<Lexer> getLexerCtor(final String clazz) throws Exception {
265265
@SuppressWarnings("unchecked")
266266
final Class<Lexer> lexer = (Class<Lexer>) Class.forName("org.apache.commons.csv." + clazz);
267-
return lexer.getConstructor(new Class<?>[]{CSVFormat.class, ExtendedBufferedReader.class});
267+
return lexer.getConstructor(CSVFormat.class, ExtendedBufferedReader.class);
268268
}
269269

270270
private static void testCSVLexer(final boolean newToken, final String test) throws Exception {
@@ -317,8 +317,7 @@ private static void testCSVLexer(final boolean newToken, final String test) thro
317317

318318
private static Lexer createTestCSVLexer(final String test, final ExtendedBufferedReader input)
319319
throws InstantiationException, IllegalAccessException, InvocationTargetException, Exception {
320-
return test.startsWith("CSVLexer") ? getLexerCtor(test)
321-
.newInstance(new Object[] { format, input }) : new Lexer(format, input);
320+
return test.startsWith("CSVLexer") ? getLexerCtor(test).newInstance(format, input) : new Lexer(format, input);
322321
}
323322

324323
private static Stats iterate(final Iterable<CSVRecord> it) {

src/test/java/org/apache/commons/csv/issues/JiraCsv203Test.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void testQuoteModeAll() throws Exception {
3737

3838
final StringBuffer buffer = new StringBuffer();
3939
try (final CSVPrinter printer = new CSVPrinter(buffer, format)) {
40-
printer.printRecord(new Object[] { null, "Hello", null, "World" });
40+
printer.printRecord(null, "Hello", null, "World");
4141
}
4242
assertEquals("\"N/A\",\"Hello\",\"N/A\",\"World\"\r\n", buffer.toString());
4343
}
@@ -51,7 +51,7 @@ public void testQuoteModeAllNonNull() throws Exception {
5151

5252
final StringBuffer buffer = new StringBuffer();
5353
try (final CSVPrinter printer = new CSVPrinter(buffer, format)) {
54-
printer.printRecord(new Object[] { null, "Hello", null, "World" });
54+
printer.printRecord(null, "Hello", null, "World");
5555
}
5656
assertEquals("N/A,\"Hello\",N/A,\"World\"\r\n", buffer.toString());
5757
}
@@ -64,7 +64,7 @@ public void testWithoutQuoteMode() throws Exception {
6464

6565
final StringBuffer buffer = new StringBuffer();
6666
try (final CSVPrinter printer = new CSVPrinter(buffer, format)) {
67-
printer.printRecord(new Object[] { null, "Hello", null, "World" });
67+
printer.printRecord(null, "Hello", null, "World");
6868
}
6969
assertEquals("N/A,Hello,N/A,World\r\n", buffer.toString());
7070
}
@@ -78,7 +78,7 @@ public void testQuoteModeMinimal() throws Exception {
7878

7979
final StringBuffer buffer = new StringBuffer();
8080
try (final CSVPrinter printer = new CSVPrinter(buffer, format)) {
81-
printer.printRecord(new Object[] { null, "Hello", null, "World" });
81+
printer.printRecord(null, "Hello", null, "World");
8282
}
8383
assertEquals("N/A,Hello,N/A,World\r\n", buffer.toString());
8484
}
@@ -92,7 +92,7 @@ public void testQuoteModeNonNumeric() throws Exception {
9292

9393
final StringBuffer buffer = new StringBuffer();
9494
try (final CSVPrinter printer = new CSVPrinter(buffer, format)) {
95-
printer.printRecord(new Object[] { null, "Hello", null, "World" });
95+
printer.printRecord(null, "Hello", null, "World");
9696
}
9797
assertEquals("N/A,\"Hello\",N/A,\"World\"\r\n", buffer.toString());
9898
}
@@ -106,7 +106,7 @@ public void testWithoutNullString() throws Exception {
106106

107107
final StringBuffer buffer = new StringBuffer();
108108
try (final CSVPrinter printer = new CSVPrinter(buffer, format)) {
109-
printer.printRecord(new Object[] { null, "Hello", null, "World" });
109+
printer.printRecord(null, "Hello", null, "World");
110110
}
111111
assertEquals(",\"Hello\",,\"World\"\r\n", buffer.toString());
112112
}
@@ -120,7 +120,7 @@ public void testWithEmptyValues() throws Exception {
120120

121121
final StringBuffer buffer = new StringBuffer();
122122
try (final CSVPrinter printer = new CSVPrinter(buffer, format)) {
123-
printer.printRecord(new Object[] { "", "Hello", "", "World" });
123+
printer.printRecord("", "Hello", "", "World");
124124
//printer.printRecord(new Object[] { null, "Hello", null, "World" });
125125
}
126126
assertEquals("\"\",\"Hello\",\"\",\"World\"\r\n", buffer.toString());

0 commit comments

Comments
 (0)