Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

Commit 87bb0d1

Browse files
committed
Backport #128 fix
1 parent 7c71cb0 commit 87bb0d1

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

release-notes/CREDITS

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ Oliver Röss (cloudyday@github)
5656
* Reported #98: Escape char is not being escaped during serialization
5757
(2.6.4)
5858

59-
<<<<<<< HEAD
6059
Justo Ruiz Ferrer (jrferrer@github)
6160

6261
* Contributed #89: Allow choice of using header-line declaration to reorder columns
@@ -84,3 +83,8 @@ Brian Moriarty (morbrian@github)
8483

8584
* Contributed #106: Null fields are always ignored when serializing list of objects
8685
(2.7.0)
86+
87+
Peter Ansell (ansell@github)
88+
89+
* Contributed fix for #128: Write out headers even if no data rows written
90+
(2.7.7)

release-notes/VERSION

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ Project: jackson-dataformat-csv
88

99
No changes since 2.7.
1010

11+
2.7.7 (not yet released)
12+
13+
#128: Write out headers even if no data rows written
14+
(contributed by Peter A)
15+
1116
2.7.6 (23-Jul-2016)
1217
2.7.5 (11-Jun-2016)
1318

src/main/java/com/fasterxml/jackson/dataformat/csv/CsvGenerator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,11 @@ public void close() throws IOException
425425

426426
// Let's mark row as closed, if we had any...
427427
finishRow();
428+
// Write the header if necessary, occurs when no rows written
429+
if (_handleFirstLine) {
430+
_handleFirstLine();
431+
}
432+
428433
_writer.close(_ioContext.isResourceManaged() || isEnabled(JsonGenerator.Feature.AUTO_CLOSE_TARGET));
429434
}
430435

0 commit comments

Comments
 (0)