Java Code Examples for java.nio.file.ClosedFileSystemException

The following examples show how to use java.nio.file.ClosedFileSystemException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: openjdk-jdk9   Source File: T8147801.java    License: GNU General Public License v2.0 6 votes vote down vote up
void test(boolean withOption) {
    System.err.println("Testing " + (withOption ? "with" : "without") + " option");
    try {
        String dump = "";
        RootDoc root = getRootDoc(withOption);
        for (ClassDoc cd: root.specifiedClasses()) {
            dump += dump(cd);
        }
        if (dump.contains("lib.Lib2.i")) {
            if (!withOption) {
                error("control case failed: Lib2 class file was read, unexpectedly, without using option");
            }
        } else {
            if (withOption) {
                error("test case failed: could not read Lib2 class file, using option");
            }
        }
    } catch (ClosedFileSystemException e) {
        error("Unexpected exception: " + e);
    }
    System.err.println();
}
 
Example 2
@Test
public void forType_build() {
	// given:
	Mockito.when(this.applicationContext.getBean(FeignContext.class))
			.thenThrow(new ClosedFileSystemException()); // throw an unusual exception
															// in the
															// FeignClientFactoryBean
	final FeignClientBuilder.Builder builder = this.feignClientBuilder
			.forType(TestClient.class, "TestClient");

	// expect: 'the build will fail right after calling build() with the mocked
	// unusual exception'
	this.thrown.expect(Matchers.isA(ClosedFileSystemException.class));
	builder.build();
}
 
Example 3
/**
 * Thread-safe ClosedFileSystemException test
 * 
 * @return
 */
protected FileSystem getOrigFS() {
	FileSystem orig = origFS;
	if (orig == null || !orig.isOpen()) {
		throw new ClosedFileSystemException();
	}
	return orig;
}
 
Example 4
@Override
public Set<String> supportedFileAttributeViews() {
	if (origFS == null) {
		throw new ClosedFileSystemException();
	}
	return origFS.supportedFileAttributeViews();
}
 
Example 5
Source Project: jimfs   Source File: FileSystemStateTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testCheckOpen() throws IOException {
  state.checkOpen(); // does not throw
  state.close();
  try {
    state.checkOpen();
    fail();
  } catch (ClosedFileSystemException expected) {
  }
}
 
Example 6
@Test
public void shouldFindDescendantExceptionMapperFromException() {
    Optional<ExceptionMapper> mapper = exceptionMapperRegistry.findMapperFor(ClosedFileSystemException.class);
    assertThat(mapper.isPresent()).isTrue();
    assertThat(mapper.get()).isExactlyInstanceOf(IllegalStateExceptionMapper.class);
}
 
Example 7
Source Project: Bytecoder   Source File: JrtFileSystem.java    License: Apache License 2.0 4 votes vote down vote up
final void ensureOpen() throws IOException {
    if (!isOpen()) {
        throw new ClosedFileSystemException();
    }
}
 
Example 8
void run() throws Exception {
    ToolBox tb = new ToolBox();
    Path jar = createJar(tb);

    Path src = Paths.get("src");
    tb.writeJavaFiles(src, "class C { p1.C1 c1; }");

    JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
    PrintWriter out = new PrintWriter(System.err, true);
    StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
    List<String> options = Arrays.asList("-classpath", jar.toString(), "-proc:none");
    Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(src.resolve("C.java"));
    com.sun.source.util.JavacTask task =
            (com.sun.source.util.JavacTask) comp.getTask(out, fm, null, options, null, files);
    task.parse();

    Elements elems = task.getElements();

    try {
        // Use  p1, p1.C1 as a control to verify normal behavior
        PackageElement p1 = elems.getPackageElement("p1");
        TypeElement p1C1 = elems.getTypeElement("p1.C1");
        System.err.println("p1: " + p1 + ";  p1C1: " + p1C1);
        if (p1C1 == null) {
            throw new Exception("p1.C1 not found");
        }

        // Now repeat for p2, p2.C2, closing the file manager early
        PackageElement p2 = elems.getPackageElement("p2");
        System.err.println("closing file manager");
        fm.close();
        TypeElement p2C2 = elems.getTypeElement("p2.C2");
        System.err.println("p2: " + p2 + ";  p2C2: " + p2C2);
        if (p2C2 != null) {
            throw new Exception("p2.C2 found unexpectedly");
        }
    } catch (ClosedFileSystemException e) {
        throw new Exception("unexpected exception thrown", e);
    }

}
 
Example 9
Source Project: openjdk-jdk9   Source File: JrtFileSystem.java    License: GNU General Public License v2.0 4 votes vote down vote up
final void ensureOpen() throws IOException {
    if (!isOpen()) {
        throw new ClosedFileSystemException();
    }
}
 
Example 10
@Test
public void shouldFindDescendantExceptionMapperFromException() throws Exception {
    Optional<JsonApiExceptionMapper> mapper = exceptionMapperRegistry.findMapperFor(ClosedFileSystemException.class);
    assertThat(mapper.isPresent()).isTrue();
    assertThat(mapper.get()).isExactlyInstanceOf(IllegalStateExceptionMapper.class);
}
 
Example 11
Source Project: ParallelGit   Source File: GfsStatusProvider.java    License: Apache License 2.0 4 votes vote down vote up
private void checkClosed() {
  if(closed) throw new ClosedFileSystemException();
}
 
Example 12
Source Project: ParallelGit   Source File: GfsObjectService.java    License: Apache License 2.0 4 votes vote down vote up
private void checkClosed() {
  if(closed) throw new ClosedFileSystemException();
}
 
Example 13
Source Project: ParallelGit   Source File: GfsStatusProvider.java    License: Apache License 2.0 4 votes vote down vote up
private void checkClosed() {
  if(closed) throw new ClosedFileSystemException();
}
 
Example 14
Source Project: ParallelGit   Source File: GfsObjectService.java    License: Apache License 2.0 4 votes vote down vote up
private void checkClosed() {
  if(closed) throw new ClosedFileSystemException();
}
 
Example 15
Source Project: jsr203-hadoop   Source File: HadoopFileSystem.java    License: Apache License 2.0 4 votes vote down vote up
private void ensureOpen() throws IOException {
    if (!isOpen)
        throw new ClosedFileSystemException();
}
 
Example 16
Source Project: jimfs   Source File: FileSystemState.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Checks that the file system is open, throwing {@link ClosedFileSystemException} if it is not.
 */
public void checkOpen() {
  if (!open.get()) {
    throw new ClosedFileSystemException();
  }
}