use of java.io.IOError in project elasticsearch by elastic.
the class ElasticsearchUncaughtExceptionHandlerTests method testUncaughtError.
public void testUncaughtError() throws InterruptedException {
final Error error = randomFrom(new InternalError(), new OutOfMemoryError(), new StackOverflowError(), new UnknownError(), new IOError(new IOException("fatal")), new Error() {
});
final Thread thread = new Thread(() -> {
throw error;
});
final String name = randomAsciiOfLength(10);
thread.setName(name);
final AtomicBoolean halt = new AtomicBoolean();
final AtomicInteger observedStatus = new AtomicInteger();
final AtomicReference<String> threadNameReference = new AtomicReference<>();
final AtomicReference<Throwable> throwableReference = new AtomicReference<>();
thread.setUncaughtExceptionHandler(new ElasticsearchUncaughtExceptionHandler(() -> "testUncaughtError") {
@Override
void halt(int status) {
halt.set(true);
observedStatus.set(status);
}
@Override
void onFatalUncaught(String threadName, Throwable t) {
threadNameReference.set(threadName);
throwableReference.set(t);
}
@Override
void onNonFatalUncaught(String threadName, Throwable t) {
fail();
}
});
thread.start();
thread.join();
assertTrue(halt.get());
final int status;
if (expectedStatus.containsKey(error.getClass())) {
status = expectedStatus.get(error.getClass());
} else {
status = 1;
}
assertThat(observedStatus.get(), equalTo(status));
assertThat(threadNameReference.get(), equalTo(name));
assertThat(throwableReference.get(), equalTo(error));
}
use of java.io.IOError in project bazel by bazelbuild.
the class BlazeJavacMain method setLocations.
private static void setLocations(JavacFileManager fileManager, BlazeJavacArguments arguments) {
try {
fileManager.setLocationFromPaths(StandardLocation.CLASS_PATH, arguments.classPath());
fileManager.setLocationFromPaths(StandardLocation.CLASS_OUTPUT, ImmutableList.of(arguments.classOutput()));
fileManager.setLocationFromPaths(StandardLocation.SOURCE_PATH, arguments.sourcePath());
// TODO(cushon): require an explicit bootclasspath
Iterable<Path> bootClassPath = arguments.bootClassPath();
if (!Iterables.isEmpty(bootClassPath)) {
fileManager.setLocationFromPaths(StandardLocation.PLATFORM_CLASS_PATH, bootClassPath);
}
fileManager.setLocationFromPaths(StandardLocation.ANNOTATION_PROCESSOR_PATH, arguments.processorPath());
if (arguments.sourceOutput() != null) {
fileManager.setLocationFromPaths(StandardLocation.SOURCE_OUTPUT, ImmutableList.of(arguments.sourceOutput()));
}
} catch (IOException e) {
throw new IOError(e);
}
}
use of java.io.IOError in project error-prone by google.
the class ErrorProneJavaCompilerTest method doCompile.
private CompilationResult doCompile(List<String> fileNames, List<String> extraArgs, List<Class<? extends BugChecker>> customCheckers) {
DiagnosticTestHelper diagnosticHelper = new DiagnosticTestHelper();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(outputStream, UTF_8), true);
ErrorProneInMemoryFileManager fileManager = new ErrorProneInMemoryFileManager();
List<String> args = Lists.newArrayList("-d", tempDir.getRoot().getAbsolutePath(), "-proc:none");
args.addAll(extraArgs);
JavaCompiler errorProneJavaCompiler = (customCheckers.isEmpty()) ? new ErrorProneJavaCompiler() : new ErrorProneJavaCompiler(ScannerSupplier.fromBugCheckerClasses(customCheckers));
JavaCompiler.CompilationTask task = errorProneJavaCompiler.getTask(printWriter, fileManager, diagnosticHelper.collector, args, null, fileManager.forResources(getClass(), fileNames.toArray(new String[0])));
try {
fileManager.close();
} catch (IOException e) {
throw new IOError(e);
}
return new CompilationResult(task.call(), diagnosticHelper);
}
use of java.io.IOError in project qpid-broker-j by apache.
the class BrokerFileLoggerStatusListenerTest method testAddStatusEventForIOError.
public void testAddStatusEventForIOError() throws Exception {
Status event = createEvent(new IOError(new IOException("Mocked: No disk space left")), Status.ERROR);
_statusListener.addStatusEvent(event);
verify(_systemConfig).closeAsync();
}
use of java.io.IOError in project qpid-broker-j by apache.
the class BrokerFileLoggerStatusListenerTest method testAddStatusEventForIOErrorWithFailOnLoggerIOErrorDisabled.
public void testAddStatusEventForIOErrorWithFailOnLoggerIOErrorDisabled() throws Exception {
Status event = createEvent(new IOError(new IOException("Mocked: No disk space left")), Status.ERROR);
when(_fileLogger.getContextValue(Boolean.class, BrokerFileLogger.BROKER_FAIL_ON_LOGGER_IO_ERROR)).thenReturn(false);
_statusListener.addStatusEvent(event);
verify(_systemConfig, never()).closeAsync();
}
Aggregations