List of usage examples for java.lang Throwable Throwable
public Throwable(String message, Throwable cause)
From source file:Main.java
public static void main(String[] argv) { Throwable t = new Exception("from java2s.com"); Throwable tNew = new Throwable("from java2s.com", t); }
From source file:com.lipy.android.http.exception.ActionException.java
public static Throwable handleException(java.lang.Throwable e) { Log.e("Novate", e.getMessage()); Throwable ex;//w ww . j av a2s . com if (e instanceof HttpException) { HttpException httpException = (HttpException) e; ex = new Throwable(e, ERROR.HTTP_ERROR); switch (httpException.code()) { case UNAUTHORIZED: ex.setMessage("?"); case FORBIDDEN: ex.setMessage("?"); case NOT_FOUND: ex.setMessage("??"); case REQUEST_TIMEOUT: ex.setMessage(""); case GATEWAY_TIMEOUT: ex.setMessage("?"); case INTERNAL_SERVER_ERROR: ex.setMessage("?"); case BAD_GATEWAY: ex.setMessage(""); case SERVICE_UNAVAILABLE: ex.setMessage("???"); case ACCESS_DENIED: ex.setMessage(""); case HANDEL_ERRROR: ex.setMessage("??"); default: ex.setMessage(e.getMessage()); break; } ex.setCode(httpException.code()); return ex; } else if (e instanceof ServerException) { ServerException resultException = (ServerException) e; ex = new Throwable(resultException, resultException.code); ex.setMessage(resultException.getMessage()); return ex; } else if (e instanceof JsonParseException || e instanceof JSONException || e instanceof ParseException) { ex = new Throwable(e, ERROR.PARSE_ERROR); ex.setMessage("?"); return ex; } else if (e instanceof ConnectException) { ex = new Throwable(e, ERROR.NETWORD_ERROR); ex.setMessage(""); return ex; } else if (e instanceof javax.net.ssl.SSLHandshakeException) { ex = new Throwable(e, ERROR.SSL_ERROR); ex.setMessage("??"); return ex; } else if (e instanceof java.security.cert.CertPathValidatorException) { ex = new Throwable(e, ERROR.SSL_NOT_FOUND); ex.setMessage("?"); return ex; } else if (e instanceof ConnectTimeoutException) { ex = new Throwable(e, ERROR.TIMEOUT_ERROR); ex.setMessage(""); return ex; } else if (e instanceof java.net.SocketTimeoutException) { ex = new Throwable(e, ERROR.TIMEOUT_ERROR); ex.setMessage(""); return ex; } else if (e instanceof ClassCastException) { ex = new Throwable(e, ERROR.FORMAT_ERROR); ex.setMessage("?"); return ex; } else if (e instanceof NullPointerException) { ex = new Throwable(e, ERROR.NULL); ex.setMessage("?"); return ex; } else if (e instanceof FormatException) { FormatException resultException = (FormatException) e; ex = new Throwable(resultException, resultException.code); ex.setMessage(resultException.message); return ex; } else { ex = new Throwable(e, ERROR.UNKNOWN); ex.setMessage(e.getLocalizedMessage()); return ex; } }
From source file:fi.jumi.core.api.StackTraceTest.java
@Test public void causes_are_also_copied_recursively() { Throwable original = new Throwable("original message", new Exception("the cause")); StackTrace copy = StackTrace.from(original); assertThat(copy.getCause(), is(instanceOf(StackTrace.class))); assertThat(copy.getCause().getMessage(), is("the cause")); }
From source file:mod.rankshank.arbitraria.client.texture.TextureTiled.java
@Override public void loadTexture(IResourceManager resourceManager) throws IOException { this.deleteGlTexture(); IResource iresource = null;//w w w. j a va2 s. c om try { iresource = resourceManager.getResource(tileSource); BufferedImage img = TextureUtil.readBufferedImage(iresource.getInputStream()); boolean blur = false; boolean clamp = false; if (iresource.hasMetadata()) { try { TextureMetadataSection texturemetadatasection = iresource.getMetadata("texture"); if (texturemetadatasection != null) { blur = texturemetadatasection.getTextureBlur(); clamp = texturemetadatasection.getTextureClamp(); } } catch (RuntimeException runtimeexception) { Arbitraria.error(new Throwable( String.format("Issue loading tiled texture for %s, aborting", tileSource.toString()), runtimeexception)); } } int width = img.getWidth(); int height = img.getHeight(); if (width != height) { Arbitraria.error(new Throwable(String.format("Tiled image failed for %s [Width = %s, Height = %s", tileSource, width, height))); return; } int factor = targetTile / width; BufferedImage finalImg = new BufferedImage(width * factor, height * factor, img.getType()); int num = 0; for (int i = 0; i < factor; i++) { for (int j = 0; j < factor; j++) { finalImg.createGraphics().drawImage(img, width * j, height * i, null); num++; } } TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), finalImg, blur, clamp); } finally { IOUtils.closeQuietly(iresource); } }
From source file:com.xwiki.authentication.sts.XWikiSTSAuthenticator.java
/** * showLogin - Makes appropriate url and sends request to the STS (Security Token Service) * and gets response with xwiki methods. * /*from www . j a v a 2 s . c om*/ * @param context XWikiContext - context - to make request and show login * @throws XWikiException java.lang.Object extended by java.lang.Throwable </br> extended by java.lang.Exception extended by com.xpn.xwiki.XWikiException */ @Override public void showLogin(XWikiContext context) throws XWikiException { log.trace("showLogin()"); XWikiRequest request = context.getRequest(); try { DefaultBootstrap.bootstrap(); } catch (ConfigurationException e) { log.error("Failed to bootstrap sts module" + e); errorCollector.addError(new Throwable("Failed to bootstrap sts module: ", e)); } // STS provider URL String url = props.getAuthURL(context) + "?wa=wsignin1.0"; // Request realm String wtrealm = props.getWtrealm(context); if (wtrealm != null && wtrealm != "") url += "&wtrealm=" + escapeHtml(wtrealm); // Request ID String wctx = props.getWctx(context); if (wctx != null && "1".equals(wctx)) { String randId = RandomStringUtils.randomAlphanumeric(42); log.debug("Request ID: " + randId); request.getSession().setAttribute("saml_id", randId); url += "&wctx=" + randId; } // Host is set manually, because XWiki is behind proxy server // and simple XWiki.getRequestURL(request) returns localhost String wreplyHost = props.getWreplyHost(context); String wreplyPage = props.getWreplyPage(context); String page = "/"; if (wreplyHost != null && !"0".equals(wreplyHost)) { if ("1".equals(wreplyPage) || "shorten".equals(wreplyPage)) { page = request.getParameter("xredirect"); if (page != null) log.trace("Got xrecdirect to: " + page); else page = XWiki.getRequestURL(request).getFile(); if ("shorten".equals(wreplyPage)) { // change reply address if URL shortening is used page = page.replace("/xwiki/bin/view/", "/"); page = page.replace("/WebHome", "/"); } log.trace("Reply page: " + page); } url += "&wreply=" + escapeHtml(wreplyHost + page); } request.getSession().setAttribute("saml_url", wreplyHost + page); // Auth request time String wct = props.getWct(context); if (wct != null && "1".equals(wct)) { SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT")); wct = dateFormatGmt.format(new Date()); url += "&wct=" + wct; } // maximum age of authentication String wfresh = props.getWfresh(context); if (wfresh != null && wfresh != "" && Integer.parseInt(wfresh) > 0) { url += "&wfresh=" + wfresh; } // Send request to the STS service log.info("SAML STS request sent to " + url); try { context.getResponse().sendRedirect(url); context.setFinished(true); } catch (Exception e) { log.debug("Cannot call sendRedirect() after the response has been committed: " + e); } }
From source file:com.brightcove.test.upload.MediaAPIcreateVideoParameterizedIntegrationTest.java
@Ignore("Until BC-24245 gets fixed") @Test/* ww w. ja v a2s. c o m*/ public void createVideo_funnyFilenames() throws Throwable, MediaAPIError, URISyntaxException, JSONException, BadEnvironmentException { try { for (Account a : mAccountHelper.getAllAccounts()) { uploadViaAPIandCheckExists(a, mVideoFile); } } catch (AssertionError ae) { AssertionError parameterizedAssertionError = new AssertionError( "Caught AssertionError for parameterized case: mRenamedFilename = " + mRenamedFilename); parameterizedAssertionError.initCause((AssertionError) ae); throw parameterizedAssertionError; } catch (Throwable t) { throw new Throwable("Caught throwable for parameterized case: mRenamedFilename = " + mRenamedFilename, t); } }
From source file:org.dita.dost.AbstractIntegrationTest.java
protected File run() throws Throwable { final File testDir = Paths.get("src", "test", "resources", name).toFile(); final File srcDir = new File(testDir, SRC_DIR); final File outDir = new File(baseTempDir, testDir.getName() + File.separator + "out"); final File tempDir = new File(baseTempDir, testDir.getName() + File.separator + "temp"); final ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String>builder(); args.forEach((k, v) -> {// w ww . j a v a 2 s . c o m if (v instanceof Path) { builder.put(k, new File(srcDir, v.toString()).getAbsolutePath()); } else if (v instanceof String) { builder.put(k, v.toString()); } else { throw new IllegalArgumentException(); } }); builder.put("args.input", new File(srcDir, input.toFile().toString()).getAbsolutePath()); final Map<String, String> params = builder.build(); try { this.log = runOt(testDir, transtype, tempDir, outDir, params, targets); assertEquals("Warn message count does not match expected", warnCount, countMessages(log, Project.MSG_WARN)); assertEquals("Error message count does not match expected", errorCount, countMessages(log, Project.MSG_ERR)); this.actDir = transtype.compareTemp ? tempDir : outDir; } catch (final RuntimeException e) { throw e; } catch (final Throwable e) { if (log != null && level >= 0) { outputLog(log); } throw new Throwable("Case " + testDir.getName() + " failed: " + e.getMessage(), e); } return new File(actDir, transtype.name); }
From source file:com.xwiki.authentication.sts.XWikiSTSAuthenticator.java
/** * checkSTSResponse - Check Response of (Security Token Service) * This method is trying to create document using XWikiContext context argument and checking is it done or not? * @param context XWikiContext - XWikiContext to check is it have right data * @return boolen - true - if check - ok, false - fault to create doc from test data etc. * @throws XWikiException java.lang.Object extended by java.lang.Throwable </br> extended by java.lang.Exception extended by com.xpn.xwiki.XWikiException * @throws ConfigurationException//from w w w. j a v a 2 s .co m */ public boolean checkSTSResponse(XWikiContext context) throws XWikiException { // read from STSResponse log.trace("checkSTSResponse()"); XWikiRequest request = context.getRequest(); Map<String, String> attributes = new HashMap<String, String>(); String authType = ""; try { Enumeration<String> headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); log.trace(headerName + ": " + request.getHeader(headerName)); } Enumeration<String> paramNames = request.getParameterNames(); while (paramNames.hasMoreElements()) { String paramName = paramNames.nextElement(); log.trace(paramName + ": " + request.getParameter(paramName)); } } catch (Exception e) { log.error("Failed to read request headers or parameters: " + e); errorCollector.addError(new Throwable("Failed to read request headers or parameters: ", e)); } String stsResponse = request.getParameter("wresult"); if (stsResponse == null) { log.debug("Didn't get wresult from request!"); log.error(errorCollector.listErrors()); errorCollector.clearErrorList(); return false; } log.debug("\n***** STS Response: *****\n" + stsResponse + "\n*****"); HttpServletRequest myRequest = context.getRequest().getHttpServletRequest(); try { log.debug("request.getParameter('wresult') is " + myRequest.getParameter("wresult")); log.debug("request.getParameter('wct') is " + myRequest.getParameter("wct")); log.debug("request.getParameter('wctx') is " + myRequest.getParameter("wctx")); log.debug("request.getParameter('wa') is " + myRequest.getParameter("wa")); } catch (Exception e) { log.error("Failed to read response request parameters" + e); errorCollector.addError(new Throwable("Failed to read response request parameters: ", e)); } // Get Context ID from the user session String prevId = (String) request.getSession().getAttribute("saml_id"); String curId = myRequest.getParameter("wctx"); String wctx = props.getWctx(context); // Check response and token if (wctx != null && "1".equals(wctx)) { try { // Check token validity if (!prevId.equals(curId)) { log.debug("Retrieved wctx parameter value doesn't match passed value. Passed: " + prevId + " retrieved: " + curId); return false; } STSTokenValidator validator = new STSTokenValidator(); validator.setSTSErrorCollector(errorCollector); validator.setContext(prevId); // Get parameters from Xwiki configuration validator.setIssuer(props.getIssuer(context)); log.debug("props.getIssuer(context) " + props.getIssuer(context)); log.debug("checkSTSResponse(props.getIssuer(context)) " + props.getIssuer(context)); STSTokenValidator.setEntityId(props.getEntityId(context)); validator.setIssuerDN(props.getIssuerDN(context)); List<String> subjectDNs = new ArrayList<String>(); subjectDNs.add(props.getSubjectDNs(context)); validator.setSubjectDNs(subjectDNs); List<URI> audienceURIs = new ArrayList<URI>(); audienceURIs.add(new URI(props.getAudienceURIs(context))); validator.setAudienceUris(audienceURIs); String wct = props.getWct(context); validator.setCertificate(props.getCertificate(context)); // If time control is set, use time validation if (wct != null && "1".equals(wct)) { int maxClockSkew = Integer.parseInt(props.getWfresh(context)) * 60 * 1000; validator.setMaxClockSkew(maxClockSkew); validator.setValidateExpiration(true); } else validator.setValidateExpiration(false); List<STSClaim> claims = validator.validate(myRequest.getParameter("wresult")); log.trace("Token claims: " + claims); } catch (Exception e) { // as validator returns validation errors as exceptions // log them only in debug mode log.error("Failed to validate token\n" + e); errorCollector.addError(new Throwable("Failed to validate token: ", e)); return false; } try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(new ByteArrayInputStream(stsResponse.getBytes("utf-8"))); doc.getDocumentElement().normalize(); log.debug("Root element:" + doc.getDocumentElement().getNodeName()); NodeList nodeList = doc.getElementsByTagName("saml:Attribute"); log.debug("Node list length:" + nodeList.getLength()); // Process all attributes for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); String attrName = node.getAttributes().getNamedItem("AttributeName").getTextContent(); String attrValue = node.getChildNodes().item(0).getTextContent(); // CAPITAL if ("CAPITAL".equals(props.getDataFormat(context))) attrValue = attrValue.toUpperCase(); // Title if ("Title".equals(props.getDataFormat(context))) attrValue = attrValue.substring(0, 1).toUpperCase() + ((attrValue.length() > 1) ? attrValue.substring(1).toLowerCase() : ""); log.debug("Node:" + attrName + ", value:" + attrValue); attributes.put(attrName, attrValue); } // get authentication method (should be known for legal reasons) authType = doc.getElementsByTagName("saml:AuthenticationStatement").item(0).getAttributes() .getNamedItem("AuthenticationMethod").getNodeValue(); } catch (Exception e) { log.error("Failed reading STS response\n" + e); errorCollector.addError(new Throwable("Failed reading STS response: ", e)); return false; } } else { log.warn("Response and token were not validated! To validate, set xwiki.authentication.sts.wctx=1"); } // let's map the data Map<String, String> userData = getExtendedInformation(attributes, context); String personID = attributes.get(props.getIdField(context)); // set conventional person code format for NORDEA, PAREX, SEB banks String person_ID; if (personID != null && personID.indexOf('-') < 0 && personID.length() == 11) { person_ID = personID.substring(0, 6) + "-" + personID.substring(6); log.debug("Changed person ID from " + personID + " to " + person_ID); } else person_ID = personID; log.debug("STS person ID is " + person_ID); log.debug("STS attributes are " + attributes); log.debug("STS user data are " + userData); // Get STSAuthClass ID field from configuration file (for backward // compatibility) // TODO should change nameid to personid for all XWiki solutions String stsAuthClassIdField = props.getStsAuthClassIdField(context); String sql = "select distinct doc.fullName from XWikiDocument as doc, BaseObject as obj, StringProperty as nameidprop where" + " doc.fullName=obj.name and obj.className='XWiki.STSAuthClass' and obj.id=nameidprop.id.id and nameidprop.id.name='" + stsAuthClassIdField + "' and nameidprop.value='" + person_ID + "'"; log.debug("XWiki search SQL string: " + sql); List<Object> list = context.getWiki().search(sql, context); String validFullUserName = null; String validUserName = null; if (list.isEmpty()) { // User does not exist. Let's generate a unique page name log.debug("Did not find XWiki User. Generating it."); String userName = generateXWikiUsername(userData, context); if ("".equals(userName)) userName = "User"; validUserName = context.getWiki().getUniquePageName("XWiki", userName, context); validFullUserName = "XWiki." + validUserName; log.debug("Generated XWiki User Name " + validFullUserName); } else { validFullUserName = (String) list.get(0); log.debug("Found XWiki User " + validFullUserName); } // we found a user or generated a unique user name if (validFullUserName != null) { // check if we need to create/update a user page String database = context.getDatabase(); try { // Switch to main wiki to force users to be global users context.setDatabase(context.getMainXWiki()); // test if user already exists if (!context.getWiki().exists(validFullUserName, context)) { log.debug("Need to create user " + validFullUserName); // create user userData.put("active", "1"); int result = context.getWiki().createUser(validUserName, userData, "XWiki.XWikiUsers", "#includeForm(\"XWiki.XWikiUserSheet\")", "edit", context); if (result < 0) { log.error("Failed to create user " + validFullUserName + " with code " + result); errorCollector.addError(new Throwable("Failed to create user: ")); return false; } XWikiDocument userDoc = context.getWiki().getDocument(validFullUserName, context); BaseObject userObj = userDoc.getObject("XWiki.XWikiUsers"); // Fix bug for e-mail field where "$email" value is set on // creation userObj.set("email", "", context); // set user profile to read only with explicit view to not // allow // changing his // name, surname and password BaseObject rightsObj = userDoc.getObject("XWiki.XWikiRights", 1); rightsObj.set("allow", 1, context); rightsObj.set("levels", "view", context); // set person ID and authentication type BaseObject stsObj = userDoc.newObject("XWiki.STSAuthClass", context); stsObj.set("nameid", person_ID, context); stsObj.set("authtype", authType, context); context.getWiki().saveDocument(userDoc, context); log.info("New user " + validFullUserName + " has been successfully created. Nameid: " + person_ID + " authtype: " + authType); } else { XWikiDocument userDoc = context.getWiki().getDocument(validFullUserName, context); BaseObject userObj = userDoc.getObject("XWiki.XWikiUsers"); boolean updated = false; for (Map.Entry<String, String> entry : userData.entrySet()) { String field = entry.getKey(); String value = entry.getValue(); BaseProperty prop = (BaseProperty) userObj.get(field); String currentValue = (prop == null || prop.getValue() == null) ? null : prop.getValue().toString(); if (value != null && !value.equals(currentValue)) { userObj.set(field, value, context); updated = true; } } BaseObject stsObj = userDoc.getObject("XWiki.STSAuthClass"); BaseProperty prop = (BaseProperty) stsObj.get("authtype"); String currenAuthType = prop.getValue().toString(); log.debug("currenAuthType: " + currenAuthType); if (!authType.equals(currenAuthType)) { stsObj.set("authtype", authType, context); updated = true; } if (updated) { context.getWiki().saveDocument(userDoc, context); log.info("Existing user " + validFullUserName + " has been successfully updated. Nameid: " + person_ID + " authtype: " + authType); } else log.info("Existing user " + validFullUserName + " was found. Properties were not changed. Nameid: " + person_ID + " authtype: " + authType); } } catch (Exception e) { log.error("Failed to create user " + validFullUserName + "\n" + e); errorCollector.addError(new Throwable("Failed to create user: ", e)); return false; } finally { context.setDatabase(database); } } log.debug("Setting authentication in session for user " + validFullUserName); // mark that we have authenticated the user in the session context.getRequest().getSession().setAttribute(props.getAuthField(context), validFullUserName); // need to redirect now String sourceurl = (String) request.getSession().getAttribute("saml_url"); log.debug("Redirecting after valid authentication to " + sourceurl); try { context.getResponse().sendRedirect(sourceurl); context.setFinished(true); return true; } catch (Exception e) { log.error("Failed to redirect after authentication\n" + e); errorCollector.addError(new Throwable("Failed to redirect after authentication: ", e)); } return false; }
From source file:org.dita.dost.AbstractIntegrationTest.java
@Deprecated protected void test(final String name) throws Throwable { final File testDir = Paths.get("src", "test", "resources", name).toFile(); final File expDir = new File(testDir, EXP_DIR); final File actDir = new File(baseTempDir, testDir.getName() + File.separator + "testresult"); List<TestListener.Message> log = null; try {/*from www .ja v a2 s .co m*/ log = run(testDir, expDir.list(), actDir); compare(expDir, actDir); } catch (final RuntimeException e) { throw e; } catch (final Throwable e) { if (log != null && level >= 0) { outputLog(log); } throw new Throwable("Case " + testDir.getName() + " failed: " + e.getMessage(), e); } }
From source file:org.apache.hadoop.mapred.TaskRunner.java
@Override public final void run() { String errorInfo = "Child Error"; try {/*from w ww . j ava2s . c o m*/ //before preparing the job localize //all the archives TaskAttemptID taskid = t.getTaskID(); final LocalDirAllocator lDirAlloc = new LocalDirAllocator("mapred.local.dir"); //simply get the location of the workDir and pass it to the child. The //child will do the actual dir creation final File workDir = new File( new Path(localdirs[rand.nextInt(localdirs.length)], TaskTracker.getTaskWorkDir(t.getUser(), taskid.getJobID().toString(), taskid.toString(), t.isTaskCleanupTask())).toString()); String user = tip.getUGI().getUserName(); // Set up the child task's configuration. After this call, no localization // of files should happen in the TaskTracker's process space. Any changes to // the conf object after this will NOT be reflected to the child. // setupChildTaskConfiguration(lDirAlloc); if (!prepare()) { return; } // Accumulates class paths for child. List<String> classPaths = getClassPaths(conf, workDir, taskDistributedCacheManager); long logSize = TaskLog.getTaskLogLength(conf); // Build exec child JVM args. Vector<String> vargs = getVMArgs(taskid, workDir, classPaths, logSize); boolean mapUseAffinity = conf.getBoolean("maptask.affinity.enable", false); boolean reduceTaskUseAffinity = conf.getBoolean("reducetask.affinity.enable", false); if (mapUseAffinity || reduceTaskUseAffinity) { int cpuCount = conf.getInt("cpu.count", 1); int corePerCpu = conf.getInt("core.per.cpu", 1); int id = t.getTaskID().getTaskID().getId(); LOG.info("cpu count: " + cpuCount + ", corePerCpu: " + corePerCpu + ", id: " + id); int afinityCpu = id % cpuCount; int affinityMinCore = afinityCpu * corePerCpu; int affinityMaxCore = (afinityCpu + 1) * corePerCpu - 1; String cpu_affinity = ""; if (affinityMinCore == affinityMaxCore) { cpu_affinity = "" + affinityMinCore; } else { cpu_affinity = "" + affinityMinCore + "-" + affinityMaxCore; } if (t.isMapTask() && mapUseAffinity) { String task_type = "map"; vargs.add(0, "taskset"); vargs.add(1, "-c"); vargs.add(2, cpu_affinity); LOG.info("YS: Set Task(" + task_type + ")'s CPU Affinity to " + cpu_affinity); } else if (reduceTaskUseAffinity) { String task_type = "reduce"; vargs.add(0, "taskset"); vargs.add(1, "-c"); vargs.add(2, cpu_affinity); LOG.info("YS: Set Task(" + task_type + ")'s CPU Affinity to " + cpu_affinity); } } tracker.addToMemoryManager(t.getTaskID(), t.isMapTask(), conf); // set memory limit using ulimit if feasible and necessary ... String setup = getVMSetupCmd(); // Set up the redirection of the task's stdout and stderr streams File[] logFiles = prepareLogFiles(taskid, t.isTaskCleanupTask()); File stdout = logFiles[0]; File stderr = logFiles[1]; tracker.getTaskTrackerInstrumentation().reportTaskLaunch(taskid, stdout, stderr); Map<String, String> env = new HashMap<String, String>(); errorInfo = getVMEnvironment(errorInfo, user, workDir, conf, env, taskid, logSize); // flatten the env as a set of export commands List<String> setupCmds = new ArrayList<String>(); for (Entry<String, String> entry : env.entrySet()) { StringBuffer sb = new StringBuffer(); sb.append("export "); sb.append(entry.getKey()); sb.append("=\""); sb.append(entry.getValue()); sb.append("\""); setupCmds.add(sb.toString()); } setupCmds.add(setup); launchJvmAndWait(setupCmds, vargs, stdout, stderr, logSize, workDir); tracker.getTaskTrackerInstrumentation().reportTaskEnd(t.getTaskID()); if (exitCodeSet) { if (!killed && exitCode != 0) { if (exitCode == 65) { tracker.getTaskTrackerInstrumentation().taskFailedPing(t.getTaskID()); } throw new IOException("Task process exit with nonzero status of " + exitCode + "."); } } } catch (FSError e) { LOG.fatal("FSError", e); try { tracker.fsErrorInternal(t.getTaskID(), e.getMessage()); } catch (IOException ie) { LOG.fatal(t.getTaskID() + " reporting FSError", ie); } } catch (Throwable throwable) { LOG.warn(t.getTaskID() + " : " + errorInfo, throwable); Throwable causeThrowable = new Throwable(errorInfo, throwable); ByteArrayOutputStream baos = new ByteArrayOutputStream(); causeThrowable.printStackTrace(new PrintStream(baos)); try { tracker.reportDiagnosticInfoInternal(t.getTaskID(), baos.toString()); } catch (IOException e) { LOG.warn(t.getTaskID() + " Reporting Diagnostics", e); } } finally { // It is safe to call TaskTracker.TaskInProgress.reportTaskFinished with // *false* since the task has either // a) SUCCEEDED - which means commit has been done // b) FAILED - which means we do not need to commit tip.reportTaskFinished(false); } }