5 Replies Latest reply on Mar 13, 2006 10:38 AM by Andrew Oliver

    Small bug in org.jboss.mail.mailbox.MessageData

    sappenin Novice

      I found a small bug in org.jboss.mail.mailbox.MessageData.semiColize().

      Basically, this function takes a MailAddress array, and is supposed to return a string containing the addresses. The function appears to work properly when an array of length 1 is passed in. However, if the array has more than 1 address, the returned value is actually a semi-colon followed by the toString representation of the array class, generally something like:
      "; [Lorg.jboss.mail.message.MailAddress;@1ca8d36". This seems to primarily affect the contents of the "toAddress" field in the Messagedata table, only when a msg has more than 1 recipient.

      Here is the orig code...

      /**
       * take a set of addresses and turn them into a semi colon seperated string
       *
       * @param address
       * @return string containing the addresses
       */
       private String semiColize(MailAddress[] address) {
       String retval = "";
       for (int i = 0; i < address.length; i++) {
       retval = retval.length() == 0 ? address.toString() : ("; " + address.toString());
       }
       return retval;
       }
      


      And a suggested fix:

       /**
       * take a set of addresses and turn them into a semi colon seperated string
       *
       * @param address
       * @return string containing the addresses
       */
       private String semiColize(MailAddress[] address) {
       String retval = "";
       for (int i = 0; i < address.length; i++) {
      
      //Append into retval instead of assignment
      
       retval += retval.length() == 0 ? address.toString(): ("; " + address.toString()); //Read the value of the i'th address, instead of the array itself.
       }
       return retval;
       }