Author: norman
Date: Fri Nov 26 06:48:17 2010
New Revision: 1039252
URL: http://svn.apache.org/viewvc?rev=1039252&view=rev
Log:
Make sure we skip the headers in all cases. See IMAP-235
Modified:
james/imap/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMessage.java
james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/streaming/InputStreamContent.java
Modified:
james/imap/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMessage.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMessage.java?rev=1039252&r1=1039251&r2=1039252&view=diff
==============================================================================
---
james/imap/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMessage.java
(original)
+++
james/imap/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMessage.java
Fri Nov 26 06:48:17 2010
@@ -152,7 +152,7 @@ public class JCRMessage extends Abstract
this.bodyStartOctet = (int) (message.getFullContentOctets() -
message.getBodyOctets());
this.headers = new ArrayList<JCRHeader>();
-
+
List<Header> originalHeaders = message.getHeaders();
for (int i = 0; i < originalHeaders.size(); i++) {
headers.add(new JCRHeader(originalHeaders.get(i),logger));
@@ -768,15 +768,6 @@ public class JCRMessage extends Abstract
* @see org.apache.james.mailbox.store.mail.model.Message#getBodyContent()
*/
public InputStream getBodyContent() throws IOException {
- if (isPersistent()) {
- try {
- //TODO: Maybe we should cache this somehow...
- InputStream contentStream =
node.getNode(JcrConstants.JCR_CONTENT).getProperty(JcrConstants.JCR_DATA).getBinary().getStream();
- return new LazySkippingInputStream(contentStream,
getBodyStartOctet());
- } catch (RepositoryException e) {
- throw new IOException("Unable to retrieve property " +
JcrConstants.JCR_CONTENT, e);
- }
- }
- return content;
+ return new LazySkippingInputStream(getFullContent(),
getBodyStartOctet());
}
}
Modified:
james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/streaming/InputStreamContent.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/streaming/InputStreamContent.java?rev=1039252&r1=1039251&r2=1039252&view=diff
==============================================================================
---
james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/streaming/InputStreamContent.java
(original)
+++
james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/streaming/InputStreamContent.java
Fri Nov 26 06:48:17 2010
@@ -77,6 +77,7 @@ public final class InputStreamContent im
*/
public void writeTo(WritableByteChannel channel) throws IOException {
InputStream in = null;
+ InputStream wrapped = null;
long skipped = 0;
try {
switch (type) {
@@ -87,11 +88,15 @@ public final class InputStreamContent im
in = m.getBodyContent();
break;
}
+
if (in instanceof LazySkippingInputStream) {
skipped = ((LazySkippingInputStream) in).getSkippedBytes();
- in = ((LazySkippingInputStream) in).getWrapped();
+ wrapped = ((LazySkippingInputStream) in).getWrapped();
+ } else {
+ wrapped = in;
}
- if (in instanceof FileInputStream) {
+
+ if (wrapped instanceof FileInputStream) {
FileChannel fileChannel = ((FileInputStream)in).getChannel();
fileChannel.transferTo(skipped, fileChannel.size(), channel);
fileChannel.close();
@@ -111,8 +116,21 @@ public final class InputStreamContent im
}
} finally {
if(in != null) {
- in.close();
+ try {
+ in.close();
+ } catch (IOException e) {
+
+ }
+ }
+
+ if(wrapped != null) {
+ try {
+ wrapped.close();
+ } catch (IOException e) {
+
+ }
}
+
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]