/*
(non-Javadoc)

@see com.ibm.ws.sib.processor.impl.ConsumerPoint#notifyException(com.ibm.ws.sib.processor.SIMPException)
436914
@Override
    public void notifyException(Throwable exception)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "notifyException", new Object[] { this, exception });

        // If an asynch consumer is registered we need to let them know something went wrong
        if (_asynchConsumerRegistered)
            _asynchConsumer.notifyExceptionListeners(exception, _consumerSession);

        this.lock();
        try
        {
            if (_waiting)
            {
                // We need to get the exception back to the synchronous consumer
                _notifiedException = exception;
                _waiter.signal();
            }
        } finally
        {
            this.unlock();
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "notifyException");
    }
445715
private void notifyBroadcastClose() {
        final IStreamAwareScopeHandler handler = getStreamAwareHandler();
        if (handler != null) {
            try {
                handler.streamBroadcastClose(this);
            } catch (Throwable t) {
                log.error("Error in notifyBroadcastClose", t);
            }
        }
    }
943055
public void notifyUserAboutException(Thread thread, final Throwable throwable) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                final ErrorInfo errorInfo = new ErrorInfo(
                        resolveExceptionCaption(throwable),
                        (String) createExceptionContent(throwable),
                        getDetailsAsHTML(throwable.getMessage(), throwable),
                        null, throwable, Level.SEVERE,  null);
                JXErrorPane pane = new JXErrorPane();
                pane.setErrorInfo(errorInfo);
                if (errorReporter != null) {
                    pane.setErrorReporter(errorReporter);
                }
                JXErrorPane.showDialog(resolveParentFrame(), pane);
            }
        });
    }
558896
public void onFailure(JoynrException newException) {
        exception = newException;
        status = new RequestStatus(RequestStatusCode.ERROR);
        try {
            statusLock.lock();
            statusLockChangedCondition.signalAll();
        } finally {
            statusLock.unlock();
        }
    }
1093966
private void errorNewClientConnected(Exception exception)
    {
        Verbose.warning(Server.class, "addClient", "Error on adding client: ", exception.getMessage());
        if (clients.remove(Byte.valueOf(lastId)) != null)
        {
            clientsNumber--;
        }
    }
205985
private void setPreviousExceptionInfo(Throwable previousException) {
        if (previousException instanceof com.ibm.websphere.exception.DistributedExceptionEnabled) {
            previousExceptionInfo = ((DistributedExceptionEnabled) previousException).getExceptionInfo();
        } else {
            previousExceptionInfo = new DistributedExceptionInfo(previousException);
        }
    }
420176
public void process(final boolean asynch)
          throws NotificationException {
    if (asynch) {
      try {
        consumer.setMessageListener(this);
        return;
      } catch (final JMSException je) {
        throw new NotificationException(je);
      }
    }

    while (running) {
      final Message m = conn.receive();

      if (m == null) {
        running = false;
        return;
      }
      onMessage(m);
    }
  }
49707
@Override
    public void onReceive(Object message) throws Exception {
        try {
            if (message instanceof RequestWorkerMsgType) {
                switch ((RequestWorkerMsgType) message) {
                case PROCESS_REQUEST:
                    tryCount++;

                    if (tryCount == 1) {
                        sender = getSender();

                        BoundRequestBuilder request = createRequest();

                        // 20150229: create the future and make sure future is
                        // killed when timeout.
                        responseFuture = request.execute(new HttpAsyncHandler(
                                this));
                        timeoutDuration = Duration.create(
                                actorMaxOperationTimeoutSec, TimeUnit.SECONDS);

                        // To handle cases where nio response never comes back,
                        // we
                        // schedule a 'timeout' message to be sent to us 2
                        // seconds
                        // after NIO's SO_TIMEOUT
                        timeoutMessageCancellable = getContext()
                                .system()
                                .scheduler()
                                .scheduleOnce(
                                        timeoutDuration,
                                        getSelf(),
                                        RequestWorkerMsgType.PROCESS_ON_TIMEOUT,
                                        getContext().system().dispatcher(),
                                        getSelf());
                    } else {
                        getLogger().error(
                                "duplicated PROCESS_REQUEST msg. ignore...");
                    }
                    break;

                case CANCEL:
                    getLogger().info(
                            "Request was CANCELLED.................{}",
                            requestUrl);
                    cancelCancellable();
                    if (sender == null)
                        sender = getSender();
                    reply(null, true, PcConstants.REQUEST_CANCELED,
                            PcConstants.REQUEST_CANCELED, PcConstants.NA,
                            PcConstants.NA_INT, null);
                    break;

                case PROCESS_ON_EXCEPTION:

                    String errorSummary = PcErrorMsgUtils.replaceErrorMsg(cause
                            .toString());
                    String stackTrace = PcStringUtils.printStackTrace(cause);
                    cancelCancellable();
                    reply(null, true, errorSummary, stackTrace, PcConstants.NA,
                            PcConstants.NA_INT, null);

                    break;

                case PROCESS_ON_TIMEOUT:

                    getLogger().error("PROCESS_ON_TIMEOUT.................{}",
                            requestUrl);
                    cancelCancellable();

                    String errorMsg = String
                            .format("HttpWorker Timedout after %d SEC (no response but no exception catched). Check URL: may be very slow or stuck.",
                                    actorMaxOperationTimeoutSec);

                    reply(null, true, errorMsg, errorMsg, PcConstants.NA,
                            PcConstants.NA_INT, null);
                    break;

                case CHECK_FUTURE_STATE:
                default:
                    this.cause = new ActorMessageTypeInvalidException(
                            "ActorMessageTypeInvalidException error for url "
                                    + this.requestUrl);
                    getSelf().tell(RequestWorkerMsgType.PROCESS_ON_EXCEPTION,
                            getSelf());
                    break;
                }
            } else {
                unhandled(message);
                this.cause = new ActorMessageTypeInvalidException(
                        "ActorMessageTypeInvalidException error for url "
                                + this.requestUrl);
                getSelf().tell(RequestWorkerMsgType.PROCESS_ON_EXCEPTION,
                        getSelf());
            }
        } catch (Exception e) {
            this.cause = e;
            getSelf()
                    .tell(RequestWorkerMsgType.PROCESS_ON_EXCEPTION, getSelf());
        }
    }
966465
protected void notifyError(String message, Throwable error)
   {
      synchronized (listeners)
      {
         Thread notifier =
            new ErrorNotifyThread(listeners.toArray(new BackupJobListener[listeners.size()]), this, message, error);
         notifier.start();
      }
   }
1369284
@Override
  public void onException(Throwable failureCause) {
    Preconditions.checkNotNull(failureCause, "failureCause");
    Status status = Status.UNAVAILABLE.withCause(failureCause);
    startGoAway(0, ErrorCode.INTERNAL_ERROR, status);
  }
678688
public static void sendExceptionToClient(Throwable throwable, String probeId,
                                             Conversation conversation, int requestNumber) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "sendExceptionToClient",
                        new Object[]
                        {
                         throwable,
                         probeId,
                         conversation,
                         requestNumber
                        });

        CommsByteBuffer buffer = poolManager.allocate();
        buffer.putException(throwable, probeId, conversation);
        // defect 99984 checking whether jmsServer feature is intact or its removed 
        if (CommsServerServiceFacade.getJsAdminService() != null)
        {
            try {
                conversation.send(buffer,
                                  JFapChannelConstants.SEG_EXCEPTION,
                                  requestNumber,
                                  JFapChannelConstants.PRIORITY_MEDIUM,
                                  true,
                                  ThrottlingPolicy.BLOCK_THREAD,
                                  null);
            } catch (SIException c) {
                FFDCFilter.processException(c, CLASS_NAME + ".sendExceptionToClient",
                                            CommsConstants.STATICCATHELPER_SEND_EXCEP_01);

                SibTr.error(tc, "COMMUNICATION_ERROR_SICO2023", c);
            }
        }
        else
        {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.entry(tc, "conversation send is not being called as jmsadminService is null");
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "sendExceptionToClient");
    }
1009526
synchronized void error(@NotNull Exception e) {
        if (isFinished) {
            throw new RuntimeException("Promise already completed!");
        }
        if (e == null) {
            throw new RuntimeException("Error can't be null");
        }
        isFinished = true;
        exception = e;
        deliverResult();
    }
539433
private void sendNotification(Sid accountId, String errMessage, int errCode, String errType, boolean createNotification) {
        NotificationsDao notifications = storage.getNotificationsDao();
        Notification notification;

        if (errType == "warning") {
            if (logger.isDebugEnabled()) {
                // https://github.com/RestComm/Restcomm-Connect/issues/1419 moved to debug to avoid polluting logs
                logger.debug(errMessage); // send message to console
            }
            if (createNotification) {
                notification = notification(accountId, ERROR_NOTIFICATION, errCode, errMessage);
                notifications.addNotification(notification);
            }
        } else if (errType == "error") {
            // https://github.com/RestComm/Restcomm-Connect/issues/1419 moved to debug to avoid polluting logs
            if (logger.isDebugEnabled()) {
                logger.debug(errMessage); // send message to console
            }
            if (createNotification) {
                notification = notification(accountId, ERROR_NOTIFICATION, errCode, errMessage);
                notifications.addNotification(notification);
            }
        } else if (errType == "info") {
            // https://github.com/RestComm/Restcomm-Connect/issues/1419 moved to debug to avoid polluting logs
            if (logger.isDebugEnabled()) {
                logger.debug(errMessage); // send message to console
            }
        }

    }
824230
private void notifyFlusherException(Throwable t) {
		if (flusherException == null) {
			LOG.error("An exception happened while flushing the outputs", t);
			flusherException = t;
		}
	}
358452
public final void notifyReceiveExclusiveChange(boolean newValue)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "notifyReceiveExclusiveChange", new Boolean(newValue));
    boolean notifyConsumers = true;
    synchronized (consumerPoints)
    {
      _cardinalityOne = newValue;
      _cardinalityChange = true;

      if (consumerPoints.size() == 0)
      {
        notifyConsumers = false;
      }
      // since we have set cardinalityChange to true, we will not allow any more consumers till we have
      // finished processing the cardinality change
    }

    // if there were consumers, we tell the CD to close all consumers.
    if (notifyConsumers)
      super.closeAllConsumersForReceiveExclusive();
    else
    {
      // all consumers are gone so finish processing the cardinality change
      // NOTE: this causes us to flush the stream.
      // Any outstanding transactions will rollback
      try
      {
        cardinalityChangeConsumersDetached();
      }
      catch(SIResourceException e)
      {
        // Exception shouldn't occur so FFDC and rethrow as runtime exception
        FFDCFilter.processException(
          e,
          "com.ibm.ws.sib.processor.impl.RemoteConsumerDispatcher.notifyReceiveExclusiveChange",
          "1:203:1.75",
          this);

        SIErrorException e2 =
          new SIErrorException(
            nls.getFormattedMessage(
              "INTERNAL_MESSAGING_ERROR_CWSIP0002",
              new Object[] { "com.ibm.ws.sib.processor.impl.RemoteConsumerDispatcher.notifyReceiveExclusiveChange",
                             "1:211:1.75",
                             e },
              null));

        SibTr.exception(tc, e);
        SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002",
          new Object[] {
            "com.ibm.ws.sib.processor.impl.RemoteConsumerDispatcher.notifyReceiveExclusiveChange",
            "1:219:1.75",
            e });
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "notifyReceiveExclusiveChange", e2);
        throw e2;
      }
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "notifyReceiveExclusiveChange");
  }
157740
public void queueErrorOccurredInvocation(Connection connection,
                                               ConversationReceiveListener listener,
                                               SIConnectionLostException exception,
                                               int segmentType,
                                               int requestNumber,
                                               int priority,
                                               Conversation conversation)
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "queueErrorOccurredInvocation", new Object[] {connection, listener, exception, ""+segmentType, ""+requestNumber, ""+priority, conversation});

      AbstractInvocation invocation =
         allocateErrorOccurredInvocation(connection,
                                         listener,
                                         exception,
                                         segmentType,
                                         requestNumber,
                                         priority,
                                         conversation);

      // Start F201521
      // We don't always want to queue this as it could end up on some random thread.
      // As such, ask the conversation how many things it has left to process - if that
      // is 0, then queue it - otherwise, save it in the Conversation so that the last
      // thread working on that Conversatioon will invoke it.
      ConversationImpl convImpl = (ConversationImpl) conversation;

      int conversationRequestCount = 0;
      // Start D262285
      boolean queueIt = true;
      synchronized (convImpl.getTotalOutstandingRequestCountLock())
      {
         if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Queueing a errorOccurred invocation for ", conversation);
         conversationRequestCount = convImpl.getTotalOutstandingRequestCount();
         if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Request count is: " + conversationRequestCount);

         if (conversationRequestCount != 0)
         {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Count != 0, saving");
            convImpl.setErrorOccurredInvocation(invocation);
            queueIt = false;
         }
      }

      if (queueIt)
      {
         if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Count = 0, queueing");
         queueInvocationCommon(invocation, convImpl);
      }
      // End D262285
      // End F201521

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "queueErrorOccurredInvocation");
   }
1290049
public void warn(Object message, Throwable exception) {
        log(Level.WARNING, String.valueOf(message), exception);
    }