Specifies that a failure has occurred if the {@code failurePredicate} matches the failure.

@throws NullPointerException if {@code failurePredicate} is null
192589
public S handleIf(Predicate<? extends Throwable> failurePredicate) {
    Assert.notNull(failurePredicate, "failurePredicate");
    failuresChecked = true;
    failureConditions.add(failurePredicateFor(failurePredicate));
    return (S) this;
  }
1243442
@Override
  public void onFailure(Throwable cause) {
    checkState();
    for (Callback<T> cb : callbacks) {
      cb.onFailure(cause);
    }
    callbacks = null; // note that we've fired
  }
625667
static boolean detect(final String detectPattern, final String failurePattern, final long timeout,
                          final int maxLines, final InputStreamReader reader,
                          final PartialLineBuffer buffer) throws IOException, ThreshholdException {
        if (null == detectPattern && null == failurePattern) {
            throw new IllegalArgumentException("detectPattern or failurePattern required");
        }
        long start = System.currentTimeMillis();
        int linecount = 0;
        final Pattern success;
        if (null != detectPattern) {
            success = Pattern.compile(detectPattern);
        } else {
            success = null;
        }
        final Pattern failure;
        if (null != failurePattern) {
            failure = Pattern.compile(failurePattern);
        } else {
            failure = null;
        }
        outer:
        while (System.currentTimeMillis() < start + timeout && linecount < maxLines && !Thread.currentThread()
            .isInterrupted()) {
            //check buffer first, it may already contain data
            String line = buffer.readLine();
            while (null != line) {
                logger.debug("read line: " + line);
                start = System.currentTimeMillis();
                linecount++;
                if (null != success && success.matcher(line).matches()) {
                    logger.debug("success matched");
                    return true;
                } else if (null != failure && failure.matcher(line).matches()) {
                    logger.debug("failure matched");
                    return false;
                }
                if (linecount >= maxLines) {
                    break outer;
                }
                line = buffer.readLine();
            }
            line = buffer.getPartialLine();
            if (null != line) {
                logger.debug("read partial: " + line);
                if (null != success && success.matcher(line).matches()) {
                    logger.debug("success matched partial");
                    buffer.clearPartial();
                    return true;
                } else if (null != failure && failure.matcher(line).matches()) {
                    logger.debug("failure matched partial");
                    buffer.clearPartial();
                    return false;
                }else {
                    buffer.unmarkPartial();
                }
            }

            if (!reader.ready()) {
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                    return false;
                }
                continue;
            }
            final int c = buffer.read(reader);
            if (c < 0) {
                //end of stream
                logger.debug("end of input");
            } else if (c > 0) {
                logger.debug("read " + c);
            }

        }
        if (Thread.currentThread().isInterrupted()) {
            logger.debug("detect interrupted");
        }
        if (linecount >= maxLines) {
            logger.debug("max input lines");
            throw new ThreshholdException(maxLines, ThresholdType.lines);
        } else if (System.currentTimeMillis() >= start + timeout) {
            logger.debug("max timeout");
            throw new ThreshholdException(timeout, ThresholdType.milliseconds);
        } else {
            //
            return false;
        }
    }
871045
public void requestFailed (final Exception cause)
    {
        apply(new ObserverOp<ResultListener<T>>() {
            public boolean apply (ResultListener<T> observer) {
                observer.requestFailed(cause);
                return true;
            }
        });
    }
1004564
public synchronized void setFailure(Exception paramE) {
        if (done)
            return; // can't mark done twice
        e = paramE;
        done = true;
        notifyAll();

        // if we have a callback to call, schedule
        // it on a different thread. Who knows what this
        // thread is doing.
        if (callback != null) {
            QueueBuffer.executor.submit(new Callable<Void>() {
                public Void call() throws Exception {
                    callback.onError(e);
                    return null;
                }
            });

        }

    }
1177011
public void setFailures(java.util.Collection<String> failures) {
        if (failures == null) {
            this.failures = null;
            return;
        }

        this.failures = new java.util.ArrayList<String>(failures);
    }
982064
public static <V> void trySuccess(Promise<? super V> p, V result, InternalLogger logger) {
        if (!p.trySuccess(result) && logger != null) {
            Throwable err = p.cause();
            if (err == null) {
                logger.warn("Failed to mark a promise as success because it has succeeded already: {}", p);
            } else {
                logger.warn(
                        "Failed to mark a promise as success because it has failed already: {}, unnotified cause:",
                        p, err);
            }
        }
    }
