NullPointerException in MimeMessage copy constructor

It looks like the copy constructor for MimeMessage does not protect against a null flags and as such throws a NullPointerException.
I'm sure that this boils down to or is triggered by an IMAP server that is in some way not compliant to the IMAP spec.
I'm wondering if there is a workaround to this that anyone could recommend or if a fix to this is in the works.
In MimeMessage.getFlags(), it should check to see if flags == null before cloning. If not, it should return a new Flags() would be my guess.
I saw a discussion in another forum that mentions wrapping MimeMessage and implementing getFlags, however there's no way for my wrapper class to identify whether or not MimeMessages flags are null or not to compensate.
Any suggestions?

Yes, your IMAP server is broken. What server (what vendor) is it?
And yes, JavaMail should better protect against such broken servers.
I'll fix that for JavaMail 1.4.2.
In the mean time, something like this should work when you're copying a message:
public class MyMimeMessage extends MimeMessage {
    public MyMimeMessage(MimeMessage source) {
        super(source);
        if (flags == null)
            flags = new Flags();
}

Similar Messages

  • 12.4 beta: private copy constructor in base class required to be called from temporary reference when -g option used

    Hi,
    We've got an abstract base class (StringBase) which various types of strings inherit from. The copy constructor for this base class is private, since we don't want to allow copying when this class shouldn't be directly instantiated. A number of our methods take specify the base class as a reference, but take a derived class temporary as a default argument (see code appended).
    This worked fine in 12.3, but in 12.4 beta, this now says:
       Error: StringBase::StringBase(const StringBase&) is not accessible from __dflt_argA().
    This works fine in clang and gcc, and indeed, this GNU document says it was a bug which was fixed in gcc 4.3.0:
        Copy constructor access check while initializing a reference
    which references http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#391
    It only appears to error when the "-g" option is used, however, which doesn't seem right, and compiles fine if the "-g" option is removed, which makes me think it's a bug. Presumably the optimizer is eliding the copy when not using -g, but it's left in for debug mode, causing the compile error?
    Many thanks,
    Jonathan.
    $ clang++ -std=c++11 defaultarg.cpp
    $ g++ -std=c++11 defaultarg.cpp
    $ /opt/SolarisStudio12.4-beta_mar14-solaris-x86/bin/CC -c defaultarg.cpp
    $ /opt/SolarisStudio12.4-beta_mar14-solaris-x86/bin/CC -g -c defaultarg.cpp
    "defaultarg.cpp", line 6: Error: StringBase::StringBase(const StringBase&) is not accessible from __dflt_argA().
    1 Error(s) detected.
    $ cat defaultarg.cpp
    #include "stringbase.h"
    #include "conststring.h"
    static const ConstString S_DEFAULT("default value");
    void SomeMethod( const StringBase& str = S_DEFAULT )
       (void) str;
    int main( void )
       SomeMethod();
    $ cat stringbase.h
    #ifndef STRINGBASE_H
    #define STRINGBASE_H
    class StringBase
    protected:
       StringBase() {}
    private:
       StringBase( const StringBase& );
    #endif
    $ cat conststring.h
    #ifndef CONSTSTRING_H
    #define CONSTSTRING_H
    #include "stringbase.h"
    class ConstString : public StringBase
    public:
       ConstString() {}
       ConstString( const char* ) {}
       ConstString( const ConstString& );
    #endif

    Thanks for reporting the problem!
    This looks like a compiler bug, I think an artifact of creating a helper function for the debugger for the default argument.
    I have filed bug 18505648 for you.

  • No Pass-by-Value or Copy Constructors

