diff --git a/pom.xml b/pom.xml
index bcb1f7325..3d0b1498b 100755
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
5.7.0
1.7.0
8803cbe8aca1b3b6ebf73e13f5c41665f393b381
- j2v8_macosx_x86_64
+ j2v8_linux_x86_64
@@ -88,7 +88,7 @@
com.eclipsesource.j2v8
${j2v8.artifactId}
- 4.6.0
+ 4.8.0
diff --git a/src/main/java/com/felixgrund/codeshovel/parser/impl/TypeScriptParser.java b/src/main/java/com/felixgrund/codeshovel/parser/impl/TypeScriptParser.java
index 994a5ec08..2e4d42d33 100644
--- a/src/main/java/com/felixgrund/codeshovel/parser/impl/TypeScriptParser.java
+++ b/src/main/java/com/felixgrund/codeshovel/parser/impl/TypeScriptParser.java
@@ -91,6 +91,7 @@ private abstract class TypeScriptMethodVisitor extends TypeScriptVisitor {
@Override
public void visit(String source) {
+ init();
sourceFile = getSource(source);
visit(sourceFile);
sourceFile = null;
diff --git a/src/main/java/com/felixgrund/codeshovel/util/TypeScript.java b/src/main/java/com/felixgrund/codeshovel/util/TypeScript.java
index 7a2b18bc1..db43bdaa0 100644
--- a/src/main/java/com/felixgrund/codeshovel/util/TypeScript.java
+++ b/src/main/java/com/felixgrund/codeshovel/util/TypeScript.java
@@ -17,12 +17,15 @@ public class TypeScript {
private static TypeScript instance;
private final NodeJS nodeJS;
private static V8Object ts;
+ private static Thread thread;
private static Logger log = LoggerFactory.getLogger(TypeScript.class);
public static TypeScript getInstance() {
- if (instance == null) {
+ Thread currentThread = Thread.currentThread();
+ if (instance == null || thread != currentThread) {
try {
+ thread = currentThread;
instance = new TypeScript();
} catch (IOException e) {
e.printStackTrace();
diff --git a/src/main/java/com/felixgrund/codeshovel/visitors/TypeScriptVisitor.java b/src/main/java/com/felixgrund/codeshovel/visitors/TypeScriptVisitor.java
index 6fce8cc92..f5ca766f5 100644
--- a/src/main/java/com/felixgrund/codeshovel/visitors/TypeScriptVisitor.java
+++ b/src/main/java/com/felixgrund/codeshovel/visitors/TypeScriptVisitor.java
@@ -17,10 +17,10 @@ public class TypeScriptVisitor {
public TypeScriptVisitor() {
ts = TypeScript.getInstance().getTS();
- init();
}
public void visit(String source) {
+ init();
visit(getSource(source));
clear();
}
@@ -44,14 +44,13 @@ protected V8Object getSource(String source) {
return ts.executeObjectFunction("createSourceFile", parameters);
}
- private void init() {
+ protected void init() {
scope = new MemoryManager(TypeScript.getInstance().getRuntime());
syntaxKind = ts.getObject("SyntaxKind");
}
protected void clear() {
scope.release();
- init();
}
protected void visit(V8Object node) {