Author: norman
Date: Mon Nov 1 06:47:01 2010
New Revision: 1029565
URL: http://svn.apache.org/viewvc?rev=1029565&view=rev
Log:
Use proper synchronization in MimeMessageCopyOnWriteProxy to fix possible
race-condition (JAMES-900)
Modified:
james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageCopyOnWriteProxy.java
Modified:
james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageCopyOnWriteProxy.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageCopyOnWriteProxy.java?rev=1029565&r1=1029564&r2=1029565&view=diff
==============================================================================
---
james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageCopyOnWriteProxy.java
(original)
+++
james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageCopyOnWriteProxy.java
Mon Nov 1 06:47:01 2010
@@ -100,7 +100,7 @@ public class MimeMessageCopyOnWriteProxy
return referenceCount;
}
- public MimeMessage getWrapped() {
+ public synchronized MimeMessage getWrapped() {
return wrapped;
}
@@ -158,12 +158,10 @@ public class MimeMessageCopyOnWriteProxy
* @throws MessagingException
* exception
*/
- protected MimeMessage getWrappedMessageForWriting() throws
MessagingException {
- synchronized (refCount) {
- if (refCount.getReferenceCount() > 1) {
- refCount.decrementReferenceCount();
- refCount = new MessageReferenceTracker(new
MimeMessageWrapper(refCount.getWrapped()));
- }
+ protected synchronized MimeMessage getWrappedMessageForWriting() throws
MessagingException {
+ if (refCount.getReferenceCount() > 1) {
+ refCount.decrementReferenceCount();
+ refCount = new MessageReferenceTracker(new
MimeMessageWrapper(refCount.getWrapped()));
}
return refCount.getWrapped();
}
@@ -173,7 +171,7 @@ public class MimeMessageCopyOnWriteProxy
*
* @return wrapped return the wrapped mimeMessage
*/
- public MimeMessage getWrappedMessage() {
+ public synchronized MimeMessage getWrappedMessage() {
return refCount.getWrapped();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]