List of usage examples for java.lang Throwable Throwable
public Throwable()
From source file:com.flexive.tests.browser.AbstractBackendBrowserTest.java
/** * a method every test should call if it decides to skip it self *///from w w w . j a v a2s .c om protected void skipMe() { Throwable t = new Throwable(); String s = t.getStackTrace()[1].toString(); skipList.add(s); }
From source file:org.o3project.ocnrm.odenos.driver.AbstractDriver.java
@Override protected boolean onFlowDeletePre(final String networkId, final Flow flow) { logger.debug(">> " + new Throwable().getStackTrace()[0].getMethodName()); logger.debug("network component ID : " + networkId); statusLog(flow);/*from ww w .j a v a2 s . com*/ if (networkId.equals(connectionIdMap.get(OCH_LAYER))) { return false; } statusLog(flow); return true; }
From source file:org.apache.hadoop.hbase.MiniHBaseCluster.java
/** * Do a simulated kill all masters and regionservers. Useful when it is * impossible to bring the mini-cluster back for clean shutdown. *///from ww w . j a va 2 s . c o m public void killAll() { for (RegionServerThread rst : getRegionServerThreads()) { rst.getRegionServer().abort("killAll"); } for (MasterThread masterThread : getMasterThreads()) { masterThread.getMaster().abort("killAll", new Throwable()); } }
From source file:hudson.FunctionsTest.java
@Issue("JDK-6507809") @Test//from w w w . j a v a 2 s . c o m public void printThrowable() throws Exception { // Basics: a single exception. No change. assertPrintThrowable(new Stack("java.lang.NullPointerException: oops", "p.C.method1:17", "m.Main.main:1"), "java.lang.NullPointerException: oops\n" + "\tat p.C.method1(C.java:17)\n" + "\tat m.Main.main(Main.java:1)\n", "java.lang.NullPointerException: oops\n" + "\tat p.C.method1(C.java:17)\n" + "\tat m.Main.main(Main.java:1)\n"); // try {} catch (Exception x) {throw new IllegalStateException(x);} assertPrintThrowable( new Stack("java.lang.IllegalStateException: java.lang.NullPointerException: oops", "p.C.method1:19", "m.Main.main:1") .cause(new Stack("java.lang.NullPointerException: oops", "p.C.method2:23", "p.C.method1:17", "m.Main.main:1")), "java.lang.IllegalStateException: java.lang.NullPointerException: oops\n" + "\tat p.C.method1(C.java:19)\n" + "\tat m.Main.main(Main.java:1)\n" + "Caused by: java.lang.NullPointerException: oops\n" + "\tat p.C.method2(C.java:23)\n" + "\tat p.C.method1(C.java:17)\n" + "\t... 1 more\n", "java.lang.NullPointerException: oops\n" + "\tat p.C.method2(C.java:23)\n" + "\tat p.C.method1(C.java:17)\n" + "Caused: java.lang.IllegalStateException\n" + "\tat p.C.method1(C.java:19)\n" + "\tat m.Main.main(Main.java:1)\n"); // try {} catch (Exception x) {throw new IllegalStateException("more info");} assertPrintThrowable( new Stack("java.lang.IllegalStateException: more info", "p.C.method1:19", "m.Main.main:1") .cause(new Stack("java.lang.NullPointerException: oops", "p.C.method2:23", "p.C.method1:17", "m.Main.main:1")), "java.lang.IllegalStateException: more info\n" + "\tat p.C.method1(C.java:19)\n" + "\tat m.Main.main(Main.java:1)\n" + "Caused by: java.lang.NullPointerException: oops\n" + "\tat p.C.method2(C.java:23)\n" + "\tat p.C.method1(C.java:17)\n" + "\t... 1 more\n", "java.lang.NullPointerException: oops\n" + "\tat p.C.method2(C.java:23)\n" + "\tat p.C.method1(C.java:17)\n" + "Caused: java.lang.IllegalStateException: more info\n" + "\tat p.C.method1(C.java:19)\n" + "\tat m.Main.main(Main.java:1)\n"); // try {} catch (Exception x) {throw new IllegalStateException("more info: " + x);} assertPrintThrowable( new Stack("java.lang.IllegalStateException: more info: java.lang.NullPointerException: oops", "p.C.method1:19", "m.Main.main:1") .cause(new Stack("java.lang.NullPointerException: oops", "p.C.method2:23", "p.C.method1:17", "m.Main.main:1")), "java.lang.IllegalStateException: more info: java.lang.NullPointerException: oops\n" + "\tat p.C.method1(C.java:19)\n" + "\tat m.Main.main(Main.java:1)\n" + "Caused by: java.lang.NullPointerException: oops\n" + "\tat p.C.method2(C.java:23)\n" + "\tat p.C.method1(C.java:17)\n" + "\t... 1 more\n", "java.lang.NullPointerException: oops\n" + "\tat p.C.method2(C.java:23)\n" + "\tat p.C.method1(C.java:17)\n" + "Caused: java.lang.IllegalStateException: more info\n" + "\tat p.C.method1(C.java:19)\n" + "\tat m.Main.main(Main.java:1)\n"); // Synthetic stack showing an exception made elsewhere, such as happens with hudson.remoting.Channel.attachCallSiteStackTrace. Throwable t = new Stack("remote.Exception: oops", "remote.Place.method:17", "remote.Service.run:9"); StackTraceElement[] callSite = new Stack("wrapped.Exception", "local.Side.call:11", "local.Main.main:1") .getStackTrace(); StackTraceElement[] original = t.getStackTrace(); StackTraceElement[] combined = new StackTraceElement[original.length + 1 + callSite.length]; System.arraycopy(original, 0, combined, 0, original.length); combined[original.length] = new StackTraceElement(".....", "remote call", null, -2); System.arraycopy(callSite, 0, combined, original.length + 1, callSite.length); t.setStackTrace(combined); assertPrintThrowable(t, "remote.Exception: oops\n" + "\tat remote.Place.method(Place.java:17)\n" + "\tat remote.Service.run(Service.java:9)\n" + "\tat ......remote call(Native Method)\n" + "\tat local.Side.call(Side.java:11)\n" + "\tat local.Main.main(Main.java:1)\n", "remote.Exception: oops\n" + "\tat remote.Place.method(Place.java:17)\n" + "\tat remote.Service.run(Service.java:9)\n" + "\tat ......remote call(Native Method)\n" + "\tat local.Side.call(Side.java:11)\n" + "\tat local.Main.main(Main.java:1)\n"); // Same but now using a cause on the remote side. t = new Stack("remote.Wrapper: remote.Exception: oops", "remote.Place.method2:19", "remote.Service.run:9") .cause(new Stack("remote.Exception: oops", "remote.Place.method1:11", "remote.Place.method2:17", "remote.Service.run:9")); callSite = new Stack("wrapped.Exception", "local.Side.call:11", "local.Main.main:1").getStackTrace(); original = t.getStackTrace(); combined = new StackTraceElement[original.length + 1 + callSite.length]; System.arraycopy(original, 0, combined, 0, original.length); combined[original.length] = new StackTraceElement(".....", "remote call", null, -2); System.arraycopy(callSite, 0, combined, original.length + 1, callSite.length); t.setStackTrace(combined); assertPrintThrowable(t, "remote.Wrapper: remote.Exception: oops\n" + "\tat remote.Place.method2(Place.java:19)\n" + "\tat remote.Service.run(Service.java:9)\n" + "\tat ......remote call(Native Method)\n" + "\tat local.Side.call(Side.java:11)\n" + "\tat local.Main.main(Main.java:1)\n" + "Caused by: remote.Exception: oops\n" + "\tat remote.Place.method1(Place.java:11)\n" + "\tat remote.Place.method2(Place.java:17)\n" + "\tat remote.Service.run(Service.java:9)\n", "remote.Exception: oops\n" + "\tat remote.Place.method1(Place.java:11)\n" + "\tat remote.Place.method2(Place.java:17)\n" + "\tat remote.Service.run(Service.java:9)\n" + // we do not know how to elide the common part in this case "Caused: remote.Wrapper\n" + "\tat remote.Place.method2(Place.java:19)\n" + "\tat remote.Service.run(Service.java:9)\n" + "\tat ......remote call(Native Method)\n" + "\tat local.Side.call(Side.java:11)\n" + "\tat local.Main.main(Main.java:1)\n"); // Suppressed exceptions: assertPrintThrowable( new Stack("java.lang.IllegalStateException: java.lang.NullPointerException: oops", "p.C.method1:19", "m.Main.main:1") .cause(new Stack("java.lang.NullPointerException: oops", "p.C.method2:23", "p.C.method1:17", "m.Main.main:1")) .suppressed( new Stack("java.io.IOException: could not close", "p.C.close:99", "p.C.method1:18", "m.Main.main:1"), new Stack("java.io.IOException: java.lang.NullPointerException", "p.C.flush:77", "p.C.method1:18", "m.Main.main:1") .cause(new Stack("java.lang.NullPointerException", "p.C.findFlushee:70", "p.C.flush:75", "p.C.method1:18", "m.Main.main:1"))), "java.lang.IllegalStateException: java.lang.NullPointerException: oops\n" + "\tat p.C.method1(C.java:19)\n" + "\tat m.Main.main(Main.java:1)\n" + "\tSuppressed: java.io.IOException: could not close\n" + "\t\tat p.C.close(C.java:99)\n" + "\t\tat p.C.method1(C.java:18)\n" + "\t\t... 1 more\n" + "\tSuppressed: java.io.IOException: java.lang.NullPointerException\n" + "\t\tat p.C.flush(C.java:77)\n" + "\t\tat p.C.method1(C.java:18)\n" + "\t\t... 1 more\n" + "\tCaused by: java.lang.NullPointerException\n" + "\t\tat p.C.findFlushee(C.java:70)\n" + "\t\tat p.C.flush(C.java:75)\n" + "\t\t... 2 more\n" + "Caused by: java.lang.NullPointerException: oops\n" + "\tat p.C.method2(C.java:23)\n" + "\tat p.C.method1(C.java:17)\n" + "\t... 1 more\n", "java.lang.NullPointerException: oops\n" + "\tat p.C.method2(C.java:23)\n" + "\tat p.C.method1(C.java:17)\n" + "Also: java.io.IOException: could not close\n" + "\t\tat p.C.close(C.java:99)\n" + "\t\tat p.C.method1(C.java:18)\n" + "Also: java.lang.NullPointerException\n" + "\t\tat p.C.findFlushee(C.java:70)\n" + "\t\tat p.C.flush(C.java:75)\n" + "\tCaused: java.io.IOException\n" + "\t\tat p.C.flush(C.java:77)\n" + "\t\tat p.C.method1(C.java:18)\n" + "Caused: java.lang.IllegalStateException\n" + "\tat p.C.method1(C.java:19)\n" + "\tat m.Main.main(Main.java:1)\n"); // Custom printStackTrace implementations: assertPrintThrowable(new Throwable() { @Override public void printStackTrace(PrintWriter s) { s.println("Some custom exception"); } }, "Some custom exception\n", "Some custom exception\n"); // Circular references: Stack stack1 = new Stack("p.Exc1", "p.C.method1:17"); Stack stack2 = new Stack("p.Exc2", "p.C.method2:27"); stack1.cause(stack2); stack2.cause(stack1); assertPrintThrowable(stack1, "p.Exc1\n" + "\tat p.C.method1(C.java:17)\n" + "Caused by: p.Exc2\n" + "\tat p.C.method2(C.java:27)\n" + "\t[CIRCULAR REFERENCE:p.Exc1]\n", "<cycle to p.Exc1>\n" + "Caused: p.Exc2\n" + "\tat p.C.method2(C.java:27)\n" + "Caused: p.Exc1\n" + "\tat p.C.method1(C.java:17)\n"); }
From source file:com.mylikes.likes.etchasketch.Slate.java
public void commitStroke() { if (mTiledCanvas == null) { final Throwable e = new Throwable(); e.fillInStackTrace();/*w ww. j av a 2s . com*/ Log.v(TAG, "commitStroke before mTiledCanvas inited", e); return; } mTiledCanvas.commit(); }
From source file:com.krawler.esp.servlets.importProjectPlanCSV.java
private String doImport(HttpServletRequest request, Connection conn) throws SessionExpiredException, ServiceException, IOException, JSONException { String contentType = request.getContentType(); CsvReader csvReader = null;//ww w .j a va 2 s . com String header = ""; FileInputStream fstream = null; try { if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) { String fileid = UUID.randomUUID().toString(); String f1 = uploadDocument(request, fileid); if (f1.length() != 0) { String destinationDirectory = StorageHandler.GetDocStorePath() + StorageHandler.GetFileSeparator() + "importplans"; File csv = new File(destinationDirectory + StorageHandler.GetFileSeparator() + f1); fstream = new FileInputStream(csv); csvReader = new CsvReader(new InputStreamReader(fstream)); csvReader.readRecord(); int i = 0; while (!(StringUtil.isNullOrEmpty(csvReader.get(i)))) { header += "{\"header\":\"" + csvReader.get(i) + "\",\"index\":" + i + "},"; i++; } header = header.substring(0, header.length() - 1); header = "{\"success\": true,\"FileName\":\"" + f1 + "\",\"Headers\":[" + header + "]}"; String fileName = request.getParameter("realfilename"); String userid = AuthHandler.getUserid(request); String companyid = AuthHandler.getCompanyid(request); String projectid = request.getParameter("projectid"); int c = ImportLogHandler.insertImportLog(conn, fileid, fileName, f1, "CSV", "", "Project plan", userid, companyid, projectid, "", "pm.common.projectplan"); if (c != 1) throw ServiceException.FAILURE("Failed to insert log", new Throwable()); // e.g. Header= "{'Task Name':0,'Start Date':1,'End Date':2,'Proirity':3,'Percent Completed':4,'Notes':5}"; } } } catch (FileNotFoundException ex) { Logger.getLogger(importProjectPlanCSV.class.getName()).log(Level.SEVERE, null, ex); } catch (ConfigurationException ex) { KrawlerLog.op.warn("Problem Storing Data In DB [importProjectPlanCSV.storeInDB()]:" + ex); throw ServiceException.FAILURE("importProjectPlanCSV.getfile", ex); } finally { if (csvReader != null) csvReader.close(); if (fstream != null) fstream.close(); } return header; }
From source file:org.apache.hadoop.hdfs.server.balancer.TestBalancer.java
private static int runBalancer(Collection<URI> namenodes, final Parameters p, Configuration conf) throws IOException, InterruptedException { final long sleeptime = conf.getLong(DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY, DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_DEFAULT) * 2000 + conf.getLong(DFSConfigKeys.DFS_NAMENODE_REPLICATION_INTERVAL_KEY, DFSConfigKeys.DFS_NAMENODE_REPLICATION_INTERVAL_DEFAULT) * 1000; LOG.info("namenodes = " + namenodes); LOG.info("parameters = " + p); LOG.info("Print stack trace", new Throwable()); System.out.println(// w w w . jav a 2 s . c o m "Time Stamp Iteration# Bytes Already Moved Bytes Left To Move Bytes Being Moved"); List<NameNodeConnector> connectors = Collections.emptyList(); try { connectors = NameNodeConnector.newNameNodeConnectors(namenodes, Balancer.class.getSimpleName(), Balancer.BALANCER_ID_PATH, conf, Balancer.Parameters.DEFAULT.maxIdleIteration); boolean done = false; for (int iteration = 0; !done; iteration++) { done = true; Collections.shuffle(connectors); for (NameNodeConnector nnc : connectors) { final Balancer b = new Balancer(nnc, p, conf); final Result r = b.runOneIteration(); r.print(iteration, System.out); // clean all lists b.resetData(conf); if (r.exitStatus == ExitStatus.IN_PROGRESS) { done = false; } else if (r.exitStatus != ExitStatus.SUCCESS) { //must be an error statue, return. return r.exitStatus.getExitCode(); } else { if (iteration > 0) { assertTrue(r.bytesAlreadyMoved > 0); } } } if (!done) { Thread.sleep(sleeptime); } } } finally { for (NameNodeConnector nnc : connectors) { IOUtils.cleanup(LOG, nnc); } } return ExitStatus.SUCCESS.getExitCode(); }
From source file:com.machinepublishers.jbrowserdriver.diagnostics.Test.java
private static String testLabel(String result, int curTest, Throwable throwable) { String stackTrace = throwable == null ? "" : " -- " + toString(throwable); StackTraceElement[] elements = throwable == null ? new Throwable().getStackTrace() : throwable.getStackTrace(); String testLocation = ""; for (int i = 0; i < elements.length; i++) { if (Test.class.getName().equals(elements[i].getClassName()) && "doTests".equals(elements[i].getMethodName())) { testLocation = elements[i].toString(); break; }/*from w ww . j a v a2 s . co m*/ } return "Test #" + curTest + " " + result + " -- " + testLocation + stackTrace; }
From source file:com.alipay.vbizplatform.web.controller.MyCarManageController.java
/** * ?//from w ww .j a v a 2s . c o m * @param request * @param response * @return */ @RequestMapping("/queryCarYear") public String queryCarYear(HttpServletRequest request, HttpServletResponse response) { logger.info("uid={},class={},method=queryCarYear,desc=", super.getUserInfo(request).getUid(), this.getClass().getName()); Map<String, String> pageParam = super.getParametersFromPage(request); //? Map<String, Object> vo = null; // Map<String, Map> vehicleTypeListMap = null; long startTime = System.currentTimeMillis(); String uId = null; try { //1?session?? // Object obj = request.getSession().getAttribute("newVehicleModel"); uId = super.getUserInfo(request).getUid(); String vehicleModelKey = uId + VEHICLE_MODEL_KEY_PREFIX; Object obj = spyMemcachedClient.get(vehicleModelKey); if (obj != null) { vo = (HashMap<String, Object>) obj; /*****???vo******/ if (StringUtils.isNotEmpty(pageParam.get("viStartTime"))) {// vo.put("viStartTime", DateUtil.parserDateFromString(pageParam.get("viStartTime"), DateUtil.DATEFORMAT5)); } if (StringUtils.isNotEmpty(pageParam.get("vlCityId"))) {// vo.put("vlCityId", pageParam.get("vlCityId")); } if (StringUtils.isNotEmpty(pageParam.get("vlCityName"))) {// ?? vo.put("vlCityName", URLDecoder.decode(pageParam.get("vlCityName"), "UTF-8")); } if (StringUtils.isNotEmpty(pageParam.get("viMileage"))) {// vo.put("viMileage", pageParam.get("viMileage")); } if (StringUtils.isNotEmpty(pageParam.get("viVin"))) {// ? vo.put("viVin", pageParam.get("viVin").toUpperCase()); } // request.getSession().setAttribute("newVehicleModel", vo); this.spyMemcachedClient.set(vehicleModelKey, Constant.MEMCACHED_SAVETIME_24, vo); // ?? request.setAttribute("brandName", vo.get("viBrandName")); request.setAttribute("carSeriesName", vo.get("viSeriesName")); if (StringUtils.isNotEmpty(ObjectUtil.toString(vo.get("viLogoUrl")))) { request.setAttribute("modPicUrl", vo.get("viLogoUrl")); } else { request.setAttribute("modPicUrl", vo.get("viBrandLogo")); } request.setAttribute("sweptVolume", pageParam.get("sweptVolume")); request.setAttribute("viId", vo.get("viId")); request.setAttribute("upst", pageParam.get("upst")); } else { // ? if (logger.isErrorEnabled()) { logger.error("session??,toPage->/page/cars/carsList.jsp"); } logUtil.log(new Throwable(), "CARYEAR", uId, MethodCallResultEnum.EXCEPTION, null, "session??,", startTime); return "redirect:/car/myCarList"; } // // 1???? vehicleTypeListMap = myCarManageService.getVehiclesNow(String.valueOf(vo.get("manufacturer")), String.valueOf(vo.get("viSeriesName"))); //mapset List<String> carYearList = null; if (vehicleTypeListMap != null && !vehicleTypeListMap.isEmpty()) { Map<String, Object> YearNode = vehicleTypeListMap .get(URLDecoder.decode(pageParam.get("sweptVolume"), "UTF-8")); carYearList = new ArrayList<String>(); if (null != YearNode) { for (Map.Entry<String, Object> entry : YearNode.entrySet()) { carYearList.add(entry.getKey()); } } request.setAttribute("carYearList", carYearList); request.setAttribute("collapseFlag", pageParam.get("collapseFlag")); } } catch (Exception e) { if (logger.isErrorEnabled()) { logger.error("??", e); } logUtil.log(new Throwable(), "CARYEAR", uId, MethodCallResultEnum.EXCEPTION, null, "??", startTime); super.redirectErrorPage("BUSY-ERR", "??", null, null, response); return null; } logUtil.log(new Throwable(), "CARYEAR", uId, MethodCallResultEnum.SUCCESS, null, "???", startTime); return "page/cars/selectCarvProductionDate"; }
From source file:org.o3project.ocnrm.odenos.driver.AbstractDriver.java
protected boolean onLinkUpdatePre(final String networkId, final Link prev, final Link curr, final ArrayList<String> attributesList) { logger.debug(">> " + new Throwable().getStackTrace()[0].getMethodName() + "Start"); if (curr.getAttribute(AttrElements.ESTABLISHMENT_STATUS) == null) { logger.debug("This link's status is null."); logger.debug(">> " + new Throwable().getStackTrace()[0].getMethodName() + "End"); return false; }/* w w w. j av a 2 s. c o m*/ logger.debug("link staus: " + curr.getAttribute(AttrElements.ESTABLISHMENT_STATUS)); logger.debug(">> " + new Throwable().getStackTrace()[0].getMethodName() + "End"); return true; }