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

(-)src/org/eclipse/jdt/core/tests/model/OptionTests.java (-1 / +11 lines)
Lines 14-19 Link Here
14
import java.util.Map;
14
import java.util.Map;
15
15
16
import junit.framework.Test;
16
import junit.framework.Test;
17
18
import org.eclipse.core.resources.ResourcesPlugin;
17
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.Path;
20
import org.eclipse.core.runtime.Path;
19
import org.eclipse.core.runtime.preferences.DefaultScope;
21
import org.eclipse.core.runtime.preferences.DefaultScope;
Lines 522-528 Link Here
522
		preferences.remove(JavaModelManager.CP_VARIABLE_PREFERENCES_PREFIX+"TEST");
524
		preferences.remove(JavaModelManager.CP_VARIABLE_PREFERENCES_PREFIX+"TEST");
523
	}
525
	}
524
}
526
}
525
527
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=217443
528
public void test13() {
529
	Hashtable options = JavaCore.getDefaultOptions();
530
	String immutableValue = (String) options.get(JavaCore.CORE_ENCODING);
531
	assertEquals(ResourcesPlugin.getEncoding(), immutableValue);
532
	options.put(JavaCore.CORE_ENCODING, immutableValue + "_extra_tail");
533
	JavaCore.setOptions(options);
534
	assertEquals(immutableValue, JavaCore.getOptions().get(JavaCore.CORE_ENCODING));
535
}
526
/**
536
/**
527
 * Bug 68993: [Preferences] IAE when opening project preferences
537
 * Bug 68993: [Preferences] IAE when opening project preferences
528
 * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=68993"
538
 * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=68993"
(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-7 / +13 lines)
Lines 1961-1971 Link Here
1961
		// set options using preferences service lookup
1961
		// set options using preferences service lookup
1962
		Iterator iterator = this.optionNames.iterator();
1962
		Iterator iterator = this.optionNames.iterator();
1963
		while (iterator.hasNext()) {
1963
		while (iterator.hasNext()) {
1964
		    String propertyName = (String) iterator.next();
1964
			String propertyName = (String) iterator.next();
1965
		    String propertyValue = service.get(propertyName, null, this.preferencesLookup);
1965
			String propertyValue = service.get(propertyName, null, this.preferencesLookup);
1966
		    if (propertyValue != null) {
1966
			if (propertyValue != null) {
1967
			    options.put(propertyName, propertyValue);
1967
				options.put(propertyName, propertyValue);
1968
		    }
1968
			}
1969
		}
1969
		}
1970
1970
1971
		// get encoding through resource plugin
1971
		// get encoding through resource plugin
Lines 4516-4521 Link Here
4516
	public void setOptions(Hashtable newOptions) {
4516
	public void setOptions(Hashtable newOptions) {
4517
4517
4518
		try {
4518
		try {
4519
			Hashtable cachedValue = newOptions == null ? null : new Hashtable(newOptions);
4519
			IEclipsePreferences defaultPreferences = getDefaultPreferences();
4520
			IEclipsePreferences defaultPreferences = getDefaultPreferences();
4520
			IEclipsePreferences instancePreferences = getInstancePreferences();
4521
			IEclipsePreferences instancePreferences = getInstancePreferences();
4521
4522
Lines 4526-4532 Link Here
4526
				while (keys.hasMoreElements()){
4527
				while (keys.hasMoreElements()){
4527
					String key = (String)keys.nextElement();
4528
					String key = (String)keys.nextElement();
4528
					if (!this.optionNames.contains(key)) continue; // unrecognized option
4529
					if (!this.optionNames.contains(key)) continue; // unrecognized option
4529
					if (key.equals(JavaCore.CORE_ENCODING)) continue; // skipped, contributed by resource prefs
4530
					if (key.equals(JavaCore.CORE_ENCODING)) {
4531
						if (cachedValue != null) {
4532
							cachedValue.put(key, JavaCore.getEncoding());
4533
						}
4534
						continue; // skipped, contributed by resource prefs
4535
					}
4530
					String value = (String)newOptions.get(key);
4536
					String value = (String)newOptions.get(key);
4531
					String defaultValue = defaultPreferences.get(key, null);
4537
					String defaultValue = defaultPreferences.get(key, null);
4532
					if (defaultValue != null && defaultValue.equals(value)) {
4538
					if (defaultValue != null && defaultValue.equals(value)) {
Lines 4541-4547 Link Here
4541
			instancePreferences.flush();
4547
			instancePreferences.flush();
4542
4548
4543
			// update cache
4549
			// update cache
4544
			this.optionsCache = newOptions==null ? null : new Hashtable(newOptions);
4550
			this.optionsCache = cachedValue;
4545
		} catch (BackingStoreException e) {
4551
		} catch (BackingStoreException e) {
4546
			// ignore
4552
			// ignore
4547
		}
4553
		}

Return to bug 217443