Return-Path: Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: (qmail 22865 invoked from network); 4 Nov 2009 12:49:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Nov 2009 12:49:57 -0000 Received: (qmail 47675 invoked by uid 500); 4 Nov 2009 12:49:57 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 47347 invoked by uid 500); 4 Nov 2009 12:49:57 -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 47232 invoked by uid 99); 4 Nov 2009 12:49:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Nov 2009 12:49: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; Wed, 04 Nov 2009 12:49:54 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id E5636234C4A7 for ; Wed, 4 Nov 2009 04:49:32 -0800 (PST) Message-ID: <1306138923.1257338972938.JavaMail.jira@brutus> Date: Wed, 4 Nov 2009 12:49:32 +0000 (UTC) From: "Hasan Hosgel (JIRA)" To: issues@cxf.apache.org Subject: [jira] Created: (CXF-2520) wrong handling in setNamespaceMap for AbstractDataBinding 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 wrong handling in setNamespaceMap for AbstractDataBinding --------------------------------------------------------- Key: CXF-2520 URL: https://issues.apache.org/jira/browse/CXF-2520 Project: CXF Issue Type: Bug Components: JAXB Databinding Affects Versions: 2.2.4 Reporter: Hasan Hosgel 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.