Example usage for java.lang Throwable getClass

List of usage examples for java.lang Throwable getClass

Introduction

In this page you can find the example usage for java.lang Throwable getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:de.tudarmstadt.lt.ltbot.postprocessor.DecesiveValueProducerPerplexity.java

private boolean testStringProviderService() {
    try {/* www  . ja  v a2s  .  c  om*/
        computePerplexity("Hello Test Run run run run.");
    } catch (Throwable t) {
        for (int i = 1; t != null && i < 10; i++) {
            LOG.log(Level.SEVERE, String.format("Initialization test failed. (%d %s:%s)", i,
                    t.getClass().getSimpleName(), t.getMessage()), t);
            t = t.getCause();
        }
        return false;
    }
    LOG.info("Initialization test succeeded.");
    return true;
}

From source file:com.espertech.esper.core.service.StatementResultServiceImpl.java

private void dispatchInternal(UniformPair<EventBean[]> events) {
    if (statementResultNaturalStrategy != null) {
        statementResultNaturalStrategy.execute(events);
    }/*from w  w w  . j  a  v  a  2s.c om*/

    EventBean[] newEventArr = events != null ? events.getFirst() : null;
    EventBean[] oldEventArr = events != null ? events.getSecond() : null;

    for (UpdateListener listener : statementListenerSet.getListeners()) {
        try {
            listener.update(newEventArr, oldEventArr);
        } catch (Throwable t) {
            String message = "Unexpected exception invoking listener update method on listener class '"
                    + listener.getClass().getSimpleName() + "' : " + t.getClass().getSimpleName() + " : "
                    + t.getMessage();
            log.error(message, t);
        }
    }
    if (statementListenerSet.getStmtAwareListeners().length > 0) {
        for (StatementAwareUpdateListener listener : statementListenerSet.getStmtAwareListeners()) {
            try {
                listener.update(newEventArr, oldEventArr, epStatement, epServiceProvider);
            } catch (Throwable t) {
                String message = "Unexpected exception invoking listener update method on listener class '"
                        + listener.getClass().getSimpleName() + "' : " + t.getClass().getSimpleName() + " : "
                        + t.getMessage();
                log.error(message, t);
            }
        }
    }
    if ((AuditPath.isAuditEnabled) && (!statementOutputHooks.isEmpty())) {
        for (StatementResultListener listener : statementOutputHooks) {
            listener.update(newEventArr, oldEventArr, epStatement.getName(), epStatement, epServiceProvider);
        }
    }
}

From source file:com.alliander.osgp.acceptancetests.devicemanagement.SetEventNotificationsSteps.java

@DomainStep("the set event notifications request is received on OSGP")
public void whenTheSetEventNotificationsRequestIsReceived() {
    LOGGER.info("WHEN: \"the set event notifications request is received on OSGP\".");

    try {//from   www. j a  v a 2 s .  c om
        this.setEventNotificationsAsyncResponse = this.deviceManagementEndpoint
                .setEventNotifications(ORGANISATION_ID_OWNER, this.request);
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        this.throwable = t;
    }
}

From source file:de.micromata.genome.logging.LoggableExceptionHandlingUtil.java

/**
 * eats up an exception. Only use this if you know how to react to the exception
 *
 * @param loglevel how well is the reaction. overwrites captured loglevel may also be null to not overwrite
 * @param category overwrites captured category (old is saved in an attribute) may also be null to not overwrite
 * @param message overwrites captured logmessage (old is saved in an attribute) may also be null to not overwrite
 * @param e Exception to be logged. Is added to attributes by this method.
 * @param attributes additional params/*  w  w w  . jav a  2s.  c o m*/
 */
public static void logException(LogLevel loglevel, LogCategory category, String message, final Throwable e,
        LogAttribute... attributes) {
    if (e != null) {
        LogAttributeRuntimeException le = logFirstLoggableRuntimeExceptionOnCauseStack(loglevel, category,
                message, e, attributes);
        if (le == e) {
            return;
        }
    }
    if (category == null) {
        category = GenomeLogCategory.Coding;
    }
    if (loglevel == null) {
        loglevel = LogLevel.Warn;
    }
    if (message == null) {
        message = "null message";
    }
    boolean nestedInServletException = false;
    Throwable re = e;
    while (re instanceof ServletException) {
        nestedInServletException = true;
        Throwable cause = ((ServletException) re).getRootCause();
        if (cause == re) {
            re = null;
        } else {
            re = cause;
        }
    }
    if (re == null) {
        if (nestedInServletException == true) {
            re = e;
            nestedInServletException = false;
        }
    }
    if (re == null) {
        LoggingServiceManager.get().getLogging().doLog(loglevel, category, message);
        return;
    }
    if (nestedInServletException == true) {
        message = "Nested in " + e.getClass().getSimpleName() + ": " + message;
    }
    LoggingServiceManager.get().getLogging().doLog(loglevel, category, message,
            (LogAttribute[]) ArrayUtils.add(attributes, new LogExceptionAttribute(re)));
}

From source file:com.alliander.osgp.acceptancetests.schedulemanagement.SetTariffScheduleSteps.java

