Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A460E200BAE for ; Fri, 28 Oct 2016 20:25:47 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A2CA5160AE4; Fri, 28 Oct 2016 18:25:47 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C197F160ACA for ; Fri, 28 Oct 2016 20:25:46 +0200 (CEST) Received: (qmail 85728 invoked by uid 500); 28 Oct 2016 18:25:45 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 85711 invoked by uid 99); 28 Oct 2016 18:25:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Oct 2016 18:25:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id A0097C18E1 for ; Fri, 28 Oct 2016 18:25:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.08 X-Spam-Level: X-Spam-Status: No, score=0.08 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=scarlet.be Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id tne5ljYjnrlt for ; Fri, 28 Oct 2016 18:25:42 +0000 (UTC) Received: from hel.is.scarlet.be (hel.is.scarlet.be [193.74.71.26]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 1783D5FB5A for ; Fri, 28 Oct 2016 18:25:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scarlet.be; s=scarlet; t=1477679134; bh=gF878qb+nOefzThgdgnGEN+9pn1wmZUzgOYtzbV2Z6A=; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Date:From:To: Subject:In-Reply-To:References:Message-ID; b=V+x6pXAz0/k1r/aisYlltFXF5IibvXDszkyzjKD0LW0CpJHkzoo8XJ26aVFNfWFyI FkNAk41tMyWeKUllnqIK8Yj2N8Xim9IoOgA0c2j2/hdqexCU0Y6hFqqsgjksQ1WZ+Y 7zlHj6FqTbRLDl03SDzfbkiP9eOzFct/jNDMq3CE= Received: from webmail.scarlet.be (gresham.is.scarlet.be [193.74.71.215]) by hel.is.scarlet.be (8.14.9/8.14.9) with ESMTP id u9SIPYmX003999 for ; Fri, 28 Oct 2016 20:25:34 +0200 X-Scarlet: d=1477679134 c=193.74.71.215 Received: from [62.235.92.178] via [62.235.92.178] by webmail.scarlet.be with HTTP (HTTP/1.1 POST); Fri, 28 Oct 2016 20:25:34 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 28 Oct 2016 20:25:34 +0200 From: Gilles To: Subject: Re: commons-csv git commit: [CSV-201] Do not use RuntimeException in CSVParser.iterator().new Iterator() {...}.getNextRecord(). Use an IllegalStateException instead (KISS for now, no need for a custom exception) In-Reply-To: References: <60131c1261f94c4aa9bdbd0c21fa7be1@git.apache.org> Message-ID: <74401a307b7ccd46822f2555c7b27d2b@scarlet.be> X-Sender: gilles@harfang.homelinux.org User-Agent: Scarlet Webmail X-DCC-scarlet.be-Metrics: hel; whitelist X-Virus-Scanned: clamav-milter 0.98.1-exp at hel X-Virus-Status: Clean archived-at: Fri, 28 Oct 2016 18:25:47 -0000 On Fri, 28 Oct 2016 08:03:58 -0700, Gary Gregory wrote: > I do not think reverting is right since the previous is obviously > bogus, to > me, that is. Throwing a RE is never useful, again IMO. We should just > evolve the code from here. > > Would you like to outline choices? > > 1) NSEE > 2) Custom > 3) ISE > 4) ? A custom exception inheriting from ISE (as previously suggested) would combine the advantages of both 2) and 3). Gilles > > Gary (will be offline most of today) > > On Oct 28, 2016 5:36 AM, "Benedikt Ritter" > wrote: > > Hello, > > Benedikt Ritter schrieb am Mi., 26. Okt. 2016 um > 21:38 Uhr: > >> Hello, >> >> schrieb am Di., 25. Okt. 2016 um 22:59 Uhr: >> >> Repository: commons-csv >> Updated Branches: >> refs/heads/master b2a50d4a3 -> 1c7a9910b >> >> >> [CSV-201] Do not use RuntimeException in CSVParser.iterator().new >> Iterator() {...}.getNextRecord(). Use an IllegalStateException >> instead >> (KISS for now, no need for a custom exception) >> >> Project: http://git-wip-us.apache.org/repos/asf/commons-csv/repo >> Commit: >> http://git-wip-us.apache.org/repos/asf/commons-csv/commit/1c7a9910 >> Tree: >> http://git-wip-us.apache.org/repos/asf/commons-csv/tree/1c7a9910 >> Diff: >> http://git-wip-us.apache.org/repos/asf/commons-csv/diff/1c7a9910 >> >> Branch: refs/heads/master >> Commit: 1c7a9910be857a4f33ed216701407806e1d20670 >> Parents: b2a50d4 >> Author: Gary Gregory >> Authored: Tue Oct 25 13:59:32 2016 -0700 >> Committer: Gary Gregory >> Committed: Tue Oct 25 13:59:32 2016 -0700 >> >> >> ---------------------------------------------------------------------- >> src/changes/changes.xml | 1 + >> src/main/java/org/apache/commons/csv/CSVParser.java | 16 >> ++++++++++------ >> 2 files changed, 11 insertions(+), 6 deletions(-) >> >> ---------------------------------------------------------------------- >> >> >> >> http://git-wip-us.apache.org/repos/asf/commons-csv/blob/ > 1c7a9910/src/changes/changes.xml >> >> ---------------------------------------------------------------------- >> diff --git a/src/changes/changes.xml b/src/changes/changes.xml >> index d5d8c8a..e49265b 100644 >> --- a/src/changes/changes.xml >> +++ b/src/changes/changes.xml >> @@ -43,6 +43,7 @@ >> > due-to="Matthias >> Wiehl">Fix incorrect method name 'withFirstRowAsHeader' in user >> guide. >> > due-to="Gary >> Gregory, Michael Graessle, Adrian Bridgett">Negative numeric values >> in the >> first column are always quoted in minimal mode. >> > due-to="Gary >> Gregory">Update platform requirement from Java 6 to 7. >> + > due-to="Benedikt Ritter, Gary Gregory">Do not use RuntimeException >> in >> CSVParser.iterator().new Iterator() {...}.getNextRecord() >> > due-to="Peter >> Holzwarth, Gary Gregory">CSVParser: Add factory method accepting >> InputStream. >> > due-to="Gary >> Gregory">Add convenience API CSVFormat.print(File, Charset) >> > due-to="Gary >> Gregory">Add convenience API CSVFormat.print(Path, Charset) >> >> >> http://git-wip-us.apache.org/repos/asf/commons-csv/blob/ > 1c7a9910/src/main/java/org/apache/commons/csv/CSVParser.java >> >> ---------------------------------------------------------------------- >> diff --git a/src/main/java/org/apache/commons/csv/CSVParser.java >> b/src/main/java/org/apache/commons/csv/CSVParser.java >> index f5829cc..410e6a4 100644 >> --- a/src/main/java/org/apache/commons/csv/CSVParser.java >> +++ b/src/main/java/org/apache/commons/csv/CSVParser.java >> @@ -501,10 +501,14 @@ public final class CSVParser implements >> Iterable, Closeable { >> /** >> * Returns an iterator on the records. >> * >> - *

IOExceptions occurring during the iteration are wrapped >> in a >> - * RuntimeException. >> - * If the parser is closed a call to {@code next()} will throw >> a >> - * NoSuchElementException.

>> + *

>> + * An {@link IOException} caught during the iteration are >> re-thrown >> as an >> + * {@link IllegalStateException}. >> + *

>> + *

>> + * If the parser is closed a call to {@link Iterator#next()} >> will >> throw a >> + * {@link NoSuchElementException}. >> + *

>> */ >> @Override >> public Iterator iterator() { >> @@ -515,8 +519,8 @@ public final class CSVParser implements >> Iterable, Closeable { >> try { >> return CSVParser.this.nextRecord(); >> } catch (final IOException e) { >> - // TODO: This is not great, throw an ISE >> instead? >> - throw new RuntimeException(e); >> + throw new IllegalStateException( >> + e.getClass().getSimpleName() + " >> reading next >> record: " + e.toString(), e); >> >> >> As discussed in CSV-201, I don't think this fix is complete. We >> should >> rather throw a custom RuntimeException to make it easy for calling >> code to >> react to exactly this problem. >> > > I think this needs to be reverted until we have consensus about how > to > solve this issue. > > >> >> Benedikt >> >> >> } >> } >> >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org