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 2020/01/20 23:36:26 UTC

[commons-csv] branch master updated (d6778b7 -> e3eca25)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-csv.git.


    from d6778b7  Fix typo performance test #55.
     new d047f83  [CSV-248] CSVRecord is not Serializable.
     new 07101a9  [CSV-248] CSVRecord is not Serializable.
     new e3eca25  [CSV-248] CSVRecord is not Serializable.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pom.xml                                            |  2 +-
 src/changes/changes.xml                            |  1 +
 .../java/org/apache/commons/csv/CSVRecord.java     |  2 +-
 .../java/org/apache/commons/csv/CSVRecordTest.java | 50 ++++++++++++++--------
 4 files changed, 35 insertions(+), 20 deletions(-)


[commons-csv] 02/03: [CSV-248] CSVRecord is not Serializable.

Posted by gg...@apache.org.
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 07101a99bc7d1445f97f4fd21fed59a210f79bf0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jan 20 18:36:02 2020 -0500

    [CSV-248] CSVRecord is not Serializable.
    
    Update JUnit from 5.5.2 to 5.6.0.
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 78b848b..432b933 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,7 @@
     <dependency>
       <groupId>org.junit.jupiter</groupId>
       <artifactId>junit-jupiter</artifactId>
-      <version>5.5.2</version>
+      <version>5.6.0</version>
       <scope>test</scope>
     </dependency>
     <dependency>


[commons-csv] 01/03: [CSV-248] CSVRecord is not Serializable.

Posted by gg...@apache.org.
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 d047f83c283757e4848cd38332d822c378bb9774
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jan 20 18:34:31 2020 -0500

    [CSV-248] CSVRecord is not Serializable.
    
    Sort members.
---
 .../java/org/apache/commons/csv/CSVRecordTest.java | 34 +++++++++++-----------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/test/java/org/apache/commons/csv/CSVRecordTest.java b/src/test/java/org/apache/commons/csv/CSVRecordTest.java
index 06e771c..97bb6fc 100644
--- a/src/test/java/org/apache/commons/csv/CSVRecordTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVRecordTest.java
@@ -41,9 +41,9 @@ public class CSVRecordTest {
         UNKNOWN_COLUMN
     }
 
-    private String[] values;
-    private CSVRecord record, recordWithHeader;
     private Map<String, Integer> headerMap;
+    private CSVRecord record, recordWithHeader;
+    private String[] values;
 
     @BeforeEach
     public void setUp() throws Exception {
@@ -134,13 +134,6 @@ public class CSVRecordTest {
     }
 
     @Test
-    public void testIsSetString() {
-        assertFalse(record.isSet("first"));
-        assertTrue(recordWithHeader.isSet("first"));
-        assertFalse(recordWithHeader.isSet("fourth"));
-    }
-
-    @Test
     public void testIsSetInt() {
         assertFalse(record.isSet(-1));
         assertTrue(record.isSet(0));
@@ -151,6 +144,13 @@ public class CSVRecordTest {
     }
 
     @Test
+    public void testIsSetString() {
+        assertFalse(record.isSet("first"));
+        assertTrue(recordWithHeader.isSet("first"));
+        assertFalse(recordWithHeader.isSet("fourth"));
+    }
+
+    @Test
     public void testIterator() {
         int i = 0;
         for (final String value : record) {
@@ -191,14 +191,6 @@ public class CSVRecordTest {
     }
 
     @Test
-    public void testToMapWithShortRecord() throws Exception {
-        try (final CSVParser parser = CSVParser.parse("a,b", CSVFormat.DEFAULT.withHeader("A", "B", "C"))) {
-            final CSVRecord shortRec = parser.iterator().next();
-            shortRec.toMap();
-        }
-    }
-
-    @Test
     public void testToMapWithNoHeader() throws Exception {
         try (final CSVParser parser = CSVParser.parse("a,b", CSVFormat.newFormat(','))) {
             final CSVRecord shortRec = parser.iterator().next();
@@ -208,6 +200,14 @@ public class CSVRecordTest {
         }
     }
 
+    @Test
+    public void testToMapWithShortRecord() throws Exception {
+        try (final CSVParser parser = CSVParser.parse("a,b", CSVFormat.DEFAULT.withHeader("A", "B", "C"))) {
+            final CSVRecord shortRec = parser.iterator().next();
+            shortRec.toMap();
+        }
+    }
+
     private void validateMap(final Map<String, String> map, final boolean allowsNulls) {
         assertTrue(map.containsKey("first"));
         assertTrue(map.containsKey("second"));


[commons-csv] 03/03: [CSV-248] CSVRecord is not Serializable.

Posted by gg...@apache.org.
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 <ga...@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);