    After having used AS3 for some months now, I've realized that
    there is no pass-by-value option when passing variables into
    functions. The only option is pass-by-reference. Similarly, there
    are no default copy constructors. So, if I want to create a copy of
    an object, I have to write code to create a new instance of the
    object and manually copy all of the source variable's properties to
    the new target object.
    This lack of a pass-by-value mechanism and copy constructors
    leads to some confusing behavior and necessitates writing quite a
    bit of extra code. A common case involving confusion is when a
    function call changes a property of a passed-in object. The caller
    might assume that the object will not be modified and then be
    surprised when it is. This is especially likely to happen when
    different people are working on the caller and the callee. It
    shouldn't be necessary for the caller to be concerned about the
    internal workings of an object being used but, because there is no
    pass-by-value mechanism, the caller often must take this into
    account.
    Because of the lack of a pass-by-value mechanism the onus is
    on the person writing a function to always make a copy of passed-in
    objects if they are going to be modified. Unfortunately, the lack
    of default copy constructors makes this an onerous task. The only
    way to copy an object is to write code to create a new object and
    then copy each property of the object. Where the properties are
    objects themselves a deep copy is needed and the amount of code can
    become large and the task tedious. To do this amounts to writing a
    set of copy constructors for each object and sub-object - each time
    a variable is accessed for modify.
    To make matters worse, it's not even possible to write a copy
    constructor for user-created classes. Consider the following
    attempt at writing a copy constructor to copy two instance
    variables for a custom Form class:
    public function Form(f:Form) {
    this._textHeight = f._textHeight;
    this._actionURL = f._actionURL;
    This causes a "Duplicate function definition" compile error
    because a default constructor already exists.
    Pass-by-value and built-in copy constructors are standard
    features in most OOP languages and their lack in AS3 is a glaring
    omission. I hope Adobe will seriously consider adding them to the
    next version of ActionScript.

    Nitin_Mathur wrote:
    at one time i had doubted my own conceptsNote that the type of a parameter may be different from the type of the object you created. However, it is still the same value that is passed, as pointed out by this example:
    public class Test {
        public Test() {
            //an object of type "MyClass" is created on the heap with the "new" operator:
            MyClass myClass = new MyClass();
            doSomething(myClass);//the reference to the object is passed by value
        private void doSomething(MyInterface myInterface) {
            //the passed value is a reference to a "MyClass" object,
            //but here it is considered to be a "MyInterface" object
            //and we don't have access to the "MyClass"-method "testClass()"
            myInterface.testInterface();
        public static void main(String[] args) {
            new Test();
    interface MyInterface {
        public void testInterface();
    class MyClass implements MyInterface {
        public void testInterface() {
            System.out.println("testInterface");
        public void testClass(){
            System.out.println("testClass");
    }

  • Copy constructor and temporary objects in C++

    I'd need some clarification on how constructor works when the argument is  a temporary object. I defined a dummy MyVect class with operator+ and copy constructor:
    class MyVect {
    public:
    MyVect() {
    cout << "Constructor" << endl;
    MyVect(const MyVect &vect){
    cout << "Copy Constructor" << endl;
    ~MyVect() {
    cout << "Destructor" << endl;
    MyVect operator+(const MyVect &v) const {
    cout << "operator+" << endl;
    MyVect result
    return result;
    Then I test it with this very simple code pattern:
    MyVect v1;
    MyVect v2;
    MyVect v3(v1 + v2);
    The output is:
    Constructor
    Constructor
    operator+
    Constructor
    Destructor
    Destructor
    Destructor
    The first two constructor calls are for v1 and v2, then operator+ for  v1+v2 is called, and  inside it there is a constructor call for result object. But then no copy constructor (nor constructor) for v3 is called. In my limited understanding of C++, I guessed that once the temporary object resulting from v1+v2 has been created, then it would be the argument of the copy constructor call. Instead it looks like the compiler transforms the temporary into v3, since v3 is correctly initialized as the sum of v1 and v2 (I tried with a more complicated version of MyVect to verify this). This behavior reminds me of the move semantics introduced with C++11, but I'm not using the -std=c++11 flag (and in fact if I try to define a move constructor the compilation fails).
    Can anyone please help me to understand what's happening under the hood? Thanks.
    Last edited by snack (2013-02-13 10:44:28)

    wikipedia wrote:The following cases may result in a call to a copy constructor:
    When an object is returned by value
    When an object is passed (to a function) by value as an argument
    When an object is thrown
    When an object is caught
    When an object is placed in a brace-enclosed initializer list
    These cases are collectively called copy-initialization and are equivalent to:[2] T x = a;
    It is however, not guaranteed that a copy constructor will be called in these cases, because the C++ Standard allows the compiler to optimize the copy away in certain cases, one example being the return value optimization (sometimes referred to as RVO).
    Last edited by Lord Bo (2013-02-13 13:58:47)

  • Copy Constructors vs clone()

    In C++, the copy constructor (along with the assignment operator, which doesn't exist in Java) was the standard way of copying an Object. In Java, we have the Clonable interface, but the option of using Copy Constructors remains.
    So, which is preferable? The Clonable interface is clumsy and poorly designed, but many programming language theorists discourage the use of Copy Constructors. Bruce Eckel (of Thinking in Java) seems to use Copy Constructors a lot, but Sun uses the Clonable interface.
    What are the pros and cons of each?

    Hallo,
    in order to use the Copy Constructor, you need to know that you have an instance of class X, eg:
    X a, b;
    a = new X();
    b = new X(a);On the other hand, if you are deep in code somewhere and you need a copy of an Object, then cloning is the only way to make a copy, as you do not know what class you have.
    doSomething (Object obj) {
       if (obj instanceof Cloneable) {
          Object objCopy = obj.clone();
    }So it is a question of horses for courses.

  • Is java supports Copy Constructor ?

    Is Java Supports copy constructor ? why?
    Thanks

    clone is perferable over copy constructors, as
    Object.clone() will produce the correct type of
    object no matter who called it, wheras you are
    responsible for this if you use copy constructors...
    unless of course the copy constructor is defined in a
    final class, in which case cc's are fine.IMHO, Clone is to be avioded as;
    - most classes don't support it.
    - class which do support it don't do a deep copy which is that most people expect it to do.
    The only really safe way to take a copy of an object is to serialize it and deserialize it.

  • NullPointerException in TaskFileUtil.copy (line 95) during publishing

    Hi,
    I am working on a migration project where the application will be upgraded from weblogic server 8.3 to oracle weblogic server 10.3.
    During publishing I am getting the nullpointer exception.
    java.lang.NullPointerException
         at com.bea.wli.ide.worklist.ui.util.TaskFileUtil.copy(TaskFileUtil.java:95)
         at com.bea.wli.ide.worklist.ui.publish.CopyTaskFilesPublishTask$Task.copyTaskFiles(CopyTaskFilesPublishTask.java:130)
         at com.bea.wli.ide.worklist.ui.publish.CopyTaskFilesPublishTask$Task.execute(CopyTaskFilesPublishTask.java:96)
         at com.bea.workshop.wls.core.server.internal.WeblogicServerBehaviour.performTasks(WeblogicServerBehaviour.java:1189)
         at com.bea.workshop.wls.core.server.internal.WeblogicServerBehaviour.publishToServer(WeblogicServerBehaviour.java:744)
         at com.bea.workshop.wls.core.server.internal.WeblogicServerBehaviour.publishOnce(WeblogicServerBehaviour.java:607)
         at com.bea.workshop.wls.core.server.internal.WeblogicServerBehaviour.publish(WeblogicServerBehaviour.java:503)
         at org.eclipse.wst.server.core.internal.Server.doPublish(Server.java:887)
         at org.eclipse.wst.server.core.internal.Server.publish(Server.java:874)
         at org.eclipse.wst.server.core.internal.PublishServerJob.run(PublishServerJob.java:72)
         at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
    Is there any workaround for this kind of problem?
    Any help will be highly appriciated.
    Thanks,
    Bishan Samaddar

    Hi,
    This problem is addressed in Bug 8489078
    A patch for WLI 10.3 and WLI 10.3.1 is available.
    Please contact customer support for patch details.
    Regards,
    Kal

  • Java error : NullPointerException while system copy

    Hi All,
    system: windowsNT 2003 with SQL 2005
    error while heterogeneous backup of system (CRM system ABAP + Java)
    SAPinit_dev.log
    SEVERE: Error during export of EP_ATTR_HEADERS
    Sep 29, 2010 7:22:32 PM com.sap.inst.jload.Jload logStackTrace
    SEVERE: java.lang.NullPointerException
         at com.sap.sql.jdbc.mss.MssSQLExceptionAnalyzer.getCategory(MssSQLExceptionAnalyzer.java:112)
         at com.sap.sql.services.core.CoreServices.isDuplicateKeyException(CoreServices.java:133)
         at com.sap.sql.jdbc.direct.DirectPreparedStatement.processSQLException(DirectPreparedStatement.java:1189)
         at com.sap.sql.jdbc.direct.DirectPreparedStatement.executeQuery(DirectPreparedStatement.java:285)
         at com.sap.sql.jdbc.common.CommonPreparedStatement.executeQuery(CommonPreparedStatement.java:185)
         at com.sap.inst.jload.db.DBTable.unload(DBTable.java:192)
         at com.sap.inst.jload.Jload.dbExport(Jload.java:179)
         at com.sap.inst.jload.Jload.executeJob(Jload.java:395)
         at com.sap.inst.jload.Jload.main(Jload.java:621)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.sap.engine.offline.OfflineToolStart.main(OfflineToolStart.java:81
    Reply soon
    jattxxx

    Hi Jattxxx,
    Which JDBC driver are you using?
    There was a similiar problem when using the Microsoft SQL Server 2005 Driver for JDBC version 1.1 or an older version 1.2. Therefore, if you're using the MSSQL 2005 JDBC driver, I would recommend to replace it by a newer one of version 1.2 (*).
    Best regards,
    Guenther
    The file "Microsoft SQL Server 2005 Driver for JDBC version 1.2" can be downloaded from:                                                            
    http://service.sap.com/swcenter-3pmain
    -> MS SQL Server -> JDBC Drivers and Tools.

  • Free case issue - very limited info of cases :(

    Very limited info/spec/images are available for various cases for iPhone 4. It is pathetic that companies don't bother to publish more info when they are reaping millions by selling their cases. It wouldn't take more than an hour to publish more info online. Unhappy with this lethargic behaviour.
    I guess Apple should pressurize some of these companies.
    If any one can give info/inside story/pics/review about following, it would be great!!
    1 Incase smoke & clear - Does smoke have plastic material or rubber? What about scratches?
    2 belkin shield micra (except that single image which keeps floating everywhere)
    3 Griffin motif diamond/smoke - has anyone used it?
    Pixelskin HD has very good videos on youtube and hence so many people might have opted for it.

    The MimeMessage constructor you're using needs to copy the entire message from the server.  It uses the Message.writeTo method, writing the message content into a pipe that is read by the constructor.  It was a bug in previous releases that the writeTo method wasn't fetching the data in chunks, as it does in other cases.  Setting partialfetch=false will revert to the old behavior for writeTo, and for all other accesses of the message content.
    It looks like both 1.4.4 and 1.5.1 are fetching the message content using a single FETCH command when you set partialfetch=false, according to your message.  If they're both sending the same commands to the server, I can't explain why it would be fast in one case and slow in the other.
    I did similar testing using my Exchange 2010 server.  Fetching a similar size message took less than 20 seconds.  Setting partialfetch=false brought it down to less than 5 seconds.  Something's clearly wrong in your environment, but I don't know what.
    Finally, I'm sure you understand that you only need to use that MimeMessage copy constructor in special circumstances, and you should probably avoid using it unless it's absolutely necessary.  Even in the best case it's wasting time and memory.

  • Javax.mail.MessagingException: Unable to load BODYSTRUCTURE

    Hi.
    when i try receive message i have next exception. (But some message recieve without this problem). Can help me?
    Exception with Session debug:
    A12 FETCH 5 (ENVELOPE INTERNALDATE RFC822.SIZE)
    * 5 FETCH (INTERNALDATE "14-Dec-2006 08:46:20 -0500" RFC822.SIZE 35458 ENVELOPE ("Thu, 14 Dec 2006 15:46:13 +0200" "Fwd: Fwd: 123" (("s2mtestAIM" NIL "s2mtest" "aim.com")) (("s2mtestAIM" NIL "s2mtest" "aim.com")) (("s2mtestAIM" NIL "s2mtest" "aim.com")) ((NIL NIL "s2mtest" "aim.com")) NIL NIL "<[email protected]>" "<[email protected]>"))
    A12 OK FETCH completed
    FROM: s2mtestAIM <[email protected]>
    TO: [email protected]
    SUBJECT: Fwd: Fwd: 123
    SendDate: Thu Dec 14 15:46:13 EET 2006
    FLAGS: XAOL-GOODCHECK-DONE
    A13 FETCH 5 (BODYSTRUCTURE)
    * 5 FETCH (BODYSTRUCTURE (("TEXT" "HTML" ("CHARSET" "windows-1251") NIL NIL "QUOTED-PRINTABLE" 4071 146 NIL NIL NIL)("MESSAGE" "RFC822" ("NAME" "1.eml") NIL NIL "7BIT" 13251 NIL ("attachment" ("FILENAME" "1.eml")) NIL)("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 17777 ("Thu, 14 Dec 2006 13:17:25 +0200" "Fwd: 123" (("s2mtestAIM" NIL "s2mtest" "aim.com")) (("s2mtestAIM" NIL "s2mtest" "aim.com")) (("s2mtestAIM" NIL "s2mtest" "aim.com")) ((NIL NIL "s2mtest" "aim.com")) NIL NIL "<[email protected]>" "<[email protected]>") (("TEXT" "HTML" ("CHARSET" "windows-1251") NIL NIL "QUOTED-PRINTABLE" 3103 124 NIL NIL NIL)("MESSAGE" "RFC822" ("NAME" "1.eml") NIL NIL "7BIT" 3723 NIL ("attachment" ("FILENAME" "1.eml")) NIL)("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 1658 ("Thu, 14 Dec 2006 12:36:23 +0200" "123" (("12323" NIL "resetdel" "gmail.com")) (("12323" NIL "resetdel" "gmail.com")) (("12323" NIL "resetdel" "gmail.com")) ((NIL NIL "s2mtest" "aol.com")) NIL NIL NIL "<[email protected]>") ("TEXT" "HTML" ("CHARSET" "windows-1251") NIL NIL "7BIT" 1658 0 NIL NIL NIL) 0 NIL NIL NIL)("TEXT" "HTML" ("CHARSET" "windows-1251") NIL NIL "QUOTED-PRINTABLE" 2063 97 NIL NIL NIL)("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 1697 35 NIL NIL NIL)("TEXT" "HTML" ("CHARSET" "windows-1251") NIL NIL "QUOTED-PRINTABLE" 2063 97 NIL NIL NIL) "MIXED" ("BOUNDARY" "----------87AC1A33733336A") NIL NIL) 440 NIL NIL NIL) "MIXED" ("BOUNDARY" "----------121BF2519BABDF9") NIL NIL))
    A13 OK FETCH completed
    javax.mail.MessagingException: Unable to load BODYSTRUCTURE
         at com.sun.mail.imap.IMAPMessage.loadBODYSTRUCTURE(IMAPMessage.java:1117)
         at com.sun.mail.imap.IMAPMessage.getContentType(IMAPMessage.java:340)
    Thanks.

    Then it's a bug in the AIM IMAP server, please report it.
    I guess this deserves a FAQ entry. Here's what I'll add:
    Q: I can read messages from my IMAP server with other mail clients,
    but even though I can connect to the server using JavaMail, when I use
    JavaMail to read some messages it fails. Doesn't that mean there's a bug
    in JavaMail?
    A: No, not usually. Most other mail clients make very little
    use of the rich IMAP protocol. They use the IMAP protocol as little
    more than a variant of the POP3 protocol, typically downloading the
    entire message to the client and parsing it in the client. This allows
    them to avoid all sorts of parsing and protocol bugs in many IMAP
    servers, but of course it comes at the cost of being less efficient
    because they don't take advantage of the IMAP protocol's ability to
    fetch only the parts of the message that are needed. These server bugs
    often manifest themselves as the following exception on the client:
    javax.mail.MessagingException: Unable to load BODYSTRUCTURE
    The best approach when running into server bugs of this sort is to contact
    the vendor of the server and get them to fix their product. Contact
    [email protected] and we'll help you
    pinpoint the problem so that you can report it to the server vendor.
    If you can't get a fix from the server vendor, the following technique
    will often allow you to work around these server bugs:
        // Get the message object from the folder in the
        // usual way, for example:
        MimeMessage msg = (MimeMessage)folder.getMessage(n);
        // Use the MimeMessage copy constructor to make a copy
        // of the entire message, which will fetch the entire
        // message from the server and parse it on the client:
        MimeMessage cmsg = new MimeMessage(msg);
        // The cmsg object is disconnected from the server so
        // setFlags will have no effect (for example).  Use
        // the original msg object for such operations.  Use
        // the cmsg object to access the content of the message.

  • Very slow with imap

    I have just got a Macbook Air 2011 with Mountain Lion. Everything goes fine, except Mail. Normally, it's working. But when I read imap messages, even the message size is less than 1MB, Mail is very slow, even frozen for a while. CPU will be used much, I can hear the fan working at max speed, I assume.
    Downloading messages is fine, it is just making me crazy when clicking to imap messages. Any idea to fix it please?
    Thanks.

    The MimeMessage constructor you're using needs to copy the entire message from the server.  It uses the Message.writeTo method, writing the message content into a pipe that is read by the constructor.  It was a bug in previous releases that the writeTo method wasn't fetching the data in chunks, as it does in other cases.  Setting partialfetch=false will revert to the old behavior for writeTo, and for all other accesses of the message content.
    It looks like both 1.4.4 and 1.5.1 are fetching the message content using a single FETCH command when you set partialfetch=false, according to your message.  If they're both sending the same commands to the server, I can't explain why it would be fast in one case and slow in the other.
    I did similar testing using my Exchange 2010 server.  Fetching a similar size message took less than 20 seconds.  Setting partialfetch=false brought it down to less than 5 seconds.  Something's clearly wrong in your environment, but I don't know what.
    Finally, I'm sure you understand that you only need to use that MimeMessage copy constructor in special circumstances, and you should probably avoid using it unless it's absolutely necessary.  Even in the best case it's wasting time and memory.

  • Very slow retrieval of messages with IMAP

    I have a problem with javamail versions greater than 1.4.4:
    I use IMAP and STARTTLS to connect to Exchange Server 2010
    The mail I try to read in this example has RFC822.SIZE = 2317220 but the problem occurs with all mails.
    This is the code where it happens ( line 3 )
    msg = (MimeMessage)currentFolder.getMessage(1);
    log.debug(mailBoxID +" start reading mail");
    fullMessage = new MimeMessage(msg);
    log.debug(mailBoxID +"   end reading mail");
    With 1.4.5 and higher it takes approx. 8 minutes ( in debug mode ) to get the full mail.
    With 1.4.4 it takes only 4 seconds ( also in debug mode ).
    I tried 3 scenario's with 1.5.1: ( but I have the same problem with 1.4.5 and 1.4.6 )
    mail.imap.fetchsize: 16384 ==> 8 minutes
    mail.imap.fetchsize: 102400 ==> 7 minutes
    mail.imap.partialfetch: false ==> 9 minutes
    I tried 2 scenario's with 1.4.4:
    mail.imap.fetchsize: 16384 ==> 4 seconds
    mail.imap.partialfetch: false ==> 4 seconds
    I suppose fetchsize and partialfetch are not part of the problem.
    There must be some configuration issue but I don't find it.
    And I have the same problem with the demo programs.
    Here are some snippets from the protocol debug and the program debug for all scenario's:
    DEBUG: setDebug: JavaMail version 1.5.1
    DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle]
    DEBUG IMAP: mail.imap.fetchsize: 16384
    DEBUG IMAP: mail.imap.ignorebodystructuresize: false
    DEBUG IMAP: mail.imap.statuscachetimeout: 1000
    DEBUG IMAP: mail.imap.appendbuffersize: -1
    DEBUG IMAP: mail.imap.minidletime: 10
    DEBUG IMAP: disable AUTH=PLAIN
    DEBUG IMAP: disable AUTH=NTLM
    DEBUG IMAP: enable STARTTLS
    ==> fetches in blocks of 16384
    A10 FETCH 1 (BODY[]<0.16384>)
    * 1 FETCH (BODY[]<0> {16384}
    FLAGS (\Seen))
    A11 OK FETCH completed.
    A12 FETCH 1 (BODY[]<32768.16384>)
    * 1 FETCH (BODY[]<32768> {16384}
    FLAGS (\Seen))
    A202 OK FETCH completed.
    A203 FETCH 1 (BODY[]<3162112.16384>)
    * 1 FETCH (BODY[]<3162112> {11800}
    FLAGS (\Seen))
    A203 OK FETCH completed.
    2013-11-19 13:10:31 [Thread-4] DEBUG MailHandler :67 -  start reading mail
    2013-11-19 13:18:31 [Thread-4] DEBUG MailHandler :69 -    end reading mail
    ==> 8 minutes
    DEBUG: setDebug: JavaMail version 1.5.1
    DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle]
    DEBUG IMAP: mail.imap.fetchsize: 102400
    DEBUG IMAP: mail.imap.ignorebodystructuresize: false
    DEBUG IMAP: mail.imap.statuscachetimeout: 1000
    DEBUG IMAP: mail.imap.appendbuffersize: -1
    DEBUG IMAP: mail.imap.minidletime: 10
    DEBUG IMAP: disable AUTH=PLAIN
    DEBUG IMAP: disable AUTH=NTLM
    DEBUG IMAP: enable STARTTLS
    ==> fetches in blocks of 102400
    FLAGS (\Seen))
    A10 OK FETCH completed.
    A11 FETCH 1 (BODY[]<102400.102400>)
    * 1 FETCH (BODY[]<102400> {102400}
    FLAGS (\Seen))
    A39 OK FETCH completed.
    A40 FETCH 1 (BODY[]<3072000.102400>)
    * 1 FETCH (BODY[]<3072000> {101912}
    FLAGS (\Seen))
    A40 OK FETCH completed.
    2013-11-19 14:23:42 [Thread-4] DEBUG MailHandler :67 -  start reading mail
    2013-11-19 14:30:30 [Thread-4] DEBUG MailHandler :69 -    end reading mail
    ==> 7 minutes
    DEBUG: setDebug: JavaMail version 1.5.1
    DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle]
    DEBUG IMAP: mail.imap.partialfetch: false
    DEBUG IMAP: mail.imap.ignorebodystructuresize: false
    DEBUG IMAP: mail.imap.statuscachetimeout: 1000
    DEBUG IMAP: mail.imap.appendbuffersize: -1
    DEBUG IMAP: mail.imap.minidletime: 10
    DEBUG IMAP: disable AUTH=PLAIN
    DEBUG IMAP: disable AUTH=NTLM
    DEBUG IMAP: enable STARTTLS
    ==> 1 big fetch
    2013-11-19 13:21:35 [Thread-4] DEBUG MailHandler :67 -  start reading mail
    2013-11-19 13:30:47 [Thread-4] DEBUG MailHandler :69 -    end reading mail
    ==> 9 minutes
    DEBUG: setDebug: JavaMail version 1.4.4
    DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]
    DEBUG: mail.imap.fetchsize: 16384
    DEBUG: mail.imap.statuscachetimeout: 1000
    DEBUG: mail.imap.appendbuffersize: -1
    DEBUG: mail.imap.minidletime: 10
    DEBUG: disable AUTH=PLAIN
    DEBUG: disable AUTH=NTLM
    DEBUG: enable STARTTLS
    ==> 1 big fetch
    2013-11-19 13:55:47 [Thread-4] DEBUG MailHandler :67 -  start reading mail
    2013-11-19 13:55:51 [Thread-4] DEBUG MailHandler :69 -    end reading mail
    ==> 4 seconds
    DEBUG: setDebug: JavaMail version 1.4.4
    DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]
    DEBUG: mail.imap.partialfetch: false
    DEBUG: mail.imap.statuscachetimeout: 1000
    DEBUG: mail.imap.appendbuffersize: -1
    DEBUG: mail.imap.minidletime: 10
    DEBUG: disable AUTH=PLAIN
    DEBUG: disable AUTH=NTLM
    DEBUG: enable STARTTLS
    ==> 1 big fetch
    2013-11-19 14:02:52 [Thread-4] DEBUG MailHandler :67 -  start reading mail
    2013-11-19 14:02:58 [Thread-4] DEBUG MailHandler :69 -    end reading mail
    ==> 4 seconds
    Here is a listing of all properties:
    java.runtime.name=Java(TM) SE Runtime Environment
    sun.boot.library.path=H:\java\jre6\bin
    java.vm.version=20.5-b03
    java.vm.vendor=Sun Microsystems Inc.
    java.vendor.url=http://java.sun.com/
    path.separator=;
    mail.mime.decodefilename=true
    java.vm.name=Java HotSpot(TM) Client VM
    file.encoding.pkg=sun.io
    user.country=BE
    sun.java.launcher=SUN_STANDARD
    sun.os.patch.level=Service Pack 2
    mail.imap.auth.ntlm.disable=true
    java.vm.specification.name=Java Virtual Machine Specification
    user.dir=H:\EclipseSpace\DigisMailBatchNewDev
    java.runtime.version=1.6.0_30-b12
    java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
    mail.imap.fetchsize=102400
    java.endorsed.dirs=H:\java\jre6\lib\endorsed
    os.arch=x86
    java.io.tmpdir=D:\Temp\
    line.separator=
    java.vm.specification.vendor=Sun Microsystems Inc.
    user.variant=
    os.name=Windows XP
    sun.jnu.encoding=Cp1252
    java.library.path=H:\java\jre6\bin;C:\WINDOWS\Sun\Java\...
    mail.imap.auth.plain.disable=true
    java.specification.name=Java Platform API Specification
    java.class.version=50.0
    mail.mime.address.strict=false
    sun.management.compiler=HotSpot Client Compiler
    os.version=5.1
    user.home=C:\Documents and Settings\******
    user.timezone=Europe/Paris
    java.awt.printerjob=sun.awt.windows.WPrinterJob
    java.specification.version=1.6
    file.encoding=Cp1252
    user.name=******
    java.class.path=H:\EclipseSpace\DigisMailBatchNewDev;...
    mail.mime.decodetext.strict=false
    java.vm.specification.version=1.0
    sun.arch.data.model=32
    java.home=H:\java\jre6
    sun.java.command=com.dexia.digis.mail.Launcher
    mail.imap.partialfetch=true
    java.specification.vendor=Sun Microsystems Inc.
    user.language=nl
    awt.toolkit=sun.awt.windows.WToolkit
    java.vm.info=mixed mode
    java.version=1.6.0_30
    java.ext.dirs=H:\java\jre6\lib\ext;C:\WINDOWS\Sun\J...
    sun.boot.class.path=H:\java\jre6\lib\resources.jar;H:\jav...
    java.vendor=Sun Microsystems Inc.
    file.separator=\
    java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport...
    mail.imap.starttls.enable=true
    sun.cpu.endian=little
    sun.io.unicode.encoding=UnicodeLittle
    mail.mime.parameters.strict=false
    sun.desktop=windows
    sun.cpu.isalist=
    And here is the complete protocol stacktrace up to the point where the mail is retrieved.
    It's the same for all cases except the snippets above:
    DEBUG IMAP: trying to connect to host "our-email-server.be", port 143, isSSL false
    * OK The Microsoft Exchange IMAP4 service is ready.
    A0 CAPABILITY
    * CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI AUTH=PLAIN STARTTLS UIDPLUS CHILDREN IDLE NAMESPACE LITERAL+
    A0 OK CAPABILITY completed.
    DEBUG IMAP: AUTH: NTLM
    DEBUG IMAP: AUTH: GSSAPI
    DEBUG IMAP: AUTH: PLAIN
    DEBUG IMAP: protocolConnect login, host=our-email-server.be, user=mydomain\userid\aliasname, password=<non-null>
    A1 STARTTLS
    A1 OK Begin TLS negotiation now.
    A2 CAPABILITY
    * CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI AUTH=PLAIN UIDPLUS CHILDREN IDLE NAMESPACE LITERAL+
    A2 OK CAPABILITY completed.
    DEBUG IMAP: AUTH: NTLM
    DEBUG IMAP: AUTH: GSSAPI
    DEBUG IMAP: AUTH: PLAIN
    DEBUG IMAP: LOGIN command trace suppressed
    DEBUG IMAP: LOGIN command result: A3 OK LOGIN completed.
    A4 CAPABILITY
    * CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI AUTH=PLAIN UIDPLUS CHILDREN IDLE NAMESPACE LITERAL+
    A4 OK CAPABILITY completed.
    DEBUG IMAP: AUTH: NTLM
    DEBUG IMAP: AUTH: GSSAPI
    DEBUG IMAP: AUTH: PLAIN
    A5 LIST "" myfolder
    * LIST (\HasNoChildren) "/" myfolder
    A5 OK LIST completed.
    DEBUG IMAP: connection available -- size: 1
    A6 SELECT myfolder
    * 1 EXISTS
    * 0 RECENT
    * FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
    * OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags
    * OK [UIDVALIDITY 39147] UIDVALIDITY value
    * OK [UIDNEXT 141] The next unique identifier value
    A6 OK [READ-WRITE] SELECT completed.
    A7 EXPUNGE
    * 1 EXISTS
    A7 OK EXPUNGE completed.
    A8 FETCH 1 (FLAGS)
    * 1 FETCH (FLAGS (\Seen))
    A8 OK FETCH completed.
    A9 FETCH 1 (ENVELOPE INTERNALDATE RFC822.SIZE)
    * 1 FETCH (ENVELOPE ("Fri, 9 Aug 2013 14:17:14 +0200" "subject" ........ INTERNALDATE "09-Aug-2013 14:17:14 +0200" RFC822.SIZE 2317220)
    A9 OK FETCH completed.
    A10 FETCH 1 (BODY[]<0.102400>)
    * 1 FETCH (BODY[]<0> {102400}

    The MimeMessage constructor you're using needs to copy the entire message from the server.  It uses the Message.writeTo method, writing the message content into a pipe that is read by the constructor.  It was a bug in previous releases that the writeTo method wasn't fetching the data in chunks, as it does in other cases.  Setting partialfetch=false will revert to the old behavior for writeTo, and for all other accesses of the message content.
    It looks like both 1.4.4 and 1.5.1 are fetching the message content using a single FETCH command when you set partialfetch=false, according to your message.  If they're both sending the same commands to the server, I can't explain why it would be fast in one case and slow in the other.
    I did similar testing using my Exchange 2010 server.  Fetching a similar size message took less than 20 seconds.  Setting partialfetch=false brought it down to less than 5 seconds.  Something's clearly wrong in your environment, but I don't know what.
    Finally, I'm sure you understand that you only need to use that MimeMessage copy constructor in special circumstances, and you should probably avoid using it unless it's absolutely necessary.  Even in the best case it's wasting time and memory.

  • Flags.Flag ANSWERED can i create a FORWARDED

    We have a way to identify the mails which are sent i.e we can set the flag ANSWERED.
    How can identify a message which has been forwarded. I dont see any flag called Flags.Flag FORWARDED.
    Can any one suggest how can I achieve this?
    Thanks a lot in advance.
    Raaki.

    Message msg = m_RepliedMessage.getMessage();
    Folder fld = msg.getFolder();
    fld.open(Folder.READ_WRITE);
    msg.setFlag(new Flags("FORWARDED"), true);
    fld.close(false);Ok, I see your problem.
    When you close the folder, the message loses all connection with
    the folder. In fact, you should assume that the Message object is
    no longer valid after you close the folder.
    So, going from a Message object, back to the Folder object that is
    closed, and trying to reopen the Folder and modify the flags for the
    message isn't going to work.
    You need to leave the Folder open until you're done processing the
    message.
    If you want to process the message "offline", you need to make an
    explicit copy of the message (e.g.,using the MimeMessage copy
    constructor), then close the Folder. If you then want to modify the
    flags for the message that are stored back in the Folder, you need
    to reopen the Folder, get a new Message object corresponding to
    the message whose flags you want to change, e.g., by looking up
    the message by UID, and then modify the flags.
    Understand?

  • Is there way to automate testing download speed

    I'm having big trouble with my IP with speeds bouncing all over the place. I would like to automate Safari going to Speakeasy in a new Safari window, selecting Los Angeles, waiting for test to complete, snapping a screenshot of the results, with that screenshot put in a specific folder. Is this possible, & if so, how do I do it? I would like to do it say every hour.
    Thanks,
    Harris

    romsrini wrote:
    We are currently forcing the entire message (writeTo(ByteArrayOutputStream)) to minimize our MessagingExceptions. Should we only do it when get an Exception ?Writing out the message doesn't really help. JavaMail doesn't cache the data from the message so when you access
    the data later, it's still going to go back to the server. If you want to ensure there's only one place where you might
    get an exception while accessing message data, you need to make a complete copy of the message (e.g., using the
    MimeMessage copy constructor) and then operate on the copy. Although the problem with that approach is that it's
    very inefficient; you might as well be using POP3 instead of IMAP. I think you need a better approach for dealing
    with exceptions...
    Also, when you say that IMAP supports what we're trying to do, do you mean that (assuming we stop calling the writeTo method) its only the part.saveFile() call that actually downloads or fetches the attachment from the store?Yes.

  • Getting FolderClosedException

    Hi all
    the code below causes a FolderClosedException
              Folder currentFolder = imapStore.getFolder("INBOX");
              currentFolder.open(Folder.READ_ONLY);
              Message message = currentFolder.getMessage(1);
              currentFolder.close(false);
                    System.out.println(message.getSubject());how can i store a Message object in a variable to use it later ?
    thanks

    You need to make a complete local copy of the message. Use the MimeMessage copy constructor:
    MimeMessage offlineMessage = new MimeMessage(currentFolder.getMessage(1));

Maybe you are looking for

  • Excise Invoice - Fields not visible

    Hi All We are having problem in created excise invoice for export sales. When i do the J1iin for the same and click on utilization, all the fields in Excise details tab(Excise invoice type - EXPORT  Bond / No Bond / Deemed / LoU) are greyed, not able

  • Adding image to JDialog in Applet

    Well.. I've decided to make my Applet load via a JDialog. Which I know is possible :). And to a start I'll make a very simple Applet in the JDialog, including a background picture, which I just can't add! So to make a long story short, I want an imag

  • Converting hexadecimal value to double   Hlep needed!!!

    Is there a way that I can convert the following hexadecimal value into double: String s = "16#1234#"; As converting this to long I am doing this if (s.startsWith("16#") && s.endsWith("#")) extractedValue = s.substring( 3, s.length()-1 ); longValue =

  • Why are my stills blurry?

    Please help wise ones. I have a problem in my timeline, after I render my project (1 hour long), a lot of stills blurred or jumped, I have to find the original still, copy & then do a paste attributes to the ones that are in the timeline. Not all sti

  • Intel AMT and Intel Small Business Advantage

    I am trying to enable Intel AMT.  When I run the ACU Wizard, I receive the following message: How can I disable/uninstall SBA? If it is not possible to disable/uninstall SBA, how do I enable Intel AMT using SBA? Many thanks.