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.text.BoilerpipeTextExtractor.java

@Override
public String getPlaintext(final String htmltext) {
    try {//from  ww w .j  av a  2 s .c o m
        String plaintext = ArticleExtractor.getInstance().getText(htmltext);
        return plaintext;
    } catch (Throwable t) {
        for (int i = 1; t != null && i < 10; i++) {
            LOG.log(Level.SEVERE,
                    String.format("Failed to get plaintext from while '%s' (%d %s:%s).",
                            StringUtils.abbreviate(htmltext, 100), i, t.getClass().getName(), t.getMessage()),
                    t);
            t = t.getCause();
        }
        return "Failed to get plaintext content \n" + htmltext;
    }
}

From source file:com.netflix.spectator.nflx.ChronosGcEventListener.java

private void sendToChronos(final byte[] json, final boolean blocking) {
    final URI uri = URI.create(CHRONOS_URI.get());

    final CountDownLatch latch = new CountDownLatch(1);
    final long start = System.nanoTime();
    rxHttp.postJson(uri, json).subscribe(new Action1<HttpClientResponse<ByteBuf>>() {
        @Override//from  ww w  . j  a v  a 2  s .  co m
        public void call(HttpClientResponse<ByteBuf> response) {
            final int code = response.getStatus().code();
            if (code != 200) {
                logger.warn("failed to send GC event to chronos (status={})", code);
            }
            final long latency = System.nanoTime() - start;
            final Id timerId = requestCount.withTag("status", "" + code);
            registry.timer(timerId).record(latency, TimeUnit.NANOSECONDS);
        }
    }, new Action1<Throwable>() {
        @Override
        public void call(Throwable t) {
            logger.warn("failed to send GC event to chronos", t);
            final String status = t.getClass().getSimpleName();
            final long latency = System.nanoTime() - start;
            final Id timerId = requestCount.withTag("status", status);
            registry.timer(timerId).record(latency, TimeUnit.NANOSECONDS);
            latch.countDown();
        }
    }, new Action0() {
        @Override
        public void call() {
            latch.countDown();
        }
    });

    // Used for unit tests so we can reliably detect completion
    if (blocking) {
        try {
            latch.await();
        } catch (InterruptedException e) {
            // Ignore
        }
    }
}

From source file:com.brightcove.zartan.common.verifier.VideoResponse.java

/**
 * @return true only if all renditions were successfully deleted
 * @throws Throwable//w  w  w  .  j  av a2 s  .c  om
 */
public boolean deleteDownloadedRenditions(List<Throwable> throwables) throws Throwable {
    boolean anyFailed = false;

    for (String localPath : renditionFiles.values()) {
        try {
            anyFailed = ((!new File(localPath).delete()) || anyFailed);
        } catch (Throwable t) {
            mLog.error("Downloaded rendition file " + localPath
                    + " failed to get deleted, because an instance of " + t.getClass() + " was thrown. ", t);
            throwables.add(t);
        }
    }

    return (!anyFailed);
}

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

@DomainStep("the device's key should be updated to (.*)")
public boolean thenTheDeviceKeyShouldBeUpdatedTo(final String key) {
    LOGGER.info("THEN: \"the device's key should be updated to {}\".", key);

    try {//  w  ww .  j  a v a2  s . co m
        final ArgumentCaptor<OslpDevice> argument = ArgumentCaptor.forClass(OslpDevice.class);

        verify(this.oslpDeviceRepositoryMock, timeout(10000).times(1)).save(argument.capture());

        Assert.assertEquals("Device identifications should match", this.device.getDeviceIdentification(),
                argument.getValue().getDeviceIdentification());
        Assert.assertEquals("Device keys should match", key, argument.getValue().getPublicKey());

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

    return true;
}

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

@DomainStep("a device should be created with (.*) and (.*)")
public boolean thenADeviceShouldBeCreatedWith(final String device, final String key) {
    LOGGER.info("THEN: \"the device should be created with {} and {}\".", device, key);

    try {// www. ja v a  2  s .  co m
        final ArgumentCaptor<OslpDevice> argument = ArgumentCaptor.forClass(OslpDevice.class);

        verify(this.oslpDeviceRepositoryMock, timeout(10000).times(1)).save(argument.capture());

        Assert.assertEquals("Device identifications should match", device,
                argument.getValue().getDeviceIdentification());
        Assert.assertEquals("Device keys should match", key, argument.getValue().getPublicKey());

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

    return true;
}

From source file:hoptoad.HoptoadNoticeBuilder.java

private void errorClass(Throwable throwable) {
    Throwable cause = throwable;
    while (cause.getCause() != null) {
        cause = cause.getCause();/*from   www  .j a  v  a  2 s.co m*/
    }
    this.errorClass = cause.getClass().getName();
    if (StringUtils.trimToNull(errorMessage) == null) {
        errorMessage = '[' + throwable.getClass().toString() + ']';
    }
}

From source file:com.visual_tools.nubomedia.nuboEarJava.NuboEarJavaHandler.java

private void setVisualization(WebSocketSession session, JsonObject jsonObject) {

    try {//from   w  w w. j a v a  2  s  .c  o  m
        visualizeEar = jsonObject.get("val").getAsInt();
        if (null != ear) {
            System.out.println("Visuzlize Ear .... " + visualizeEar);
            ear.showEars(visualizeEar);
        }

    } catch (Throwable t) {
        error(session, t.getClass().getSimpleName() + ": " + t.getMessage());
    }
}

From source file:io.joynr.logging.DistributedLoggingAppender.java

/**
 * Pass of the logEvent to the manager, where it is written to the proxy
 *
 * @param event/*  w  w w .  j av  a  2s.  co m*/
 *            The LogEvent.
 */
@Override
public void append(final LogEvent event) {
    try {
        String message = new String(getLayout().toByteArray(event), "UTF-8");
        Throwable thrown = event.getThrown();
        JoynrLoggedError exception = null;
        if (thrown != null) {
            exception = new JoynrLoggedError(thrown.getClass().getName(), thrown.getMessage());
        }
        JoynrLogEvent logEvent = new JoynrLogEvent(event.getMillis(), "1", "host", event.getFQCN(), message,
                JoynrLogLevel.valueOf(event.getLevel().name()), exception, new JoynrLoggingContextTag[0]);
        manager.queue(logEvent);
    } catch (final Exception ex) {
        throw new AppenderLoggingException(ex);
    }
}

From source file:com.visual_tools.nubomedia.nuboEarJava.NuboEarJavaHandler.java

private void setScaleFactor(WebSocketSession session, JsonObject jsonObject) {

    try {//  w  ww  .ja  va  2s  .c  o m
        int scale = jsonObject.get("val").getAsInt();

        if (null != ear) {
            log.debug("Sending setscaleFactor...." + scale);
            ear.multiScaleFactor(scale);
        }

    } catch (Throwable t) {
        error(session, t.getClass().getSimpleName() + ": " + t.getMessage());
    }
}

From source file:com.visual_tools.nubomedia.nuboEarJava.NuboEarJavaHandler.java

private void setWidthToProcess(WebSocketSession session, JsonObject jsonObject) {

    try {//from  w  w w.  jav  a 2  s. c om
        int width = jsonObject.get("val").getAsInt();

        if (null != ear) {
            log.debug("Sending width...." + width);
            ear.widthToProcess(width);
        }

    } catch (Throwable t) {
        error(session, t.getClass().getSimpleName() + ": " + t.getMessage());
    }
}