Return-Path: Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: (qmail 29090 invoked from network); 9 Nov 2009 21:14:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Nov 2009 21:14:56 -0000 Received: (qmail 27840 invoked by uid 500); 9 Nov 2009 21:14:56 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 27822 invoked by uid 500); 9 Nov 2009 21:14:56 -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 27803 invoked by uid 99); 9 Nov 2009 21:14:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Nov 2009 21:14:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED 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 21:14:53 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 89C17234C1F1 for ; Mon, 9 Nov 2009 13:14:32 -0800 (PST) Message-ID: <1446204625.1257801272563.JavaMail.jira@brutus> Date: Mon, 9 Nov 2009 21:14:32 +0000 (UTC) From: "Daniel Kulp (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 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/CXF-2520?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniel Kulp updated CXF-2520: ----------------------------- Fix Version/s: (was: 2.3) 2.2.5 > 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.2.5 > > > 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.