List of usage examples for java.lang Throwable Throwable
public Throwable()
From source file:org.o3project.ocnrm.odenos.linklayerizer.LinkLayerizer.java
private boolean checkLayerizerEvent(String networkId, Link link) { logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " Start"); String type = conversionTable().getConnectionType(networkId); // check connection type if (!LAYERIZER.equals(type)) { logger.debug("type not layerizer."); return false; }/* w w w . java 2 s .c o m*/ // check upper has been registered if (!conversionTable().isConnectionType(UPPER)) { logger.debug("upper networkInterface Not found."); return false; } // check validate if (!link.validate()) { logger.debug("link validate Failure"); return false; } return true; }
From source file:org.o3project.ocnrm.odenos.linklayerizer.LinkLayerizer.java
@Override protected final Response onRequest(final Request request) { logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " Start"); logger.debug("received {}", request.path); RequestParser<IActionCallback>.ParsedRequest parsed = parser.parse(request); if (parsed == null) { return new Response(Response.BAD_REQUEST, "Error unknown request "); }//from w ww. jav a2 s.c o m IActionCallback callback = parsed.getResult(); if (callback == null) { return new Response(Response.BAD_REQUEST, "Error unknown request "); } try { return callback.process(parsed); } catch (Exception e) { logger.error("Error unknown request"); return new Response(Response.BAD_REQUEST, "Error unknown request "); } }
From source file:com.alipay.vbizplatform.web.controller.MyCarManageController.java
/** * ?/*from w w w. ja v a 2 s. c o m*/ * @param request * @param response * @return */ @RequestMapping("/addNewCarInfoAjax") public @ResponseBody Object addNewCarInfoAjax(HttpServletRequest request, HttpServletResponse response) { Map<String, String> pageParam = super.getParametersFromPage(request); Map<String, Object> vo = null; long startTime = System.currentTimeMillis(); String uId = null; Map<String, Object> map = new HashMap<String, Object>(); map.put("success", "false"); try { // 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; UserModel userModel = (UserModel) request.getSession() .getAttribute(Constant.ALIPAY_USER_SESSION_KEY); vo.put("uid", userModel.getUid()); if (pageParam.get("viNumber") != null) { vo.put("viNumber", URLDecoder.decode(pageParam.get("viNumber"), "UTF-8").toUpperCase()); } 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")); } // vo.put("viMileage", pageParam.get("viMileage")); // ? vo.put("viVin", pageParam.get("viVin").toUpperCase()); // ?? vo.put("engineNo", pageParam.get("engineNo").toUpperCase()); if (StringUtils.isNotEmpty(pageParam.get("sweptVolume"))) { //? vo.put("sweptVolume", URLDecoder.decode(pageParam.get("sweptVolume"), "UTF-8")); } // request.getSession().setAttribute("newVehicleModel", vo); this.spyMemcachedClient.set(vehicleModelKey, Constant.MEMCACHED_SAVETIME_24, vo); // 1?sofa? Map<String, String> resMap = myCarManageService.addVehicle(vo); if (resMap == null) {// ??? if (logger.isErrorEnabled()) { logger.error("????sofa?null"); } map.put("errorUrl", super.errorPageUrl("BUSY-ERR", "???", null, null)); return map; } else if (!Constant.SOFA_RETURN_CODE_SUCCESS.equals(resMap.get("returnCode"))) { String errorMsg = "?"; if ("11006".equals(resMap.get("returnCode"))) { errorMsg = ""; } if (logger.isErrorEnabled()) { logger.error( "????sofa??{} |??{}", resMap.get("returnCode"), resMap.get("returnDesc")); } logUtil.log(new Throwable(), "NEWCARINFO", uId, MethodCallResultEnum.EXCEPTION, null, "????", startTime); map.put("errorUrl", super.errorPageUrl("BUSY-ERR", errorMsg, null, null)); return map; } else { String backUrl = "/car/myCarList"; Object backObj = request.getSession().getAttribute("backUrl"); if (backObj != null) { backUrl = backObj.toString(); } request.setAttribute("backUrl", backUrl); logUtil.log(new Throwable(), "NEWCARINFO", uId, MethodCallResultEnum.SUCCESS, null, "?????", startTime); map.put("success", "true"); return map; } } else { // ? logUtil.log(new Throwable(), "NEWCARINFO", uId, MethodCallResultEnum.EXCEPTION, null, "????", startTime); map.put("errorUrl", super.errorPageUrl("BUSY-ERR", ",?", null, null)); return map; } } catch (Exception e) { if (logger.isErrorEnabled()) { logger.error("????", e); } logUtil.log(new Throwable(), "NEWCARINFO", uId, MethodCallResultEnum.EXCEPTION, null, "????", startTime); map.put("errorUrl", super.errorPageUrl("BUSY-ERR", "???", null, null)); return map; } }
From source file:org.o3project.ocnrm.odenos.linklayerizer.LinkLayerizer.java
private String postBoundary(String bodyInfo) throws Exception { logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " Start"); LinklayerizerBoundary boundary = createBoundary(new JSONObject(bodyInfo)); if (!checkBoundary(boundary)) { return "Undefined Boundary. NetworkID is Lower=" + boundary.getLower_nw() + " Upper=" + boundary.getUpper_nw(); }/*w w w . j a v a2 s .c om*/ boundaryset.putBoundary(boundary.getBoundary_id(), boundary); String rtnJsonVal = ""; try { ObjectMapper mapper = new ObjectMapper(); rtnJsonVal = mapper.writeValueAsString(boundary); logger.debug("jsonBoundary:" + rtnJsonVal); } catch (JsonProcessingException e) { e.printStackTrace(); logger.error("** Failed to postBoundary {}", bodyInfo); } logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " End"); return rtnJsonVal; }
From source file:com.buaa.cfs.security.UserGroupInformation.java
private void logPrivilegedAction(Subject subject, Object action) { if (LOG.isDebugEnabled()) { // would be nice if action included a descriptive toString() String where = new Throwable().getStackTrace()[2].toString(); LOG.debug("PrivilegedAction as:" + this + " from:" + where); }//w w w . j av a 2 s . c o m }
From source file:com.alipay.vbizplatform.web.controller.MyCarManageController.java
/** * ?/*from w ww .j a v a 2s . c om*/ * * @param request * @param response * @return */ @RequestMapping(value = "/myCarList") public String myCarList(HttpServletRequest request, HttpServletResponse response) { long startTime = System.currentTimeMillis(); String uId = null; try { // 1?session?? UserModel userModel = (UserModel) request.getSession().getAttribute(Constant.ALIPAY_USER_SESSION_KEY); uId = userModel.getUid(); // 2?? List<Map<String, Object>> vehicleList = myCarManageService.queryVehicleListByUid(uId); if (vehicleList == null || vehicleList.size() == 0) { return "page/cars/carsListNull"; } // ??24? spyMemcachedClient.set(uId + "_myCarList", Constant.MEMCACHED_SAVETIME_24, vehicleList); request.setAttribute("myCarList", vehicleList); } catch (Exception e) { if (logger.isErrorEnabled()) { logger.error("??", e); } logUtil.log(new Throwable(), "PORTAL", uId, MethodCallResultEnum.EXCEPTION, null, "??", startTime); super.redirectErrorPage("BUSY-ERR", "???", null, null, response); return null; } logUtil.log(new Throwable(), "PORTAL", uId, MethodCallResultEnum.SUCCESS, null, "???", startTime); return "page/cars/carsList"; }
From source file:com.atlassian.jira.ComponentManager.java
/** * Looks up a service from the OsgiContainerManager. This method should be avoided since it creates and closes a * new ServiceTracker each time it is called. * * @see JiraOsgiContainerManager#getOsgiComponentOfType(Class) *///from ww w .j a v a 2s. c o m private static <T> T getOsgiComponentOfType(@Nonnull Class<T> clazz, @Nonnull OsgiContainerManager osgiContainerManager) { if (log.isDebugEnabled()) { log.debug(String.format( "Using slow getOsgiComponentOfType() to get '%s'. COMPONENT MANAGER. Y U NO JiraOsgiContainerManager!?", clazz.getName()), new Throwable()); } ServiceTracker serviceTracker = osgiContainerManager.getServiceTracker(clazz.getName()); if (serviceTracker != null) { try { return clazz.cast(serviceTracker.getService()); } finally { serviceTracker.close(); } } return null; }
From source file:de.hybris.platform.test.TransactionTest.java
@Test public void testToException() { final ConsistencyCheckException businessExceptionSubClass = new ConsistencyCheckException("a", 0); final JaloBusinessException businessException = new JaloBusinessException("a", 0); final RuntimeException runtimeException = new RuntimeException(); final Exception exception = new Exception(); final Error error = new OutOfMemoryError(); final Throwable throwable = new Throwable(); //Business exception should be returned from the method {/*from w ww. j a v a 2s . co m*/ final JaloBusinessException result = Transaction.toException(businessException, JaloBusinessException.class); assertTrue(businessException == result); } //Subclass of business exception should be returned from the method (return type is the business exception) { final JaloBusinessException result = Transaction.toException(businessExceptionSubClass, JaloBusinessException.class); assertTrue(businessExceptionSubClass == result); } //This should not match and throw new RuntimeException { try { Transaction.toException(businessException, ConsistencyCheckException.class); } catch (final Throwable t) { assertEquals(RuntimeException.class, t.getClass()); assertTrue(businessException == t.getCause()); } } { try { Transaction.toException(runtimeException, JaloBusinessException.class); } catch (final Throwable t) { assertEquals(runtimeException, t); } } { try { Transaction.toException(exception, JaloBusinessException.class); } catch (final Throwable t) { assertEquals(RuntimeException.class, t.getClass()); assertTrue(exception == t.getCause()); } } { try { Transaction.toException(error, JaloBusinessException.class); } catch (final Throwable t) { assertEquals(error, t); } } { try { Transaction.toException(throwable, JaloBusinessException.class); } catch (final Throwable t) { assertEquals(RuntimeException.class, t.getClass()); assertTrue(throwable == t.getCause()); } } }
From source file:com.orange.cepheus.broker.controller.NgsiControllerTest.java
@Test public void postQueryContextWithExecutionException() throws Exception { //localRegistrations mock return always a providingApplication when(providingApplication.hasNext()).thenReturn(true); when(providingApplication.next()).thenReturn(new URI("http//iotagent:1234")); when(localRegistrations.findProvidingApplication(any(), any())).thenReturn(providingApplication); when(queryContextResponseListenableFuture.get()) .thenThrow(new ExecutionException("execution exception", new Throwable())); //ngsiclient mock return always createUpdateContextREsponseTemperature when call updateContext when(ngsiClient.queryContext(any(), any(), any())).thenReturn(queryContextResponseListenableFuture); mockMvc.perform(post("/v1/queryContext").content(json(mapper, createQueryContextTemperature())) .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) .andExpect(MockMvcResultMatchers.jsonPath("$.errorCode.code").value("500")) .andExpect(/*from ww w .ja v a2s.c o m*/ MockMvcResultMatchers.jsonPath("$.errorCode.reasonPhrase").value("Receiver internal error")) .andExpect(MockMvcResultMatchers.jsonPath("$.errorCode.details") .value("An unknown error at the receiver has occured")); }