BlockingBuffer - Fix internal locking code

bug 37028, from Sebastian Bazley

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@312957 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2005-10-11 21:09:15 +00:00
parent 4fd151ac2d
commit 16cd754b19
3 changed files with 11 additions and 6 deletions

View File

@ -94,6 +94,7 @@ If this causes major headaches to anyone please contact commons-dev at jakarta.a
<li>BoundedFifoBuffer - Fix iterator remove bug causing ArrayIndexOutOfBounds error [33071]</li>
<li>UnboundedFifoBuffer - Fix iterator remove bug causing ArrayIndexOutOfBounds error [35733]</li>
<li>UnboundedFifoBuffer - Fix deserialization to work with subsequant object manipulation [35763]</li>
<li>BlockingBuffer - Fix internal locking code (internal fix, no effect on users of BlockingBuffer) [37028]</li>
<li>IteratorChain.remove() - Fix to avoid IllegalStateException when one of the underlying iterators is a FilterIterator [34267]</li>
<li>ExtendedProperties.convertProperties() - Fix to handle default properties maps correctly [32204]</li>
<li>Add casts to avoid some JDK1.5 compilation warnings [35474]</li>

View File

@ -147,6 +147,9 @@
<contributor>
<name>Nicola Ken Barozzi</name>
</contributor>
<contributor>
<name>Sebastian Bazley</name>
</contributor>
<contributor>
<name>Ola Berg</name>
</contributor>

View File

@ -41,6 +41,7 @@ import org.apache.commons.collections.BufferUnderflowException;
* @author Stephen Colebourne
* @author Janek Bogucki
* @author Phil Steitz
* @author Sebastian Bazley
* @version $Revision$ $Date$
* @since Commons Collections 3.0
*/
@ -76,7 +77,7 @@ public class BlockingBuffer extends SynchronizedBuffer {
public boolean add(Object o) {
synchronized (lock) {
boolean result = collection.add(o);
notifyAll();
lock.notifyAll();
return result;
}
}
@ -84,7 +85,7 @@ public class BlockingBuffer extends SynchronizedBuffer {
public boolean addAll(Collection c) {
synchronized (lock) {
boolean result = collection.addAll(c);
notifyAll();
lock.notifyAll();
return result;
}
}
@ -93,7 +94,7 @@ public class BlockingBuffer extends SynchronizedBuffer {
synchronized (lock) {
while (collection.isEmpty()) {
try {
wait();
lock.wait();
} catch (InterruptedException e) {
PrintWriter out = new PrintWriter(new StringWriter());
e.printStackTrace(out);
@ -110,7 +111,7 @@ public class BlockingBuffer extends SynchronizedBuffer {
long timeLeft = expiration - System.currentTimeMillis();
while (timeLeft > 0 && collection.isEmpty()) {
try {
wait(timeLeft);
lock.wait(timeLeft);
timeLeft = expiration - System.currentTimeMillis();
} catch(InterruptedException e) {
PrintWriter out = new PrintWriter(new StringWriter());
@ -129,7 +130,7 @@ public class BlockingBuffer extends SynchronizedBuffer {
synchronized (lock) {
while (collection.isEmpty()) {
try {
wait();
lock.wait();
} catch (InterruptedException e) {
PrintWriter out = new PrintWriter(new StringWriter());
e.printStackTrace(out);
@ -146,7 +147,7 @@ public class BlockingBuffer extends SynchronizedBuffer {
long timeLeft = expiration - System.currentTimeMillis();
while (timeLeft > 0 && collection.isEmpty()) {
try {
wait(timeLeft);
lock.wait(timeLeft);
timeLeft = expiration - System.currentTimeMillis();
} catch(InterruptedException e) {
PrintWriter out = new PrintWriter(new StringWriter());