Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 108191

Summary: Unmeaningful error message in case of permission denied
Product: [Eclipse Project] Platform Reporter: Martijn van Steenbergen <mvsteenbergen>
Component: Update (deprecated - use Eclipse>Equinox>p2)Assignee: Platform-Update-Inbox <platform-update-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: Brady.barnard, hugo.a.garcia, lfrenzel, maxime_daniel
Version: 3.1   
Target Milestone: ---   
Hardware: Macintosh   
OS: All   
Whiteboard: obsolete
Attachments:
Description Flags
Fixed type problems for internal data structure
none
test case that provokes the reported ClassCastException none

Description Martijn van Steenbergen CLA 2005-08-27 07:00:12 EDT
If I try to install a plugin into the eclipse installatation directory while I don't have write permission in 
this directory, Update gives me a popup dialog with message 
"org.eclipse.update.internal.core.SiteFilePackedPluginContentConsumer". This seems to be the 
getMessage() of a ClassCastException, since the Error Log shows:

java.lang.ClassCastException: org.eclipse.update.internal.core.SiteFilePackedPluginContentConsumer
at org.eclipse.update.internal.core.SiteFileContentConsumer.abort(SiteFileContentConsumer.java:209)
at org.eclipse.update.internal.core.FeatureExecutableContentConsumer.abort
(FeatureExecutableContentConsumer.java:152)
at org.eclipse.update.core.Feature.install(Feature.java:516)
at org.eclipse.update.internal.core.SiteFile.install(SiteFile.java:74)
at org.eclipse.update.internal.core.ConfiguredSite.install(ConfiguredSite.java:122)
at org.eclipse.update.internal.core.ConfiguredSite.install(ConfiguredSite.java:86)
at org.eclipse.update.internal.operations.InstallOperation.execute(InstallOperation.java:72)
at org.eclipse.update.internal.operations.BatchInstallOperation.execute(BatchInstallOperation.java:84)
at org.eclipse.update.internal.ui.wizards.InstallWizard2.install(InstallWizard2.java:373)
at org.eclipse.update.internal.ui.wizards.InstallWizard2.access$1(InstallWizard2.java:370)
at org.eclipse.update.internal.ui.wizards.InstallWizard2$2.run(InstallWizard2.java:465)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)

Two questions:
- Should a ClassCastException occur or is this a bug?
- If a user does not have write permission in the target directory, could Eclipse give a more meaningful 
message?
Comment 1 Leif Frenzel CLA 2005-11-12 05:27:36 EST
I was not able to reproduce this behaviour on Windows or Linux (haven't got a 
Mac). On Linux, the error message is about write permissions.

However, it is clearly visible from the code what goes wrong, so I fixed at 
least the ClassCastException.

I attached a test case that exposes the bug and a patch with a fix. I was not
sure in which package the test case should go, so I stuck with the common
practice to put it into the same package where the tested class is. The test
will become unnecessary once we switch to Java 5, where problems like this are
checked by the compiler already. Depending on when that will be, we won't
probably need it in the test suite.
Comment 2 Leif Frenzel CLA 2005-11-12 05:29:19 EST
Created attachment 29821 [details]
Fixed type problems for internal data structure
Comment 3 Leif Frenzel CLA 2005-11-12 05:31:29 EST
Created attachment 29822 [details]
test case that provokes the reported ClassCastException
Comment 4 Pascal Rapicault CLA 2006-02-17 09:04:10 EST
*** Bug 122930 has been marked as a duplicate of this bug. ***
Comment 5 Hugo A. Garcia CLA 2006-12-27 15:11:23 EST
Hi

This problem is caused when code tries to write to a installation directory to which the user does not have write permission. I am writing my own automatic update code and it seems that the the ConfiguredSite.isUpdatable() is not correctly detecting the directory to be read only. I tried the following:

<psuedo>

ConfiguredSite targetSite = the installation site;

Site tSite = (Site) targetSite.getSite();
if (tSite.isReadOnly()) {
    logger.log(Level.INFO, "The site is read only");
} else {
    logger.log(Level.INFO, "The site is NOT read only");
}
		
			
if (targetSite.isUpdatable()) {
    logger.log(Level.INFO, "Site is updatable");
} else {
    logger.log(Level.INFO, "Site is NOT updatable");
}

</pseudo>

with the install site being read only (Windows) and I get back the following in the logs:

"The site is NOT read only" and "Site is updatable".

When the InstallationJob executes then it fails with the ClassCastException.

=======

As a workaround: I am trying to find a way to get the Location of the installation or plugin directory and grab an IFile instace so that I can test if is is read only or not. Hopefully something like this will work until this problem is resolved.
Comment 6 Hugo A. Garcia CLA 2006-12-27 16:05:23 EST
As a workaround:

Platform.getInstallLocation().isReadOnly()

correctly detects the installationLocation as read only if the permissions on the directory are deny write in Windows.

a simple conditional to avoid the installation job works. This is mainly for people writing their own update managers but it might provide a way to fix this bug.
Comment 7 John Arthorne CLA 2012-07-24 10:16:11 EDT
The Eclipse Update component is no longer under development, and no longer exists in the Eclipse Platform 4.x stream. If this problem still occurs in Eclipse Platform 4.2 or later, please enter a new bug report against Equinox p2.
Comment 8 Brady Barnard CLA 2015-03-05 21:17:09 EST
Im trying to use this software to download some things but it won't work and i dont know why it will work everytime i trey downloading it seems too be a problem even when I try to swipe my entire computer on the harddrives and uninstall a program or a program that does have a bug.Even when I try installing  i try cleaning the software also and it doesnt seem to be working i find it not being helpful or useful and when i try to fix it again it seems to be having the same problems over and over again.