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;
}
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());
}
}
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()));
}
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);
}
}
};
}
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);
}
Aggregations