View | Details | Raw Unified | Return to bug 255501
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/EncodingTests.java (-1 / +22 lines)
Lines 715-721 Link Here
715
			deleteFile("Encoding/Test34.txt");
715
			deleteFile("Encoding/Test34.txt");
716
		}
716
		}
717
	}
717
	}
718
718
	
719
	/**
719
	/**
720
	 * Bug 66898: refactor-rename: encoding is not preserved
720
	 * Bug 66898: refactor-rename: encoding is not preserved
721
	 * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=66898"
721
	 * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=66898"
Lines 910-915 Link Here
910
		}
910
		}
911
	}
911
	}
912
912
913
	/**
914
	 * Bug 255501: EncodingTests failing when run by itself
915
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=255501"
916
	 */
917
	public void testBug255501() throws Exception {
918
		String savedEncoding = null;
919
		String resourcesPluginId = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
920
		IEclipsePreferences preferences = new InstanceScope().getNode(resourcesPluginId);
921
		try {
922
			savedEncoding = preferences.get(ResourcesPlugin.PREF_ENCODING, "");
923
			JavaCore.getOptions(); // force options to be cached
924
			preferences.put(ResourcesPlugin.PREF_ENCODING, "UTF-16");
925
			preferences.flush();
926
			String encoding = (String) JavaCore.getOptions().get(JavaCore.CORE_ENCODING);
927
			assertEquals("Unexpected encoding", "UTF-16", encoding);
928
		} finally {
929
			preferences.put(ResourcesPlugin.PREF_ENCODING, savedEncoding);
930
			preferences.flush();
931
		}
932
	}
933
913
	private void verifyUtf8BOM(IFile file) throws CoreException {
934
	private void verifyUtf8BOM(IFile file) throws CoreException {
914
		assertNull("File should not have any explicit charset", file.getCharset(false));
935
		assertNull("File should not have any explicit charset", file.getCharset(false));
915
		IContentDescription contentDescription = file.getContentDescription();
936
		IContentDescription contentDescription = file.getContentDescription();
(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-5 / +15 lines)
Lines 1423-1433 Link Here
1423
	/**
1423
	/**
1424
	 * Listener on properties changes.
1424
	 * Listener on properties changes.
1425
	 */
1425
	 */
1426
	IEclipsePreferences.IPreferenceChangeListener propertyListener = new IEclipsePreferences.IPreferenceChangeListener() {
1426
	IEclipsePreferences.IPreferenceChangeListener propertyListener;
1427
		public void preferenceChange(PreferenceChangeEvent event) {
1427
	IEclipsePreferences.IPreferenceChangeListener resourcesPropertyListener;
1428
			JavaModelManager.this.optionsCache = null;
1429
		}
1430
	};
1431
1428
1432
	/**
1429
	/**
1433
	 * Constructs a new JavaModelManager
1430
	 * Constructs a new JavaModelManager
Lines 4465-4470 Link Here
4465
				}
4462
				}
4466
			};
4463
			};
4467
			new InstanceScope().getNode(JavaCore.PLUGIN_ID).addPreferenceChangeListener(this.propertyListener);
4464
			new InstanceScope().getNode(JavaCore.PLUGIN_ID).addPreferenceChangeListener(this.propertyListener);
4465
			
4466
			// listen for encoding changes (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=255501 )
4467
			this.resourcesPropertyListener = new IEclipsePreferences.IPreferenceChangeListener() {
4468
				public void preferenceChange(PreferenceChangeEvent event) {
4469
					if (ResourcesPlugin.PREF_ENCODING.equals(event.getKey())) {
4470
						JavaModelManager.this.optionsCache = null;
4471
					}
4472
				}
4473
			};
4474
			String resourcesPluginId = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
4475
			new InstanceScope().getNode(resourcesPluginId).addPreferenceChangeListener(this.resourcesPropertyListener);
4468
4476
4469
			// Listen to content-type changes
4477
			// Listen to content-type changes
4470
			 Platform.getContentTypeManager().addContentTypeChangeListener(this);
4478
			 Platform.getContentTypeManager().addContentTypeChangeListener(this);
Lines 4561-4566 Link Here
4561
		((IEclipsePreferences) this.preferencesLookup[PREF_INSTANCE].parent()).removeNodeChangeListener(this.instanceNodeListener);
4569
		((IEclipsePreferences) this.preferencesLookup[PREF_INSTANCE].parent()).removeNodeChangeListener(this.instanceNodeListener);
4562
		this.preferencesLookup[PREF_INSTANCE].removePreferenceChangeListener(this.instancePreferencesListener);
4570
		this.preferencesLookup[PREF_INSTANCE].removePreferenceChangeListener(this.instancePreferencesListener);
4563
		this.preferencesLookup[PREF_INSTANCE] = null;
4571
		this.preferencesLookup[PREF_INSTANCE] = null;
4572
		String resourcesPluginId = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
4573
		new InstanceScope().getNode(resourcesPluginId).removePreferenceChangeListener(this.resourcesPropertyListener);
4564
4574
4565
		// wait for the initialization job to finish
4575
		// wait for the initialization job to finish
4566
		try {
4576
		try {

Return to bug 255501