Bug 196582 - ClassCastException when doing copy/paste with Remote Search view open
Summary: ClassCastException when doing copy/paste with Remote Search view open
Status: CLOSED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 2.0.1   Edit
Assignee: Kevin Doyle CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-07-15 17:38 EDT by Kevin Doyle CLA
Modified: 2012-05-23 17:15 EDT (History)
2 users (show)

See Also:
mober.at+eclipse: pmc_approved+


Attachments
Changed mentions of Vector to List so ArrayList is handled. (2.26 KB, patch)
2007-07-23 15:22 EDT, Kevin Doyle CLA
no flags Details | Diff
SystemCommonDeleteAction now pass's Vector instead of ArrayList (3.85 KB, patch)
2007-07-24 10:56 EDT, Kevin Doyle CLA
no flags Details | Diff
Updated to deprecate getRemoteObjectIdentifier (6.57 KB, patch)
2007-08-08 11:38 EDT, Kevin Doyle CLA
no flags Details | Diff
Added Contributer Line (7.10 KB, patch)
2007-08-08 17:30 EDT, Kevin Doyle CLA
mober.at+eclipse: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Doyle CLA 2007-07-15 17:38:02 EDT
If the Remote Search view is open and you do a copy/paste you will get a ClassCastException.

Log file contains:

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.ClassCastException: java.util.ArrayList cannot be cast to org.eclipse.core.runtime.IAdaptable)
at org.eclipse.swt.SWT.error(SWT.java:3563)
at org.eclipse.swt.SWT.error(SWT.java:3481)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:126)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3659)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3296)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:153)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:504)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:443)
at org.eclipse.equinox.launcher.Main.run(Main.java:1169)
Caused by: java.lang.ClassCastException: java.util.ArrayList cannot be cast to org.eclipse.core.runtime.IAdaptable
at org.eclipse.rse.internal.ui.view.SystemTableTreeView.getRemoteObjectIdentifier(SystemTableTreeView.java:1450)
at org.eclipse.rse.internal.ui.view.SystemTableTreeView.getRemoteResourceAbsoluteName(SystemTableTreeView.java:1062)
at org.eclipse.rse.internal.ui.view.SystemTableTreeView.systemRemoteResourceChanged(SystemTableTreeView.java:905)
at org.eclipse.rse.internal.ui.view.search.SystemSearchTableView.systemRemoteResourceChanged(SystemSearchTableView.java:259)
at org.eclipse.rse.internal.core.model.SystemRemoteChangeEventManager.notify(SystemRemoteChangeEventManager.java:69)
at org.eclipse.rse.ui.internal.model.SystemRegistry.fireRemoteResourceChangeEvent(SystemRegistry.java:2767)
at org.eclipse.rse.internal.ui.view.SystemDNDTransferRunnable$RefreshJob.runInUIThread(SystemDNDTransferRunnable.java:659)
at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:94)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
... 22 more


-----------Enter bugs above this line-----------
TM 2.0.1 Testing
installation : eclipse-SDK-3.3
RSE install  : RSE I20070713-0605
java.runtime : Sun 1.5.0_06-b05
os.name:     : Windows XP 5.1, Service Pack 2
------------------------------------------------
Comment 1 Martin Oberhuber CLA 2007-07-16 05:47:15 EDT
Kevin you've been most exposed to search, could you investigate?
Comment 2 Kevin Doyle CLA 2007-07-23 15:22:24 EDT
Created attachment 74390 [details]
Changed mentions of Vector to List so ArrayList is handled.

Another case where trying to cast an ArrayList to Vector.  Changed it to List's.  Also changed getRemoteResourceAbsoluteName(Object) to use an ISystemViewElementAdapter instead of IRemoteObjectIdentifier.

