axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Archit Shah (JIRA)" <>
Subject [jira] Updated: (AXIS-2142) ClassCastException in JavaUtils.convert
Date Tue, 26 Jul 2005 17:26:21 GMT
     [ ]

Archit Shah updated AXIS-2142:

    Attachment: DH.patch

This patch replaces the calls to getContent with calls to getInputStream in four locations
(3 in JavaUtils and 1 in SourceDataHandlerDeserializer). It produces no regressions in the
Axis tests when run with the Sun javamail implementation and fixes two test failures encountered
when using Axis with the GNU javamail implementation.

> ClassCastException in JavaUtils.convert
> ---------------------------------------
>          Key: AXIS-2142
>          URL:
>      Project: Apache Axis
>         Type: Bug
>     Versions: current (nightly)
>  Environment: Axis 1.2 CVS using GNU classpathx javamail and activation implementations
with Sun JDK 1.4.2_06
>     Reporter: Archit Shah
>  Attachments: DH.patch
> When running the Axis (not Axis2) CVS tip with javamail and activation implementations
from GNU classpathx, two tests fail with ClassCastExceptions. These failures are due to incorrect
use of DataHandlers. The failing tests are:
> test.wsdl.interop4.groupG.dime.rpc.DimeRPCInteropTestCase
> #test2DimeRPCSoapPortEchoAttachments
> test.wsdl.interop4.groupG.mime.rpc.MimeRPCInteropTestCase
> #test2MimeRPCSoapPortEchoAttachments
> And the stack trace is:
> java.lang.ClassCastException
>     at org.apache.axis.utils.JavaUtils.convert(
>     at org.apache.axis.utils.JavaUtils.convert(
>     at
>     at
>     at org.apache.axis.strategies.InvocationStrategy.visit(
>     at org.apache.axis.SimpleChain.doVisiting(
>     at org.apache.axis.SimpleChain.invoke(
>     at org.apache.axis.handlers.soap.SOAPService.invoke(
>     at org.apache.axis.server.AxisServer.invoke(
>     at org.apache.axis.transport.http.SimpleAxisWorker.execute(
>     at
>     at
>     at org.apache.axis.transport.http.SimpleAxisServer.start(
>     at org.apache.axis.transport.http.SimpleAxisServer.start(
>     at org.apache.axis.transport.http.SimpleAxisServer.main(
> The convert method of org.apache.axis.utils.JavaUtils relies on the getContent method
of javax.activation.DataHandler to get an InputStream for the data, twice doing the following:
>   in = (InputStream)handler.getContent();
> instead of:
>   in = handler.getInputStream();
> Calling getContent and casting to InputStream is not guaranteed to work. The Javadoc
for the getContent method specifies "If no DataContentHandler can be found for the the type
of this data, the DataHandler returns an InputStream for the data." Therefore, the cast can
fail if a DataContentHandler is installed.  I ran into this exceptions because the GNU javamail
implementation has a DataContentHandler for the MIME type application/octet-stream and getContent
returns a byte array instead of the input stream.
> Casting the return value of getContent is also done in another context. JavaUtils and
SourceDataHandlerDeserializer both do:
>   StreamSource ss = new StreamSource(new StringReader(
>     (String) dh.getContent()));
> when the following would suffice:
>   StreamSource ss = new StreamSource(dh.getInputStream());

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message