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 F1EDC200BF7 for ; Mon, 9 Jan 2017 17:57:42 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id F09BB160B3E; Mon, 9 Jan 2017 16:57:42 +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 B9F48160B2F for ; Mon, 9 Jan 2017 17:57:41 +0100 (CET) Received: (qmail 86924 invoked by uid 500); 9 Jan 2017 16:57:39 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 86914 invoked by uid 99); 9 Jan 2017 16:57:39 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Jan 2017 16:57:39 +0000 Received: from [192.168.23.9] (host86-147-88-117.range86-147.btcentralplus.com [86.147.88.117]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id E136F1A0329 for ; Mon, 9 Jan 2017 16:57:38 +0000 (UTC) Subject: Re: Tomcat 8, 8.5 and 9 returning another apps environment with context.lookup() from a .parallelStream() Reply-To: Tomcat Users List References: To: Tomcat Users List From: Mark Thomas Message-ID: <12b089db-727f-55f9-65dc-8608293ec5b4@apache.org> Date: Mon, 9 Jan 2017 16:57:28 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit archived-at: Mon, 09 Jan 2017 16:57:43 -0000 On 09/01/2017 14:29, Mark Thomas wrote: > On 08/01/2017 22:04, Christopher Zinn wrote: >> We are running into an issue where we have multiple copies of the same >> WAR loaded on a Tomcat instance each with its own context.xml. >> The initial problem I was trying to diagnose was A JNDI lookup to a >> Connection Pool in one of the WARs was returning the connection pool of one >> of the others. >> The problem only happens when the JNDI lookup is performed within a >> parallelStream(). >> >> I was able to produce a very simple WAR with a single servlet and a >> context XML to reproduce the problem I'm having (See below). >> >> If you run the servlet from the first application, it works correctly. >> You will see that it only ever looks up 'Test 1'. >> When I run the servlet from the second application it will only return Test >> 1 in the first part (stream()) but a mix of 'Test 1' and 'Test 2' in the >> parallelStream() part. > A quick look at the JRE source code suggests this is handled correctly > but the code isn't the easiest to trace through. I'll set up the > provided test case and take a closer look. That may take an hour or two. I can confirm that the root cause is a JRE bug. Unless you are running under a SecurityManager the default ForkJoinWorkerThreadFactory does not take any steps to ensure correct operation in a multi-class loader environment. You have a couple of work-arounds available - Run under a SecurityManager - Set the java.util.concurrent.ForkJoinPool.common.threadFactory system property to java.util.concurrent.ForkJoinPool.InnocuousForkJoinWorkerThreadFactory Meanwhile, I'll be doing the following: - Updating Tomcat's JreMemoryLeakPreventionListener to include protection for this memory leak. - Adding this leak to https://github.com/markt-asf/memory-leaks - Raising a JRE bug - Pinging our friendly Oracle contact to get this fixed (we've been pretty successful at getting this fixed recently) Cheers, Mark --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org