public static void printStackTraces(Throwable T) { printStackTraces(T, System.err, null); }
public static void printStackTraces(Throwable T, Object[] extraInfo) { printStackTraces(T, System.err, extraInfo); }
public static void printStackTraces(Throwable T, Appendable out) { printStackTraces(T, out, null); }
/** * Gets the entire exception report as a <code>String</code>. This is not * as efficient as directly writing the report due to the extra buffering. */ public static String getStackTraces(Throwable thrown, Object[] extraInfo) { StringBuilder out = new StringBuilder(); printStackTraces(thrown, out, extraInfo); return out.toString(); } }
@Override public void run() { int count=0; try { RandomAccessFile raf=new RandomAccessFile(file, "r"); long length=raf.length(); try { long endTime=System.currentTimeMillis()+30*1000; while(System.currentTimeMillis()<endTime) { raf.seek((long)(Math.random()*(length-4096))); raf.read(buff, 0, 4096); count++; } } finally { raf.close(); } } catch(IOException err) { ErrorPrinter.printStackTraces(err); } synchronized(counter) { counter[0]+=count; } } };
@Override public void run() { while(thread==Thread.currentThread()) { try { while(thread==Thread.currentThread()) { if(verbose) System.out.println("Accepting connections on "+listen_address+":"+listen_port); ServerSocket serverSocket = new ServerSocket(listen_port, 50, listen_address.equals("*") ? null : InetAddress.getByName(listen_address)); while(true) { Socket socket = serverSocket.accept(); if(verbose) System.out.println("New connection from "+socket.getInetAddress().getHostAddress()+":"+socket.getPort()); new BandwidthLimitingTunnelHandler(verbose, connect_address, connect_port, upstream_bandwidth, downstream_bandwidth, socket); } } } catch(ThreadDeath TD) { throw TD; } catch(Throwable T) { ErrorPrinter.printStackTraces(T); try { Thread.sleep(10000); } catch(InterruptedException err) { ErrorPrinter.printStackTraces(err); // Restore the interrupted status Thread.currentThread().interrupt(); } } } } }
public void format(LogRecord record, Appendable out) { List<Object> extraInfo = new ArrayList<Object>(9); // At most 9 elements added below String loggerName = record.getLoggerName(); if(loggerName!=null) extraInfo.add("record.loggerName="+loggerName); extraInfo.add("record.level="+record.getLevel()); extraInfo.add("record.sequenceNumber="+record.getSequenceNumber()); String sourceClassName = record.getSourceClassName(); if(sourceClassName!=null) extraInfo.add("record.sourceClassName="+sourceClassName); String sourceMethodName = record.getSourceMethodName(); if(sourceMethodName!=null) extraInfo.add("record.sourceMethodName="+sourceMethodName); String message = record.getMessage(); if(message==null) message = ""; extraInfo.add("record.message="+message); String formatted = formatMessage(record); if(formatted==null) formatted = ""; if(!message.equals(formatted)) extraInfo.add("record.message.formatted="+formatted); extraInfo.add("record.threadID="+record.getThreadID()); extraInfo.add("record.millis="+record.getMillis()); Throwable thrown = record.getThrown(); ErrorPrinter.printStackTraces( thrown, out, extraInfo.toArray() ); }
/** * Manually adds entropy to the kernel, reads from standard in. */ public static void main(String[] args) { try { byte[] buff=new byte[16]; int ret; while((ret=System.in.read(buff, 0, 16))!=-1) { if(ret!=16) { byte[] newBuff=new byte[ret]; System.arraycopy(buff, 0, newBuff, 0, ret); DevRandom.addEntropy(newBuff); } else DevRandom.addEntropy(buff); } } catch(IOException err) { ErrorPrinter.printStackTraces(err); } } }
public static void main(String[] args) { try { if(args.length>0) { final byte[] buff = BufferManager.getBytes(); try { for (String filename : args) { long startTime = System.currentTimeMillis(); RandomAccessFile raf=new RandomAccessFile(filename, "r"); long length=raf.length(); try { for(long pos=1;pos<length;pos+=(1024*4096+4096)) { raf.seek(pos); raf.readFully(buff, 0, BufferManager.BUFFER_SIZE); } } finally { raf.close(); } System.out.println(filename+" scanned in "+BigDecimal.valueOf(System.currentTimeMillis()-startTime, 3)+" seconds"); } } finally { BufferManager.release(buff, false); } } else { System.err.println("Usage: BenchmarkCounterBlockDevice filename [filename] [...]"); } } catch(IOException err) { ErrorPrinter.printStackTraces(err); } } }
public ErrorDialog(Component parent, String title, Throwable T, Object[] extraInfo) { super((parent instanceof JFrame) ? (JFrame)parent : new JFrame(), title, true, 400, 300); Container contentPane=getContentPane(); contentPane.setLayout(new MultiBorderLayout()); contentPane.add(new JLabel(" "), BorderLayout.NORTH); contentPane.add(new JLabel("An application error has occurred. Please provide a", JLabel.CENTER), BorderLayout.NORTH); contentPane.add(new JLabel("copy of this error to your system administrator.", JLabel.CENTER), BorderLayout.NORTH); contentPane.add(new JLabel(" "), BorderLayout.NORTH); // Convert the error CharArrayWriter cout=new CharArrayWriter(); PrintWriter pout=new PrintWriter(cout); ErrorPrinter.printStackTraces(T, pout, extraInfo); pout.flush(); String errorText=cout.toString(); // Setup the GUI JTextArea textArea=new JTextArea(errorText, 25, 80); textArea.setEditable(false); textArea.setCaretPosition(0); contentPane.add(new JScrollPane(textArea)); JPanel buttonPanel=new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); contentPane.add(buttonPanel, BorderLayout.SOUTH); closeButton=new EnterJButton("Close"); buttonPanel.add(closeButton); closeButton.addActionListener(this); closeButton.setToolTipText("Close this window."); pack(); center(parent); closeButton.requestFocus(); }
ErrorPrinter.printStackTraces(err); } finally { long timeSpan = System.currentTimeMillis() - startTime; threads[d].join(); } catch(InterruptedException err) { ErrorPrinter.printStackTraces(err);
ErrorPrinter.printStackTraces(err);
+ " <span id='stack_").append(Integer.toString(c)).append("' style='text-align:left; white-space:nowrap; position:absolute; visibility: hidden; z-index:").append(Integer.toString(c+1)).append("'>\n" + " <pre style='text-align:left; background-color:white; border: 2px solid; border-color: black;'>\n"); ErrorPrinter.printStackTraces(T, out); out.append(" </pre>\n" + " </span>\n");
/** * If arguments were provided, executes that command. Otherwise, * reads from <code>in</code> until end of file or <code>exit</code>. */ @Override final public void run() { try { if(args.length>0) handleCommand(args); else runImpl(); status="Done"; } catch(IOException exception) { this.err.println(getName()+": "+exception.getMessage()); status="IO Error: "+exception.getMessage(); this.err.flush(); } catch(SQLException exception) { this.err.println(getName()+": "+exception.getMessage()); status="SQL Error: "+exception.getMessage(); this.err.flush(); } catch(ThreadDeath TD) { throw TD; } catch(Throwable T) { ErrorPrinter.printStackTraces(T, this.err); status="Error: "+T.toString(); this.err.flush(); } finally { if(Thread.currentThread()==thread) thread=null; } }
ErrorPrinter.printStackTraces(err);
ErrorPrinter.printStackTraces(e, stepError); throw TD; } catch(Throwable T) { ErrorPrinter.printStackTraces(T, stepError); stepError.append('\n'); steps.add(
} catch(Throwable T) { if(isInteractive) { ErrorPrinter.printStackTraces(T, err); err.flush(); return true;