void (@NotNull Path corruptionMarkerFile, @Nullable String message, @Nullable Throwable errorCause) { final VFSCorruptedException corruptedException = new VFSCorruptedException( message == null ? "(No specific reason of corruption was given)" : message, errorCause ); if (errorCause == null) { //Without 'errorCause' it is not an error, but, likely, an explicit 'invalidateCache' call: // no need to print stacktrace then, also no need for a WARN LOG.info("VFS rebuild is requested: creating VFS rebuild marker. Message: " + message); } else { LOG.warn("VFS is corrupted: creating VFS rebuild marker.", corruptedException); } try { final ByteArrayOutputStream out = new ByteArrayOutputStream(); try (PrintStream stream = new PrintStream(out, false, UTF_8)) { stream.println("VFS files are corrupted and must be rebuilt from the scratch on next startup"); corruptedException.printStackTrace(stream); } Files.write( corruptionMarkerFile, out.toByteArray(), StandardOpenOption.WRITE, StandardOpenOption.CREATE ); } catch (IOException ex) {// No luck: LOG.info("Can't create VFS corruption marker", ex); } }