Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 151180 Details for
Bug 262178
"out of sync with file system" error cannot be cleared by refresh or restart
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch
patch.txt (text/plain), 12.04 KB, created by
Michael Spector
on 2009-11-03 07:59:30 EST
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Michael Spector
Created:
2009-11-03 07:59:30 EST
Size:
12.04 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.dltk.core >Index: model/org/eclipse/dltk/internal/core/BufferManager.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/BufferManager.java,v >retrieving revision 1.3 >diff -u -r1.3 BufferManager.java >--- model/org/eclipse/dltk/internal/core/BufferManager.java 22 May 2008 07:54:36 -0000 1.3 >+++ model/org/eclipse/dltk/internal/core/BufferManager.java 3 Nov 2009 12:58:13 -0000 >@@ -15,6 +15,7 @@ > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IResource; > import org.eclipse.dltk.core.IBuffer; >+import org.eclipse.dltk.core.IBufferFactory; > import org.eclipse.dltk.core.IModelElement; > import org.eclipse.dltk.core.IOpenable; > >@@ -31,7 +32,19 @@ > * LRU cache of buffers. The key and value for an entry in the table is the > * identical buffer. > */ >- protected OverflowingLRUCache openBuffers = new BufferCache(60); >+ private BufferCache openBuffers = new BufferCache(60); >+ >+ /** >+ * @deprecated >+ */ >+ protected IBufferFactory defaultBufferFactory = new IBufferFactory() { >+ /** >+ * @deprecated >+ */ >+ public IBuffer createBuffer(IOpenable owner) { >+ return BufferManager.createBuffer(owner); >+ } >+ }; > > /** > * Adds a buffer to the table of open buffers. >@@ -42,7 +55,11 @@ > .toStringWithAncestors(); > System.out.println("Adding buffer for " + owner); //$NON-NLS-1$ > } >+ synchronized (this.openBuffers) { > this.openBuffers.put(buffer.getOwner(), buffer); >+ } >+ // close buffers that were removed from the cache if space was needed >+ this.openBuffers.closeBuffers(); > if (VERBOSE) { > System.out > .println("-> Buffer cache filling ratio = " + NumberFormat.getInstance().format(this.openBuffers.fillingRatio()) + "%"); //$NON-NLS-1$//$NON-NLS-2$ >@@ -50,19 +67,28 @@ > } > > public static IBuffer createBuffer(IOpenable owner) { >- IModelElement element = owner; >+ IModelElement element = (IModelElement) owner; > IResource resource = element.getResource(); > return new Buffer(resource instanceof IFile ? (IFile) resource : null, > owner, element.isReadOnly()); > } > >+ public static IBuffer createNullBuffer(IOpenable owner) { >+ IModelElement element = (IModelElement) owner; >+ IResource resource = element.getResource(); >+ return new NullBuffer(resource instanceof IFile ? (IFile) resource >+ : null, owner, element.isReadOnly()); >+ } >+ > /** > * Returns the open buffer associated with the given owner, or > * <code>null</code> if the owner does not have an open buffer associated > * with it. > */ > public IBuffer getBuffer(IOpenable owner) { >- return (IBuffer) this.openBuffers.get(owner); >+ synchronized (this.openBuffers) { >+ return (IBuffer) this.openBuffers.get(owner); >+ } > } > > /** >@@ -71,11 +97,20 @@ > public synchronized static BufferManager getDefaultBufferManager() { > if (DEFAULT_BUFFER_MANAGER == null) { > DEFAULT_BUFFER_MANAGER = new BufferManager(); >- } >+ } > return DEFAULT_BUFFER_MANAGER; > } > > /** >+ * Returns the default buffer factory. >+ * >+ * @deprecated >+ */ >+ public IBufferFactory getDefaultBufferFactory() { >+ return this.defaultBufferFactory; >+ } >+ >+ /** > * Returns an enumeration of all open buffers. > * <p> > * The <code>Enumeration</code> answered is thread safe. >@@ -84,10 +119,14 @@ > * @return Enumeration of IBuffer > */ > public Enumeration getOpenBuffers() { >+ Enumeration result; > synchronized (this.openBuffers) { > this.openBuffers.shrink(); >- return this.openBuffers.elements(); >- } >+ result = this.openBuffers.elements(); >+ } >+ // close buffers that were removed from the cache if space was needed >+ this.openBuffers.closeBuffers(); >+ return result; > } > > /** >@@ -98,8 +137,12 @@ > String owner = ((Openable) buffer.getOwner()) > .toStringWithAncestors(); > System.out.println("Removing buffer for " + owner); //$NON-NLS-1$ >- } >+ } >+ synchronized (this.openBuffers) { > this.openBuffers.remove(buffer.getOwner()); >+ } >+ // close buffers that were removed from the cache (should be only one) >+ this.openBuffers.closeBuffers(); > if (VERBOSE) { > System.out > .println("-> Buffer cache filling ratio = " + NumberFormat.getInstance().format(this.openBuffers.fillingRatio()) + "%"); //$NON-NLS-1$//$NON-NLS-2$ >Index: model/org/eclipse/dltk/internal/core/BufferCache.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/BufferCache.java,v >retrieving revision 1.2 >diff -u -r1.2 BufferCache.java >--- model/org/eclipse/dltk/internal/core/BufferCache.java 2 May 2007 15:05:00 -0000 1.2 >+++ model/org/eclipse/dltk/internal/core/BufferCache.java 3 Nov 2009 12:58:13 -0000 >@@ -9,6 +9,8 @@ > *******************************************************************************/ > package org.eclipse.dltk.internal.core; > >+import java.util.ArrayList; >+ > import org.eclipse.dltk.core.IBuffer; > import org.eclipse.dltk.internal.core.util.LRUCache; > >@@ -16,6 +18,8 @@ > * An LRU cache of <code>IBuffers</code>. > */ > public class BufferCache extends OverflowingLRUCache { >+ >+ private ThreadLocal buffersToClose = new ThreadLocal(); > /** > * Constructs a new buffer cache of the given size. > */ >@@ -37,20 +41,35 @@ > */ > protected boolean close(LRUCacheEntry entry) { > IBuffer buffer= (IBuffer) entry._fValue; >- >+ > // prevent buffer that have unsaved changes or working copy buffer to be removed > // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=39311 > if (!((Openable)buffer.getOwner()).canBufferBeRemovedFromCache(buffer)) { > return false; > } else { >- buffer.close(); >+ ArrayList buffers = (ArrayList) this.buffersToClose.get(); >+ if (buffers == null) { >+ buffers = new ArrayList(); >+ this.buffersToClose.set(buffers); >+ } >+ buffers.add(buffer); > return true; > } > } >+ >+ void closeBuffers() { >+ ArrayList buffers = (ArrayList) this.buffersToClose.get(); >+ if (buffers == null) >+ return; >+ this.buffersToClose.set(null); >+ for (int i = 0, length = buffers.size(); i < length; i++) { >+ ((IBuffer) buffers.get(i)).close(); >+ } >+ } > /** > * Returns a new instance of the reciever. > */ >- protected LRUCache newInstance(int size, int overflow) { >- return new BufferCache(size, overflow); >+ protected LRUCache newInstance(int size, int newOverflow) { >+ return new BufferCache(size, newOverflow); > } > } >Index: model/org/eclipse/dltk/internal/core/AbstractSourceModule.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/AbstractSourceModule.java,v >retrieving revision 1.40.2.1 >diff -u -r1.40.2.1 AbstractSourceModule.java >--- model/org/eclipse/dltk/internal/core/AbstractSourceModule.java 19 Oct 2009 11:40:25 -0000 1.40.2.1 >+++ model/org/eclipse/dltk/internal/core/AbstractSourceModule.java 3 Nov 2009 12:58:13 -0000 >@@ -618,63 +618,67 @@ > protected IBuffer openBuffer(IProgressMonitor pm, Object info) > throws ModelException { > // create buffer >- final BufferManager bufManager = getBufferManager(); >- final boolean isWorkingCopy = isWorkingCopy(); >+ BufferManager bufManager = getBufferManager(); >+ boolean isWorkingCopy = isWorkingCopy(); > IBuffer buffer = isWorkingCopy ? this.owner.createBuffer(this) > : BufferManager.createBuffer(this); >- if (buffer == null) { >+ if (buffer == null) > return null; >+ >+ ISourceModule original = null; >+ boolean mustSetToOriginalContent = false; >+ if (isWorkingCopy) { >+ // ensure that isOpen() is called outside the bufManager >+ // synchronized block >+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=237772 >+ mustSetToOriginalContent = !isPrimary() >+ && (original = new SourceModule((ModelElement) getParent(), >+ getElementName(), DefaultWorkingCopyOwner.PRIMARY)) >+ .isOpen(); > } > >- /* >- * synchronize to ensure that 2 threads are not putting 2 different >- * buffers at the same time see >- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=146331 >- */ >+ // synchronize to ensure that 2 threads are not putting 2 different >+ // buffers at the same time >+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=146331 > synchronized (bufManager) { >- final IBuffer existingBuffer = bufManager.getBuffer(this); >+ IBuffer existingBuffer = bufManager.getBuffer(this); > if (existingBuffer != null) > return existingBuffer; >+ > // set the buffer source >- char[] chars = buffer.getCharacters(); >- if ((chars == null) || (chars.length == 0)) { >+ if (buffer.getCharacters() == null) { > if (isWorkingCopy) { >- ISourceModule original; >- if (!isPrimary() >- && (original = getOriginalSourceModule()).isOpen()) { >+ if (mustSetToOriginalContent) { > buffer.setContents(original.getSource()); > } else { >- char[] content; >- try { >- content = getBufferContent(); >- } catch (ModelException e) { >- if (e.getStatus().getCode() == IModelStatusConstants.ELEMENT_DOES_NOT_EXIST) { >- content = CharOperation.NO_CHAR; >- } else { >- throw e; >- } >+ IFile file = (IFile) getResource(); >+ if (file == null || !file.exists()) { >+ // initialize buffer with empty contents >+ buffer.setContents(CharOperation.NO_CHAR); >+ } else { >+ buffer.setContents(Util >+ .getResourceContentsAsCharArray(file)); > } >- buffer.setContents(content); > } > } else { >- char[] content = getBufferContent(); >- buffer.setContents(content); >+ IFile file = (IFile) getResource(); >+ if (file == null || !file.exists()) >+ throw newNotPresentException(); >+ buffer.setContents(Util >+ .getResourceContentsAsCharArray(file)); > } > } > > // add buffer to buffer cache >- /* >- * note this may cause existing buffers to be removed from the >- * buffer cache, but only primary compilation unit's buffer can be >- * closed, thus no call to a client's IBuffer#close() can be done in >- * this synchronized block. >- */ >+ // note this may cause existing buffers to be removed from the >+ // buffer cache, but only primary compilation unit's buffer >+ // can be closed, thus no call to a client's IBuffer#close() can be >+ // done in this synchronized block. > bufManager.addBuffer(buffer); > > // listen to buffer changes > buffer.addBufferChangedListener(this); > } >- > return buffer; > } > >Index: model/org/eclipse/dltk/internal/core/NullBuffer.java >=================================================================== >RCS file: model/org/eclipse/dltk/internal/core/NullBuffer.java >diff -N model/org/eclipse/dltk/internal/core/NullBuffer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/org/eclipse/dltk/internal/core/NullBuffer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ >+ *******************************************************************************/ >+package org.eclipse.dltk.internal.core; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.dltk.core.IOpenable; >+ >+/** >+ * This class represents a null buffer. This buffer is used to represent a buffer for a class file >+ * that has no source attached. >+ */ >+public class NullBuffer extends Buffer { >+ /** >+ * Creates a new null buffer on an underlying resource. >+ */ >+ public NullBuffer(IFile file, IOpenable owner, boolean readOnly) { >+ super(file, owner, readOnly); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 262178
: 151180