You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Davanum Srinivas <da...@gmail.com> on 2004/10/14 22:45:26 UTC
Re: cvs commit: ws-axis/java/src/org/apache/axis/encoding Seriali zationContext.java
i'd prefer it to NPE's :) Note that this happens ONLY when someone
programatically uses the SerializationContext one-arg constructor
which is not the case in the rest of axis code.
-- dims
On Thu, 14 Oct 2004 16:40:41 -0400, Tom Jordahl <to...@macromedia.com> wrote:
>
> We really want the default to be encoded?
>
> --
> Tom Jordahl
> Macromedia Server Development
>
> > -----Original Message-----
> > From: dims@apache.org [mailto:dims@apache.org]
> > Sent: Thursday, October 14, 2004 4:29 PM
> > To: ws-axis-cvs@apache.org
> > Subject: cvs commit: ws-axis/java/src/org/apache/axis/encoding
> > SerializationContext.java
> >
> > dims 2004/10/14 13:28:47
> >
> > Modified: java/src/org/apache/axis/encoding/ser BeanSerializer.java
> > java/src/org/apache/axis/encoding SerializationContext.java
> > Log:
> > Fix for AXIS-1585 - npe after using SerializationContext one-arg
> > constructor
> >
> > Revision Changes Path
> > 1.77 +2 -2 ws-
> > axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java
> >
> > Index: BeanSerializer.java
> > ===================================================================
> > RCS file: /home/cvs/ws-
> > axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java,v
> > retrieving revision 1.76
> > retrieving revision 1.77
> > diff -u -r1.76 -r1.77
> > --- BeanSerializer.java 2 Jul 2004 13:04:52 -0000 1.76
> > +++ BeanSerializer.java 14 Oct 2004 20:28:47 -0000 1.77
> > @@ -103,11 +103,11 @@
> > Attributes beanAttrs = getObjectAttributes(value, attributes,
> > context);
> >
> > // Get the encoding style
> > - String encodingStyle =
> > context.getMessageContext().getEncodingStyle();
> > + String encodingStyle = context.getEncodingStyle();
> > boolean isEncoded = Constants.isSOAP_ENC(encodingStyle);
> >
> > // check whether we have and xsd:any namespace="##any" type
> > - boolean suppressElement =
> > !context.getMessageContext().isEncoded() &&
> > + boolean suppressElement = !context.isEncoded() &&
> > name.getNamespaceURI().equals("") &&
> > name.getLocalPart().equals("any");
> >
> >
> >
> >
> > 1.92 +29 -4 ws-
> > axis/java/src/org/apache/axis/encoding/SerializationContext.java
> >
> > Index: SerializationContext.java
> > ===================================================================
> > RCS file: /home/cvs/ws-
> > axis/java/src/org/apache/axis/encoding/SerializationContext.java,v
> > retrieving revision 1.91
> > retrieving revision 1.92
> > diff -u -r1.91 -r1.92
> > --- SerializationContext.java 29 Jul 2004 21:40:26 -0000 1.91
> > +++ SerializationContext.java 14 Oct 2004 20:28:47 -0000 1.92
> > @@ -18,6 +18,9 @@
> >
> > import java.io.IOException;
> > import java.io.Writer;
> > +import java.lang.IllegalAccessException;
> > +import java.lang.NoSuchMethodException;
> > +import java.lang.reflect.InvocationTargetException;
> > import java.lang.reflect.Method;
> > import java.util.ArrayList;
> > import java.util.Calendar;
> > @@ -457,6 +460,26 @@
> > }
> >
> > /**
> > + * Returns this context's encoding style. If we've got a message
> > + * context then we'll get the style from that; otherwise we'll
> > + * return a default.
> > + *
> > + * @return a <code>String</code> value
> > + */
> > + public String getEncodingStyle() {
> > + return msgContext == null ? Use.ENCODED.getEncoding() :
> > msgContext.getEncodingStyle();
> > + }
> > +
> > + /**
> > + * Returns whether this context should be encoded or not.
> > + *
> > + * @return a <code>boolean</code> value
> > + */
> > + public boolean isEncoded() {
> > + return msgContext == null ? true : msgContext.isEncoded();
> > + }
> > +
> > + /**
> > * Convert QName to a string of the form <prefix>:<localpart>
> > * @param qName
> > * @return prefixed qname representation for serialization.
> > @@ -698,7 +721,7 @@
> > // hashCode() and equals() methods have been overloaded to make
> > two
> > // Objects appear equal.
> >
> > - if (doMultiRefs && (msgContext == null ||
> > msgContext.isEncoded()) &&
> > + if (doMultiRefs && isEncoded() &&
> > (value != forceSer) && !isPrimitive(value)) {
> > if (multiRefIndex == -1)
> > multiRefValues = new HashMap();
> > @@ -1277,9 +1300,11 @@
> > SERIALIZER_METHOD, SERIALIZER_CLASSES);
> > if (method != null) {
> > serializer = (Serializer) method.invoke(null,
> > - new Object[] {msgContext.getEncodingStyle(),
> > javaType, qname});
> > + new Object[] {getEncodingStyle(), javaType,
> > qname});
> > }
> > - } catch (Exception e) {
> > + } catch (NoSuchMethodException e) {
> > + } catch (IllegalAccessException e) {
> > + } catch (InvocationTargetException e) {
> > }
> > return serializer;
> > }
> > @@ -1363,7 +1388,7 @@
> > actualXMLType.value =
> > ((BaseSerializerFactory)
> > serFactory).getXMLType();
> > }
> > - boolean encoded = (msgContext == null ||
> > msgContext.isEncoded());
> > + boolean encoded = isEncoded();
> > if (actualXMLType.value == null ||
> > (!encoded &&
> > actualXMLType.value.equals(soapConstants.getArrayType()))) {
> > actualXMLType.value = tm.getXMLType(javaType,
> >
> >
> >
>
--
Davanum Srinivas - http://webservices.apache.org/~dims/
Re: cvs commit: ws-axis/java/src/org/apache/axis/encoding Seriali zationContext.java
Posted by toby cabot <to...@caboteria.org>.
On Thu, Oct 14, 2004 at 04:45:26PM -0400, Davanum Srinivas wrote:
> i'd prefer it to NPE's :) Note that this happens ONLY when someone
> programatically uses the SerializationContext one-arg constructor
> which is not the case in the rest of axis code.
>
> -- dims
>
>
> On Thu, 14 Oct 2004 16:40:41 -0400, Tom Jordahl <to...@macromedia.com> wrote:
> >
> > We really want the default to be encoded?
> >
Hi Tom, Davanum,
Please don't read too much into my choice of ENCODED as the default in
the patch that you're discussing. I wasn't really sure what it should
be; feel free to over-ride. As Davanum mentioned, the default is used
only in a narrow set of cases, but I'd rather it be correct even in
those cases.
Regards,
Toby