Skip to content

Commit

Permalink
one last cleanup before merge #2009 #1883
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Aug 2, 2022
1 parent 5cee841 commit 763590e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ public JsEngine copy() {
Value v = bindings.getMember(key);
if (v.isHostObject()) {
temp.bindings.putMember(key, v);
// } else if (v.canExecute()) {
// Value fun = temp.evalForValue("(" + v.getSourceLocation().getCharacters() + ")");
// temp.bindings.putMember(key, fun);
} else {
temp.bindings.putMember(key, JsValue.toJava(v));
}
Expand Down
13 changes: 8 additions & 5 deletions karate-core/src/main/java/com/intuit/karate/graal/JsValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ public boolean removeMember(String key) {

public static final Object LOCK = new Object();

public static class SharableMembersAndExecutable extends SharableMembers implements ProxyExecutable {
static class SharableMembersAndExecutable extends SharableMembers implements ProxyExecutable {

SharableMembersAndExecutable(Value v) {
super(v);
Expand All @@ -406,7 +406,7 @@ public Object execute(Value... args) {

}

public static class SharableMembersAndInstantiable extends SharableMembersAndExecutable implements ProxyInstantiable {
static class SharableMembersAndInstantiable extends SharableMembersAndExecutable implements ProxyInstantiable {

SharableMembersAndInstantiable(Value v) {
super(v);
Expand All @@ -415,10 +415,13 @@ public static class SharableMembersAndInstantiable extends SharableMembersAndExe
@Override
public Object newInstance(Value... args) {
Object[] newArgs = new Object[args.length];
for (int i = 0; i < newArgs.length; i++) {
newArgs[i] = new JsValue(args[i]).value;
// the synchronized block should include the pre-processing of arguments
synchronized (LOCK) {
for (int i = 0; i < newArgs.length; i++) {
newArgs[i] = new JsValue(args[i]).value;
}
return new JsValue(v.execute(newArgs)).value;
}
return new JsValue(v.execute(newArgs)).value;
}

}
Expand Down

0 comments on commit 763590e

Please sign in to comment.