You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/03/10 22:25:37 UTC
[commons-csv] branch master updated: [CSV-295] Support for parallelism in CSVPrinter.
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 e5bbf94 [CSV-295] Support for parallelism in CSVPrinter.
e5bbf94 is described below
commit e5bbf9423f6670d854e56e10a37dc1545b71f7c8
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Mar 10 17:25:32 2022 -0500
[CSV-295] Support for parallelism in CSVPrinter.
---
src/changes/changes.xml | 1 +
src/main/java/org/apache/commons/csv/CSVFormat.java | 8 ++++----
src/main/java/org/apache/commons/csv/CSVPrinter.java | 10 +++++-----
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 720671f..42a0f52 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -47,6 +47,7 @@
<!-- ADD -->
<action issue="CSV-291" type="add" dev="ggregory" due-to="Gary Gregory">Make CSVRecord#values() public.</action>
<action issue="CSV-264" type="add" dev="ggregory" due-to="Sagar Tiwari, Seth Falco, Alex Herbert, Gary Gregory">Add DuplicateHeaderMode for flexibility with header strictness. #114.</action>
+ <action issue="CSV-295" type="add" dev="ggregory" due-to="Gary Gregory">Support for parallelism in CSVPrinter.</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Dependabot">Bump checkstyle from 8.44 to 9.2.1 #180, #190, #194, #202, #207.</action>
<action type="update" dev="ggregory" due-to="Dependabot">Bump junit-jupiter from 5.8.0-M1 to 5.8.2 #179, #186, #201.</action>
diff --git a/src/main/java/org/apache/commons/csv/CSVFormat.java b/src/main/java/org/apache/commons/csv/CSVFormat.java
index 77a009d..27574b2 100644
--- a/src/main/java/org/apache/commons/csv/CSVFormat.java
+++ b/src/main/java/org/apache/commons/csv/CSVFormat.java
@@ -1793,7 +1793,7 @@ public final class CSVFormat implements Serializable {
* @throws IOException If an I/O error occurs.
* @since 1.4
*/
- public void print(final Object value, final Appendable out, final boolean newRecord) throws IOException {
+ public synchronized void print(final Object value, final Appendable out, final boolean newRecord) throws IOException {
// null values are considered empty
// Only call CharSequence.toString() if you have to, helps GC-free use cases.
CharSequence charSequence;
@@ -1818,7 +1818,7 @@ public final class CSVFormat implements Serializable {
print(value, charSequence, out, newRecord);
}
- private void print(final Object object, final CharSequence value, final Appendable out, final boolean newRecord) throws IOException {
+ private synchronized void print(final Object object, final CharSequence value, final Appendable out, final boolean newRecord) throws IOException {
final int offset = 0;
final int len = value.length();
if (!newRecord) {
@@ -1893,7 +1893,7 @@ public final class CSVFormat implements Serializable {
* @throws IOException If an I/O error occurs.
* @since 1.4
*/
- public void println(final Appendable appendable) throws IOException {
+ public synchronized void println(final Appendable appendable) throws IOException {
if (getTrailingDelimiter()) {
append(getDelimiterString(), appendable);
}
@@ -1915,7 +1915,7 @@ public final class CSVFormat implements Serializable {
* @throws IOException If an I/O error occurs.
* @since 1.4
*/
- public void printRecord(final Appendable appendable, final Object... values) throws IOException {
+ public synchronized void printRecord(final Appendable appendable, final Object... values) throws IOException {
for (int i = 0; i < values.length; i++) {
print(values[i], appendable, i == 0);
}
diff --git a/src/main/java/org/apache/commons/csv/CSVPrinter.java b/src/main/java/org/apache/commons/csv/CSVPrinter.java
index 171bcff..9dcb95c 100644
--- a/src/main/java/org/apache/commons/csv/CSVPrinter.java
+++ b/src/main/java/org/apache/commons/csv/CSVPrinter.java
@@ -162,7 +162,7 @@ public final class CSVPrinter implements Flushable, Closeable {
* @throws IOException
* If an I/O error occurs
*/
- public void print(final Object value) throws IOException {
+ public synchronized void print(final Object value) throws IOException {
format.print(value, appendable, newRecord);
newRecord = false;
}
@@ -188,7 +188,7 @@ public final class CSVPrinter implements Flushable, Closeable {
* @throws IOException
* If an I/O error occurs
*/
- public void printComment(final String comment) throws IOException {
+ public synchronized void printComment(final String comment) throws IOException {
if (comment == null || !format.isCommentMarkerSet()) {
return;
}
@@ -226,7 +226,7 @@ public final class CSVPrinter implements Flushable, Closeable {
* @throws SQLException If a database access error occurs or this method is called on a closed result set.
* @since 1.9.0
*/
- public void printHeaders(final ResultSet resultSet) throws IOException, SQLException {
+ public synchronized void printHeaders(final ResultSet resultSet) throws IOException, SQLException {
printRecord((Object[]) format.builder().setHeader(resultSet).build().getHeader());
}
@@ -236,7 +236,7 @@ public final class CSVPrinter implements Flushable, Closeable {
* @throws IOException
* If an I/O error occurs
*/
- public void println() throws IOException {
+ public synchronized void println() throws IOException {
format.println(appendable);
newRecord = true;
}
@@ -254,7 +254,7 @@ public final class CSVPrinter implements Flushable, Closeable {
* @throws IOException
* If an I/O error occurs
*/
- public void printRecord(final Iterable<?> values) throws IOException {
+ public synchronized void printRecord(final Iterable<?> values) throws IOException {
for (final Object value : values) {
print(value);
}