Search in sources :

Example 31 with IOError

use of java.io.IOError in project bazel by bazelbuild.

the class JavacTurbineTest method getDeps.

private Deps.Dependencies getDeps() throws IOError {
    Deps.Dependencies depsProto;
    try (BufferedInputStream in = new BufferedInputStream(Files.newInputStream(outputDeps))) {
        Deps.Dependencies.Builder builder = Deps.Dependencies.newBuilder();
        builder.mergeFrom(in);
        depsProto = builder.build();
    } catch (IOException e) {
        throw new IOError(e);
    }
    return depsProto;
}
Also used : Deps(com.google.devtools.build.lib.view.proto.Deps) BufferedInputStream(java.io.BufferedInputStream) IOError(java.io.IOError) IOException(java.io.IOException)

Example 32 with IOError

use of java.io.IOError in project checkstyle by checkstyle.

the class CheckerTest method testCatchErrorInProcessFilesMethod.

@Test
public void testCatchErrorInProcessFilesMethod() throws Exception {
    // The idea of the test is to satisfy coverage rate.
    // An Error indicates serious problems that a reasonable application should not try to
    // catch, but due to issue https://github.com/checkstyle/checkstyle/issues/2285
    // we catch errors in 'processFiles' method. Most such errors are abnormal conditions,
    // that is why we use PowerMockito to reproduse them.
    final File mock = PowerMockito.mock(File.class);
    // Assume that I/O error is happened when we try to invoke 'lastModified()' method.
    final String errorMessage = "Java Virtual Machine is broken" + " or has run out of resources necessary for it to continue operating.";
    final Error expectedError = new IOError(new InternalError(errorMessage));
    when(mock.lastModified()).thenThrow(expectedError);
    final Checker checker = new Checker();
    final List<File> filesToProcess = new ArrayList<>();
    filesToProcess.add(mock);
    try {
        checker.process(filesToProcess);
        fail("IOError is expected!");
    }// -@cs[IllegalCatchExtended] Testing for catch Error is part of 100% coverage.
     catch (Error error) {
        assertThat(error.getCause(), instanceOf(IOError.class));
        assertThat(error.getCause().getCause(), instanceOf(InternalError.class));
        assertEquals(errorMessage, error.getCause().getCause().getMessage());
    }
}
Also used : IOError(java.io.IOError) ArrayList(java.util.ArrayList) IOError(java.io.IOError) File(java.io.File) Test(org.junit.Test)

Example 33 with IOError

use of java.io.IOError in project elasticsearch by elastic.

the class ElasticsearchUncaughtExceptionHandlerTests method testIsFatalCause.

public void testIsFatalCause() {
    assertFatal(new MergePolicy.MergeException(new OutOfMemoryError(), null));
    assertFatal(new OutOfMemoryError());
    assertFatal(new StackOverflowError());
    assertFatal(new InternalError());
    assertFatal(new UnknownError());
    assertFatal(new IOError(new IOException()));
    assertNonFatal(new RuntimeException());
    assertNonFatal(new UncheckedIOException(new IOException()));
}
Also used : IOError(java.io.IOError) MergePolicy(org.apache.lucene.index.MergePolicy) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 34 with IOError

use of java.io.IOError in project cassandra by apache.

the class UnfilteredRowIteratorSerializer method deserialize.

public UnfilteredRowIterator deserialize(DataInputPlus in, int version, TableMetadata metadata, SerializationHelper.Flag flag, Header header) throws IOException {
    if (header.isEmpty)
        return EmptyIterators.unfilteredRow(metadata, header.key, header.isReversed);
    final SerializationHelper helper = new SerializationHelper(metadata, version, flag);
    final SerializationHeader sHeader = header.sHeader;
    return new AbstractUnfilteredRowIterator(metadata, header.key, header.partitionDeletion, sHeader.columns(), header.staticRow, header.isReversed, sHeader.stats()) {

        private final Row.Builder builder = BTreeRow.sortedBuilder();

        protected Unfiltered computeNext() {
            try {
                Unfiltered unfiltered = UnfilteredSerializer.serializer.deserialize(in, sHeader, helper, builder);
                return unfiltered == null ? endOfData() : unfiltered;
            } catch (IOException e) {
                throw new IOError(e);
            }
        }
    };
}
Also used : IOError(java.io.IOError) IOException(java.io.IOException)

Example 35 with IOError

use of java.io.IOError in project bazel by bazelbuild.

the class HeaderClassLoader method findClass.

@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
    String filename = rewriter.unprefix(name.replace('.', '/') + ".class");
    JarFile jarfile = indexedJars.getJarFile(filename);
    if (jarfile == null) {
        throw new ClassNotFoundException();
    }
    ZipEntry entry = jarfile.getEntry(filename);
    byte[] bytecode;
    try (InputStream content = jarfile.getInputStream(entry)) {
        ClassReader reader = rewriter.reader(content);
        // Have ASM compute maxs so we don't need to figure out how many formal parameters there are
        ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
        reader.accept(new CodeStubber(writer), 0);
        bytecode = writer.toByteArray();
    } catch (IOException e) {
        throw new IOError(e);
    }
    return defineClass(name, bytecode, 0, bytecode.length);
}
Also used : IOError(java.io.IOError) InputStream(java.io.InputStream) ZipEntry(java.util.zip.ZipEntry) ClassReader(org.objectweb.asm.ClassReader) IOException(java.io.IOException) JarFile(java.util.jar.JarFile) ClassWriter(org.objectweb.asm.ClassWriter)

Aggregations

IOError (java.io.IOError)50 IOException (java.io.IOException)43 File (java.io.File)8 DataInputStream (java.io.DataInputStream)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Console (java.io.Console)4 IPartitioner (org.apache.cassandra.dht.IPartitioner)4 FastByteArrayInputStream (org.apache.cassandra.io.util.FastByteArrayInputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 QueryPath (org.apache.cassandra.db.filter.QueryPath)3 SshClient (org.apache.sshd.client.SshClient)3 UserInteraction (org.apache.sshd.client.auth.keyboard.UserInteraction)3 ClientChannel (org.apache.sshd.client.channel.ClientChannel)3 ClientSession (org.apache.sshd.client.session.ClientSession)3 BufferedReader (java.io.BufferedReader)2 FileInputStream (java.io.FileInputStream)2 InputStreamReader (java.io.InputStreamReader)2 PrintWriter (java.io.PrintWriter)2