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 59886 Details for
Bug 175531
Livelock in OverflowingLRUCache.privateRemoveEntry
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
175531.txt (text/plain), 4.14 KB, created by
Jerome Lanneluc
on 2007-02-27 11:42:08 EST
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2007-02-27 11:42:08 EST
Size:
4.14 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/BufferCache.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferCache.java,v >retrieving revision 1.16 >diff -u -r1.16 BufferCache.java >--- model/org/eclipse/jdt/internal/core/BufferCache.java 10 May 2006 18:03:47 -0000 1.16 >+++ model/org/eclipse/jdt/internal/core/BufferCache.java 27 Feb 2007 16:35:14 -0000 >@@ -10,6 +10,8 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.core; > >+import java.util.ArrayList; >+ > import org.eclipse.jdt.core.IBuffer; > import org.eclipse.jdt.internal.core.util.LRUCache; > >@@ -17,6 +19,8 @@ > * An LRU cache of <code>IBuffers</code>. > */ > public class BufferCache extends OverflowingLRUCache { >+ >+ private ArrayList buffersToClose = new ArrayList(); > /** > * Constructs a new buffer cache of the given size. > */ >@@ -44,10 +48,18 @@ > if (!((Openable)buffer.getOwner()).canBufferBeRemovedFromCache(buffer)) { > return false; > } else { >- buffer.close(); >+ this.buffersToClose.add(buffer); > return true; > } > } >+ >+void closeBuffers() { >+ ArrayList buffers = this.buffersToClose; >+ this.buffersToClose = new ArrayList(); >+ for (int i = 0, length = buffers.size(); i < length; i++) { >+ ((IBuffer) buffers.get(i)).close(); >+ } >+} > /** > * Returns a new instance of the reciever. > */ >Index: model/org/eclipse/jdt/internal/core/BufferManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferManager.java,v >retrieving revision 1.24 >diff -u -r1.24 BufferManager.java >--- model/org/eclipse/jdt/internal/core/BufferManager.java 10 May 2006 18:03:47 -0000 1.24 >+++ model/org/eclipse/jdt/internal/core/BufferManager.java 27 Feb 2007 16:35:14 -0000 >@@ -32,7 +32,7 @@ > * 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 >@@ -54,7 +54,11 @@ > String owner = ((Openable)buffer.getOwner()).toStringWithAncestors(); > System.out.println("Adding buffer for " + owner); //$NON-NLS-1$ > } >- this.openBuffers.put(buffer.getOwner(), buffer); >+ 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$ > } >@@ -74,7 +78,9 @@ > * buffer associated with it. > */ > public IBuffer getBuffer(IOpenable owner) { >- return (IBuffer)this.openBuffers.get(owner); >+ synchronized (this.openBuffers) { >+ return (IBuffer)this.openBuffers.get(owner); >+ } > } > /** > * Returns the default buffer manager. >@@ -101,10 +107,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; > } > > /** >@@ -115,7 +125,11 @@ > String owner = ((Openable)buffer.getOwner()).toStringWithAncestors(); > System.out.println("Removing buffer for " + owner); //$NON-NLS-1$ > } >- this.openBuffers.remove(buffer.getOwner()); >+ 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$ > }
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 175531
:
59790
| 59886