Legal Message: I, Kevin Doyle, declare that I developed attached code from
scratch, without referencing any 3rd party materials except material licensed
under the EPL. I am authorized by my employer, IBM Canada Ltd. to make this
contribution under the EPL.
Comment 3 David McKnight CLA 2007-07-23 15:30:51 EDT
I've committed this to cvs.
Comment 4 Martin Oberhuber CLA 2007-07-23 18:28:39 EDT
(In reply to comment #2)
> Another case where trying to cast an ArrayList to Vector.

Have you ever analyzed why we keep getting ArrayList passed into methods that expect a Vector? - I'm all in favor of moving away from Vector to the more general List interface, but in the light of getting bugs fixed for 2.0.1 we should also fix the source of the issue, e.g.
    SystemCommonDeleteAction
which fires remoteChangedEvents with an ArrayList. We should also consider updating API docs to read what our API really expects -- ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DELETED talks about "List" being expected although ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE talks about "Vector" being expected. 

This is inconsistent, and for the sake of being API compatible in 2.0.1 I'd like to see us fire events with the less general "Vector" but expect events with the more general "List". With respect to the API docs, I'm not sure but there might even already exist a bug report asking for this to be sanitized, and if it is not yet there it should be created (I'm in favor of moving to "List" everywhere).

> Also changed getRemoteResourceAbsoluteName(Object) to use an
> ISystemViewElementAdapter instead of IRemoteObjectIdentifier.

Why? This change makes no sense. ISystemViewElementAdapter is a subclass of IRemoteObjectIdentifier, and by moving to a less general interface you're essentially breaking API (somebody who registers an adapter that's just an IRemoteObjectIdentifier but not an ISystemViewElementAdapter would no longer get his adapter called.

Reopening to get the previous version of getting the adapter restored, and getting the internal ArrayList replaced by a Vector in SystemCommonDeleteAction.
Comment 5 Kevin Doyle CLA 2007-07-23 23:00:16 EDT
I do not see a bug open for fixing up the API docs in regards to what is expected.  Though I do remember talking about Lists instead of Vector's, but maybe that was for the Validator's only.

In regards to making the change to ISystemViewElementAdapter.  I think I understood this wrong before.  Since the name isn't view specific and ISystemViewElementAdapter is a subclass of IRemoteObjectIdentifier it would be okay to use IRemoteObjectIdentifier for getting the absolute name, but for anything relating to the view itself we should be using ISystemViewElementAdapter.  

SystemView, SystemScratchpadView, and SystemTableView all use ISystemViewElementAdapter for getRemoteResourceAbsoluteName().  I'm not sure why we are doing it differently in this case.  It's weird seeing things done differently in different spots.

Though looking back at this I noticed that the code for getting an IRemoteObjectIdentifier adapter doesn't work.  It returns null.

return (IRemoteObjectIdentifier) ((IAdaptable)o).getAdapter(IRemoteObjectIdentifier.class);

Also SystemView has a protected getRemoteObjectIdentifier(Object) method that is never even used.  With that same line of code.
Comment 6 Martin Oberhuber CLA 2007-07-24 01:30:01 EDT
(In reply to comment #5)
> SystemView, SystemScratchpadView, and SystemTableView all use
> ISystemViewElementAdapter for getRemoteResourceAbsoluteName().  I'm not sure
> why we are doing it differently in this case.  It's weird seeing things done
> differently in different spots.

That's right.

> Though looking back at this I noticed that the code for getting an
> IRemoteObjectIdentifier adapter doesn't work.  It returns null.

I now see why -- the plugin.xml for files.ui has:
<!-- TODO Check: These are not in the adapter factories 
     getAdapterList() Although the adapter implements them
   <adapter type="org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier"/>
-->

The comments would need to be removed, and the factory class updated, to make it work. I want to think a little bit more about this, but now that it didn't ever work your change certainly is not a regression. Let's keep your code in the repository for now.

> Also SystemView has a protected getRemoteObjectIdentifier(Object) method that
> is never even used.  With that same line of code.

We should mark that deprecated right away since it does not work in 2.0.1 as of today.
Comment 7 Kevin Doyle CLA 2007-07-24 10:56:47 EDT
Created attachment 74471 [details]
SystemCommonDeleteAction now pass's Vector instead of ArrayList

This patch updates SystemCommonDeleteAction, so Vector's are passed instead of ArrayList's.  Also went through all class's implementing ISystemRemoteChangeListener to make sure they used the more general List.  SystemMonitorViewPart was the only one that wasn't and it's updated in the patch.

Legal Message: I, Kevin Doyle, declare that I developed attached code from
scratch, without referencing any 3rd party materials except material licensed
under the EPL. I am authorized by my employer, IBM Canada Ltd. to make this
contribution under the EPL.
Comment 8 Kevin Doyle CLA 2007-08-08 11:38:01 EDT
Created attachment 75681 [details]
Updated to deprecate getRemoteObjectIdentifier

Forgot to deprecate getRemoteObjectIdentifier in the previous patch.  Updated patch deprecates it.

Legal Message: I, Kevin Doyle, declare that I developed attached code from
scratch, without referencing any 3rd party materials except material licensed
under the EPL. I am authorized by my employer, IBM Canada Ltd. to make this
contribution under the EPL.
Comment 9 Xuan Chen CLA 2007-08-08 17:02:27 EDT
The patch looks good.  
Comment 10 Xuan Chen CLA 2007-08-08 17:08:01 EDT
You forgot to update the Contributor list in SystemView.java.  Please add it in.  Thanks.
Comment 11 Kevin Doyle CLA 2007-08-08 17:30:41 EDT
Created attachment 75712 [details]
Added Contributer Line

Legal Message: I, Kevin Doyle, declare that I developed attached code from
scratch, without referencing any 3rd party materials except material licensed
under the EPL. I am authorized by my employer, IBM Canada Ltd. to make this
contribution under the EPL.
Comment 12 Xuan Chen CLA 2007-08-08 23:45:08 EDT
I've committed the patch.
Comment 13 Kevin Doyle CLA 2007-09-13 13:57:51 EDT
Verified fixed in 2.0.1 RC1.