Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6CCC2200B53 for ; Tue, 12 Jul 2016 19:21:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 6B1CC160A56; Tue, 12 Jul 2016 17:21:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B4400160A53 for ; Tue, 12 Jul 2016 19:21:21 +0200 (CEST) Received: (qmail 47253 invoked by uid 500); 12 Jul 2016 17:21:20 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 47242 invoked by uid 99); 12 Jul 2016 17:21:20 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jul 2016 17:21:20 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 839492C02A4 for ; Tue, 12 Jul 2016 17:21:20 +0000 (UTC) Date: Tue, 12 Jul 2016 17:21:20 +0000 (UTC) From: "Henri Biestro (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (JEXL-205) testCancelForever() is not terminated properly MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 12 Jul 2016 17:21:22 -0000 [ https://issues.apache.org/jira/browse/JEXL-205?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15373278#comment-15373278 ] Henri Biestro commented on JEXL-205: ------------------------------------ I updated the test with a latch, tell me if you can reproduce. > testCancelForever() is not terminated properly > ---------------------------------------------- > > Key: JEXL-205 > URL: https://issues.apache.org/jira/browse/JEXL-205 > Project: Commons JEXL > Issue Type: Task > Affects Versions: 3.0 > Reporter: Dmitri Blinov > > After runnning Jexl tests I have noticed that the thread from testCancelForever() test is still executing, and its stack trace is as follows: > {code} > org.apache.commons.jexl3.ScriptCallableTest$TestContext.runForever(ScriptCallableTest.java:159) > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > java.lang.reflect.Method.invoke(Method.java:606) > org.apache.commons.jexl3.internal.introspection.MethodExecutor.invoke(MethodExecutor.java:93) > org.apache.commons.jexl3.internal.Interpreter.call(Interpreter.java:1816) > org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1535) > org.apache.commons.jexl3.parser.ASTFunctionNode.jjtAccept(ASTFunctionNode.java:18) > org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1119) > org.apache.commons.jexl3.parser.ASTJexlScript.jjtAccept(ASTJexlScript.java:55) > org.apache.commons.jexl3.internal.Interpreter.interpret(Interpreter.java:210) > org.apache.commons.jexl3.internal.Script$Callable.interpret(Script.java:364) > org.apache.commons.jexl3.internal.Script$Callable.call(Script.java:372) > - locked org.apache.commons.jexl3.internal.Script$Callable@35595365 > java.util.concurrent.FutureTask.run(FutureTask.java:262) > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) > java.lang.Thread.run(Thread.java:745) > {code} > may be its worth rewriting the test to something like this > {code} > public static class TestContext extends MapContext implements JexlContext.NamespaceResolver { > protected volatile boolean x = false; > public int runForever() { > while (true) { > if (x) { > break; > } > } > return 1; > } > ... > @Test > public void testCancelForever() throws Exception { > JexlScript e = JEXL.createScript("runForever()"); > TestContext tctx = new TestContext(); > Callable c = e.callable(tctx); > ExecutorService executor = Executors.newFixedThreadPool(1); > Future future = executor.submit(c); > Object t = 42; > try { > t = future.get(100, TimeUnit.MILLISECONDS); > Assert.fail("should have timed out"); > } catch (TimeoutException xtimeout) { > // ok, ignore > future.cancel(true); > tctx.x = true; > } finally { > executor.shutdown(); > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)