Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B536A9A25 for ; Mon, 26 Mar 2012 12:56:51 +0000 (UTC) Received: (qmail 58522 invoked by uid 500); 26 Mar 2012 12:56:51 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 58425 invoked by uid 500); 26 Mar 2012 12:56:51 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 58417 invoked by uid 99); 26 Mar 2012 12:56:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Mar 2012 12:56:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Mar 2012 12:56:48 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 5166A346C18 for ; Mon, 26 Mar 2012 12:56:27 +0000 (UTC) Date: Mon, 26 Mar 2012 12:56:27 +0000 (UTC) From: "Emmanuel Bourg (Commented) (JIRA)" To: issues@commons.apache.org Message-ID: <1977550161.17174.1332766587349.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1404225049.8952.1332523769906.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (CSV-82) CSVRecord inconsistent behaviour when header mapping is not found MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CSV-82?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13238343#comment-13238343 ] Emmanuel Bourg commented on CSV-82: ----------------------------------- I don't find this inconsistent. There are two cases to handle: # The header is missing and a field is accessed by name # The header is present but the column name requested doesn't exist In case 1 an IllegalStateException is thrown, because the expectation of the user is severely broken. He attempts to access the fields by name which is completely impossible. In case 2 a null value is returned, because some column may be optional. It's not reasonable to throw an exception in this case, otherwise reading optional columns in a try catch block will become very cumbersome. If you want to differentiate between missing columns and null values this can be done with a CSVRecord#has(String) method. But is it actually useful? > CSVRecord inconsistent behaviour when header mapping is not found > ----------------------------------------------------------------- > > Key: CSV-82 > URL: https://issues.apache.org/jira/browse/CSV-82 > Project: Commons CSV > Issue Type: Bug > Reporter: Sebb > > The CSVRecord#get(String) method has inconsistent behaviour. > If no header mapping was provided, then it throws IllegalStateException. > If the header name is not found, null is returned. > Apart from being inconsistent, it might be useful in the future to be able to return null as a column value (as distinct from the empty string). > It should throw IllegalArgumentException for a missing header name, instead of returning null. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira