Bug 190904 - [SSH] Changing Read-Only Attribute Throws Exception
Summary: [SSH] Changing Read-Only Attribute Throws Exception
Status: CLOSED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 RC2   Edit
Assignee: Martin Oberhuber CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: bugday
Depends on:
Blocks:
 
Reported: 2007-06-04 17:32 EDT by Kevin Doyle CLA
Modified: 2008-05-30 15:55 EDT (History)
3 users (show)

See Also:
rgerganov: review+


Attachments
Patch fixing the issue (2.60 KB, patch)
2008-05-26 17:29 EDT, Martin Oberhuber CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Doyle CLA 2007-06-04 17:32:10 EDT
After making a file/folder read-only an exception is thrown sometimes.  Usually see it when making a file/folder not read-only.

Steps to Reproduce:
1. Create an SSH connection
2. Create a directory
3. Make it read-only.
4. Make it not read-only.  
----> Sometimes an exception is thrown and the Remote Systems View is not refreshed.  So the read-only attribute is incorrect when going back to Preferences.

Stacktrace:
org.eclipse.rse.services.files.RemoteFileSecurityException: Operation failed. Security violation
	at org.eclipse.rse.internal.services.ssh.files.SftpFileService.makeSystemMessageException(SftpFileService.java:235)
	at org.eclipse.rse.internal.services.ssh.files.SftpFileService.setReadOnly(SftpFileService.java:873)
	at org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem.setReadOnly(FileServiceSubSystem.java:635)
	at org.eclipse.rse.internal.files.ui.propertypages.SystemFilePropertyPage.performOk(SystemFilePropertyPage.java:490)
	at org.eclipse.jface.preference.PreferenceDialog$12.run(PreferenceDialog.java:922)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.runtime.Platform.run(Platform.java:850)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:46)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:193)
	at org.eclipse.jface.preference.PreferenceDialog.okPressed(PreferenceDialog.java:902)
	at org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.okPressed(FilteredPreferenceDialog.java:374)
	at org.eclipse.jface.preference.PreferenceDialog.buttonPressed(PreferenceDialog.java:230)
	at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:616)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3673)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3284)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
	at org.eclipse.jface.window.Window.open(Window.java:796)
	at org.eclipse.ui.dialogs.PropertyDialogAction.run(PropertyDialogAction.java:156)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:545)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:402)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3673)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3284)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2365)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2329)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2204)
	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:497)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:436)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1162)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1137)

-----------Enter bugs above this line-----------
TM 2.0RC1 Testing
installation : eclipse-SDK-3.3M7
RSE install  : RSE 2.0 RC1
java.runtime : Sun 1.5.0_11-b03
os.name:     : Windows XP, Service Pack 2
------------------------------------------------
Comment 1 Martin Oberhuber CLA 2007-06-06 05:58:59 EDT
The SystemMessageException should include the original SftpException that caused it. But I do not see it in the backtrace below.

Was there a "caused by..." entry in the backtrace?
Was an error dialog shown that would include the cause?

If not, we'll need to imporve error reporting to ensure we get the real cause of this displayed to the user. Tentatively targeting 2.0RC3, but I'll need more info to address this.
Comment 2 Kevin Doyle CLA 2007-06-06 15:44:51 EDT
No error dialog is shown.  It looks like in SystemFilePropertyPage.performOk() we catch the exceptions and display them in the dialog, but ok = true so the dialog still closes.

The SftpException that is wrapped shows the error message: 4: Failure.
Comment 3 Martin Oberhuber CLA 2007-06-12 08:03:08 EDT
Assigning 2.0.1 since this does not happen consistently and is not critical. 

We should add a unit test for this (potentially exercising the function through EFS) and set folders and files read-only / writable repeatedly.
Comment 4 Martin Oberhuber CLA 2007-10-01 07:57:13 EDT
Bulk update target milestone 2.0.1 -> 3.0
Comment 5 Martin Oberhuber CLA 2008-05-26 17:29:38 EDT
Created attachment 102052 [details]
Patch fixing the issue

Attached patch fixes the issue. Problem was that JSch.setStat(SftpATTR) doesn't really work properly because the flags in SftpATTR cannot be re-set with API as needed. The ChannelSftp.chmod() call must be done instead.

Unittest for the fix is RSEFileStoreTest.testDeleteSpecialCases()
Comment 6 Martin Oberhuber CLA 2008-05-26 17:32:19 EDT
Patch committed:
[190904] Changing read-only attribute throws exception

Rado please review. This is a simple small one :-)
Comment 7 Radoslav Gerganov CLA 2008-05-27 07:20:45 EDT
Looks good to me. It's nice to also have a unit test.
Comment 8 Kevin Doyle CLA 2008-05-30 15:55:11 EDT
Verified Fixed with 3.0RC2.