Author: hlship
Date: Mon Jun 23 11:17:56 2008
New Revision: 670700
URL: http://svn.apache.org/viewvc?rev=670700&view=rev
Log:
TAPESTRY-2473: Application locks up, with all threads waiting for read lock
inside ConcurrentBarrier
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/ConcurrentBarrier.java
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/ConcurrentBarrier.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/ConcurrentBarrier.java?rev=670700&r1=670699&r2=670700&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/ConcurrentBarrier.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/ConcurrentBarrier.java
Mon Jun 23 11:17:56 2008
@@ -61,13 +61,21 @@
*/
public <T> T withRead(Invokable<T> invokable)
{
- boolean readLockedAtEntry = threadHasReadLock.get();
+ boolean readLockedAtEntry;
+
+ synchronized (threadHasReadLock)
+ {
+ readLockedAtEntry = threadHasReadLock.get();
+ }
if (!readLockedAtEntry)
{
lock.readLock().lock();
- threadHasReadLock.set(true);
+ synchronized (threadHasReadLock)
+ {
+ threadHasReadLock.set(true);
+ }
}
try
@@ -80,7 +88,10 @@
{
lock.readLock().unlock();
- threadHasReadLock.remove();
+ synchronized (threadHasReadLock)
+ {
+ threadHasReadLock.remove();
+ }
}
}
}
@@ -135,14 +146,23 @@
private boolean releaseReadLock()
{
- boolean readLockedAtEntry = threadHasReadLock.get();
+ boolean readLockedAtEntry;
+
+ synchronized (threadHasReadLock)
+ {
+ readLockedAtEntry = threadHasReadLock.get();
+ }
if (readLockedAtEntry)
{
lock.readLock().unlock();
- threadHasReadLock.set(false);
+ synchronized (threadHasReadLock)
+ {
+ threadHasReadLock.set(false);
+ }
}
+
return readLockedAtEntry;
}
@@ -152,11 +172,17 @@
{
lock.readLock().lock();
- threadHasReadLock.set(true);
+ synchronized (threadHasReadLock)
+ {
+ threadHasReadLock.set(true);
+ }
}
else
{
- threadHasReadLock.remove();
+ synchronized (threadHasReadLock)
+ {
+ threadHasReadLock.remove();
+ }
}
}