/** * Create the supporting directory for this plugin if it doesn't yet exist. * @throws IOException */ private void createIfNecessary() throws IOException { if(!config.createIfMissing()) { return; } try { // no need to exists here as FileSystemWrapper does an exists check and this is a noop if already existing. fs.mkdirs(config.getPath()); } catch (IOException ex) { try { if(fs.exists(config.getPath())) { // race creation, ignore. return; } } catch (IOException existsFailure) { // we're doing the check above to detect a race condition. if we fail, ignore the failure and just fall through to throwing the originally caught exception. ex.addSuppressed(existsFailure); } throw new IOException(String.format("Failure to create directory %s.", config.getPath().toString()), ex); } }