@Override public void run() throws Exception { HadoopConfigurationInjector.prepareResourcesToInject(getJobProps(), getWorkingDirectory()); if (shouldProxy && obtainTokens) { userToProxy = getJobProps().getString("user.to.proxy"); getLog().info("Need to proxy. Getting tokens."); // get tokens in to a file, and put the location in props Props props = new Props(); props.putAll(getJobProps()); props.putAll(getSysProps()); tokenFile = HadoopJobUtils.getHadoopTokens(hadoopSecurityManager, props, getLog()); getJobProps().put("env." + HADOOP_TOKEN_FILE_LOCATION, tokenFile.getAbsolutePath()); } try { super.run(); } catch (Throwable t) { t.printStackTrace(); getLog().error("caught error running the job", t); throw new Exception(t); } finally { if (tokenFile != null) { HadoopJobUtils.cancelHadoopTokens(hadoopSecurityManager, userToProxy, tokenFile, getLog()); if (tokenFile.exists()) { tokenFile.delete(); } } } }