Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 345548
Collapse All | Expand All

(-)src/org/eclipse/core/internal/resources/SaveManager.java (-3 / +27 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 23-28 Link Here
23
import org.eclipse.osgi.util.NLS;
23
import org.eclipse.osgi.util.NLS;
24
24
25
public class SaveManager implements IElementInfoFlattener, IManager, IStringPoolParticipant {
25
public class SaveManager implements IElementInfoFlattener, IManager, IStringPoolParticipant {
26
	class MasterTable extends Properties {
27
		private static final long serialVersionUID = 1L;
28
29
		/* (non-Javadoc)
30
		 * @see java.util.Hashtable#put(java.lang.Object, java.lang.Object)
31
		 */
32
		public synchronized Object put(Object key, Object value) {
33
			Object prev = super.put(key, value);
34
			if (prev != null && ROOT_SEQUENCE_NUMBER_KEY.equals(key)) {
35
				int prevSeqNum = new Integer((String) prev).intValue();
36
				int currSeqNum = new Integer((String) value).intValue();
37
				if (prevSeqNum > currSeqNum) {
38
					//revert last put operation
39
					super.put(key, prev);
40
					//notify about the problem, do not throw exception but add the exception to know where it occurred
41
					String message = "Cannot set lower sequence number for root (previous: " + prevSeqNum + ", new: " + currSeqNum + "). Ignoring the new value."; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
42
					Policy.log(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IResourceStatus.INTERNAL_ERROR, message, new IllegalArgumentException(message)));
43
				}
44
			}
45
			return prev;
46
		}
47
	}
48
49
	protected static final String ROOT_SEQUENCE_NUMBER_KEY = Path.ROOT.toString() + LocalMetaArea.F_TREE;
26
	protected static final String CLEAR_DELTA_PREFIX = "clearDelta_"; //$NON-NLS-1$
50
	protected static final String CLEAR_DELTA_PREFIX = "clearDelta_"; //$NON-NLS-1$
27
	protected static final String DELTA_EXPIRATION_PREFIX = "deltaExpiration_"; //$NON-NLS-1$
51
	protected static final String DELTA_EXPIRATION_PREFIX = "deltaExpiration_"; //$NON-NLS-1$
28
	protected static final int DONE_SAVING = 3;
52
	protected static final int DONE_SAVING = 3;
Lines 44-50 Link Here
44
	protected static final String SAVE_NUMBER_PREFIX = "saveNumber_"; //$NON-NLS-1$
68
	protected static final String SAVE_NUMBER_PREFIX = "saveNumber_"; //$NON-NLS-1$
45
	protected static final int SAVING = 2;
69
	protected static final int SAVING = 2;
46
	protected ElementTree lastSnap;
70
	protected ElementTree lastSnap;
47
	protected Properties masterTable;
71
	protected MasterTable masterTable;
48
72
49
	/**
73
	/**
50
	 * A flag indicating that a save operation is occurring.  This is a signal
74
	 * A flag indicating that a save operation is occurring.  This is a signal
Lines 738-744 Link Here
738
762
739
	protected void restoreMasterTable() throws CoreException {
763
	protected void restoreMasterTable() throws CoreException {
740
		long start = System.currentTimeMillis();
764
		long start = System.currentTimeMillis();
741
		masterTable = new Properties();
765
		masterTable = new MasterTable();
742
		IPath location = workspace.getMetaArea().getSafeTableLocationFor(ResourcesPlugin.PI_RESOURCES);
766
		IPath location = workspace.getMetaArea().getSafeTableLocationFor(ResourcesPlugin.PI_RESOURCES);
743
		java.io.File target = location.toFile();
767
		java.io.File target = location.toFile();
744
		if (!target.exists()) {
768
		if (!target.exists()) {

Return to bug 345548