Bug 102266 - [Encoding] Changing Text file encoding to UTF-8 causes exception
Summary: [Encoding] Changing Text file encoding to UTF-8 causes exception
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Team (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: Platform Team Inbox CLA Friend
QA Contact:
URL:
Whiteboard:
Keywords:
: 116256 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-06-30 01:07 EDT by Jed Anderson CLA Friend
Modified: 2005-11-14 15:58 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jed Anderson CLA Friend 2005-06-30 01:07:06 EDT
I tried to change the encoding on a file and got the following exception.

Afterwards the Properties dialog for the file continued to indicate that the
file encoding had been changed.  But when I restarted Eclipse it was reset to
the previous value (the default).

!ENTRY org.eclipse.core.runtime 4 2 2005-06-29 21:55:01.621
!MESSAGE An internal error occurred during: "Setting encoding".
!STACK 0
java.lang.IllegalArgumentException: Attempted to beginRule: R/, does not match
outer scope rule: P/<project name>
	at org.eclipse.core.internal.runtime.Assert.isLegal(Assert.java:58)
	at org.eclipse.core.internal.jobs.ThreadJob.illegalPush(ThreadJob.java:117)
	at org.eclipse.core.internal.jobs.ThreadJob.push(ThreadJob.java:211)
	at org.eclipse.core.internal.jobs.ImplicitJobs.begin(ImplicitJobs.java:59)
	at org.eclipse.core.internal.jobs.JobManager.beginRule(JobManager.java:190)
	at org.eclipse.core.internal.resources.WorkManager.checkIn(WorkManager.java:96)
	at
org.eclipse.core.internal.resources.Workspace.prepareOperation(Workspace.java:1674)
	at org.eclipse.core.internal.resources.Folder.create(Folder.java:88)
	at
org.eclipse.core.internal.resources.ProjectPreferences$2.run(ProjectPreferences.java:304)
	at
org.eclipse.core.internal.resources.ProjectPreferences.save(ProjectPreferences.java:315)
	at
org.eclipse.core.internal.preferences.EclipsePreferences.flush(EclipsePreferences.java:351)
	at
org.eclipse.core.internal.resources.ProjectPreferences.flush(ProjectPreferences.java:585)
	at
org.eclipse.core.internal.preferences.EclipsePreferences.flush(EclipsePreferences.java:339)
	at
org.eclipse.core.internal.resources.ProjectPreferences.flush(ProjectPreferences.java:585)
	at
org.eclipse.core.internal.resources.CharsetManager.setCharsetFor(CharsetManager.java:280)
	at org.eclipse.core.internal.resources.File.setCharset(File.java:448)
	at
org.eclipse.ui.ide.dialogs.ResourceEncodingFieldEditor$1.run(ResourceEncodingFieldEditor.java:136)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)
Comment 1 Tod Creasey CLA Friend 2005-06-30 08:22:10 EDT
Which build are you using?
Comment 2 John Arthorne CLA Friend 2005-06-30 09:55:04 EDT
Jed, was the project in question associated with any kind of repository (CVS or
otherwise)?
Comment 3 Rafael Chaves CLA Friend 2005-06-30 10:49:28 EDT
Also, can you reproduce it consistently?
Comment 4 Jed Anderson CLA Friend 2005-07-01 00:06:50 EDT
This is a 3.1 Release build bug.

The project was connected to a Perforce server via the P4WSAD plugin which can
be found at http://www.perforce.com/perforce/products/p4wsad.html

I tried creating a simple project, adding a file to it, and then changing the
encoding.

That worked.

Then I associated the project with the P4WSAD repo provider and tried to change
the settings and it failed.  Cool.

If you want to try it, the bug reproduces even if you don't have a Perforce
repository.  Just install the provider and dummy up some values for the
connection settings.  The update site for the provider is: 
http://www.perforce.com/downloads/http/p4-wsad/install/

I used the following for the values for the connection settings:

Port: codenovo.com:1666
User: jkca
Client Workspace: jkca
Comment 5 Rafael Chaves CLA Friend 2005-07-05 12:34:11 EDT
When setting the charset for a project, we might end up using use two nested rules:

outer: charsetRule(project)
inner: createRule(.settings directory)

The PessimisticResourceRuleFactory is in charge in this case, but does not
override charsetRule(). Thus, the charsetRule() (inherited from
ResourceRuleFactory) will return the project, but then later the createRule()
will return the workspace root, causing the problem above. So, the fix would be
to make sure PessimisticResourceRuleFactory overrides charsetRule() as well.

Moving to Platform/Team.
Comment 6 Rafael Chaves CLA Friend 2005-07-05 13:18:11 EDT
Too bad this just came up now. It had been like that for a long time (see bug
75750).
Comment 7 Michael Valenta CLA Friend 2005-08-04 11:55:06 EDT
Fix released to both 3.1.1 and 3.2.
Comment 8 Michael Valenta CLA Friend 2005-09-26 11:41:44 EDT
Verified fixed in M20050923-1430
Comment 9 John Arthorne CLA Friend 2005-11-14 15:58:21 EST
*** Bug 116256 has been marked as a duplicate of this bug. ***