List of usage examples for java.lang RuntimeException toString
public String toString()
From source file:net.sourceforge.pmd.ant.internal.PMDTaskImpl.java
private void handleError(RuleContext ctx, Report errorReport, RuntimeException pmde) { pmde.printStackTrace();/* w ww .ja v a 2 s . c o m*/ project.log(pmde.toString(), Project.MSG_VERBOSE); Throwable cause = pmde.getCause(); if (cause != null) { try (StringWriter strWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(strWriter)) { cause.printStackTrace(printWriter); project.log(strWriter.toString(), Project.MSG_VERBOSE); } catch (IOException e) { project.log("Error while closing stream", e, Project.MSG_ERR); } if (StringUtils.isNotBlank(cause.getMessage())) { project.log(cause.getMessage(), Project.MSG_VERBOSE); } } if (failOnError) { throw new BuildException(pmde); } errorReport.addError(new Report.ProcessingError(pmde, ctx.getSourceCodeFilename())); }
From source file:org.mitre.honeyclient.WorkerThread.java
@Override public void run() { Logger.getLogger(WorkerThread.class.getName()).log(Level.FINEST, getName() + " accepted a new connection"); byte[] buf = new byte[1024]; StringBuffer buffer = new StringBuffer(); InputStream in = null;/* ww w. j a v a 2s. c om*/ OutputStream out = null; try { in = socket.getInputStream(); out = socket.getOutputStream(); int len; boolean cont = true; while (cont) { len = in.read(buf); buffer.append(new String(buf, 0, len)); if (buffer.charAt(buffer.length() - 1) == '}') { cont = false; } Logger.getLogger(WorkerThread.class.getName()).log(Level.FINEST, getName() + " read: '" + new String(buf, 0, len) + "'"); Logger.getLogger(WorkerThread.class.getName()).log(Level.FINEST, getName() + " last charcted read: '" + Character.toString(buffer.charAt(buffer.length() - 1)) + "'"); Logger.getLogger(WorkerThread.class.getName()).log(Level.FINEST, getName() + " continue reading on port: " + Boolean.toString(cont)); } String text = buffer.toString(); File inputFile = null, outputFile = null; Response response = null; Request request = null; byte[] file_bytes; try { Logger.getLogger(WorkerThread.class.getName()).log(Level.FINEST, getName() + " request text : " + text); request = server.getMapper().readValue(text, Request.class); if ((FilenameUtils.getPath(request.getInputFilename()) != null) && (FilenameUtils.getPath(request.getOutputFilename()) != null) && (new File(request.getInputFilename()).exists())) { inputFile = new File(request.getInputFilename()); outputFile = new File(request.getOutputFilename()); } else if (request.getInputBase64FileContents() != null) { file_bytes = Base64.decodeBase64(request.getInputBase64FileContents().getBytes()); if (file_bytes.length > server.getFileSizeMax()) { throw new RuntimeException("Fail; File too big to process."); } FileUtils.writeByteArrayToFile( inputFile = File.createTempFile(FilenameUtils.getBaseName(request.getInputFilename()), "." + FilenameUtils.getExtension(request.getInputFilename())), file_bytes); outputFile = File.createTempFile(FilenameUtils.getBaseName(request.getOutputFilename()), "." + FilenameUtils.getExtension(request.getOutputFilename())); } else { throw new RuntimeException( "No Base64 encoded input file content, nor path provided with input filename."); } Logger.getLogger(WorkerThread.class.getName()).log(Level.FINEST, "calling convert of " + inputFile.getPath() + " to " + outputFile.getPath()); // TODO: convert using convert(File inputFile, File outputFile, DocumentFormat outputFormat), modify Request to handle server.getDocumentConverter().convert(inputFile, outputFile); if (!outputFile.exists()) throw new RuntimeException("The file could not be converted."); if (request.inputBase64FileContents != null) { byte[] outputFileBytes = new byte[(int) outputFile.length()]; FileInputStream f = new FileInputStream(outputFile.getPath()); f.read(outputFileBytes, 0, outputFileBytes.length); f.close(); String outputBase64encoded = new String(Base64.encodeBase64(outputFileBytes)); response = new Response("Success; output returned in Base64 format", request.getOutputFilename(), outputBase64encoded); } else { response = new Response("Success; output can found in the output file", request.getOutputFilename(), null); } } catch (RuntimeException e) { Logger.getLogger(WorkerThread.class.getName()).log(Level.SEVERE, e.toString()); response = new Response(e.getMessage(), null, null); //} catch (java.io.EOFException e) { //swallow } finally { if ((request != null) && (request.getInputBase64FileContents() != null)) { if (inputFile != null) { inputFile.delete(); } if (outputFile != null) { outputFile.delete(); } } server.getMapper().writeValue(out, response); } } catch (Exception e) { // catch everything else Logger.getLogger(WorkerThread.class.getName()).log(Level.SEVERE, e.getMessage()); } finally { try { in.close(); out.close(); socket.close(); } catch (IOException e) { Logger.getLogger(WorkerThread.class.getName()).log(Level.SEVERE, null, e); } } Logger.getLogger(WorkerThread.class.getName()).log(Level.FINEST, getName() + " done"); }
From source file:org.apache.usergrid.apm.service.ComplexEventProcessingService.java
private StatefulKnowledgeSession createSession(ClockTypeOption clockTypeOption) { KnowledgeBase kbase = loadRuleBase(); KnowledgeSessionConfiguration conf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(); //conf.setOption( ClockTypeOption.get( "pseudo" ) ); conf.setOption(clockTypeOption);//from w w w .ja v a2 s .c o m StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession(conf, null); //Added a logger session.setGlobal("log", LogFactory.getLog("RulesEngine")); log.info("Finishing session creation"); try { session.fireAllRules(); } catch (RuntimeException e) { log.error("Found an exception" + e.toString()); } return session; }
From source file:br.gov.frameworkdemoiselle.internal.interceptor.AuditableInterceptor.java
/** * @param ic/* ww w.ja va 2 s.c o m*/ * @param operation * @param internalAuditor * @param auditorClass * @param auditInfo * @throws Exception */ private void processAuditInfo(InvocationContext ic, String operation, Auditor internalAuditor, String auditorClass, AuditInfo auditInfo) throws Exception { setAuditInfoProperties(ic, operation, auditInfo); try { // Asking the auditorInstances to implement de audit operation internalAuditor.audit(auditInfo); } catch (RuntimeException ex) { log.error(ex.toString(), ex); throw ex; } }
From source file:org.glite.security.voms.admin.service.VOMSACLService.java
public ACLEntry[] getDefaultACL(String container) throws RemoteException, VOMSException { log.info("getDefaultACL(" + container + ");"); if (container == null) throw new NullArgumentException("container cannot be null!"); try {/*from w w w .jav a2 s .c o m*/ ACLEntry[] retVal = getACLImpl(container, true); HibernateFactory.commitTransaction(); return retVal; } catch (RuntimeException e) { log.error(e.toString()); if (log.isDebugEnabled()) { log.error(e.getMessage(), e); } throw e; } }
From source file:org.glite.security.voms.admin.service.VOMSACLService.java
public ACLEntry[] getACL(String container) throws RemoteException, VOMSException { log.info("getACL(" + container + ");"); if (container == null) throw new NullArgumentException("container cannot be null!"); try {//from w w w .j a v a 2s .co m ACLEntry[] retVal = getACLImpl(container, false); HibernateFactory.commitTransaction(); return retVal; } catch (RuntimeException e) { log.error(e.toString()); if (log.isDebugEnabled()) { log.error(e.getMessage(), e); } throw e; } }
From source file:podd.dataaccess.fedora.AbstractFedoraDAOImpl.java
/** * A two-step operation: (1) save the object itsely and recursively any descendent object in both * DB and Fedora Commons (object only, no <code>PODD</code> datastream yet); and (2) update the object in * Fedora Commons to add the <code>PODD</code>. * @param object The object to be saved. * @throws DataAccessException/* w ww.ja v a 2 s . c o m*/ */ @Override @Idempotent public void save(T object) throws DataAccessException { try { doSave(object); doUpdate(object); } catch (RuntimeException e) { logger.error("Caught runtime exception: " + e.toString()); throw e; } catch (Exception e) { throw new DataAccessException( "Exception occurred while saving " + object.getClass() + ": " + object.getPid(), e); } }
From source file:podd.dataaccess.fedora.AbstractFedoraDAOImpl.java
/** * Force deletion of the object rather than marking it as deleted * @param object//from w w w.ja va 2 s . c om * @return * @throws DataAccessException */ @Override @Idempotent public T forceDelete(T object) throws DataAccessException { try { pidDao.delete(object); purgeCache(object.getPid()); return object; } catch (RuntimeException e) { logger.info("Runtime exception caught: " + e.toString()); throw e; } catch (Exception e) { throw new DataAccessException("Exception occurred deleting object.", e); } }
From source file:podd.dataaccess.fedora.AbstractFedoraDAOImpl.java
/** * Mark an object to be "deleted" in DB instead of really deleting it. Also purge it from the cache store. * * @param object The object to be deleted. * @return The object that needs to be deleted. * @throws DataAccessException/*from w ww .j a va 2 s . c o m*/ */ @Override @Idempotent public T delete(T object) throws DataAccessException { try { final String pid = object.getPid(); T newObject = (T) pidDao.markDeleted(object); objectManipulator.setObjectState(object, STATE_DELETED, "deleting object [" + pid + "] on request of " + object.getCreator().getUserName()); purgeCache(object.getPid()); return newObject; } catch (RuntimeException e) { logger.info("Runtime exception caught: " + e.toString()); throw e; } catch (Exception e) { throw new DataAccessException("Exception occurred deleting object.", e); } }
From source file:net.sourceforge.pmd.ant.PMDTask.java
private void handleError(RuleContext ctx, Report errorReport, RuntimeException pmde) { pmde.printStackTrace();//w ww . ja v a 2 s. c o m log(pmde.toString(), Project.MSG_VERBOSE); Throwable cause = pmde.getCause(); if (cause != null) { StringWriter strWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(strWriter); cause.printStackTrace(printWriter); log(strWriter.toString(), Project.MSG_VERBOSE); IOUtils.closeQuietly(printWriter); if (StringUtil.isNotEmpty(cause.getMessage())) { log(cause.getMessage(), Project.MSG_VERBOSE); } } if (failOnError) { throw new BuildException(pmde); } errorReport.addError(new Report.ProcessingError(pmde.getMessage(), ctx.getSourceCodeFilename())); }