List of usage examples for java.lang Throwable getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.telefonica.euro_iaas.paasmanager.manager.async.impl.ProductInstanceAsyncManagerImpl.java
private void updateErrorTask(Task task, String message, Throwable t) { TaskError error = new TaskError(message); error.setMajorErrorCode(t.getMessage()); error.setMinorErrorCode(t.getClass().getSimpleName()); task.setEndTime(new Date()); task.setStatus(TaskStates.ERROR);/* ww w . j a v a2s.co m*/ task.setError(error); taskManager.updateTask(task); log.info("An error occurs while executing a product action. See task " + task.getHref() + "for more information"); }
From source file:com.alliander.osgp.acceptancetests.devicemanagement.RemoveDeviceSteps.java
@DomainStep("no oslp message should be sent to device (.*)") public boolean thenNoOslpMessageShouldBeSent(final String device) { LOGGER.info("THEN: no oslp message should be sent to device {}.", device); try {//from w w w . j a v a 2 s .c om verify(this.channelMock, 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.RemoveDeviceSteps.java
@DomainStep("the device (.*) should be removed (.*)") public boolean thenTheDeviceShouldBeRemoved(final String device, final Boolean removed) { LOGGER.info("THEN: the device {} should be removed: {}.", device, removed); try {//from w w w. ja va2 s . c o m final int count = removed ? 1 : 0; verify(this.deviceRepositoryMock, times(count)).delete(this.device); } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); return false; } return true; }
From source file:es.fcs.batch.integration.chunk.GenericChunkProcessorChunkHandler.java
/** * //from w w w. j a v a2 s . com * @see ChunkHandler#handleChunk(ChunkRequest) */ @ServiceActivator public ChunkResponse handleChunk(ChunkRequest<S> cRequest) throws Exception { MyChunkRequest<S> chunkRequest = (MyChunkRequest<S>) cRequest; logger.debug("Handling chunk: " + chunkRequest); StepContribution stepContribution = chunkRequest.getStepContribution(); Throwable failure = process(chunkRequest, stepContribution); if (failure != null) { logger.debug("Failed chunk", failure); return new ChunkResponse(false, chunkRequest.getJobId(), stepContribution, failure.getClass().getName() + ": " + failure.getMessage()); } logger.debug("Completed chunk handling with " + stepContribution); return new ChunkResponse(true, chunkRequest.getJobId(), stepContribution); }
From source file:com.alliander.osgp.acceptancetests.devicemanagement.RemoveDeviceSteps.java
@DomainStep("(.*) authorisations for device (.*) should be removed (.*)") public boolean thenTheAuthorizationsForTheDeviceShouldBeRemoved(final Integer numberOfAuthorizations, final String device, final Boolean removed) { LOGGER.info("THEN: {} authorizations for device {} should be removed: {}.", new Object[] { numberOfAuthorizations, device, removed }); try {/*ww w . java2s . c o m*/ final int count = removed ? numberOfAuthorizations : 0; verify(this.deviceAuthorizationRepositoryMock, times(count)).delete(any(DeviceAuthorization.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.RemoveDeviceSteps.java
@DomainStep("(.*) events for device (.*) should be removed (.*)") public boolean thenTheEventsForTheDeviceShouldBeRemoved(final Integer numberOfEvents, final String device, final Boolean removed) { LOGGER.info("THEN: {} events for device {} should be removed: {}.", new Object[] { numberOfEvents, device, removed }); try {//from w ww . ja v a2s. co m final int count = removed ? numberOfEvents : 0; verify(this.eventRepositoryMock, times(count)).delete(any(Event.class)); } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); return false; } return true; }
From source file:com.telefonica.euro_iaas.paasmanager.manager.async.impl.TierInstanceAsyncManagerImpl.java
private void updateErrorTask(Task task, String message, Throwable t) { TaskError error = new TaskError(message); error.setMajorErrorCode(t.getMessage()); error.setMinorErrorCode(t.getClass().getSimpleName()); task.setEndTime(new Date()); task.setStatus(TaskStates.ERROR);/*from ww w .jav a 2s.c om*/ task.setError(error); taskManager.updateTask(task); log.info("An error occurs while executing an Tier Instance action. See task " + task.getHref() + " for more information " + message); }
From source file:co.elastic.tealess.SSLChecker.java
private void checkHandshake(SSLReport sslReport, SocketChannel socket) { final InetSocketAddress address = sslReport.getAddress(); final String name = sslReport.getHostname(); IOObserver ioObserver = new IOObserver(); ObservingSSLEngine sslEngine = new ObservingSSLEngine(ctx.createSSLEngine(name, address.getPort()), ioObserver);//from www.ja v a 2 s .c o m sslReport.setIOObserver(ioObserver); sslEngine.setUseClientMode(true); try { sslEngine.beginHandshake(); } catch (SSLException e) { sslReport.setFailed(e); Throwable cause = Blame.get(e); logger.warn("beginHandshake failed: [{}] {}", cause.getClass(), cause.getMessage()); } // TODO: Is this enough bytes? int size = sslEngine.getSession().getApplicationBufferSize() * 2; ByteBuffer localText = ByteBuffer.allocate(size); ByteBuffer localWire = ByteBuffer.allocate(size); ByteBuffer peerText = ByteBuffer.allocate(size); ByteBuffer peerWire = ByteBuffer.allocate(size); // TODO: I wonder... do we need to send any data at all? localText.put("SSL TEST. HELLO.".getBytes()); localText.flip(); SSLEngineResult result; logger.info("Starting SSL handshake [{}] ", address); try { SSLEngineResult.HandshakeStatus state; state = sslEngine.getHandshakeStatus(); while (state != FINISHED) { // XXX: Use a Selector to wait for data. //logger.trace("State: {} [{}]", state, address); switch (state) { case NEED_TASK: sslEngine.getDelegatedTask().run(); state = sslEngine.getHandshakeStatus(); break; case NEED_WRAP: localWire.clear(); result = sslEngine.wrap(localText, localWire); state = result.getHandshakeStatus(); localWire.flip(); while (localWire.hasRemaining()) { socket.write(localWire); //logger.trace("Sent {} bytes [{}]", bytes, address); } localWire.compact(); break; case NEED_UNWRAP: // Try reading until we get data. Selector selector = Selector.open(); while (peerWire.position() == 0) { socket.read(peerWire); try { Thread.currentThread().sleep(5); } catch (InterruptedException e) { e.printStackTrace(); } } System.out.println("Read " + peerWire.position() + " bytes"); peerWire.flip(); result = sslEngine.unwrap(peerWire, peerText); state = result.getHandshakeStatus(); peerWire.compact(); break; } } } catch (IOException e) { sslReport.setFailed(e); sslReport.setSSLSession(sslEngine.getHandshakeSession()); sslReport.setPeerCertificateDetails(peerCertificateDetails); logger.warn("beginHandshake failed", e); return; } logger.info("handshake completed [{}]", address); // Handshake OK! sslReport.setSSLSession(sslEngine.getSession()); }
From source file:co.runrightfast.core.application.event.AppEvent.java
private void addException(final JsonObjectBuilder json) { if (exception != null) { final JsonObjectBuilder exBuilder = Json.createObjectBuilder() .add("class", exception.getClass().getName()) .add("stacktrace", ExceptionUtils.getStackTrace(exception)); final Throwable rootCause = ExceptionUtils.getRootCause(exception); if (rootCause != null) { exBuilder.add("rootCause", rootCause.getClass().getName()); }/*from ww w . j av a 2 s. c om*/ json.add("exception", exBuilder); } }
From source file:net.solarnetwork.node.job.AbstractJob.java
/** * Helper method for logging a Throwable. * //from w w w . ja v a 2 s. c o m * @param e * the exception */ protected void logThrowable(Throwable e) { final String name = (getName() == null ? getClass().getSimpleName() : getName()); Throwable root = e; while (root.getCause() != null) { root = root.getCause(); } final Object[] logParams; if (log.isDebugEnabled()) { // include stack trace with log message in Debug logParams = new Object[] { root.getClass().getSimpleName(), name, e.toString(), e }; } else { logParams = new Object[] { root.getClass().getSimpleName(), name, e.getMessage() }; } log.error("{} in job {}: {}", logParams); }