private boolean isLambdaGenericProblem(ClassCastException ex) { return (ex.getMessage() == null || startsWithArgumentClassName(ex.getMessage())); }
protected final <R> InvocationResult<R> invoke(C callbackInstance, Supplier<R> supplier) { if (this.filter.match(this.callbackType, callbackInstance, this.argument, this.additionalArguments)) { try { return InvocationResult.of(supplier.get()); } catch (ClassCastException ex) { if (!isLambdaGenericProblem(ex)) { throw ex; } logNonMatchingType(callbackInstance, ex); } } return InvocationResult.noResult(); }
/** * Use a specific filter to determine when a callback should apply. If no explicit * filter is set filter will be attempted using the generic type on the callback * type. * @param filter the filter to use * @return this instance */ public SELF withFilter(Filter<C, A> filter) { Assert.notNull(filter, "Filter must not be null"); this.filter = filter; return self(); }
/** * Use the specified logger to report any lambda failures. * @param logger the logger to use * @return this instance */ public SELF withLogger(Log logger) { Assert.notNull(logger, "Logger must not be null"); this.logger = logger; return self(); }
private boolean startsWithArgumentClassName(String message) { Predicate<Object> startsWith = (argument) -> startsWithArgumentClassName( message, argument); return startsWith.test(this.argument) || Stream.of(this.additionalArguments).anyMatch(startsWith); }
/** * Use the specified logger source to report any lambda failures. * @param loggerSource the logger source to use * @return this instance */ public SELF withLogger(Class<?> loggerSource) { return withLogger(LogFactory.getLog(loggerSource)); }