private void fail(
     InsertException e, boolean forceFatal, ObjectContainer container, ClientContext context) {
   synchronized (this) {
     if (finished) return;
     finished = true;
   }
   if (persistent) container.store(this);
   if (e.isFatal() || forceFatal) parent.fatallyFailedBlock(container, context);
   else parent.failedBlock(container, context);
   unregister(container, context, getPriorityClass(container));
   if (freeData) {
     if (persistent) container.activate(sourceData, 1);
     sourceData.free();
     if (persistent) sourceData.removeFrom(container);
     sourceData = null;
     if (persistent) container.store(this);
   }
   if (persistent) container.activate(cb, 1);
   cb.onFailure(e, this, container, context);
 }
  @Override
  public synchronized void onFailure(
      InsertException e, BaseClientPutter state, ObjectContainer container) {
    try {
      if (e.getMode() == InsertException.COLLISION) {
        Logger.warning(
            this, "WoTOwnMessageList insert collided, trying to insert with higher index ...");
        try {
          synchronized (mMessageManager) {
            // We must call getOwnMessageList() before calling onMessageListInsertFailed() because
            // the latter will increment the message list's
            // index, resulting in the ID of the message list changing - getIDFromURI would fail
            // with the old state.getURI() if we called it after
            // onMessageListInsertFailed()
            WoTOwnMessageList list =
                (WoTOwnMessageList)
                    mMessageManager.getOwnMessageList(
                        MessageListID.construct(state.getURI()).toString());
            mMessageManager.onMessageListInsertFailed(state.getURI(), true);
            insertMessageList(list);
          }
        } catch (Exception ex) {
          Logger.error(this, "Inserting WoTOwnMessageList with higher index failed", ex);
        }
      } else {
        if (e.isFatal()) Logger.error(this, "WoTOwnMessageList insert failed", e);
        else Logger.warning(this, "WoTOwnMessageList insert failed non-fatally", e);

        mMessageManager.onMessageListInsertFailed(state.getURI(), false);
      }
    } catch (Exception ex) {
      Logger.error(this, "WoTOwnMessageList insert failed and failure handling threw", ex);
    } finally {
      removeInsert(state);
      Closer.close(((ClientPutter) state).getData());
    }
  }