This is an automated email from the ASF dual-hosted git repository.
matthiasblaesing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new f4db42eb02 [JS] Fix ConcurrentModificationException scanning export
class {} with multiple members
new 9b87a377c6 Merge pull request #5983 from
matthiasblaesing/js_concurrent_modification_exception
f4db42eb02 is described below
commit f4db42eb02125a1f9184df16d24aad26dde91e8b
Author: Matthias Bläsing <[email protected]>
AuthorDate: Tue May 23 21:12:02 2023 +0200
[JS] Fix ConcurrentModificationException scanning export class {} with
multiple members
Fix applies same pattern, that is used in other places where
ModelUtils#moveProperty is invoked.
---
.../modules/javascript2/model/ModelVisitor.java | 5 +++--
.../data/testfiles/structure/issueGH5184_03.js | 25 ++++++++++++++++++++++
.../testfiles/structure/issueGH5184_03.js.model | 12 +++++++++++
.../modules/javascript2/model/ModelTest.java | 4 ++++
4 files changed, 44 insertions(+), 2 deletions(-)
diff --git
a/webcommon/javascript2.model/src/org/netbeans/modules/javascript2/model/ModelVisitor.java
b/webcommon/javascript2.model/src/org/netbeans/modules/javascript2/model/ModelVisitor.java
index 7ca7de8280..74cc9471fa 100644
---
a/webcommon/javascript2.model/src/org/netbeans/modules/javascript2/model/ModelVisitor.java
+++
b/webcommon/javascript2.model/src/org/netbeans/modules/javascript2/model/ModelVisitor.java
@@ -712,8 +712,9 @@ public class ModelVisitor extends PathNodeVisitor
implements ModelResolver {
);
JsObject origClassObject = parent.getProperty(className.getName());
if (origClassObject != null) {
- for (Entry<String, ? extends JsObject> e :
origClassObject.getProperties().entrySet()) {
- ModelUtils.moveProperty(classObject, e.getValue());
+ List<JsObject> properties = new
ArrayList<>(origClassObject.getProperties().values());
+ for (JsObject property : properties) {
+ ModelUtils.moveProperty(classObject, property);
}
}
parent.addProperty(className.getName(), classObject);
diff --git
a/webcommon/javascript2.model/test/unit/data/testfiles/structure/issueGH5184_03.js
b/webcommon/javascript2.model/test/unit/data/testfiles/structure/issueGH5184_03.js
new file mode 100644
index 0000000000..1303049e1b
--- /dev/null
+++
b/webcommon/javascript2.model/test/unit/data/testfiles/structure/issueGH5184_03.js
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export class test {
+ field1 = "Value1";
+
+ method1() {
+ }
+}
\ No newline at end of file
diff --git
a/webcommon/javascript2.model/test/unit/data/testfiles/structure/issueGH5184_03.js.model
b/webcommon/javascript2.model/test/unit/data/testfiles/structure/issueGH5184_03.js.model
new file mode 100644
index 0000000000..70f70b48ae
--- /dev/null
+++
b/webcommon/javascript2.model/test/unit/data/testfiles/structure/issueGH5184_03.js.model
@@ -0,0 +1,12 @@
+FUNCTION issueGH5184_03 [ANONYMOUS: false, DECLARED: true - issueGH5184_03,
MODIFIERS: PUBLIC, FILE]
+# RETURN TYPES
+undefined, RESOLVED: true
+# PROPERTIES
+test : OBJECT test [ANONYMOUS: false, DECLARED: true - test, MODIFIERS:
PUBLIC, CLASS]
+ # PROPERTIES
+ field1 : OBJECT field1 [ANONYMOUS: false, DECLARED: true - field1,
MODIFIERS: PUBLIC, PROPERTY]
+ method1 : FUNCTION method1 [ANONYMOUS: false, DECLARED: true - method1,
MODIFIERS: PUBLIC, METHOD]
+ # RETURN TYPES
+ undefined, RESOLVED: true
+ # PROPERTIES
+ arguments : OBJECT arguments [ANONYMOUS: false, DECLARED: false -
arguments, MODIFIERS: PRIVATE, VARIABLE]
diff --git
a/webcommon/javascript2.model/test/unit/src/org/netbeans/modules/javascript2/model/ModelTest.java
b/webcommon/javascript2.model/test/unit/src/org/netbeans/modules/javascript2/model/ModelTest.java
index 494b8adcab..e7c5b63ace 100644
---
a/webcommon/javascript2.model/test/unit/src/org/netbeans/modules/javascript2/model/ModelTest.java
+++
b/webcommon/javascript2.model/test/unit/src/org/netbeans/modules/javascript2/model/ModelTest.java
@@ -234,6 +234,10 @@ public class ModelTest extends ModelTestBase {
checkModel("testfiles/structure/issueGH5184_02.js");
}
+ public void testIssueGH5184_03() throws Exception {
+ checkModel("testfiles/structure/issueGH5184_03.js");
+ }
+
public void testBogusGlobalThis() throws Exception {
checkModel("testfiles/structure/bogusGlobalThis_01.js");
checkModel("testfiles/structure/bogusGlobalThis_02.js");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists