I think the null value should be handled at the OMOutputFormat but the
getCharSetEncoding shouldn't worry about it. As Andreas pointed in this
thread [1] for a binary protocol the charsetEncoding has to be optional :-(

Thanks,
Ruwan

[1] -
http://mail-archives.apache.org/mod_mbox/synapse-dev/200910.mbox/%3cb67458760910111234ve431fek4b9e7af21316e...@mail.gmail.com%3e

On Sun, Oct 11, 2009 at 4:22 PM, Andreas Veithen
<andreas.veit...@gmail.com>wrote:

> This change causes a regression in a dependent project; see
> SYNAPSE-590. Comments?
>
> Andreas
>
> On Thu, Sep 24, 2009 at 04:22,  <n...@apache.org> wrote:
> > Author: nagy
> > Date: Thu Sep 24 02:22:02 2009
> > New Revision: 818346
> >
> > URL: http://svn.apache.org/viewvc?rev=818346&view=rev
> > Log:
> > Fix potential NPE during serialization if an encoding has not been set
> for the OMOutputFormat.
> >
> > Modified:
> >
>  
> webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMOutputFormat.java
> >
>  
> webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMSourcedElementTest.java
> >
> > Modified:
> webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMOutputFormat.java
> > URL:
> http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMOutputFormat.java?rev=818346&r1=818345&r2=818346&view=diff
> >
> ==============================================================================
> > ---
> webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMOutputFormat.java
> (original)
> > +++
> webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMOutputFormat.java
> Thu Sep 24 02:22:02 2009
> > @@ -214,7 +214,7 @@
> >      * @return Returns encoding string.
> >      */
> >     public String getCharSetEncoding() {
> > -        return this.charSetEncoding;
> > +        return (this.charSetEncoding !=
> null)?this.charSetEncoding:DEFAULT_CHAR_SET_ENCODING;
> >     }
> >
> >     public void setCharSetEncoding(String charSetEncoding) {
> >
> > Modified:
> webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMSourcedElementTest.java
> > URL:
> http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMSourcedElementTest.java?rev=818346&r1=818345&r2=818346&view=diff
> >
> ==============================================================================
> > ---
> webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMSourcedElementTest.java
> (original)
> > +++
> webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/OMSourcedElementTest.java
> Thu Sep 24 02:22:02 2009
> > @@ -139,7 +139,15 @@
> >         String payload = new String(bytes, "utf-16");
> >         assertTrue("The obtained bytes did not match the payload",
> >                    payload1.equals(payload));
> > -
> > +
> > +        // Test getting the raw bytes with the default encoding
> > +        OMOutputFormat outputFormat = new OMOutputFormat();
> > +        baos = new ByteArrayOutputStream();
> > +        ds.serialize(baos, outputFormat);
> > +        output =
> baos.toString(OMOutputFormat.DEFAULT_CHAR_SET_ENCODING);
> > +        System.out.println(output);
> > +        assertTrue("The obtained bytes did not match the payload",
> > +                   payload1.equals(output));
> >     }
> >
> >     /**
> >
> >
> >
>



-- 
Ruwan Linton
Technical Lead & Product Manager; WSO2 ESB; http://wso2.org/esb
WSO2 Inc.; http://wso2.org
email: ru...@wso2.com; cell: +94 77 341 3097
blog: http://ruwansblog.blogspot.com

Reply via email to