diff --git a/karate-core/src/main/java/com/intuit/karate/core/MockHandler.java b/karate-core/src/main/java/com/intuit/karate/core/MockHandler.java index 024be6aa1..24ce68716 100644 --- a/karate-core/src/main/java/com/intuit/karate/core/MockHandler.java +++ b/karate-core/src/main/java/com/intuit/karate/core/MockHandler.java @@ -151,7 +151,7 @@ private ScenarioRuntime initRuntime(Feature feature, Map args) { private static final String ALLOWED_METHODS = "GET, HEAD, POST, PUT, DELETE, PATCH"; @Override - public synchronized Response handle(Request req) { // note the [synchronized] + public Response handle(Request req) { if (corsEnabled && "OPTIONS".equals(req.getMethod())) { Response response = new Response(200); response.setHeader("Allow", ALLOWED_METHODS); @@ -170,6 +170,9 @@ public synchronized Response handle(Request req) { // note the [synchronized] // snapshot existing thread-local to restore ScenarioEngine prevEngine = ScenarioEngine.get(); for (Map.Entry entry : scenarioRuntimes.entrySet()) { + if (!entry.getKey().getName().startsWith(req.getPath().split("/")[1])){ + continue; + } Feature feature = entry.getKey(); ScenarioRuntime runtime = entry.getValue(); // important for graal to work properly