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/12/29 19:23:17 UTC
svn commit: r1053694 -
/james/server/trunk/core/src/main/java/org/apache/james/core/MimeMessageWrapper.java
Author: norman
Date: Wed Dec 29 18:23:17 2010
New Revision: 1053694
URL: http://svn.apache.org/viewvc?rev=1053694&view=rev
Log:
Start to rewrite MimeMessageWrapper to not load the whole Message content when only the headers are modified. Still in progress... Part of JAMES-1132
Modified:
james/server/trunk/core/src/main/java/org/apache/james/core/MimeMessageWrapper.java
Modified: james/server/trunk/core/src/main/java/org/apache/james/core/MimeMessageWrapper.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core/src/main/java/org/apache/james/core/MimeMessageWrapper.java?rev=1053694&r1=1053693&r2=1053694&view=diff
==============================================================================
--- james/server/trunk/core/src/main/java/org/apache/james/core/MimeMessageWrapper.java (original)
+++ james/server/trunk/core/src/main/java/org/apache/james/core/MimeMessageWrapper.java Wed Dec 29 18:23:17 2010
@@ -271,18 +271,8 @@ public class MimeMessageWrapper
* Rewritten for optimization purposes
*/
public synchronized void writeTo(OutputStream os) throws IOException, MessagingException {
- if (source != null && !isModified()) {
- // We do not want to instantiate the message... just read from source
- // and write to this outputstream
- InputStream in = source.getInputStream();
- try {
- IOUtils.copy(in, os);
- } finally {
- IOUtils.closeQuietly(in);
- }
- } else {
writeTo(os, os);
- }
+
}
/**
@@ -300,6 +290,9 @@ public class MimeMessageWrapper
}
public synchronized void writeTo(OutputStream headerOs, OutputStream bodyOs, String[] ignoreList) throws IOException, MessagingException {
+ if (!saved)
+ saveChanges();
+
if (source != null && !isModified()) {
//We do not want to instantiate the message... just read from source
// and write to this outputstream
@@ -307,14 +300,19 @@ public class MimeMessageWrapper
//First handle the headers
InputStream in = source.getInputStream();
try {
- InternetHeaders headers = new InternetHeaders(in);
- IOUtils.copy(new InternetHeadersInputStream(headers), headerOs);
+ MailHeaders headers = new MailHeaders(in);
+ IOUtils.copy(new InternetHeadersInputStream(headers.getNonMatchingHeaderLines(ignoreList)), headerOs);
IOUtils.copy(in, bodyOs);
} finally {
IOUtils.closeQuietly(in);
}
} else {
- MimeMessageUtil.writeToInternal(this, headerOs, bodyOs, ignoreList);
+ //MimeMessageUtil.writeToInternal(this, headerOs, bodyOs, ignoreList);
+ if (headers == null) {
+ loadHeaders();
+ }
+ IOUtils.copy(new InternetHeadersInputStream(headers.getNonMatchingHeaderLines(ignoreList)), headerOs);
+ MimeMessageUtil.writeMessageBodyTo(this, bodyOs);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org