Search in sources :

Example 51 with UncheckedIOException

use of java.io.UncheckedIOException in project spf4j by zolyfarkas.

the class Threads method dumpToPrintStream.

// jdk printstreams are sync I don't want interleaving.
@SuppressFBWarnings("NOS_NON_OWNED_SYNCHRONIZATION")
public static void dumpToPrintStream(final PrintStream stream) {
    synchronized (stream) {
        Thread[] threads = getThreads();
        StackTraceElement[][] stackTraces = getStackTraces(threads);
        for (int i = 0; i < threads.length; i++) {
            StackTraceElement[] stackTrace = stackTraces[i];
            if (stackTrace != null && stackTrace.length > 0) {
                Thread thread = threads[i];
                stream.println("Thread " + thread.getName());
                try {
                    Throwables.writeTo(stackTrace, stream, Throwables.PackageDetail.SHORT, true);
                } catch (IOException ex) {
                    throw new UncheckedIOException(ex);
                }
            }
        }
    }
}
Also used : UncheckedIOException(java.io.UncheckedIOException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 52 with UncheckedIOException

use of java.io.UncheckedIOException in project spf4j by zolyfarkas.

the class TSDB2ViewJInternalFrame method jButton1ActionPerformed.

// </editor-fold>//GEN-END:initComponents
@SuppressFBWarnings("UP_UNUSED_PARAMETER")
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_jButton1ActionPerformed
    TreePath[] selectionPaths = measurementTree.getSelectionPaths();
    JPanel content = new JPanel();
    content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
    chartPannel.setViewportView(content);
    try {
        Set<String> selectedTables = getSelectedTables(selectionPaths);
        for (String tableName : selectedTables) {
            addChartToPanel(tableName, content);
        }
    } catch (IOException ex) {
        throw new UncheckedIOException(ex);
    }
    chartPannel.repaint();
}
Also used : JPanel(javax.swing.JPanel) TreePath(javax.swing.tree.TreePath) BoxLayout(javax.swing.BoxLayout) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 53 with UncheckedIOException

use of java.io.UncheckedIOException in project spf4j by zolyfarkas.

the class Explorer method openMenuItemActionPerformed.

// GEN-LAST:event_exitMenuItemActionPerformed
private void openMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_openMenuItemActionPerformed
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogType(JFileChooser.OPEN_DIALOG);
    chooser.setFileFilter(new Spf4jFileFilter());
    if (folder != null) {
        chooser.setCurrentDirectory(folder);
    }
    int returnVal = chooser.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = chooser.getSelectedFile();
        folder = file.getParentFile();
        try {
            openFile(file);
        } catch (IOException ex) {
            throw new UncheckedIOException(ex);
        }
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) UncheckedIOException(java.io.UncheckedIOException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) File(java.io.File)

Example 54 with UncheckedIOException

use of java.io.UncheckedIOException in project spf4j by zolyfarkas.

the class JmhProfiler method afterIteration.

@Override
@Nonnull
public Collection<? extends Result> afterIteration(final BenchmarkParams benchmarkParams, final IterationParams iterationParams, final IterationResult ir) {
    try {
        SAMPLER.stop();
    } catch (InterruptedException ex) {
        Thread.currentThread().interrupt();
        return Collections.EMPTY_LIST;
    }
    Map<String, SampleNode> c = SAMPLER.getStackCollectionsAndReset();
    if (c.isEmpty()) {
        return Collections.EMPTY_LIST;
    }
    SampleNode collected = c.values().iterator().next();
    try {
        return Arrays.asList(new StackResult(collected, benchmarkParams.id(), true));
    } catch (IOException ex) {
        throw new UncheckedIOException(ex);
    }
}
Also used : UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) Nonnull(javax.annotation.Nonnull)

Example 55 with UncheckedIOException

use of java.io.UncheckedIOException in project spf4j by zolyfarkas.

the class LogRecord method materializeMessage.

public synchronized void materializeMessage() {
    if (message == null) {
        StringBuilder sb = new StringBuilder(format.length() + arguments.length * 8);
        try {
            this.startExtra = Slf4jMessageFormatter.format(LogPrinter::exHandle, 0, sb, format, ObjectAppenderSupplier.TO_STRINGER, arguments);
        } catch (IOException ex) {
            throw new UncheckedIOException(ex);
        }
        message = sb.toString();
    }
}
Also used : UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Aggregations

UncheckedIOException (java.io.UncheckedIOException)826 IOException (java.io.IOException)786 File (java.io.File)109 Path (java.nio.file.Path)106 ArrayList (java.util.ArrayList)70 InputStream (java.io.InputStream)58 Map (java.util.Map)58 List (java.util.List)55 HashMap (java.util.HashMap)44 Test (org.junit.Test)38 Files (java.nio.file.Files)37 Collectors (java.util.stream.Collectors)37 Stream (java.util.stream.Stream)31 URL (java.net.URL)29 StringWriter (java.io.StringWriter)27 CursorContext (org.neo4j.io.pagecache.context.CursorContext)25 FileInputStream (java.io.FileInputStream)23 HashSet (java.util.HashSet)23 PageCursor (org.neo4j.io.pagecache.PageCursor)22 Optional (java.util.Optional)21