summaryrefslogtreecommitdiff
path: root/scripting/java/com/sun/star/script/framework
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-08-13 09:02:41 +0200
committerNoel Grandin <noel@peralex.com>2014-08-20 10:35:51 +0200
commit252ed1708ad5a007e4c47c243595206650876a2b (patch)
treeb2a7a47f8a39c598c25355640a77022918c2d209 /scripting/java/com/sun/star/script/framework
parenta240a78cc771a89febfe181abe78d2cf16e1970f (diff)
double-checked locking is not thread-safe in Java
found by PMD Change-Id: Ibd4a9139c626932bec56c0b1dd32b4d59c8440b1
Diffstat (limited to 'scripting/java/com/sun/star/script/framework')
-rw-r--r--scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java10
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java12
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java12
3 files changed, 9 insertions, 25 deletions
diff --git a/scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java b/scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java
index 3a5989febcc3..bb3bd6f47c34 100644
--- a/scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java
+++ b/scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java
@@ -36,13 +36,9 @@ public class XMLParserFactory {
private XMLParserFactory() {}
- public static XMLParser getParser() {
- if (parser == null) {
- synchronized (XMLParserFactory.class) {
- if (parser == null)
- parser = new DefaultParser();
- }
- }
+ public static synchronized XMLParser getParser() {
+ if (parser == null)
+ parser = new DefaultParser();
return parser;
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
index fb88968159a8..34061c473847 100644
--- a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
@@ -94,18 +94,12 @@ public class ScriptEditorForBeanShell
/**
* Returns the global ScriptEditorForBeanShell instance.
*/
- public static ScriptEditorForBeanShell getEditor()
+ public static synchronized ScriptEditorForBeanShell getEditor()
{
if (theScriptEditorForBeanShell == null)
{
- synchronized(ScriptEditorForBeanShell.class)
- {
- if (theScriptEditorForBeanShell == null)
- {
- theScriptEditorForBeanShell =
- new ScriptEditorForBeanShell();
- }
- }
+ theScriptEditorForBeanShell =
+ new ScriptEditorForBeanShell();
}
return theScriptEditorForBeanShell;
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
index e7ac14c1b5e8..4755a54c9af9 100644
--- a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
+++ b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
@@ -82,18 +82,12 @@ public class ScriptEditorForJavaScript implements ScriptEditor
/**
* Returns the global ScriptEditorForJavaScript instance.
*/
- public static ScriptEditorForJavaScript getEditor()
+ public static synchronized ScriptEditorForJavaScript getEditor()
{
if (theScriptEditorForJavaScript == null)
{
- synchronized(ScriptEditorForJavaScript.class)
- {
- if (theScriptEditorForJavaScript == null)
- {
- theScriptEditorForJavaScript =
- new ScriptEditorForJavaScript();
- }
- }
+ theScriptEditorForJavaScript =
+ new ScriptEditorForJavaScript();
}
return theScriptEditorForJavaScript;
}