949849
public static void tryFailure(Promise<?> p, Throwable cause, InternalLogger logger) {
        if (!p.tryFailure(cause) && logger != null) {
            Throwable err = p.cause();
            if (err == null) {
                logger.warn("Failed to mark a promise as failure because it has succeeded already: {}", p, cause);
            } else {
                logger.warn(
                        "Failed to mark a promise as failure because it has failed already: {}, unnotified cause: {}",
                        p, ThrowableUtil.stackTraceToString(err), cause);
            }
        }
    }
1123533
public void onFailure(Throwable t)
    {
        MessagingService.instance().sendOneWay(new SyncComplete(desc, request.src, request.dst, false).createMessage(), request.initiator);
    }
1146925
public static Matcher<PrintableResult> hasSingleFailureMatching(final Matcher<Throwable> matcher) {
        return new TypeSafeMatcher<PrintableResult>() {
            @Override
            public boolean matchesSafely(PrintableResult item) {
                return item.failureCount() == 1 && matcher.matches(item.failures().get(0).getException());
            }

            public void describeTo(Description description) {
                description.appendText("has failure with exception matching ");
                matcher.describeTo(description);
            }
        };
    }
172860
private static void checkPreconditions(final Pattern pattern, final String replacement) {
        if(pattern == null ) {
            throw new NullPointerException("regex should not be null");
        }
        
        if(replacement == null) {
            throw new NullPointerException("replacement should not be null");
        }
    }
617969
@Override
  public void onFailedTask() {
    LOG.entering("TaskNodeImpl", "onFailedTask", getQualifiedName());
    if (!running.compareAndSet(true, false)) {
      LOG.fine(getQualifiedName() + "Trying to set failed on an already failed task. Something fishy!!!");
      LOG.exiting("TaskNodeImpl", "onFailedTask", getQualifiedName() +
          "Trying to set failed on an already failed task. Something fishy!!!");
      return;
    }
    taskNodeStatus.clearStateAndReleaseLocks();
    LOG.finest(getQualifiedName() + "Changed status to failed.");
    LOG.finest(getQualifiedName() + "Resetting topoSetupSent to false");
    topoSetupSent.set(false);
    if (parent != null && parent.isRunning()) {
      parent.onChildDead(taskId);
    } else {
      LOG.finest(getQualifiedName() + "Skipping asking parent to process child death");
    }
    for (final TaskNode child : children) {
      if (child.isRunning()) {
        child.onParentDead();
      }
    }
    final int newVersion = this.version.incrementAndGet();
    LOG.finest(getQualifiedName() + "Bumping up to version-" + newVersion);
    LOG.exiting("TaskNodeImpl", "onFailedTask", getQualifiedName());
  }
834595
private static void checkPreconditions(final String trueValue, final String falseValue) {
		if( trueValue == null ) {
			throw new NullPointerException("trueValue should not be null");
		}
		if( falseValue == null ) {
			throw new NullPointerException("falseValue should not be null");
		}
	}
1343005
@Override
    protected RpcResponse onFailure(ServiceRequestContext ctx, RpcRequest req, @Nullable Throwable cause)
            throws Exception {
        return RpcResponse.ofFailure(HttpStatusException.of(HttpStatus.SERVICE_UNAVAILABLE));
    }
294521
@Override
    public void failed(Throwable x) {
        boolean failure = false;
        try (Locker.Lock lock = _locker.lock()) {
            switch (_state) {
                case SUCCEEDED:
                case FAILED:
                case IDLE:
                case CLOSED:
                case CALLED:
                    // too late!.
                    break;

                case PENDING:
                case PROCESSING: {
                    _state = State.FAILED;
                    failure = true;
                    break;
                }
                default:
                    throw new IllegalStateException(toString());
            }
        }
        if (failure)
            onCompleteFailure(x);
    }
47515
public final void fail(@NullableDecl String format, Object /*@NullableDeclType*/... args) {
    doFail(lenientFormat(format, args));
  }
507025
public void setFailureReason(java.util.Collection<String> failureReason) {
        if (failureReason == null) {
            this.failureReason = null;
            return;
        }

        this.failureReason = new java.util.ArrayList<String>(failureReason);
    }