void () { ProjectJdkTable table = ProjectJdkTable.getInstance(); if (table == null) { return; } Sdk[] jdks = table.getAllJdks(); if (jdks.length == 0) { return; } Set<Sdk> old = Set.of(oldSdks); Collection<Sdk> leaked = ContainerUtil.subtract(Set.of(jdks), old); try { if (!leaked.isEmpty()) { String message = "Leaked SDKs: " + leaked + ". " + "Please remove leaking SDKs by e.g. ProjectJdkTable.getInstance().removeJdk() or by disposing the ProjectJdkImpl"; Pair<Sdk, Throwable> withTrace = findSdkWithRegistrationTrace(leaked); if (withTrace != null) { throw new AssertionError(message + ". Registration trace for '" + withTrace.first.getName() + "' is shown as the cause", withTrace.second); } else { throw new AssertionError(message); } } } finally { for (Sdk jdk : leaked) { WriteAction.run(() -> table.removeJdk(jdk)); } } }