Return-Path: X-Original-To: apmail-cxf-issues-archive@www.apache.org Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DB9ED17897 for ; Tue, 11 Nov 2014 18:06:35 +0000 (UTC) Received: (qmail 95484 invoked by uid 500); 11 Nov 2014 18:06:35 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 95416 invoked by uid 500); 11 Nov 2014 18:06:35 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 95243 invoked by uid 99); 11 Nov 2014 18:06:34 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Nov 2014 18:06:34 +0000 Date: Tue, 11 Nov 2014 18:06:34 +0000 (UTC) From: "Alessio Soldano (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Reopened] (CXF-6089) XmlAccessorOrder.ALPHABETICAL, Exception.getMessage() duplicate WSDL elements generated MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CXF-6089?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Alessio Soldano reopened CXF-6089: ---------------------------------- mmh... reopening as there's a testcase failing, I didn't notice that locally (likely run with -Pfastinstall) https://builds.apache.org/job/CXF-3.0.x/org.apache.cxf$cxf-tools-java2ws/3131/testReport/junit/org.apache.cxf.tools.java2wsdl.processor/JavaToProcessorTest/testPropOrderInException/ Rebecca, please have a look, I might revert the changes in the mean time. > XmlAccessorOrder.ALPHABETICAL, Exception.getMessage() duplicate WSDL elements generated > --------------------------------------------------------------------------------------- > > Key: CXF-6089 > URL: https://issues.apache.org/jira/browse/CXF-6089 > Project: CXF > Issue Type: Bug > Affects Versions: 2.7.13 > Reporter: Rebecca Searls > Assignee: Alessio Soldano > Fix For: 3.1.0, 3.0.3, 2.7.14 > > Attachments: CXF-6089.patch, testApp.zip > > > When presented with a custom exception class with a XmlAccessorOrder.ALPHABETICAL > annotation attribute the Exception.getMessage() method is listed twice as an element in a generated WSDL. > The cause of duplicate message elements being listed in the generated WSDL > is a duplication of the processing of "cls" by Utils.getGetters at line > 562 and addExceptionMessage() at line 587. Utils.getGetters checks for an > Exception class defining method, getMessage. If method, "getMessage" is NOT > annotated with @XmlTransient it is returned as a method to be processed and > added to "seq" (lines 575-581) . A similar evaluation is performed by > addExceptionMessage(). It adds a second ref to "getMessage" to "seq" when > @XmlTransient is not present on the method, hence the duplicate elements in > the WSDL. > This same basic code exists back to version (2.6.x-fixes) > http://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes > I did not check version prior to that. > {code} > ----- > org.apache.cxf.jaxb.JAXBSchemaInitializer > 562 for (Method m : Utils.getGetters(cls, accessType)) { > .......... > 575 JAXBBeanInfo beanInfo = getBeanInfo(type); > 576 if (beanInfo != null) { > 577 int idx = m.getName().startsWith("get") ? 3 : 2; > 578 String name = m.getName().substring(idx); > 579 name = Character.toLowerCase(name.charAt(0)) + name.substring(1); > 580 XmlElement xmlElementAnno = m.getAnnotation(XmlElement.class); > 581 addElement(schema, seq, beanInfo, new QName(namespace, name), isArray(type), xmlElementAnno); > } > } > } > // Create element in xsd:sequence for Exception.class > if (Exception.class.isAssignableFrom(cls)) { > 587 addExceptionMessage(cls, schema, seq); > } > ----- > org.apache.cxf.jaxb.JAXBSchemaInitializer > private void addExceptionMessage(Class cls, XmlSchema schema, XmlSchemaSequence seq) { > try { > //a subclass could mark the message method as transient > 611 Method m = cls.getMethod("getMessage"); > 612 if (!m.isAnnotationPresent(XmlTransient.class)) { > JAXBBeanInfo beanInfo = getBeanInfo(java.lang.String.class); > XmlSchemaElement exEle = new XmlSchemaElement(schema, false); > exEle.setName("message"); > exEle.setSchemaTypeName(getTypeName(beanInfo)); > exEle.setMinOccurs(0); > 618 seq.getItems().add(exEle); > } > } catch (Exception e) { > //ignore, just won't have the message element > } > ----- > org.apache.cxf.jaxb.Utils > 121 if (method.isBridge() > 122 || Modifier.isStatic(method.getModifiers()) > 123 >> || method.isAnnotationPresent(XmlTransient.class) > 124 || method.getDeclaringClass().equals(Throwable.class) > 125 || "getClass".equals(method.getName())) { > 126 return false; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)