, Closeable {
}
}
if (headerNames == null) {
- headerNames = Collections.emptyList(); //immutable
+ headerNames = Collections.emptyList(); //immutable
} else {
- headerNames = Collections.unmodifiableList(headerNames);
+ headerNames = Collections.unmodifiableList(headerNames);
}
return new Headers(hdrMap, headerNames);
}
diff --git a/src/main/resources/checkstyle/checkstyle-suppressions.xml b/src/main/resources/checkstyle/checkstyle-suppressions.xml
new file mode 100644
index 00000000..edc67836
--- /dev/null
+++ b/src/main/resources/checkstyle/checkstyle-suppressions.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
diff --git a/src/main/resources/findbugs/findbugs-exclude-filter.xml b/src/main/resources/findbugs/findbugs-exclude-filter.xml
new file mode 100644
index 00000000..da2896a2
--- /dev/null
+++ b/src/main/resources/findbugs/findbugs-exclude-filter.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/pmd/pmd-ruleset.xml b/src/main/resources/pmd/pmd-ruleset.xml
new file mode 100644
index 00000000..8d52e45a
--- /dev/null
+++ b/src/main/resources/pmd/pmd-ruleset.xml
@@ -0,0 +1,89 @@
+
+
+
+
+ This ruleset checks the code for discouraged programming constructs.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
index 913b5ead..75253f21 100644
--- a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
@@ -1471,4 +1471,45 @@ public class CSVPrinterTest {
return CSVParser.parse(expected, format).getRecords().get(0).values();
}
+ /**
+ * Test to target the use of {@link IOUtils#copyLarge(java.io.Reader, Writer)} which directly
+ * buffers the value from the Reader to the Writer.
+ *
+ * Requires the format to have no quote or escape character, value to be a
+ * {@link java.io.Reader Reader} and the output MUST be a
+ * {@link java.io.Writer Writer}.
+ *
+ * @throws IOException Not expected to happen
+ */
+ @Test
+ public void testPrintReaderWithoutQuoteToWriter() throws IOException {
+ final StringWriter sw = new StringWriter();
+ final String content = "testValue";
+ try (final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(null))) {
+ final StringReader value = new StringReader(content);
+ printer.print(value);
+ }
+ assertEquals(content, sw.toString());
+ }
+
+ /**
+ * Test to target the use of {@link IOUtils#copy(java.io.Reader, Appendable)} which directly
+ * buffers the value from the Reader to the Appendable.
+ *
+ * Requires the format to have no quote or escape character, value to be a
+ * {@link java.io.Reader Reader} and the output MUST NOT be a
+ * {@link java.io.Writer Writer} but some other Appendable.
+ *
+ * @throws IOException Not expected to happen
+ */
+ @Test
+ public void testPrintReaderWithoutQuoteToAppendable() throws IOException {
+ final StringBuilder sb = new StringBuilder();
+ final String content = "testValue";
+ try (final CSVPrinter printer = new CSVPrinter(sb, CSVFormat.DEFAULT.withQuote(null))) {
+ final StringReader value = new StringReader(content);
+ printer.print(value);
+ }
+ assertEquals(content, sb.toString());
+ }
}