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

commit e3eca25d1329a202db4e63fb623117b63c74aa71
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Mon Jan 20 18:36:22 2020 -0500

    [CSV-248] CSVRecord is not Serializable.
    
    Make field transient.
---
 src/changes/changes.xml                                 |  1 +
 src/main/java/org/apache/commons/csv/CSVRecord.java     |  2 +-
 src/test/java/org/apache/commons/csv/CSVRecordTest.java | 16 +++++++++++++++-
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 3cc48b2..cd44e5b 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -48,6 +48,7 @@
       <action issue="CSV-245" type="fix" dev="ggregory" due-to="Alex 
Herbert">Post 1.7 release fixes.</action>
       <action issue="CSV-252" type="fix" dev="ggregory" due-to= "Alex 
Herbert">Upgrade test framework to JUnit 5 Jupiter #49, #50.</action>
       <action issue="CSV-247" type="fix" dev="ggregory" due-to="Alex Herbert, 
Gary Gregory">A single empty header is allowed when not allowing empty column 
headers. #47.</action>
+      <action issue="CSV-248" type="fix" dev="ggregory" due-to="Alex 
Herbert">CSVRecord is not Serializable.</action>
       <action                 type="fix" dev="ggregory" due-to="Alex 
Herbert">Use test scope for supercsv #48.</action>
       <action                 type="update" dev="ggregory" due-to="Gary 
Gregory">Update tests from H2 1.4.199 to 1.4.200.</action>
       <action                 type="update" dev="ggregory" due-to="Gary 
Gregory">Update tests from Hamcrest 2.1 to 2.2.</action>
diff --git a/src/main/java/org/apache/commons/csv/CSVRecord.java 
b/src/main/java/org/apache/commons/csv/CSVRecord.java
index e75403e..b7bf53e 100644
--- a/src/main/java/org/apache/commons/csv/CSVRecord.java
+++ b/src/main/java/org/apache/commons/csv/CSVRecord.java
@@ -46,7 +46,7 @@ public final class CSVRecord implements Serializable, 
Iterable<String> {
     private final String[] values;
 
     /** The parser that originates this record. */
-    private final CSVParser parser;
+    private final transient CSVParser parser;
 
     CSVRecord(final CSVParser parser, final String[] values, final String 
comment, final long recordNumber,
             final long characterPosition) {
diff --git a/src/test/java/org/apache/commons/csv/CSVRecordTest.java 
b/src/test/java/org/apache/commons/csv/CSVRecordTest.java
index 97bb6fc..d13e84a 100644
--- a/src/test/java/org/apache/commons/csv/CSVRecordTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVRecordTest.java
@@ -23,7 +23,9 @@ import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.ObjectOutputStream;
 import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -58,7 +60,7 @@ public class CSVRecordTest {
             headerMap = parser.getHeaderMap();
         }
     }
-
+    
     @Test
     public void testGetInt() {
         assertEquals(values[0], record.get(0));
@@ -185,6 +187,18 @@ public class CSVRecordTest {
     }
 
     @Test
+    public void testSerialization() throws IOException {
+        CSVRecord shortRec;
+        try (final CSVParser parser = CSVParser.parse("a,b", 
CSVFormat.newFormat(','))) {
+            shortRec = parser.iterator().next();
+        }
+        final ByteArrayOutputStream out = new ByteArrayOutputStream();
+        try (ObjectOutputStream oos = new ObjectOutputStream(out)) {
+            oos.writeObject(shortRec);
+        }
+    }
+
+    @Test
     public void testToMap() {
         final Map<String, String> map = this.recordWithHeader.toMap();
         this.validateMap(map, true);

Reply via email to