From a1156b08ddd544f7470d7184fbe822fab61c642e Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Thu, 20 Aug 2026 10:14:26 +0200 Subject: [PATCH 1/2] Restore auto-building when smart import fails SmartImportJob turns auto-building off for the duration of the import and turns it back on as the last statement of its try block. A configurator that throws, or a cancellation, skips that statement, so the workspace is left with auto-building permanently disabled until the user notices and toggles it manually. Restore the previous setting in a finally block instead. Also null check the optional import listener when closing projects after the import. --- .../wizards/datatransfer/SmartImportJob.java | 31 ++++++++++++------- .../tests/datatransfer/SmartImportTests.java | 16 ++++++++++ 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SmartImportJob.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SmartImportJob.java index c7bf3059348..6b0596e9ef1 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SmartImportJob.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SmartImportJob.java @@ -168,13 +168,11 @@ public void setListener(RecursiveImportListener listener) { @Override public IStatus run(IProgressMonitor monitor) { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + boolean isAutoBuilding = workspace.isAutoBuilding(); try { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IWorkspaceDescription description = workspace.getDescription(); - boolean isAutoBuilding = workspace.isAutoBuilding(); if (isAutoBuilding) { - description.setAutoBuilding(false); - workspace.setDescription(description); + setAutoBuilding(workspace, false); } if (directoriesToImport != null) { @@ -270,21 +268,32 @@ protected IStatus run(IProgressMonitor aMonitor) { try { project.close(monitor); } catch (CoreException e) { - listener.errorHappened(project.getLocation(), e); + if (listener != null) { + listener.errorHappened(project.getLocation(), e); + } } }); } - - if (isAutoBuilding) { - description.setAutoBuilding(true); - workspace.setDescription(description); - } } catch (Exception ex) { return new Status(IStatus.ERROR, IDEWorkbenchPlugin.IDE_WORKBENCH, ex.getMessage(), ex); + } finally { + if (isAutoBuilding) { + try { + setAutoBuilding(workspace, true); + } catch (CoreException ex) { + IDEWorkbenchPlugin.log("Could not restore auto-building after import", ex); //$NON-NLS-1$ + } + } } return Status.OK_STATUS; } + private static void setAutoBuilding(IWorkspace workspace, boolean autoBuilding) throws CoreException { + IWorkspaceDescription description = workspace.getDescription(); + description.setAutoBuilding(autoBuilding); + workspace.setDescription(description); + } + protected boolean rootProjectWorthBeingRemoved() { if (this.report.size() == 1) { return false; diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/SmartImportTests.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/SmartImportTests.java index 9c26d87df35..b15869f9f12 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/SmartImportTests.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/SmartImportTests.java @@ -572,4 +572,20 @@ public void testSmartImportJobSkipsDotFoldersInProposals() throws Exception { org.eclipse.core.tests.harness.FileSystemHelper.clear(tempDir.toFile()); } } + + @Test + public void testAutoBuildingRestoredAfterFailedImport() throws Exception { + assertTrue("Test expects auto-building to be enabled", ResourcesPlugin.getWorkspace().isAutoBuilding()); + // a regular file as import root makes the project creation fail + java.nio.file.Path notADirectory = Files.createTempFile("smartImportFailure", ".txt"); + try { + SmartImportJob job = new SmartImportJob(notADirectory.toFile(), Collections.emptySet(), true, true); + IStatus status = job.run(new NullProgressMonitor()); + assertEquals("Import was expected to fail", IStatus.ERROR, status.getSeverity()); + assertTrue("Auto-building must be restored after a failed import", + ResourcesPlugin.getWorkspace().isAutoBuilding()); + } finally { + Files.deleteIfExists(notADirectory); + } + } } From fa3cf70d50ee0eab4f574c5b90b5e0d34adfcc2b Mon Sep 17 00:00:00 2001 From: Eclipse Platform Bot Date: Sun, 30 Aug 2026 17:58:31 +0000 Subject: [PATCH 2/2] Version bump(s) for 4.42 stream --- bundles/org.eclipse.ui.ide/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.eclipse.ui.ide/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.ide/META-INF/MANIFEST.MF index 32bc975604a..94d64b2f966 100644 --- a/bundles/org.eclipse.ui.ide/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.ui.ide/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Plugin.name Bundle-SymbolicName: org.eclipse.ui.ide; singleton:=true -Bundle-Version: 3.23.200.qualifier +Bundle-Version: 3.23.300.qualifier Bundle-Activator: org.eclipse.ui.internal.ide.IDEWorkbenchPlugin Bundle-ActivationPolicy: lazy Bundle-Vendor: %Plugin.providerName