List of usage examples for java.lang Throwable fillInStackTrace
public synchronized Throwable fillInStackTrace()
From source file:Main.java
public static void main(String[] argv) { Throwable t = new Exception("from java2s.com"); t.fillInStackTrace(); }
From source file:org.codice.ddf.status.CpuService.java
static Map<String, Object> getCpuStatus() { Map<String, Object> obj = new LinkedHashMap<String, Object>(); Sigar sigar = null;//from w w w . ja va 2s. c om try { sigar = new Sigar(); // call it to make sure the library was loaded sigar.getPid(); org.hyperic.sigar.CpuInfo[] cpuinfo = null; try { cpuinfo = sigar.getCpuInfoList(); } catch (SigarException se) { se.printStackTrace(); } org.hyperic.sigar.CpuPerc[] cpuperc = null; try { cpuperc = sigar.getCpuPercList(); } catch (SigarException se) { se.printStackTrace(); } Map<String, Object> data = new LinkedHashMap<String, Object>(); for (int i = 0; i < cpuinfo.length; i++) { @SuppressWarnings("unchecked") Map<String, Object> cpu = cpuinfo[i].toMap(); cpu.put("User", cpuperc[i].getUser()); cpu.put("Sys", cpuperc[i].getSys()); data.put("CPU" + i, cpu); } obj.put("data", data); obj.put("type", "cpu"); obj.put("time", new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()).toString()); sigar.close(); } catch (Throwable t) { t.fillInStackTrace(); logger.log(Level.SEVERE, "Failed to load sigar", t); if (sigar != null) { try { sigar.close(); } catch (Throwable t1) { // ignore } finally { sigar = null; } } } return obj; }
From source file:mashup.fm.github.BaseService.java
/** * Define the url that will be inquired on the remote API service * /*from w w w . ja va 2 s .c o m*/ * @param url * the url * @param args * the args * @return the string */ private static String url(String url, String... args) { try { String u = String.format(url, args); String empty = ""; u = StringUtils.replace(u, String.valueOf('"'), empty); Logger.info("Github Url: %s", u); return u; } catch (Throwable t) { Logger.error(ExceptionUtil.getStackTrace(t)); throw new RuntimeException(t.fillInStackTrace()); } }
From source file:org.eclipse.epp.internal.logging.aeri.ui.log.StandInStacktraceProvider.java
public void insertStandInStacktraceIfEmpty(final Status status, ServerConfiguration configuration) { if (requiresStandInStacktrace(status)) { Throwable syntetic = new StandInException(STAND_IN_MESSAGE); syntetic.fillInStackTrace(); StackTraceElement[] stacktrace = syntetic.getStackTrace(); StackTraceElement[] clearedStacktrace = clearBlacklistedTopStackframes(stacktrace, Constants.STAND_IN_STACKTRACE_BLACKLIST); syntetic.setStackTrace(clearedStacktrace); status.setException(Reports.newThrowable(syntetic)); status.setFingerprint(computeFingerprintFor(status, configuration)); }/*from w w w . ja va 2s .c o m*/ }
From source file:net.kamhon.ieagle.aop.DwrDelegateAdvice.java
public void afterThrowing(Throwable throwable) { if (!(throwable instanceof ValidatorException)) { log.error(throwable, throwable.fillInStackTrace()); }//from w w w .j a va 2s . c om }
From source file:com.example.base.http.ResponseStream.java
public String readString() throws IOException { if (directResult != null) return directResult; if (baseStream == null) return null; try {//from w ww . j av a2 s . c o m BufferedReader reader = new BufferedReader(new InputStreamReader(baseStream, charset)); StringBuilder sb = new StringBuilder(); String line = ""; while ((line = reader.readLine()) != null) { sb.append(line); } directResult = sb.toString(); if (requestUrl != null) { //?? AppHttpClient.mHttpGetCache.put(requestUrl, directResult, expiry); } return directResult; } finally { if (baseStream != null) { try { baseStream.close(); } catch (Throwable e) { e.fillInStackTrace(); } } } }
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.simulator.viewcomponent.actions.RecreateDatabaseTask.java
@Override protected void failed(Throwable e) { String simpleMessage = "Error recreating database." + e.getMessage(); setMessage(simpleMessage);//from w w w. j av a 2 s .c o m applicationService.notifyError(simpleMessage, e, Level.WARNING); logger.warn(simpleMessage + "Nested exception is : " + e.fillInStackTrace().getMessage()); }
From source file:uk.nhs.cfh.dsp.srth.expression.repository.actions.core.PurgeTCTableTask.java
@Override protected void failed(Throwable e) { String simpleMessage = "Error transitive closure table"; setMessage(simpleMessage);//from w ww .ja v a 2 s.com applicationService.notifyError(simpleMessage, e, Level.WARNING); logger.warn(simpleMessage + "Nested exception is : " + e.fillInStackTrace().getMessage()); }
From source file:code.google.nfs.rpc.client.AbstractClient.java
private Object invokeSyncIntern(RequestWrapper wrapper) throws Exception { long beginTime = System.currentTimeMillis(); ArrayBlockingQueue<Object> responseQueue = new ArrayBlockingQueue<Object>(1); responses.put(wrapper.getId(), responseQueue); ResponseWrapper responseWrapper = null; try {/* www .j av a2 s . c o m*/ if (isDebugEnabled) { // for performance trace LOGGER.debug("client ready to send message,request id: " + wrapper.getId()); } getClientFactory().checkSendLimit(); sendRequest(wrapper, wrapper.getTimeout()); if (isDebugEnabled) { // for performance trace LOGGER.debug( "client write message to send buffer,wait for response,request id: " + wrapper.getId()); } } catch (Exception e) { responses.remove(wrapper.getId()); responseQueue = null; LOGGER.error("send request to os sendbuffer error", e); throw e; } Object result = null; try { result = responseQueue.poll(wrapper.getTimeout() - (System.currentTimeMillis() - beginTime), TimeUnit.MILLISECONDS); } catch (Exception e) { responses.remove(wrapper.getId()); LOGGER.error("Get response error", e); throw new Exception("Get response error", e); } responses.remove(wrapper.getId()); if (PRINT_CONSUME_MINTIME > 0 && isWarnEnabled) { long consumeTime = System.currentTimeMillis() - beginTime; if (consumeTime > PRINT_CONSUME_MINTIME) { LOGGER.warn("client.invokeSync consume time: " + consumeTime + " ms, server is: " + getServerIP() + ":" + getServerPort() + " request id is:" + wrapper.getId()); } } if (result == null) { String errorMsg = "receive response timeout(" + wrapper.getTimeout() + " ms),server is: " + getServerIP() + ":" + getServerPort() + " request id is:" + wrapper.getId(); throw new Exception(errorMsg); } if (result instanceof ResponseWrapper) { responseWrapper = (ResponseWrapper) result; } else if (result instanceof List) { @SuppressWarnings("unchecked") List<ResponseWrapper> responseWrappers = (List<ResponseWrapper>) result; for (ResponseWrapper response : responseWrappers) { if (response.getRequestId() == wrapper.getId()) { responseWrapper = response; } else { putResponse(response); } } } else { throw new Exception("only receive ResponseWrapper or List as response"); } try { // do deserialize in business threadpool if (responseWrapper.getResponse() instanceof byte[]) { String responseClassName = null; if (responseWrapper.getResponseClassName() != null) { responseClassName = new String(responseWrapper.getResponseClassName()); } // avoid server no return object if (((byte[]) responseWrapper.getResponse()).length == 0) { responseWrapper.setResponse(null); } else { Object responseObject = Codecs.getDecoder(responseWrapper.getCodecType()) .decode(responseClassName, (byte[]) responseWrapper.getResponse()); if (responseObject instanceof Throwable) { responseWrapper.setException((Throwable) responseObject); } else { responseWrapper.setResponse(responseObject); } } } } catch (Exception e) { LOGGER.error("Deserialize response object error", e); throw new Exception("Deserialize response object error", e); } if (responseWrapper.isError()) { Throwable t = responseWrapper.getException(); t.fillInStackTrace(); String errorMsg = "server error,server is: " + getServerIP() + ":" + getServerPort() + " request id is:" + wrapper.getId(); LOGGER.error(errorMsg, t); throw new Exception(errorMsg, t); } return responseWrapper.getResponse(); }
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.simulator.viewcomponent.actions.DeleteAllRecordsTask.java
@Override protected void failed(Throwable e) { String simpleMessage = "Error deleting records from database." + e.getMessage(); setMessage(simpleMessage);//ww w. j av a 2 s. c o m applicationService.notifyError(simpleMessage, e, Level.WARNING); logger.warn(simpleMessage + "Nested exception is : " + e.fillInStackTrace().getMessage()); }