org.apache.commons.lang3.exception.ExceptionUtils#wrapAndThrow ( )源码实例Demo

下面列出了org.apache.commons.lang3.exception.ExceptionUtils#wrapAndThrow ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: beihu-boot   文件: AbstractTransmission.java
@Override
public void acquire() {
    lock.lock();
    try {
        acquireCnt++;
        while (!acquirable()) {
            try {
                doWait();
            } catch (InterruptedException e) {
                ExceptionUtils.wrapAndThrow(e);
            }
        }
        onAcquired();
    } finally {
        acquireCnt--;
        lock.unlock();
    }
}
 
源代码2 项目: beihu-boot   文件: RunsUtils.java
protected void onException(Throwable e) {

            if (!this.exception.isInstance(e)) {
                ExceptionUtils.wrapAndThrow(e);
            }
            if (onException != null) {
                onException.accept(e);
            }
        }
 
源代码3 项目: beihu-boot   文件: Runs.java
public static void uncheckDo(RunnableWithError runnable) {
    try {
        runnable.run();
    } catch (Throwable e) {
        ExceptionUtils.wrapAndThrow(e);
    }
}
 
源代码4 项目: beihu-boot   文件: Runs.java
public static <T, E extends Throwable> T uncheckCall(ThrowaleCallable<T, E> callable) {
    try {
        return callable.call();
    } catch (Throwable e) {
        ExceptionUtils.wrapAndThrow(e);
        return null;//不会触发
    }
}
 
源代码5 项目: beihu-boot   文件: PeakTransmission.java
public void waitCompleted() {
    lock.lock();
    try {
        while (acquires != 0) {
            try {
                completed.await();
            } catch (InterruptedException e) {
                ExceptionUtils.wrapAndThrow(e);
            }
        }
    } finally {
        lock.unlock();
    }

}
 
源代码6 项目: beihu-boot   文件: Predicates.java
/**
 * Creates a safe {@code Predicate},
 *
 * @param <T>                the type of the input to the predicate
 * @param throwablePredicate the predicate that may throw an exception
 * @return the predicate result or {@code null} if exception was thrown
 * @throws NullPointerException if {@code throwablePredicate} is null
 */
public static <T> Predicate<T> uncheck(
        ThrowablePredicate<? super T, Throwable> throwablePredicate) {
    Objects.requireNonNull(throwablePredicate);
    return value -> {
        try {
            return throwablePredicate.test(value);
        } catch (Throwable throwable) {
            ExceptionUtils.wrapAndThrow(throwable);
            //never
            return false;
        }
    };
}
 
源代码7 项目: beihu-boot   文件: Predicates.java
/**
 * Creates a safe {@code BiPredicate},
 *
 * @param <T,U>                the type of the input to the predicate
 * @param throwableBiPredicate the predicate that may throw an exception
 * @return the predicate result or {@code null} if exception was thrown
 * @throws NullPointerException if {@code throwableBiPredicate} is null
 */
public static <T, U> BiPredicate<T, U> uncheck(
        ThrowableBiPredicate<? super T, ? super U, Throwable> throwableBiPredicate) {
    Objects.requireNonNull(throwableBiPredicate);
    return (t, u) -> {
        try {
            return throwableBiPredicate.test(t, u);
        } catch (Throwable throwable) {
            ExceptionUtils.wrapAndThrow(throwable);
            //never
            return false;
        }
    };
}
 
源代码8 项目: beihu-boot   文件: Suppliers.java
/**
 * Creates a safe {@code Supplier},
 *
 * @param <T>               the type of the input of the supplier
 * @param throwableSupplier the supplier that may throw an exception
 * @return the supplier result or {@code null} if exception was thrown
 * @throws NullPointerException if {@code throwableSupplier} is null
 */
public static <T> Supplier<T> uncheck(
        ThrowableSupplier<? extends T, Throwable> throwableSupplier) {
    Objects.requireNonNull(throwableSupplier);
    return () -> {
        try {
            return throwableSupplier.get();
        } catch (Throwable throwable) {
            ExceptionUtils.wrapAndThrow(throwable);
            //never
            return null;
        }
    };
}
 
