Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8DE7C200C35 for ; Thu, 2 Feb 2017 00:19:18 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 8C9ED160B66; Wed, 1 Feb 2017 23:19:18 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D8125160B67 for ; Thu, 2 Feb 2017 00:19:17 +0100 (CET) Received: (qmail 13969 invoked by uid 500); 1 Feb 2017 23:19:17 -0000 Mailing-List: contact notifications-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list notifications@groovy.apache.org Received: (qmail 13910 invoked by uid 99); 1 Feb 2017 23:19:17 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Feb 2017 23:19:17 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 8F5ACC0E29 for ; Wed, 1 Feb 2017 23:19:16 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id lMsja4fjBfba for ; Wed, 1 Feb 2017 23:19:15 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 307D860DBE for ; Wed, 1 Feb 2017 23:19:13 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id D1EF6E06C9 for ; Wed, 1 Feb 2017 23:19:07 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id B343725290 for ; Wed, 1 Feb 2017 23:19:07 +0000 (UTC) Date: Wed, 1 Feb 2017 23:19:07 +0000 (UTC) From: "Paul King (JIRA)" To: notifications@groovy.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Closed] (GROOVY-7044) Cloned NodeBuilder created nodes share values (child nodes) with original node. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 01 Feb 2017 23:19:18 -0000 [ https://issues.apache.org/jira/browse/GROOVY-7044?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul King closed GROOVY-7044. ----------------------------- > Cloned NodeBuilder created nodes share values (child nodes) with original node. > ------------------------------------------------------------------------------- > > Key: GROOVY-7044 > URL: https://issues.apache.org/jira/browse/GROOVY-7044 > Project: Groovy > Issue Type: Bug > Components: groovy-jdk, XML Processing > Affects Versions: 2.3.6 > Reporter: Damir Perovi? > Assignee: Shil Sinha > Priority: Minor > Fix For: 2.4.8 > > Attachments: NodeBuilderTest.groovy > > > Cloning nodes created by NodeBuilder share child nodes with original node. > If node is added to original node or child node value is changed, the cloned node will see those changes. Same applies to cloned node, adding node or changing child node value will be seen by original node. > The problem seem to originate in NodeBuilder methods: > {code} > protected Object createNode(Object name) > protected Object createNode(Object name, Map attributes) > {code} > which use ArrayList when creating new Node instead of NodeList. > Can be easily reproduced by groovysh or use attached junit file. > {noformat} > groovy:000> x1 = new NodeBuilder().a() { b() } > ===> a[attributes={}; value=[b[attributes={}; value=[]]]] > groovy:000> x2 = x1.clone() > ===> a[attributes={}; value=[b[attributes={}; value=[]]]] > groovy:000> x1.appendNode('c') > ===> c[attributes={}; value=[]] > groovy:000> x1 > ===> a[attributes={}; value=[b[attributes={}; value=[]], c[attributes={}; value=[]]]] > groovy:000> x2 > ===> a[attributes={}; value=[b[attributes={}; value=[]], c[attributes={}; value=[]]]] > groovy:000> x1.b[0].setValue(1) > ===> null > groovy:000> x1 > ===> a[attributes={}; value=[b[attributes={}; value=1], c[attributes={}; value=[]]]] > groovy:000> x2 > ===> a[attributes={}; value=[b[attributes={}; value=1], c[attributes={}; value=[]]]] > groovy:000> x2.c[0].setValue(2) > ===> null > groovy:000> x1 > ===> a[attributes={}; value=[b[attributes={}; value=1], c[attributes={}; value=2]]] > {noformat} -- This message was sent by Atlassian JIRA (v6.3.15#6346)