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 2012/10/15 01:22:18 UTC

svn commit: r1398148 - in /commons/proper/csv/trunk/src: main/java/org/apache/commons/csv/CSVFormat.java test/java/org/apache/commons/csv/CSVFormatTest.java

Author: ggregory
Date: Sun Oct 14 23:22:17 2012
New Revision: 1398148

URL: http://svn.apache.org/viewvc?rev=1398148&view=rev
Log:
Validation fails if no quotes mode set but no escape character is set.

Modified:
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
    commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java

Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java?rev=1398148&r1=1398147&r2=1398148&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java Sun Oct 14 23:22:17 2012
@@ -199,6 +199,10 @@ public class CSVFormat implements Serial
         if (escape != null && escape == commentStart) {
             throw new IllegalStateException("The comment start and the escape character cannot be the same ('" + commentStart + "')");
         }
+
+        if (escape == null && quotePolicy == Quote.NONE) {
+            throw new IllegalStateException("No quotes mode set but no escape character is set");
+        }
     }
 
     /**

Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java?rev=1398148&r1=1398147&r2=1398148&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java Sun Oct 14 23:22:17 2012
@@ -153,7 +153,14 @@ public class CSVFormatTest {
         } catch (final IllegalStateException e) {
             // expected
         }
-    }
+
+        try {
+            format.withQuoteChar('!').withQuotePolicy(Quote.NONE).validate();
+            fail();
+        } catch (final IllegalStateException e) {
+            // expected
+        }
+}
 
     @SuppressWarnings("boxing") // no need to worry about boxing here
     @Test