[jdk] Fix leaking SDK in test

The NPW JDK combo can register a JDK if none were registered. This needs to be taken into account in tests #tearDown.

GitOrigin-RevId: bc407e3d7e18e192ab8bacc3e3e4f24803ca9de7
This commit is contained in:
Louis Vignier
2024-02-01 09:51:48 +00:00
committed by intellij-monorepo-bot
parent bc8062ceb1
commit fa3556e841
@@ -15,6 +15,7 @@ import com.intellij.openapi.module.BasePackageParameterFactory
import com.intellij.openapi.module.Module
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ex.ProjectManagerEx
import com.intellij.openapi.projectRoots.ProjectJdkTable
import com.intellij.openapi.roots.ModuleRootManager
import com.intellij.openapi.roots.ProjectRootManager
import com.intellij.openapi.vfs.LocalFileSystem
@@ -138,6 +139,9 @@ public class Bar {
override fun tearDown() {
try {
ProjectJdkTable.getInstance().apply {
allJdks.forEach { removeJdk(it) }
}
(FileTemplateManager.getDefaultInstance() as FileTemplateManagerImpl).setTestDate(null)
PropertiesComponent.getInstance().unsetValue(ProjectTemplateParameterFactory.IJ_BASE_PACKAGE)
}