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 A2D1C200C7F for ; Wed, 24 May 2017 10:22:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A1B24160B9C; Wed, 24 May 2017 08:22:10 +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 D3AE9160BD0 for ; Wed, 24 May 2017 10:22:09 +0200 (CEST) Received: (qmail 17612 invoked by uid 500); 24 May 2017 08:22:09 -0000 Mailing-List: contact issues-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list issues@drill.apache.org Received: (qmail 17485 invoked by uid 99); 24 May 2017 08:22:09 -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; Wed, 24 May 2017 08:22:08 +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 7E0C0190DC2 for ; Wed, 24 May 2017 08:22:08 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id OKyLCZ1k4HV6 for ; Wed, 24 May 2017 08:22:06 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id AAE2460E2E for ; Wed, 24 May 2017 08:22:05 +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 2BDC7E0D49 for ; Wed, 24 May 2017 08:22:05 +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 617B523FDE for ; Wed, 24 May 2017 08:22:04 +0000 (UTC) Date: Wed, 24 May 2017 08:22:04 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DRILL-5533) Fix flag assignment in FunctionInitializer.checkInit() method MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 24 May 2017 08:22:10 -0000 [ https://issues.apache.org/jira/browse/DRILL-5533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16022515#comment-16022515 ] ASF GitHub Bot commented on DRILL-5533: --------------------------------------- Github user arina-ielchiieva commented on a diff in the pull request: https://github.com/apache/drill/pull/843#discussion_r118186385 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionInitializer.java --- @@ -74,41 +70,43 @@ public String getClassName() { * @return the imports of this class (for java code gen) */ public List getImports() { - checkInit(); + loadFunctionBody(); return imports; } /** - * @param methodName + * @param methodName method name * @return the content of the method (for java code gen inlining) */ public String getMethod(String methodName) { - checkInit(); + loadFunctionBody(); return methods.get(methodName); } - private void checkInit() { - if (ready) { + /** + * Loads function body: methods (for instance, eval, setup, reset) and imports. + * Loading is done once per class instance upon first function invocation. + * Double-checked locking is used to avoid concurrency issues + * when two threads are trying to load the function body at the same time. + */ + private void loadFunctionBody() { + if (isLoaded) { return; } synchronized (this) { - if (ready) { + if (isLoaded) { return; } - // get function body. - + logger.debug("Getting function body for the {}", className); --- End diff -- Done. > Fix flag assignment in FunctionInitializer.checkInit() method > ------------------------------------------------------------- > > Key: DRILL-5533 > URL: https://issues.apache.org/jira/browse/DRILL-5533 > Project: Apache Drill > Issue Type: Bug > Affects Versions: 1.10.0 > Reporter: Arina Ielchiieva > Assignee: Arina Ielchiieva > Priority: Minor > > FunctionInitializer.checkInit() method uses DCL to ensure that function body is loaded only once. But flag parameter is never updated and all threads are entering synchronized block. > Also FunctionInitializer.getImports() always returns empty list. > https://github.com/apache/drill/blob/3e8b01d5b0d3013e3811913f0fd6028b22c1ac3f/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionInitializer.java > Changes: > 1. Fix DCL in FunctionInitializer.checkInit() method (update flag parameter when function body is loaded). > 2. Fix ImportGrabber.getImports() method to return list with imports. > 3. Add unit tests for FunctionInitializer. > 4. Minor refactoring (rename methods, add javadoc). -- This message was sent by Atlassian JIRA (v6.3.15#6346)