Element (@NotNull Path file) { int i = 0; while (true) { try { return JDOMUtil.load(file); } catch (NoSuchFileException e) { return null; } catch (IOException | JDOMException e) { if (++i == MAX_ATTEMPTS) { //noinspection InstanceofCatchParameter throw new CannotLoadJpsModelException(file.toFile(), "Cannot " + (e instanceof IOException ? "read" : "parse") + " file " + file.toAbsolutePath() + ": " + e.getMessage(), e); } LOG.info("Loading attempt #" + i + " failed for " + file.toAbsolutePath(), e); try { LOG.info("File content: " + FileUtil.loadFile(file.toFile())); } catch (IOException ignored) { } } //most likely configuration file is being written by IDE so we'll wait a little try { //noinspection BusyWait Thread.sleep(300); } catch (InterruptedException ignored) { return null; } } }