Java 类java.nio.channels.FileLockInterruptionException 实例源码

项目:In-the-Box-Fork    文件:FileLockInterruptionExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility.
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "!SerializationSelf",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "FileLockInterruptionException",
        args = {}
    )
})
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new FileLockInterruptionException());
}
项目:In-the-Box-Fork    文件:FileLockInterruptionExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "!SerializationGolden",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "FileLockInterruptionException",
        args = {}
    )
})
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this,
            new FileLockInterruptionException());
}
项目:jimfs    文件:JimfsFileChannel.java   
@Override
public FileLock lock(long position, long size, boolean shared) throws IOException {
  checkLockArguments(position, size, shared);

  // lock is interruptible
  boolean completed = false;
  try {
    begin();
    completed = true;
    return new FakeFileLock(this, position, size, shared);
  } finally {
    try {
      end(completed);
    } catch (ClosedByInterruptException e) {
      throw new FileLockInterruptionException();
    }
  }
}
项目:jimfs    文件:JimfsFileChannelTest.java   
/**
 * Asserts that when the given operation is run on an interrupted thread,
 * {@code ClosedByInterruptException} is thrown, the channel is closed and the thread is no
 * longer interrupted.
 */
private static void assertClosedByInterrupt(FileChannelMethod method) throws IOException {
  FileChannel channel = channel(regularFile(10), READ, WRITE);
  Thread.currentThread().interrupt();
  try {
    method.call(channel);
    fail(
        "expected the method to throw ClosedByInterruptException or "
            + "FileLockInterruptionException");
  } catch (ClosedByInterruptException | FileLockInterruptionException expected) {
    assertFalse("expected the channel to be closed", channel.isOpen());
    assertTrue("expected the thread to still be interrupted", Thread.interrupted());
  } finally {
    Thread.interrupted(); // ensure the thread isn't interrupted when this method returns
  }
}
项目:OasisLight-ServerManager    文件:ServerFileCommunicatorTask.java   
public synchronized boolean updateServerMonitorData(Server s) {
    if (!s.isLinked()) {
        return false;
    }
    File file = new File(Storage.getSettings().getCommunicationDir() + "/" + s.getName() + EXTENSION);
    if (file.isFile()) {
        try (FileOutputStream fos = new FileOutputStream(file, true); FileInputStream fis = new FileInputStream(file)) {
            locker = new Thread() {
                public void run() {
                    try {
                        fos.getChannel().lock();
                    } catch (FileLockInterruptionException ex) {
                    } catch (IOException ex) {
                        Printer.printError(PNAME, "Failed to acquire lock on file \"" + file + "\".", ex);
                    }
                }
            };
            locker.start();
            locker.join(3000);
            if (locker.isAlive()) {
                Printer.printBackgroundFail(PNAME, "Failed to read the file \"" + file + "\". Could not acquire lock.");
                return false;
            }
            Scanner sc = new Scanner(fis);
            s.setFileUpdateInterval(Long.parseLong(sc.nextLine()));
            s.setLastPing(Long.parseLong(sc.nextLine()));
            ArrayList<String> msgs = new ArrayList();
            while (sc.hasNextLine()) {
                msgs.add(sc.nextLine());
            }
            s.setCustomMessages(msgs);
            return true;
        } catch (Exception e) {
            Printer.printError(PNAME, "The server \"" + s.getName() + "\" monitor data file is broken.", e);
        }
    } else {
        Printer.printBackgroundFail(PNAME, "The monitor data file \"" + file.getAbsolutePath() + "\" was not found for the server \"" + s.getName() + "\".");
    }
    return false;
}
项目:In-the-Box-Fork    文件:FileLockInterruptionExceptionTest.java   
/**
 * @tests {@link java.nio.channels.FileLockInterruptionException#FileLockInterruptionException()}
 */
public void test_Constructor() {
    FileLockInterruptionException e = new FileLockInterruptionException();
    assertNull(e.getMessage());
    assertNull(e.getLocalizedMessage());
    assertNull(e.getCause());
}
项目:cn1    文件:FileLockInterruptionExceptionTest.java   
/**
 * @tests {@link java.nio.channels.FileLockInterruptionException#FileLockInterruptionException()}
 */
public void test_Constructor() {
    FileLockInterruptionException e = new FileLockInterruptionException();
    assertNull(e.getMessage());
    assertNull(e.getLocalizedMessage());
    assertNull(e.getCause());
}
项目:freeVM    文件:FileLockInterruptionExceptionTest.java   
/**
 * @tests {@link java.nio.channels.FileLockInterruptionException#FileLockInterruptionException()}
 */
public void test_Constructor() {
    FileLockInterruptionException e = new FileLockInterruptionException();
    assertNull(e.getMessage());
    assertNull(e.getLocalizedMessage());
    assertNull(e.getCause());
}
项目:cn1    文件:FileLockInterruptionExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new FileLockInterruptionException());
}
项目:cn1    文件:FileLockInterruptionExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this,
            new FileLockInterruptionException());
}
项目:freeVM    文件:FileLockInterruptionExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new FileLockInterruptionException());
}
项目:freeVM    文件:FileLockInterruptionExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this,
            new FileLockInterruptionException());
}
项目:freeVM    文件:FileLockInterruptionExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new FileLockInterruptionException());
}
项目:freeVM    文件:FileLockInterruptionExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this,
            new FileLockInterruptionException());
}