The exception is caught somewhere, so I set at earlier calling function
stack.
But
message is null
and it goes to finally.
Somewhere the exception is caught and never thrown back.
------------------
private synchronized void loadMessage() throws MessagingException {
if (message != null) {
//Another thread has already loaded this message
return;
}
InputStream in = null;
try {
in = source.getInputStream();
headers = new MailHeaders(in);
ByteArrayInputStream headersIn
= new ByteArrayInputStream(headers.toByteArray());
in = new SequenceInputStream(headersIn, in);
message = new MimeMessage(session, in);
} catch (IOException ioe) {
System.out.println(ioe);
throw new MessagingException("Unable to parse stream: " +
ioe.getMessage(), ioe);
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
} finally {
IOUtil.shutdownStream(in);
}
}
----------------------------
On 12/30/05, Edward Tan <[EMAIL PROTECTED]> wrote:
>
> I haven't pasted the exception message since I am confused why my Eclipse
> couldn't stop at the generic Exception and goes directly to finally. Or
> maybe my eyes are too tired.
>
> The exception is caught here, inside
> org.apache.james.core.MimeMessageWrapper
> ----------------------
> private synchronized void loadMessage() throws MessagingException {
> if (message != null) {
> //Another thread has already loaded this message
> return;
> }
> InputStream in = null;
> try {
> in = source.getInputStream();
> headers = new MailHeaders(in);
>
> ByteArrayInputStream headersIn
> = new ByteArrayInputStream(headers.toByteArray());
> in = new SequenceInputStream(headersIn, in);
>
> message = new MimeMessage(session, in);
> } catch (IOException ioe) {
> System.out.println(ioe);
> throw new MessagingException("Unable to parse stream: " +
> ioe.getMessage(), ioe);
> } catch (Exception e) {
> System.out.println(e);
> e.printStackTrace();
> } finally {
> IOUtil.shutdownStream(in);
> }
> }
> -------------------------
>
> But it doesn't stop at the breakpoints I set at
>
> throw new MessagingException....
>
> and
>
> e.printStackTrace....
>
> but it stops at IOUtil.shutdownStream(in);
>
> ----------------
>
> I add
> } catch (Exception e) {
> System.out.println(e);
> e.printStackTrace();
> in case it is other exception, but it was not caught here.
>
>
> -----------------
>
> I will try your suggestion.
>
>
> On 12/30/05, Stefano Bagnara <[EMAIL PROTECTED]> wrote:
> >
> > Edward Tan wrote:
> > > I just found out the culprit, it is not James code. It is
> > > javax.mail.MimeMessage
> > > [...]
> > > if (is instanceof SharedInputStream) {
> > > SharedInputStream sis = (SharedInputStream)is;
> > > contentStream = sis.newStream(sis.getPosition(), -1);
> > > } else {
> > > try {
> > > content = ASCIIUtility.getBytes(is);
> > > } catch (IOException ioex) {
> > > throw new MessagingException("IOException", ioex);
> > > }
> > > }
> >
> > I investigated a few months ago on using always
> > com.sun.mail.util.SharedByteArrayInputStream when loading message
> > sources to improve sun javamail performance.
> >
> > I replaced the following line in MimeMessageWrapper.loadMessage()
> >
> > ByteArrayInputStream headersIn = new
> > SharedByteArrayInputStream(headers.toByteArray());
> >
> > And the following in MimeMessageJDBCSource.getInputStream():
> >
> > InputStream in = new SharedByteArrayInputStream(headers);
> >
> > But I've had no time to do more tests.
> >
> > > -------------------------------------------
> > >
> > > I traced that the
> > >
> > > while ((len = is.read(buf, 0, size)) != -1)
> > > bos.write (buf, 0, len);
> > >
> > > causes the exception.
> > > -----------------------------------
> >
> > Again, What is the real exception? ;-)
> >
> > > With big attachment, this will crash. Any idea to avoid this?
> >
> > If you are confortable with james building try the above change and let
> > us know if it solve the problem!
> >
> > Stefano
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>