Return-Path: Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: (qmail 68382 invoked from network); 9 Nov 2009 01:49:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Nov 2009 01:49:55 -0000 Received: (qmail 97597 invoked by uid 500); 9 Nov 2009 01:49:55 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 97528 invoked by uid 500); 9 Nov 2009 01:49:54 -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 97518 invoked by uid 99); 9 Nov 2009 01:49:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Nov 2009 01:49:54 +0000 X-ASF-Spam-Status: No, hits=-10.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Nov 2009 01:49:52 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 672D0234C045 for ; Sun, 8 Nov 2009 17:49:32 -0800 (PST) Message-ID: <198095722.1257731372408.JavaMail.jira@brutus> Date: Mon, 9 Nov 2009 01:49:32 +0000 (UTC) From: "Benson Margulies (JIRA)" To: issues@cxf.apache.org Subject: [jira] Updated: (CXF-2520) wrong handling in setNamespaceMap for AbstractDataBinding In-Reply-To: <1306138923.1257338972938.JavaMail.jira@brutus> 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-2520?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Benson Margulies updated CXF-2520: ---------------------------------- Component/s: (was: JAXB Databinding) Core > wrong handling in setNamespaceMap for AbstractDataBinding > --------------------------------------------------------- > > Key: CXF-2520 > URL: https://issues.apache.org/jira/browse/CXF-2520 > Project: CXF > Issue Type: Bug > Components: Core > Affects Versions: 2.2.4 > Reporter: Hasan Hosgel > Fix For: 2.3 > > > The Class org.apache.cxf.databinding.AbstractDataBinding has a Bug in the checking of duplicate NamespacePrefixes during the setting of the namespaceMap. > Extraction of class: > public void setNamespaceMap(Map namespaceMap) { > // make some checks. This is a map from namespace to prefix, but we want unique prefixes. > if (namespaceMap != null) { > Set prefixesSoFar = new HashSet(); > for (Map.Entry mapping : namespaceMap.entrySet()) { > if (prefixesSoFar.contains(mapping.getValue())) { > throw new IllegalArgumentException("Duplicate prefix " + mapping.getValue()); > } > } > } > this.namespaceMap = namespaceMap; > } > There is no adding method for prefixesSoFar-Set. > My solving idea is: > /** > * @param namespaceMap The namespaceMap to set. > */ > public void setNamespaceMap(Map namespaceMap) { > // make some checks. This is a map from namespace to prefix, but we want unique prefixes. > if ((namespaceMap == null) || namespaceMap.isEmpty()) { > throw new IllegalArgumentException("adding a null or empty namespaceMap is not allowed"); > } else { > Set prefixesSoFar = new HashSet(); > for (Map.Entry mapping : namespaceMap.entrySet()) { > if (prefixesSoFar.contains(mapping.getValue())) { > throw new IllegalArgumentException("Duplicate prefix " + mapping.getValue()); > } > prefixesSoFar.add(mapping.getValue()); > } > mapper = new NamespaceMapper(namespaceMap); > } > } > This solution is more strict, because it does not allow to add a null or an empty Map. > The same Bug goes for checkNameSpaceMap. > The both method are smelling, because it is copy paste. It can be solved in a smater way :). -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.