Skip to content

Commit

Permalink
WorkingSetModel.setActiveWorkingSets: fix IllegalArgumentException #1863
Browse files Browse the repository at this point in the history


The getter getAllWorkingSets() illegally caches - i.e. modified its
state while that is unexpected during setWorkingSets()

#1863

tested by WorkingSetDropAdapterTest
  • Loading branch information
jukzi committed Dec 20, 2024
1 parent 9c980bf commit d2a6005
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.eclipse.swt.dnd.DND;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.ILogListener;
import org.eclipse.core.runtime.Platform;

import org.eclipse.core.resources.IFolder;

Expand Down Expand Up @@ -60,10 +62,11 @@ public class WorkingSetDropAdapterTest {
private PackageExplorerPart fPackageExplorer;
private Accessor fPackageExplorerPartAccessor;
private WorkingSetDropAdapter fAdapter;

private ILogListener expectNoLogging= (status, plugin) -> {throw new AssertionError(status.getMessage(), status.getException());};

@BeforeEach
public void setUp() throws Exception {
Platform.addLogListener(expectNoLogging);
fProject= JavaProjectHelper.createJavaProject("Test", "bin");
IWorkbenchPage activePage= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
fPackageExplorer= (PackageExplorerPart)activePage.showView(JavaUI.ID_PACKAGES);
Expand All @@ -77,6 +80,7 @@ public void tearDown() throws Exception {
IWorkbenchPage activePage= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
activePage.hideView(fPackageExplorer);
assertTrue(fPackageExplorer.getTreeViewer().getTree().isDisposed());
Platform.removeLogListener(expectNoLogging);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,9 @@ public void setWorkingSets(IWorkingSet[] allWorkingSets, boolean isSortingEnable
* @param workingSets the active working sets to be set
*/
public void setActiveWorkingSets(IWorkingSet[] workingSets) {
List<IWorkingSet> backup= fAllWorkingSets; // modified by getAllWorkingSets, see gh#1863:
Assert.isLegal(Arrays.asList(getAllWorkingSets()).containsAll(Arrays.asList(workingSets)));
fAllWorkingSets= backup;
if (fIsSortingEnabled) {
Arrays.sort(workingSets, new WorkingSetComparator(true));
}
Expand Down

0 comments on commit d2a6005

Please sign in to comment.