Bug 206901 - SystemFilter.getPersistableChildren() returns ArrayStoreException
Summary: SystemFilter.getPersistableChildren() returns ArrayStoreException
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M4   Edit
Assignee: David Dykstal CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: api, core
Depends on:
Blocks:
 
Reported: 2007-10-19 10:55 EDT by Ankit Pasricha CLA
Modified: 2007-12-18 13:15 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ankit Pasricha CLA 2007-10-19 10:55:51 EDT
I have some code that calls SystemRegistry.getLocalHost when my plugin is loaded. When eclipse starts up with this code, I get the following exception in the log:

java.lang.ArrayStoreException
at java.lang.System.arraycopy(Native Method)
at java.util.ArrayList.toArray(ArrayList.java:330)
at org.eclipse.rse.internal.core.filters.SystemFilter.getPersistableChildren(SystemFilter.java:1391)
at org.eclipse.rse.internal.persistence.RSEPersistenceManager.cleanTree(RSEPersistenceManager.java:447)
at org.eclipse.rse.internal.persistence.RSEPersistenceManager.cleanTree(RSEPersistenceManager.java:450)
at org.eclipse.rse.internal.persistence.RSEPersistenceManager.cleanTree(RSEPersistenceManager.java:450)
at org.eclipse.rse.internal.persistence.RSEPersistenceManager.load(RSEPersistenceManager.java:399)
at org.eclipse.rse.internal.persistence.RSEPersistenceManager.loadProfiles(RSEPersistenceManager.java:374)
at org.eclipse.rse.internal.persistence.RSEPersistenceManager.restoreProfiles(RSEPersistenceManager.java:233)
at org.eclipse.rse.internal.persistence.RSEPersistenceManager.restoreProfiles(RSEPersistenceManager.java:219)
at org.eclipse.rse.internal.core.model.SystemProfileManager.getDefault(SystemProfileManager.java:58)
at org.eclipse.rse.ui.internal.model.SystemRegistry.getSystemProfileManager(SystemRegistry.java:464)
at org.eclipse.rse.ui.internal.model.SystemRegistry.getHostPools(SystemRegistry.java:1357)
at org.eclipse.rse.ui.internal.model.SystemRegistry.getHosts(SystemRegistry.java:1398)
at org.eclipse.rse.ui.internal.model.SystemRegistry.getHostsBySystemType(SystemRegistry.java:1492)
at org.eclipse.rse.ui.internal.model.SystemRegistry.getLocalHost(SystemRegistry.java:1388)
Comment 1 David Dykstal CLA 2007-10-20 08:21:19 EDT
I believe this is happening because the profiles have not yet finished loading. See the reply to Bug 202040 and see if that helps.
Comment 2 Ankit Pasricha CLA 2007-10-22 20:04:52 EDT
I took a look at the RSE code. In getPersistableChildren() it does:

if (filterStringVector != null) {
    children.addAll(filterStringVector);
}
children.addAll(Arrays.asList(getPropertySets()));
IRSEPersistableContainer[] result = new IRSEPersistableContainer[children.size()];
children.toArray(result);
return result;

The "children" list is filled with the filterStringVector elements. These elements are strings. However, the children list is expected to contain elements of type IRSEPersistableContainer. I think that is the source of the problem. Please let me know if I am missing something.
Comment 3 Ankit Pasricha CLA 2007-11-10 20:30:43 EST
I was wondering if there is any progress on this problem?
Comment 4 David Dykstal CLA 2007-12-13 16:51:21 EST
This is probably the direct cause of the exception. I'm having a hard time writing a test case to confirm a fix. Can you give some hints as to what sort of filter is causing this problem?
Comment 5 Martin Oberhuber CLA 2007-12-14 13:42:59 EST
This bug was probably also caused by the SystemHostPool not being thread-safe. My fix in bug 206742 might thus also fix this issue -- the traceback in that bug was also rooted on SystemRegistry.getLocalHost().

Was this problem ever reproducable?
Is it still reproducable with the latest TM I-build?
Comment 6 David Dykstal CLA 2007-12-18 13:15:50 EST
I am integrating changes that simplify the internal structure of the classes and that should take care of the initial problem that Ankit found. 

There is one API change in SystemFilterSimple -- some fields were changed from protected to private visibility. All method signatures remain the same.

I will be cleanup up commented out code in both classes later today as [cleanup].