源代码9 项目: beihu-boot   文件: Functions.java
/**
 * Creates a safe {@code Function},
 *
 * @param <T>               the type of the input of the function
 * @param <R>               the type of the result of the function
 * @param throwableFunction the function that may throw an exception
 * @return the function result or {@code null} if exception was thrown
 * @throws NullPointerException if {@code throwableFunction} is null
 */
public static <T, R> Function<T, R> uncheck(
        ThrowableFunction<? super T, ? extends R, Throwable> throwableFunction) {
    Objects.requireNonNull(throwableFunction);
    return value -> {
        try {
            return throwableFunction.apply(value);
        } catch (Throwable throwable) {
            ExceptionUtils.wrapAndThrow(throwable);
            //never
            return null;
        }
    };
}
 
源代码10 项目: beihu-boot   文件: Functions.java
/**
 * Creates a safe {@code BiFunction},
 *
 * @param <T>                 the type of the input of the biFunction
 * @param <R>                 the type of the result of the biFunction
 * @param throwableBiFunction the biFunction that may throw an exception
 * @return the biFunction result or {@code null} if exception was thrown
 * @throws NullPointerException if {@code throwableBiFunction} is null
 */
public static <T, U, R> BiFunction<T, U, R> uncheck(
        ThrowableBiFunction<? super T, ? super U, ? extends R, Throwable> throwableBiFunction) {
    Objects.requireNonNull(throwableBiFunction);
    return (t, u) -> {
        try {
            return throwableBiFunction.apply(t, u);
        } catch (Throwable throwable) {
            ExceptionUtils.wrapAndThrow(throwable);
            //never
            return null;
        }
    };
}
 
源代码11 项目: beihu-boot   文件: Consumers.java
/**
 * Creates a safe {@code Consumer} without catch Throwable.
 *
 * @param <T>               the type of the input to the consumer
 * @param throwableConsumer the consumer that may throw an exception
 * @return a {@code Consumer}
 * @throws NullPointerException if {@code throwableConsumer} is null
 * @see #safe(ThrowableConsumer, Consumer)
 */
public static <T> Consumer<T> uncheck(ThrowableConsumer<? super T, Throwable> throwableConsumer) {
    Objects.requireNonNull(throwableConsumer);
    return value -> {
        try {
            throwableConsumer.accept(value);
        } catch (Throwable ex) {
            ExceptionUtils.wrapAndThrow(ex);
        }
    };
}
 
源代码12 项目: beihu-boot   文件: Consumers.java
/**
 * Creates a safe {@code BiConsumer} without catch Throwable.
 *
 * @param <T>               the type of the first argument to the operation
 * @param <U>               the type of the second argument to the operation
 * @param throwableConsumer the consumer that may throw an exception
 * @return a {@code BiConsumer}
 * @throws NullPointerException if {@code throwableConsumer} is null
 * @see #safe(ThrowableBiConsumer, BiConsumer)
 */
public static <T, U> BiConsumer<T, U> uncheck(ThrowableBiConsumer<? super T, ? super U, Throwable> throwableConsumer) {
    Objects.requireNonNull(throwableConsumer);
    return (t, u) -> {
        try {
            throwableConsumer.accept(t, u);
        } catch (Throwable ex) {
            ExceptionUtils.wrapAndThrow(ex);
        }
    };
}
 
源代码13 项目: riiablo   文件: SequenceBuffer.java
public SequenceBuffer(Class<T> dataContainer, int bufferSize) {
  numEntries = bufferSize;
  entrySequence = new int[numEntries];
  Arrays.fill(entrySequence, INVALID_SEQUENCE);
  entryData = new Object[numEntries];
  try {
    for (int i = 0; i < numEntries; i++) entryData[i] = dataContainer.newInstance();
  } catch (Throwable t) {
    ExceptionUtils.wrapAndThrow(t);
  }

  sequence = 0;
}