예제 #1
0
 /**
  * Removes all the successful minor results. Also checks if the result is roughly consistent and
  * complete. (e.g. does not have unknown operation status, etc.)
  *
  * <p>The argument "e" is for easier use of the cleanup in the exceptions handlers. The original
  * exception is passed to the IAE that this method produces for easier debugging.
  */
 public void cleanupResult(Throwable e) {
   if (status == OperationResultStatus.UNKNOWN) {
     LOGGER.error(
         "Attempt to cleanup result of operation " + operation + " that is still UNKNOWN:\n{}",
         this.debugDump());
     throw new IllegalStateException(
         "Attempt to cleanup result of operation " + operation + " that is still UNKNOWN");
   }
   if (subresults == null) {
     return;
   }
   Iterator<OperationResult> iterator = subresults.iterator();
   while (iterator.hasNext()) {
     OperationResult subresult = iterator.next();
     if (subresult.getStatus() == OperationResultStatus.UNKNOWN) {
       String message =
           "Subresult "
               + subresult.getOperation()
               + " of operation "
               + operation
               + " is still UNKNOWN during cleanup";
       LOGGER.error("{}:\n{}", message, this.debugDump(), e);
       if (e == null) {
         throw new IllegalStateException(message);
       } else {
         throw new IllegalStateException(message + "; during handling of exception " + e, e);
       }
     }
     if (subresult.canCleanup()) {
       iterator.remove();
     }
   }
 }