james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gabriel Bucher <gabriel.buc...@razor.ch>
Subject Re: MailImpl.getSize() (Re: cvs commit: jakarta-james/src/java/org/apache/james/core MailImpl.java)
Date Tue, 30 Oct 2001 06:18:59 GMT
Quoting Oki DZ <okidz@pindad.com>:

> On 27 Oct 2001 danny@apache.org wrote:
> >   diff -u -r1.7 -r1.8
> >   --- MailImpl.java	2001/10/26 04:58:47	1.7
> >   +++ MailImpl.java	2001/10/27 18:09:20	1.8
> >   @@ -138,7 +138,7 @@
> >            int size = message.getSize();
> >            Enumeration e = message.getAllHeaderLines();
> >            while (e.hasMoreElements()) {
> >   -            size +=
> ((Header)e.nextElement()).toString().length();
> >   +            size += ((String)e.nextElement()).length();
> >            }
> >            return size;
> >        }
> 
> In MimeMessageJDBCSource.java:
>  public synchronized long getSize() throws IOException {
>         if (retrieveMessageBodySizeSQL == null) {
>             //There was no SQL statement for this repository... figure
> it
> out the hard way
>             return super.getSize();
>         }
> 
>         try {
>             Connection conn = repository.getConnection();
> 
>             PreparedStatement retrieveMessageSize =
> conn.prepareStatement(retrieveMessageBodySizeSQL);
>             retrieveMessageSize.setString(1, key);
>             retrieveMessageSize.setString(2,
> repository.repositoryName);
>             ResultSet rsRetrieveMessageSize =
> retrieveMessageSize.executeQuery();
> 
>             if (!rsRetrieveMessageSize.next()) {
>                 throw new IOException("Could not find message");
>             }
> 
>             long size = rsRetrieveMessageSize.getLong(1);
> //...
> 
> AFAIK, the messages stored in message_body field of James.Message are
> always including the header lines; so I believe that MailImpl.getSize()
If I understand James right, MailImpl.getSize() should be 'Message Content' + 
'Message Headers'!
> 
> and MimeMessageWrapper.getSize() (in which MimeMessageWrapper has a
> MimeMessageJDBCSource as one of its fields; if you use a db repository)
I think, the getSize() from MimeMessageYYYSource get back the wrong size! The 
class MimeMessageWrapper extends from MimeMessage. If you read the JavaDoc from 
JavaMail then you can see... that MimeMessage.getSize() is only the size of the 
'Message content'! MimeMessageWrapper.getSize() should get back the same as 
MimeMessage.getSize()! If you take a look into the MimeMessageInputStreamSource,  
you calculate the size of the hole message (headers + content).

> 
> would return different numbers. Is this all right? 
> 
> I don't think I've ever used MailImpl.getSize(); to get a message size,
> I
> always use MimeMessage message = MailImpl.getMessage(); int size =
> message.getSize(). I use a db repository, so I always get whatever
> length(message_body) returned by MySQL. But I believe that
> MailImpl.getSize()  and MimeMessageWrapper.getSize() should return the
> same number, right? No matter what kind of mail repository you use.
Both sould return the same size, thats correct!
I think, the most time, you are more interesting in the size of Headers + 
Content (MailImpl.getSize()) (for LIST/STAT) instead of only the size of the 
content (MimeMessageWrapper.getSize()).

I think, there are a couple of more problems in the classes MailImpl, 
MimeMessageWrapper, ....
I'm working on a couple of JUnit TestCases for this!

Cheers,
Buchi

> 
> Oki
> 
> 
> 
> --
> To unsubscribe, e-mail:  
> <mailto:james-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:james-dev-help@jakarta.apache.org>
> 
> 

--
To unsubscribe, e-mail:   <mailto:james-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:james-dev-help@jakarta.apache.org>


Mime
View raw message