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/08/24 13:42:16 UTC

[commons-csv] branch master updated: Only clone header comments once

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 cce8f28f Only clone header comments once
cce8f28f is described below

commit cce8f28fb91db6251279b1b68ea601b6f4eda3d3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Aug 24 09:42:11 2022 -0400

    Only clone header comments once
---
 src/main/java/org/apache/commons/csv/CSVPrinter.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/csv/CSVPrinter.java b/src/main/java/org/apache/commons/csv/CSVPrinter.java
index 6cefff9e..a7c62da1 100644
--- a/src/main/java/org/apache/commons/csv/CSVPrinter.java
+++ b/src/main/java/org/apache/commons/csv/CSVPrinter.java
@@ -114,8 +114,9 @@ public final class CSVPrinter implements Flushable, Closeable {
         this.format = format.copy();
         // TODO: Is it a good idea to do this here instead of on the first call to a print method?
         // It seems a pain to have to track whether the header has already been printed or not.
-        if (format.getHeaderComments() != null) {
-            for (final String line : format.getHeaderComments()) {
+        final String[] headerComments = format.getHeaderComments();
+        if (headerComments != null) {
+            for (final String line : headerComments) {
                 this.printComment(line);
             }
         }