@DomainStep("a set tariff schedule oslp message is sent to device (.*) should be (.*)")
public boolean thenASetTariffScheduleOslpMessageShouldBeSent(final String deviceIdentification,
        final Boolean isMessageSent) {
    LOGGER.info("THEN: \"a set tariff schedule oslp message is sent to device [{}] should be [{}]\".",
            deviceIdentification, isMessageSent);

    final int count = isMessageSent ? 1 : 0;

    try {//from ww  w  .j  a v  a2 s .c o m
        final ArgumentCaptor<OslpEnvelope> argument = ArgumentCaptor.forClass(OslpEnvelope.class);
        verify(this.channelMock, timeout(10000).times(count)).write(argument.capture());

        if (isMessageSent) {
            this.oslpMessage = argument.getValue();

            Assert.assertTrue("Message should contain set schedule request.",
                    this.oslpMessage.getPayloadMessage().hasSetScheduleRequest());
        }
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }
    return true;
}

From source file:com.alliander.osgp.acceptancetests.devicemanagement.SetEventNotificationsSteps.java

@DomainStep("a set event notifications oslp message should be sent to device (.*)")
public boolean thenASetEventNotificationOslpMessageShouldBeSent(final String device) {
    LOGGER.info(// w  w  w .j a va 2  s . co m
            "THEN: \"a set event notifications oslp message should be sent to device (.*)\" with device [{}].",
            device);

    try {
        verify(this.channelMock, timeout(1000).times(1)).write(any(OslpEnvelope.class));
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }
    return true;
}

From source file:com.alliander.osgp.acceptancetests.devicemanagement.SetEventNotificationsSteps.java

@DomainStep("a set event notifications oslp message should not be sent to device (.*)")
public boolean thenASetEventNotificationOslpMessageShouldNotBeSent(final String device) throws Throwable {
    LOGGER.info(/*from   w w  w . j  av a  2s  . co m*/
            "THEN: \"a set event notifications oslp message should not be sent to device (.*)\" with device [{}].",
            device);

    try {
        verify(this.channelMock, timeout(1000).times(0)).write(any(OslpEnvelope.class));
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }
    return true;
}

From source file:com.alliander.osgp.acceptancetests.devicemanagement.SetEventNotificationsSteps.java

@DomainStep("the get set event notifications response request is received")
public void whenTheGetSetEventNotificationsResultRequestIsReceived() {
    LOGGER.info("WHEN: \"the set event notifications request is received\".");

    try {/*from  www .j av a2s  .co  m*/

        this.response = this.deviceManagementEndpoint.getSetEventNotificationsResponse(ORGANISATION_ID_OWNER,
                this.setEventNotificationsAsyncRequest);

    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        this.throwable = t;
    }
}

From source file:com.alliander.osgp.acceptancetests.schedulemanagement.SetTariffScheduleSteps.java

@DomainStep("an ovl set tariff schedule result message with result (.*) and description (.*) should be sent to the ovl out queue")
public boolean thenAnOvlSetTariffScheduleResultMessageShouldBeSentToTheOvlOutQueue(final String result,
        final String description) {
    LOGGER.info(/* w  w  w  . jav  a2s .c o m*/
            "THEN: \"an ovl set tariff schedule result message with result [{}] and description [{}] should be sent to the ovl out queue\".",
            result, description);

    try {
        final ArgumentCaptor<ResponseMessage> argument = ArgumentCaptor.forClass(ResponseMessage.class);
        verify(this.webServiceResponseMessageSenderMock, timeout(10000).times(1)).send(argument.capture());

        final String expected = result.equals("NULL") ? null : result;
        final String actual = argument.getValue().getResult().getValue();

        LOGGER.info("THEN: message description: " + (argument.getValue().getOsgpException() == null ? ""
                : argument.getValue().getOsgpException().getMessage()));

        Assert.assertTrue("Invalid result, found: " + actual + " , expected: " + expected,
                actual.equals(expected));
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }
    return true;
}

From source file:de.tudarmstadt.lt.ltbot.writer.PlainTextDocumentWriter.java

protected File updateOuputFile() throws IOException {
    File basedir = getPath().getFile();
    File out = _current_file;/*from   ww w .  j av  a2s.  c  om*/
    if (out == null || out.length() > _maxFileSizeBytes) {
        synchronized (_lck) {
            if (_current_stream != null)
                _current_stream.close();
            int not_ok_count = 0;
            while (not_ok_count > -1 && not_ok_count < 10) {
                for (++_num_current_file; out == null || out.exists(); ++_num_current_file) {
                    out = new File(basedir, getFilename());
                }
                _current_file = out;
                try {
                    _current_stream = openPrintToFileStream(_current_file);
                } catch (Throwable t) {
                    for (int i = 1; t != null && i < 10; i++) {
                        String message = String.format("Failed to open file for writing: '%s'. (%d %s:%s)",
                                _current_file.getAbsolutePath(), i, t.getClass().getSimpleName(),
                                t.getMessage());
                        LOG.log(Level.SEVERE, message, t);
                        t = t.getCause();
                    }
                    not_ok_count++;
                    if (not_ok_count >= 10)
                        throw new IOException(String.format(
                                "Failed to open file for writing: '%s'. I tried %d times but I give up now.",
                                _current_file.getAbsolutePath(), not_ok_count));
                    continue;
                }
                // break this loop, we're ok now
                not_ok_count = -1;
                break;
            }
        }
    }
    return out;
}