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 4D260200C49 for ; Fri, 17 Mar 2017 21:54:47 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 4BB8F160B80; Fri, 17 Mar 2017 20:54:47 +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 934F3160B70 for ; Fri, 17 Mar 2017 21:54:46 +0100 (CET) Received: (qmail 52103 invoked by uid 500); 17 Mar 2017 20:54:45 -0000 Mailing-List: contact common-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-issues@hadoop.apache.org Received: (qmail 52092 invoked by uid 99); 17 Mar 2017 20:54:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Mar 2017 20:54:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 4891518E86A for ; Fri, 17 Mar 2017 20:54:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.651 X-Spam-Level: X-Spam-Status: No, score=0.651 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_NEUTRAL=0.652] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 0uTILeJOKbju for ; Fri, 17 Mar 2017 20:54:44 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 4E14460D0C for ; Fri, 17 Mar 2017 20:54:43 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 1B72AE086A for ; Fri, 17 Mar 2017 20:54:42 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 95EDE254B8 for ; Fri, 17 Mar 2017 20:54:41 +0000 (UTC) Date: Fri, 17 Mar 2017 20:54:41 +0000 (UTC) From: "John Zhuge (JIRA)" To: common-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Assigned] (HADOOP-14195) CredentialProviderFactory is not thread-safe MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 17 Mar 2017 20:54:47 -0000 [ https://issues.apache.org/jira/browse/HADOOP-14195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] John Zhuge reassigned HADOOP-14195: ----------------------------------- Assignee: Vihang Karajgaonkar (was: John Zhuge) > CredentialProviderFactory is not thread-safe > -------------------------------------------- > > Key: HADOOP-14195 > URL: https://issues.apache.org/jira/browse/HADOOP-14195 > Project: Hadoop Common > Issue Type: Bug > Components: security > Affects Versions: 2.7.0 > Reporter: Vihang Karajgaonkar > Assignee: Vihang Karajgaonkar > Attachments: TestCredentialProvider.java > > > Multi-threaded access to CredentialProviderFactory is not thread-safe because {{java.util.ServiceLoader}} is not thread-safe (as noted in its Java doc). Thanks to [~jzhuge] I was able to reproduce this issue but creating a simple multi-threaded application which executes the following code in parallel. > {code:java} > for (int i = 0; i < ITEMS; i++) { > futures.add(executor.submit(new Callable() { > @Override > public Void call() throws Exception { > boolean found = false; > for (CredentialProviderFactory factory : serviceLoader) { > CredentialProvider kp = factory.createProvider(uri, conf); > if (kp != null) { > result.add(kp); > found = true; > break; > } > } > if (!found) { > throw new IOException(Thread.currentThread() + "No CredentialProviderFactory for " + uri); > } else { > System.out.println(Thread.currentThread().getName() + " found credentialProvider for " + path); > } > return null; > } > })); > } > {code} > I see the following exception trace when I execute the above code. > {code:java} > java.util.concurrent.ExecutionException: java.util.NoSuchElementException > at java.util.concurrent.FutureTask.report(FutureTask.java:122) > at java.util.concurrent.FutureTask.get(FutureTask.java:192) > at TestCredentialProvider.main(TestCredentialProvider.java:58) > Caused by: java.util.NoSuchElementException > at java.net.URLClassLoader$3.nextElement(URLClassLoader.java:615) > at java.net.URLClassLoader$3.nextElement(URLClassLoader.java:590) > at sun.misc.CompoundEnumeration.nextElement(CompoundEnumeration.java:61) > at java.util.ServiceLoader$LazyIterator.hasNextService(ServiceLoader.java:357) > at java.util.ServiceLoader$LazyIterator.hasNext(ServiceLoader.java:393) > at java.util.ServiceLoader$1.hasNext(ServiceLoader.java:474) > at TestCredentialProvider$1.call(TestCredentialProvider.java:38) > at TestCredentialProvider$1.call(TestCredentialProvider.java:1) > at java.util.concurrent.FutureTask.run(FutureTask.java:266) > at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) > at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) > at java.lang.Thread.run(Thread.java:745) > {code} > I also see a NPE sometimes > {code:java} > java.util.concurrent.ExecutionException: java.lang.NullPointerException > at java.util.concurrent.FutureTask.report(FutureTask.java:122) > at java.util.concurrent.FutureTask.get(FutureTask.java:192) > at TestCredentialProvider.main(TestCredentialProvider.java:58) > Caused by: java.lang.NullPointerException > at java.util.ServiceLoader.parse(ServiceLoader.java:304) > at java.util.ServiceLoader.access$200(ServiceLoader.java:185) > at java.util.ServiceLoader$LazyIterator.hasNextService(ServiceLoader.java:357) > at java.util.ServiceLoader$LazyIterator.hasNext(ServiceLoader.java:393) > at java.util.ServiceLoader$1.hasNext(ServiceLoader.java:474) > at TestCredentialProvider$1.call(TestCredentialProvider.java:38) > at TestCredentialProvider$1.call(TestCredentialProvider.java:1) > at java.util.concurrent.FutureTask.run(FutureTask.java:266) > at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) > at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) > at java.lang.Thread.run(Thread.java:745) > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346) --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-issues-help@hadoop.apache.org