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 2013/09/18 16:57:58 UTC
svn commit: r1524435 - in /commons/proper/csv/trunk/src:
main/java/org/apache/commons/csv/CSVParser.java
test/java/org/apache/commons/csv/CSVParserTest.java
Author: ggregory
Date: Wed Sep 18 14:57:57 2013
New Revision: 1524435
URL: http://svn.apache.org/r1524435
Log:
[CSV-100] CSVParser: getHeaderMap throws NPE.
Modified:
commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java?rev=1524435&r1=1524434&r2=1524435&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java Wed Sep 18 14:57:57 2013
@@ -281,11 +281,11 @@ public final class CSVParser implements
* Returns a copy of the header map that iterates in column order.
* <p>
* The map keys are column names. The map values are 0-based indices.
- *
+ * </p>
* @return a copy of the header map that iterates in column order.
*/
public Map<String, Integer> getHeaderMap() {
- return new LinkedHashMap<String, Integer>(this.headerMap);
+ return this.headerMap == null ? null : new LinkedHashMap<String, Integer>(this.headerMap);
}
/**
Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java?rev=1524435&r1=1524434&r2=1524435&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java Wed Sep 18 14:57:57 2013
@@ -665,6 +665,12 @@ public class CSVParserTest {
}
@Test
+ public void testNoHeaderMap() throws Exception {
+ final CSVParser parser = CSVParser.parse("a,b,c\n1,2,3\nx,y,z", CSVFormat.DEFAULT);
+ Assert.assertNull(parser.getHeaderMap());
+ }
+
+ @Test
public void testGetLineNumberWithLF() throws Exception {
this.validateLineNumbers(String.valueOf(LF));
}
Re: svn commit: r1524435 - in /commons/proper/csv/trunk/src:
main/java/org/apache/commons/csv/CSVParser.java test/java/org/apache/commons/csv/CSVParserTest.java
Posted by Gary Gregory <ga...@gmail.com>.
On Wed, Sep 18, 2013 at 4:16 PM, Emmanuel Bourg <eb...@apache.org> wrote:
> Le 18/09/2013 21:32, Benedikt Ritter a écrit :
>
> > Furthermore the contributor should be added to pom.xml and changes.xml.
>
> Isn't this a bit far fetched for a one line NPE check?
>
I could see that changes.xml could have the due-to field set even though
that duplicates what is already in JIRA. Different projects use due-to
differently...
For the POM, I see that as for more important, sustained and continuous
contributions. Not for an NPE check ;)
Gary
>
> Emmanuel Bourg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory
Re: svn commit: r1524435 - in /commons/proper/csv/trunk/src:
main/java/org/apache/commons/csv/CSVParser.java test/java/org/apache/commons/csv/CSVParserTest.java
Posted by Benedikt Ritter <br...@apache.org>.
2013/9/18 Emmanuel Bourg <eb...@apache.org>
> Le 18/09/2013 21:32, Benedikt Ritter a écrit :
>
> > Furthermore the contributor should be added to pom.xml and changes.xml.
>
> Isn't this a bit far fetched for a one line NPE check?
>
Just got the answer from Oliver on the other thread. I thought this is a
must have.
>
> Emmanuel Bourg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
--
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter
Re: svn commit: r1524435 - in /commons/proper/csv/trunk/src: main/java/org/apache/commons/csv/CSVParser.java
test/java/org/apache/commons/csv/CSVParserTest.java
Posted by Emmanuel Bourg <eb...@apache.org>.
Le 18/09/2013 21:32, Benedikt Ritter a écrit :
> Furthermore the contributor should be added to pom.xml and changes.xml.
Isn't this a bit far fetched for a one line NPE check?
Emmanuel Bourg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r1524435 - in /commons/proper/csv/trunk/src:
main/java/org/apache/commons/csv/CSVParser.java test/java/org/apache/commons/csv/CSVParserTest.java
Posted by Benedikt Ritter <br...@apache.org>.
2013/9/18 Emmanuel Bourg <eb...@apache.org>
> Le 18/09/2013 16:57, ggregory@apache.org a écrit :
>
> > public Map<String, Integer> getHeaderMap() {
> > - return new LinkedHashMap<String, Integer>(this.headerMap);
> > + return this.headerMap == null ? null : new
> LinkedHashMap<String, Integer>(this.headerMap);
> > }
> >
>
> Would it be possible to use an UnmodifiableMap for headerMap? That would
> avoid the need to copy the map on calling getHeaderMap().
>
Furthermore the contributor should be added to pom.xml and changes.xml.
Benedikt
>
> Emmanuel Bourg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
--
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter
Re: svn commit: r1524435 - in /commons/proper/csv/trunk/src: main/java/org/apache/commons/csv/CSVParser.java
test/java/org/apache/commons/csv/CSVParserTest.java
Posted by Emmanuel Bourg <eb...@apache.org>.
Le 18/09/2013 16:57, ggregory@apache.org a écrit :
> public Map<String, Integer> getHeaderMap() {
> - return new LinkedHashMap<String, Integer>(this.headerMap);
> + return this.headerMap == null ? null : new LinkedHashMap<String, Integer>(this.headerMap);
> }
>
Would it be possible to use an UnmodifiableMap for headerMap? That would
avoid the need to copy the map on calling getHeaderMap().
Emmanuel Bourg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org