synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Veithen <andreas.veit...@skynet.be>
Subject Re: svn commit: r638978 - /synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/mail/MailUtils.java
Date Wed, 19 Mar 2008 20:15:00 GMT
Ruwan,

I think there are some other things that should be cleaned up in this  
piece of code:

* The condition mbp != null is useless: if mbp is null, the expression  
mbp.getContentType() will cause a NPE before reaching the if  
statement. Anyway, the result of MimeBodyPart#getBodyPart is never null.
* plain/text is not a valid content type, so this condition is  
confusing and should be removed.
* The first if statement contains contType != null. If contType is  
null, the expression contType.indexOf(...) in the second if statement  
will always throw a NPE. Anyway, the result of getContentType is never  
null.
* After the for loop, the variable firstTextPart will actually store a  
reference to the *last* text part.

Andreas

On 19 Mar 2008, at 20:33, ruwan@apache.org wrote:
> Author: ruwan
> Date: Wed Mar 19 12:33:50 2008
> New Revision: 638978
>
> URL: http://svn.apache.org/viewvc?rev=638978&view=rev
> Log:
> Fixing issue SYNAPSE-256, (it seems gmail send the contentType as  
> text/plain rather than plain/text)
>
> Modified:
>    synapse/trunk/java/modules/transports/src/main/java/org/apache/ 
> synapse/transport/mail/MailUtils.java
>
> Modified: synapse/trunk/java/modules/transports/src/main/java/org/ 
> apache/synapse/transport/mail/MailUtils.java
> URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/mail/MailUtils.java?rev=638978&r1=638977&r2=638978&view=diff
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- synapse/trunk/java/modules/transports/src/main/java/org/apache/ 
> synapse/transport/mail/MailUtils.java (original)
> +++ synapse/trunk/java/modules/transports/src/main/java/org/apache/ 
> synapse/transport/mail/MailUtils.java Wed Mar 19 12:33:50 2008
> @@ -79,12 +79,15 @@
>                               
> contType.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) != -1)) {
>                             // this part is a SOAP 11 or 12 payload,  
> treat this as the message
>                             return mbp.getInputStream();
> -                        } else if (mbp == null &&  
> contType.indexOf("plain/text") != -1) {
> +                        } else if (mbp != null &&  
> (contType.indexOf("plain/text") != -1
> +                                || contType.indexOf("text/plain") ! 
> = -1)) {
>                             firstTextPart = mbp;
>                         }
>                     }
>                     // if a soap 11 or soap12 payload was not found,  
> treat first text part as message
> -                    return firstTextPart.getInputStream();
> +                    if (firstTextPart != null) {
> +                        return firstTextPart.getInputStream();
> +                    }
>
>                 } else {
>                     return ((Message) message).getInputStream();
> @@ -94,6 +97,7 @@
>             handleException("Error creating an input stream to : " +
>                 ((Message) message).getMessageNumber(), e);
>         }
> +
>         return null;
>     }
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


Mime
View raw message