Skip to content

Commit cce8f28

Browse files
committed
Only clone header comments once
1 parent 226628a commit cce8f28

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ public CSVPrinter(final Appendable appendable, final CSVFormat format) throws IO
114114
this.format = format.copy();
115115
// TODO: Is it a good idea to do this here instead of on the first call to a print method?
116116
// It seems a pain to have to track whether the header has already been printed or not.
117-
if (format.getHeaderComments() != null) {
118-
for (final String line : format.getHeaderComments()) {
117+
final String[] headerComments = format.getHeaderComments();
118+
if (headerComments != null) {
119+
for (final String line : headerComments) {
119120
this.printComment(line);
120121
}
121122
}

0 commit comments

Comments
 (0)