verhas commented on a change in pull request #448: Lang 1482
URL: https://github.com/apache/commons-lang/pull/448#discussion_r317709154
 
 

 ##########
 File path: src/main/java/org/apache/commons/lang3/Functions.java
 ##########
 @@ -143,164 +151,141 @@
     }
 
     /**
-     * Converts the given {@link FailableRunnable} into a standard {@link 
Runnable}.
+     * <p>Converts the given {@link FailableRunnable} into a standard {@link 
Runnable}.</p>
+     *
+     * <p>If the execution of the failable argument throws an exception it is 
enveloped
+     * and rethrown using the {@link #rethrow(Throwable)} method.</p>
      *
      * @param pRunnable a {@code FailableRunnable}
      * @return a standard {@code Runnable}
      */
     public static Runnable asRunnable(FailableRunnable<?> pRunnable) {
-        return () -> {
-            try {
-                pRunnable.run();
-            } catch (Throwable t) {
-                throw rethrow(t);
-            }
-        };
+        return () -> run(pRunnable);
     }
 
     /**
      * Converts the given {@link FailableConsumer} into a standard {@link 
Consumer}.
      *
+     * <p>If the execution of the failable argument throws an exception it is 
enveloped
+     * and rethrown using the {@link #rethrow(Throwable)} method.</p>
+     *
      * @param <I> the type used by the consumers
      * @param pConsumer a {@code FailableConsumer}
      * @return a standard {@code Consumer}
      */
     public static <I> Consumer<I> asConsumer(FailableConsumer<I, ?> pConsumer) 
{
-        return (pInput) -> {
-            try {
-                pConsumer.accept(pInput);
-            } catch (Throwable t) {
-                throw rethrow(t);
-            }
-        };
+        return pInput -> accept(pConsumer,pInput);
     }
 
     /**
      * Converts the given {@link FailableCallable} into a standard {@link 
Callable}.
      *
+     * <p>If the execution of the failable argument throws an exception it is 
enveloped
+     * and rethrown using the {@link #rethrow(Throwable)} method.</p>
+     *
      * @param <O> the type used by the callables
      * @param pCallable a {@code FailableCallable}
      * @return a standard {@code Callable}
      */
     public static <O> Callable<O> asCallable(FailableCallable<O, ?> pCallable) 
{
-        return () -> {
-            try {
-                return pCallable.call();
-            } catch (Throwable t) {
-                throw rethrow(t);
-            }
-        };
+        return () -> call(pCallable);
 
 Review comment:
   The functionality as it was implemented the first hand is already there.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to