aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorhannesw <none@none>2014-05-06 12:38:12 +0200
committerhannesw <none@none>2014-05-06 12:38:12 +0200
commit67726fbf7d0d142b5d436dfede4c3f79a2b82be4 (patch)
tree85dfd6c0e9524a53e2d9e069654dfb2d3e987432 /test
parent4ae14685521e0b8db04d64ba1a75371889d437db (diff)
downloadnashorn-67726fbf7d0d142b5d436dfede4c3f79a2b82be4.tar.gz
8041998: RegExp implementation is not thread-safe
Reviewed-by: lagergren, sundar, attila
Diffstat (limited to 'test')
-rw-r--r--test/script/basic/JDK-8041998.js52
-rw-r--r--test/script/basic/JDK-8041998.js.EXPECTED4
2 files changed, 56 insertions, 0 deletions
diff --git a/test/script/basic/JDK-8041998.js b/test/script/basic/JDK-8041998.js
new file mode 100644
index 00000000..33e4d136
--- /dev/null
+++ b/test/script/basic/JDK-8041998.js
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8041998: RegExp implementation is not thread-safe
+ *
+ * @test
+ * @run
+ */
+
+var Thread = java.lang.Thread;
+
+function run() {
+ var line = 'content-type: text/html';
+ for (var i = 0; i < 300; i++) {
+ Thread.sleep(1);
+ line.split(/: /);
+ }
+ print("done");
+}
+
+var threads = [];
+
+for (var i = 0; i < 4; i++) {
+ var thread = new Thread(run);
+ thread.start();
+ threads.push(thread);
+}
+
+for (var i = 0; i < 4; i++) {
+ threads[i].join();
+}
diff --git a/test/script/basic/JDK-8041998.js.EXPECTED b/test/script/basic/JDK-8041998.js.EXPECTED
new file mode 100644
index 00000000..8f92fbfa
--- /dev/null
+++ b/test/script/basic/JDK-8041998.js.EXPECTED
@@ -0,0 +1,4 @@
+done
+done
+done
+done