@@ -68,6 +68,7 @@ public CharsetManagerJob() {
6868 super (Messages .resources_charsetUpdating );
6969 setSystem (true );
7070 setPriority (Job .INTERACTIVE );
71+ setRule (workspace .getRoot ());
7172 }
7273
7374 @ Override
@@ -102,7 +103,7 @@ protected IStatus run(IProgressMonitor monitor) {
102103 workspace .prepareOperation (rule , monitor );
103104 workspace .beginOperation (true );
104105 Map .Entry <IProject , Boolean > next ;
105- while (( next = getNextChange ()) != null ) {
106+ while (! monitor . isCanceled () && (( next = getNextChange ()) != null ) ) {
106107 //just exit if the system is shutting down or has been shut down
107108 //it is too late to change the workspace at this point anyway
108109 if (systemBundle .getState () != Bundle .ACTIVE )
@@ -143,6 +144,16 @@ public boolean shouldRun() {
143144 return !asyncChanges .isEmpty ();
144145 }
145146 }
147+
148+ public void shutDown () {
149+ cancel ();
150+ wakeUp ();
151+ try {
152+ join (3000 , null );
153+ } catch (OperationCanceledException | InterruptedException ignored ) {
154+ // nothing
155+ }
156+ }
146157 }
147158
148159 private class ResourceChangeListener implements IResourceChangeListener {
@@ -495,6 +506,9 @@ private void setCharsetForHasFailed(IPath resourcePath, BackingStoreException e)
495506
496507 @ Override
497508 public void shutdown (IProgressMonitor monitor ) {
509+ if (job != null ) {
510+ job .shutDown ();
511+ }
498512 InstanceScope .INSTANCE .getNode (ResourcesPlugin .PI_RESOURCES )
499513 .removePreferenceChangeListener (preferenceChangeListener );
500514
0 commit comments