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 2022/09/12 19:50:21 UTC

[commons-csv] branch master updated: Move package-private method.

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 b5b3cca9 Move package-private method.
b5b3cca9 is described below

commit b5b3cca98b2776fdcdac69bb0e4b701c06cc11f5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Sep 12 12:50:16 2022 -0700

    Move package-private method.
---
 src/main/java/org/apache/commons/csv/CSVPrinter.java | 17 ++---------------
 src/main/java/org/apache/commons/csv/IOUtils.java    | 13 +++++++++++++
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/main/java/org/apache/commons/csv/CSVPrinter.java b/src/main/java/org/apache/commons/csv/CSVPrinter.java
index 9db13c3d..dba6de9e 100644
--- a/src/main/java/org/apache/commons/csv/CSVPrinter.java
+++ b/src/main/java/org/apache/commons/csv/CSVPrinter.java
@@ -70,19 +70,6 @@ import java.util.stream.Stream;
  */
 public final class CSVPrinter implements Flushable, Closeable {
 
-    /**
-     * Throws the given throwable.
-     *
-     * @param <T> The throwable cast type.
-     * @param throwable The throwable to rethrow.
-     * @return nothing because we throw.
-     * @throws T Always thrown.
-     */
-    @SuppressWarnings("unchecked")
-    private static <T extends Throwable> RuntimeException rethrow(final Throwable throwable) throws T {
-        throw (T) throwable;
-    }
-
     /** The place that the values get written. */
     private final Appendable appendable;
 
@@ -313,7 +300,7 @@ public final class CSVPrinter implements Flushable, Closeable {
             try {
                 print(t);
             } catch (final IOException e) {
-                throw rethrow(e);
+                throw IOUtils.rethrow(e);
             }
         });
         println();
@@ -502,7 +489,7 @@ public final class CSVPrinter implements Flushable, Closeable {
             try {
                 printRecordObject(t);
             } catch (final IOException e) {
-                throw rethrow(e);
+                throw IOUtils.rethrow(e);
             }
         });
     }
diff --git a/src/main/java/org/apache/commons/csv/IOUtils.java b/src/main/java/org/apache/commons/csv/IOUtils.java
index e5c51da0..c4baeb47 100644
--- a/src/main/java/org/apache/commons/csv/IOUtils.java
+++ b/src/main/java/org/apache/commons/csv/IOUtils.java
@@ -131,4 +131,17 @@ final class IOUtils {
         // Noop
     }
 
+    /**
+     * Throws the given throwable.
+     *
+     * @param <T> The throwable cast type.
+     * @param throwable The throwable to rethrow.
+     * @return nothing because we throw.
+     * @throws T Always thrown.
+     */
+    @SuppressWarnings("unchecked")
+    static <T extends Throwable> RuntimeException rethrow(final Throwable throwable) throws T {
+        throw (T) throwable;
+    }
+
 }