You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2010/11/05 13:35:20 UTC
svn commit: r1031540 - in
/james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq:
FileSystemBlobStrategy.java MimeMessageBlobMessageSource.java
Author: norman
Date: Fri Nov 5 12:35:20 2010
New Revision: 1031540
URL: http://svn.apache.org/viewvc?rev=1031540&view=rev
Log:
Make sure we close the InputStream of the BlobMessage on dispose() if that is not done we get problems when try to delete the file on windows
Modified:
james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java
james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/MimeMessageBlobMessageSource.java
Modified: james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java
URL: http://svn.apache.org/viewvc/james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java?rev=1031540&r1=1031539&r2=1031540&view=diff
==============================================================================
--- james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java (original)
+++ james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java Fri Nov 5 12:35:20 2010
@@ -34,6 +34,7 @@ import org.apache.activemq.blob.BlobDown
import org.apache.activemq.blob.BlobTransferPolicy;
import org.apache.activemq.blob.BlobUploadStrategy;
import org.apache.activemq.command.ActiveMQBlobMessage;
+import org.apache.commons.io.FileUtils;
import org.apache.james.core.NonClosingSharedInputStream;
import org.apache.james.services.FileSystem;
@@ -85,7 +86,9 @@ public class FileSystemBlobStrategy impl
public void deleteFile(ActiveMQBlobMessage message) throws IOException, JMSException {
File f = getFile(message);
if (f.exists()) {
- f.delete();
+ if (f.delete() == false) {
+ throw new IOException("Unable to delete file " + f);
+ }
}
}
@@ -93,8 +96,7 @@ public class FileSystemBlobStrategy impl
* Returns a {@link SharedFileInputStream} for the give {@link BlobMessage}
*/
public InputStream getInputStream(ActiveMQBlobMessage message) throws IOException, JMSException {
- // return a NonClosingSharedInputStream to make sure the stream will only get closed on dispose call later
- return new NonClosingSharedInputStream<SharedFileInputStream>(new SharedFileInputStream(getFile(message)));
+ return new SharedFileInputStream(getFile(message));
}
Modified: james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/MimeMessageBlobMessageSource.java
URL: http://svn.apache.org/viewvc/james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/MimeMessageBlobMessageSource.java?rev=1031540&r1=1031539&r2=1031540&view=diff
==============================================================================
--- james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/MimeMessageBlobMessageSource.java (original)
+++ james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/MimeMessageBlobMessageSource.java Fri Nov 5 12:35:20 2010
@@ -22,29 +22,27 @@ import java.io.IOException;
import java.io.InputStream;
import javax.jms.JMSException;
+import javax.mail.util.SharedFileInputStream;
import org.apache.activemq.BlobMessage;
import org.apache.activemq.Disposable;
import org.apache.james.core.MimeMessageSource;
-import org.apache.james.core.NonClosingSharedInputStream;
-import org.apache.james.lifecycle.LifecycleUtil;
/**
* {@link MimeMessageSource} which use a {@link BlobMessage} as input. Be aware that {@link BlobMessage} must contain
- * a {@link NonClosingSharedInputStream} for this implementation!
+ * a {@link SharedFileInputStream} for this implementation!
*
*/
-@SuppressWarnings("unchecked")
public class MimeMessageBlobMessageSource extends MimeMessageSource implements ActiveMQSupport, Disposable{
- private NonClosingSharedInputStream in;
+ private SharedFileInputStream in;
private String sourceId;
private long size;
public MimeMessageBlobMessageSource(BlobMessage message) throws JMSException, IOException {
this.sourceId = message.getJMSMessageID();
this.size = message.getLongProperty(JAMES_MAIL_MESSAGE_SIZE);
- this.in = (NonClosingSharedInputStream)message.getInputStream();
+ this.in = (SharedFileInputStream) message.getInputStream();
}
@@ -77,6 +75,10 @@ public class MimeMessageBlobMessageSourc
* Call dispose on the {@link InputStream}
*/
public void dispose() {
- LifecycleUtil.dispose(in);
+ try {
+ in.close();
+ } catch (IOException e) {
+ // ingore on dispose
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org