Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 16378 invoked from network); 26 Jul 2005 17:26:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Jul 2005 17:26:53 -0000 Received: (qmail 96288 invoked by uid 500); 26 Jul 2005 17:26:48 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 96236 invoked by uid 500); 26 Jul 2005 17:26:48 -0000 Mailing-List: contact axis-dev-help@ws.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-dev@ws.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-dev@ws.apache.org Received: (qmail 96220 invoked by uid 99); 26 Jul 2005 17:26:48 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=SPF_FAIL X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Jul 2005 10:26:36 -0700 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 2D656EA for ; Tue, 26 Jul 2005 19:26:21 +0200 (CEST) Message-ID: <1872596737.1122398781184.JavaMail.jira@ajax.apache.org> Date: Tue, 26 Jul 2005 19:26:21 +0200 (CEST) From: "Archit Shah (JIRA)" To: axis-dev@ws.apache.org Subject: [jira] Updated: (AXIS-2142) ClassCastException in JavaUtils.convert In-Reply-To: <1642765541.1122398780044.JavaMail.jira@ajax.apache.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/AXIS-2142?page=all ] 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: http://issues.apache.org/jira/browse/AXIS-2142 > 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(JavaUtils.java:325) > at org.apache.axis.utils.JavaUtils.convert(JavaUtils.java:472) > at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:118) > at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323) > at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) > at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) > at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) > at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:453) > at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281) > at org.apache.axis.transport.http.SimpleAxisWorker.execute(SimpleAxisWorker.java:428) > at org.apache.axis.transport.http.SimpleAxisWorker.run(SimpleAxisWorker.java:155) > at org.apache.axis.transport.http.SimpleAxisServer.run(SimpleAxisServer.java:245) > at org.apache.axis.transport.http.SimpleAxisServer.start(SimpleAxisServer.java:296) > at org.apache.axis.transport.http.SimpleAxisServer.start(SimpleAxisServer.java:304) > at org.apache.axis.transport.http.SimpleAxisServer.main(SimpleAxisServer.java:385) > 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: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira