void cancel() throws IOException { if (casCurrent(this, CLOSED)) { delegate.close(); final Path newPath = path.resolveSibling(path.getFileName() + ".new"); Files.deleteIfExists(newPath); } } }
void close() throws IOException { if (casCurrent(this, CLOSED)) { // atomic cleanup operation: close out our stream delegate.close(); final Path path = this.path; final Path newPath = path.resolveSibling(path.getFileName() + ".new"); try { // move new file in Files.move(newPath, path, REPLACE_EXISTING, ATOMIC_MOVE); } catch (Throwable t) { try { // didn't work, gotta delete our temp copy Files.deleteIfExists(newPath); } catch (Throwable problem) { problem.addSuppressed(t); throw problem; } throw t; } } }
void cancel() throws IOException { if (casCurrent(this, CLOSED)) { delegate.close(); final Path newPath = path.resolveSibling(path.getFileName() + ".new"); Files.deleteIfExists(newPath); } } }
void cancel() throws IOException { if (casCurrent(this, CLOSED)) { delegate.close(); final Path newPath = path.resolveSibling(path.getFileName() + ".new"); Files.deleteIfExists(newPath); } } }
void cancel() throws IOException { if (casCurrent(this, CLOSED)) { delegate.close(); final Path newPath = path.resolveSibling(path.getFileName() + ".new"); Files.deleteIfExists(newPath); } } }
void close() throws IOException { if (casCurrent(this, CLOSED)) { // atomic cleanup operation: close out our stream delegate.close(); final Path path = this.path; final Path newPath = path.resolveSibling(path.getFileName() + ".new"); try { // move new file in Files.move(newPath, path, REPLACE_EXISTING, ATOMIC_MOVE); } catch (Throwable t) { try { // didn't work, gotta delete our temp copy Files.deleteIfExists(newPath); } catch (Throwable problem) { problem.addSuppressed(t); throw problem; } throw t; } } }
void close() throws IOException { if (casCurrent(this, CLOSED)) { // atomic cleanup operation: close out our stream delegate.close(); final Path path = this.path; final Path newPath = path.resolveSibling(path.getFileName() + ".new"); try { // move new file in Files.move(newPath, path, REPLACE_EXISTING, ATOMIC_MOVE); } catch (Throwable t) { try { // didn't work, gotta delete our temp copy Files.deleteIfExists(newPath); } catch (Throwable problem) { problem.addSuppressed(t); throw problem; } throw t; } } }
void close() throws IOException { if (casCurrent(this, CLOSED)) { // atomic cleanup operation: close out our stream delegate.close(); final Path path = this.path; final Path newPath = path.resolveSibling(path.getFileName() + ".new"); try { // move new file in Files.move(newPath, path, REPLACE_EXISTING, ATOMIC_MOVE); } catch (Throwable t) { try { // didn't work, gotta delete our temp copy Files.deleteIfExists(newPath); } catch (Throwable problem) { problem.addSuppressed(t); throw problem; } throw t; } } }