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 2024/12/17 14:24:59 UTC
(commons-csv) branch master updated: CSVParser.nextRecord() should throw CSVException (an IOException subclass) instead of IOException and IllegalStateException, no method signature changes needed
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
The following commit(s) were added to refs/heads/master by this push:
new fa15e2b6 CSVParser.nextRecord() should throw CSVException (an IOException subclass) instead of IOException and IllegalStateException, no method signature changes needed
fa15e2b6 is described below
commit fa15e2b68ff952a5f0caee4e7965e881eb128217
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Dec 17 09:24:54 2024 -0500
CSVParser.nextRecord() should throw CSVException (an IOException
subclass) instead of IOException and IllegalStateException, no method
signature changes needed
---
src/changes/changes.xml | 1 +
src/main/java/org/apache/commons/csv/CSVParser.java | 14 ++++++++------
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index fdf068e1..31459912 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -43,6 +43,7 @@
<release version="1.13.0" date="YYYY-MM-DD" description="This is a feature and maintenance release. Java 8 or later is required.">
<!-- FIX -->
<action type="fix" issue="CSV-314" dev="ggregory" due-to="Gary Gregory">Required OSGi Import-Package version numbers in MANIFEST.MF #504.</action>
+ <action type="fix" issue="CSV-314" dev="ggregory" due-to="Gary Gregory">CSVParser.nextRecord() should throw CSVException (an IOException subclass) instead of IOException and IllegalStateException, no method signature changes needed.</action>
<!-- ADD -->
<action type="add" issue="CSV-313" dev="ggregory" due-to="Gary Gregory">Add CSVPrinter.getRecordCount().</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add and use CSVParser.Builder and builder() and deprecate CSVParser constructors.</action>
diff --git a/src/main/java/org/apache/commons/csv/CSVParser.java b/src/main/java/org/apache/commons/csv/CSVParser.java
index 5195a494..f4b8f08a 100644
--- a/src/main/java/org/apache/commons/csv/CSVParser.java
+++ b/src/main/java/org/apache/commons/csv/CSVParser.java
@@ -208,6 +208,8 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
/**
* Gets the next record.
*
+ * @throws IOException on parse error or input read-failure
+ * @throws CSVException on invalid input.
* @return the next record.
*/
private CSVRecord getNextRecord() {
@@ -498,8 +500,8 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
* @throws IllegalArgumentException
* If the parameters of the format are inconsistent or if either the reader or format is null.
* @throws IOException
- * If there is a problem reading the header or skipping the first record
- * @throws CSVException Thrown on invalid input.
+ * if there is a problem reading the header or skipping the first record
+ * @throws CSVException on invalid input.
* @since 1.1
* @deprecated Will be private in the next major version, use {@link Builder#get()}.
*/
@@ -547,7 +549,7 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
*
* @return null if the format has no header.
* @throws IOException if there is a problem reading the header or skipping the first record
- * @throws CSVException Thrown on invalid input.
+ * @throws CSVException on invalid input.
*/
private Headers createHeaders() throws IOException {
Map<String, Integer> hdrMap = null;
@@ -830,7 +832,7 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
*
* @return the record as an array of values, or {@code null} if the end of the stream has been reached
* @throws IOException on parse error or input read-failure
- * @throws CSVException Thrown on invalid input.
+ * @throws CSVException on invalid input.
*/
CSVRecord nextRecord() throws IOException {
CSVRecord result = null;
@@ -855,7 +857,7 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
}
break;
case INVALID:
- throw new IOException("(line " + getCurrentLineNumber() + ") invalid parse sequence");
+ throw new CSVException("(line %,d) invalid parse sequence", getCurrentLineNumber());
case COMMENT: // Ignored currently
if (sb == null) { // first comment for this record
sb = new StringBuilder();
@@ -866,7 +868,7 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
reusableToken.type = TOKEN; // Read another token
break;
default:
- throw new IllegalStateException("Unexpected Token type: " + reusableToken.type);
+ throw new CSVException("Unexpected Token type: %s", reusableToken.type);
}
} while (reusableToken.type == TOKEN);