Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 127554 Details for
Bug 194917
stack overflow error from working set management
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
JUnit that shows how it is possible to create a cycle
patch aggregate sets 1.txt (text/plain), 10.64 KB, created by
Oleg Besedin
on 2009-03-04 16:01:41 EST
(
hide
)
Description:
JUnit that shows how it is possible to create a cycle
Filename:
MIME Type:
Creator:
Oleg Besedin
Created:
2009-03-04 16:01:41 EST
Size:
10.64 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.tests >Index: Eclipse UI Tests/org/eclipse/ui/tests/api/IAggregateWorkingSetTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IAggregateWorkingSetTest.java,v >retrieving revision 1.1 >diff -u -r1.1 IAggregateWorkingSetTest.java >--- Eclipse UI Tests/org/eclipse/ui/tests/api/IAggregateWorkingSetTest.java 23 Jan 2009 18:09:25 -0000 1.1 >+++ Eclipse UI Tests/org/eclipse/ui/tests/api/IAggregateWorkingSetTest.java 4 Mar 2009 20:57:07 -0000 >@@ -1,103 +1,158 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.ui.tests.api; >- >-import org.eclipse.core.resources.IWorkspace; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.ui.IAggregateWorkingSet; >-import org.eclipse.ui.IMemento; >-import org.eclipse.ui.IWorkingSet; >-import org.eclipse.ui.IWorkingSetManager; >-import org.eclipse.ui.XMLMemento; >-import org.eclipse.ui.internal.IWorkbenchConstants; >-import org.eclipse.ui.tests.harness.util.ArrayUtil; >-import org.eclipse.ui.tests.harness.util.UITestCase; >- >-public class IAggregateWorkingSetTest extends UITestCase { >- >- final static String WORKING_SET_NAME = "testws"; >- final static String AGGREGATE_WORKING_SET_NAME_ = "testaggregatews"; >- >- IWorkspace fWorkspace; >- >- IWorkingSet[] components; >- IAggregateWorkingSet fWorkingSet; >- >- public IAggregateWorkingSetTest(String testName) { >- super(testName); >- } >- >- protected void doSetUp() throws Exception { >- super.doSetUp(); >- IWorkingSetManager workingSetManager = fWorkbench >- .getWorkingSetManager(); >- >- fWorkspace = ResourcesPlugin.getWorkspace(); >- components = new IWorkingSet[4]; >- for (int i = 0; i < 4; i++) { >- components[i] = workingSetManager.createWorkingSet(WORKING_SET_NAME >- + i, new IAdaptable[] {}); >- workingSetManager.addWorkingSet(components[i]); >- } >- fWorkingSet = (IAggregateWorkingSet) workingSetManager >- .createAggregateWorkingSet(AGGREGATE_WORKING_SET_NAME_, >- AGGREGATE_WORKING_SET_NAME_, components); >- >- workingSetManager.addWorkingSet(fWorkingSet); >- } >- protected void doTearDown() throws Exception { >- IWorkingSetManager workingSetManager = fWorkbench.getWorkingSetManager(); >- workingSetManager.removeWorkingSet(fWorkingSet); >- for (int i = 0; i < components.length; i++) { >- workingSetManager.removeWorkingSet(components[i]); >- } >- super.doTearDown(); >- } >- >- public void testSaveWSet() throws Throwable { >- //<possible client code> >- IWorkingSetManager workingSetManager = fWorkbench >- .getWorkingSetManager(); >- IWorkingSet set=workingSetManager.getWorkingSet(AGGREGATE_WORKING_SET_NAME_); >- if(set.isAggregateWorkingSet()){ >- IWorkingSet[] sets=((IAggregateWorkingSet)set).getComponents(); >- if(sets.length>=1){ >- sets[0]=null; //client fails to pay enough attention to specs or unknowingly does this >- } >- } >- //</possible client code> >- //error makes it look like it comes from workingsets api, with no clue about the actual culprit >- IMemento memento=XMLMemento.createWriteRoot(IWorkbenchConstants.TAG_WORKING_SET); >- set.saveState(memento); >- } >- public void testGetElemets() throws Throwable { >- //<possible client code> >- IWorkingSetManager workingSetManager = fWorkbench >- .getWorkingSetManager(); >- IWorkingSet set=workingSetManager.getWorkingSet(AGGREGATE_WORKING_SET_NAME_); >- if(set.isAggregateWorkingSet()){ >- IWorkingSet[] sets=((IAggregateWorkingSet)set).getComponents(); >- if(sets.length>1){ >- //code 2 fails to pay enough attention to specs or unknowingly does this >- sets[0]=workingSetManager.createWorkingSet(WORKING_SET_NAME, new IAdaptable[] { fWorkspace.getRoot() }); >- //code 1 part removes a workingset >- workingSetManager.removeWorkingSet(sets[1]); >- } >- } >- //</possible client code> >- >- //unexpected >- assertTrue(ArrayUtil.equals( >- new IAdaptable[] {}, >- fWorkingSet.getElements())); >- } >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.tests.api; >+ >+import org.eclipse.core.resources.IWorkspace; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.ui.IAggregateWorkingSet; >+import org.eclipse.ui.IMemento; >+import org.eclipse.ui.IWorkingSet; >+import org.eclipse.ui.IWorkingSetManager; >+import org.eclipse.ui.XMLMemento; >+import org.eclipse.ui.internal.IWorkbenchConstants; >+import org.eclipse.ui.tests.harness.util.ArrayUtil; >+import org.eclipse.ui.tests.harness.util.UITestCase; >+ >+public class IAggregateWorkingSetTest extends UITestCase { >+ >+ final static String WORKING_SET_NAME = "testws"; >+ final static String AGGREGATE_WORKING_SET_NAME_ = "testaggregatews"; >+ >+ IWorkspace fWorkspace; >+ >+ IWorkingSet[] components; >+ IAggregateWorkingSet fWorkingSet; >+ >+ public IAggregateWorkingSetTest(String testName) { >+ super(testName); >+ } >+ >+ protected void doSetUp() throws Exception { >+ super.doSetUp(); >+ IWorkingSetManager workingSetManager = fWorkbench >+ .getWorkingSetManager(); >+ >+ fWorkspace = ResourcesPlugin.getWorkspace(); >+ components = new IWorkingSet[4]; >+ for (int i = 0; i < 4; i++) { >+ components[i] = workingSetManager.createWorkingSet(WORKING_SET_NAME >+ + i, new IAdaptable[] {}); >+ workingSetManager.addWorkingSet(components[i]); >+ } >+ fWorkingSet = (IAggregateWorkingSet) workingSetManager >+ .createAggregateWorkingSet(AGGREGATE_WORKING_SET_NAME_, >+ AGGREGATE_WORKING_SET_NAME_, components); >+ >+ workingSetManager.addWorkingSet(fWorkingSet); >+ } >+ protected void doTearDown() throws Exception { >+ IWorkingSetManager workingSetManager = fWorkbench.getWorkingSetManager(); >+ workingSetManager.removeWorkingSet(fWorkingSet); >+ for (int i = 0; i < components.length; i++) { >+ workingSetManager.removeWorkingSet(components[i]); >+ } >+ super.doTearDown(); >+ } >+ >+ public void testSaveWSet() throws Throwable { >+ //<possible client code> >+ IWorkingSetManager workingSetManager = fWorkbench >+ .getWorkingSetManager(); >+ IWorkingSet set=workingSetManager.getWorkingSet(AGGREGATE_WORKING_SET_NAME_); >+ if(set.isAggregateWorkingSet()){ >+ IWorkingSet[] sets=((IAggregateWorkingSet)set).getComponents(); >+ if(sets.length>=1){ >+ sets[0]=null; //client fails to pay enough attention to specs or unknowingly does this >+ } >+ } >+ //</possible client code> >+ //error makes it look like it comes from workingsets api, with no clue about the actual culprit >+ IMemento memento=XMLMemento.createWriteRoot(IWorkbenchConstants.TAG_WORKING_SET); >+ set.saveState(memento); >+ } >+ public void testGetElemets() throws Throwable { >+ //<possible client code> >+ IWorkingSetManager workingSetManager = fWorkbench >+ .getWorkingSetManager(); >+ IWorkingSet set=workingSetManager.getWorkingSet(AGGREGATE_WORKING_SET_NAME_); >+ if(set.isAggregateWorkingSet()){ >+ IWorkingSet[] sets=((IAggregateWorkingSet)set).getComponents(); >+ if(sets.length>1){ >+ //code 2 fails to pay enough attention to specs or unknowingly does this >+ sets[0]=workingSetManager.createWorkingSet(WORKING_SET_NAME, new IAdaptable[] { fWorkspace.getRoot() }); >+ //code 1 part removes a workingset >+ workingSetManager.removeWorkingSet(sets[1]); >+ } >+ } >+ //</possible client code> >+ >+ //unexpected >+ assertTrue(ArrayUtil.equals( >+ new IAdaptable[] {}, >+ fWorkingSet.getElements())); >+ } >+ >+ /** >+ * Core of the problem: while Eclipse is running, name collisions among working sets >+ * don't matter. However, on save and restart names will be used to identify working >+ * sets, which could possibly lead to cycles in aggregate working sets. >+ * >+ * Bottom line: if there are multiple aggregate working sets with the same name, expect >+ * trouble on restart. >+ * >+ * To create a cycle we have to be creative: >+ * - create an aggregate1 with an ID = "testCycle" >+ * - create an aggregate2 with an ID = "testCycle" containing aggregate1 >+ * - save it into IMemento >+ * >+ * Now the IMememnto creates a self reference: >+ * >+ * <workingSet name="testCycle" label="testCycle" aggregate="true"> >+ * <workingSet IMemento.internal.id="testCycle" /> >+ * </workingSet> >+ * >+ * All we have to do to emulate stack overflow is to create a working set based on this IMemento. >+ * >+ * @throws Throwable >+ */ >+ public void testDirectCycle() throws Throwable { >+ IWorkingSetManager manager = fWorkbench.getWorkingSetManager(); >+ >+ // 1) create an IMemento with a cycle in it >+ IAggregateWorkingSet aggregate = (IAggregateWorkingSet) manager >+ .createAggregateWorkingSet("testCycle","testCycle", new IWorkingSet[0]); >+ >+ IAggregateWorkingSet aggregate2 = (IAggregateWorkingSet) manager >+ .createAggregateWorkingSet("testCycle","testCycle", new IWorkingSet[] {aggregate}); >+ >+ IMemento memento=XMLMemento.createWriteRoot(IWorkbenchConstants.TAG_WORKING_SET); >+ aggregate2.saveState(memento); >+ >+ // 2) clean the slate >+ manager.removeWorkingSet(aggregate); >+ manager.removeWorkingSet(aggregate2); >+ >+ // 3) load the IMemento >+ try { >+ IAggregateWorkingSet aggregateReloaded = (IAggregateWorkingSet) manager.createWorkingSet(memento); >+ manager.addWorkingSet(aggregateReloaded); >+ aggregateReloaded.getComponents(); >+ // TBD test updates as well >+ } catch (StackOverflowError e) { >+ e.printStackTrace(); >+ fail("Stack overflow for self-referenced aggregate working set", e); >+ } >+ } >+ // TBD create a test for indirect inclusions: A contains B contains A >+ >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 194917
:
100844
|
127554
|
127694
|
127804