From reviews-return-103-archive-asf-public=cust-asf.ponee.io@livy.incubator.apache.org Wed Nov 28 23:05:26 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id CE246180658 for ; Wed, 28 Nov 2018 23:05:25 +0100 (CET) Received: (qmail 28477 invoked by uid 500); 28 Nov 2018 22:05:25 -0000 Mailing-List: contact reviews-help@livy.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: reviews@livy.incubator.apache.org Delivered-To: mailing list reviews@livy.incubator.apache.org Received: (qmail 28461 invoked by uid 99); 28 Nov 2018 22:05:24 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Nov 2018 22:05:24 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3D395E10CA; Wed, 28 Nov 2018 22:05:24 +0000 (UTC) From: bjoernlohrmann To: reviews@livy.apache.org Reply-To: reviews@livy.apache.org References: In-Reply-To: Subject: [GitHub] incubator-livy pull request #128: [LIVY-533] Use setJobGroup/cancelJobGroup ... Content-Type: text/plain Message-Id: <20181128220524.3D395E10CA@git1-us-west.apache.org> Date: Wed, 28 Nov 2018 22:05:24 +0000 (UTC) Github user bjoernlohrmann commented on a diff in the pull request: https://github.com/apache/incubator-livy/pull/128#discussion_r237280060 --- Diff: rsc/src/main/java/org/apache/livy/rsc/driver/JobWrapper.java --- @@ -39,20 +39,27 @@ private final RSCDriver driver; private final Job job; - private final AtomicInteger completed; - private Future future; + private volatile Future future; public JobWrapper(RSCDriver driver, String jobId, Job job) { this.driver = driver; this.jobId = jobId; this.job = job; - this.completed = new AtomicInteger(); } @Override public Void call() throws Exception { try { + // this is synchronized to avoid races with cancel() --- End diff -- `future` will only be null for synchronous bypass jobs, but those cannot be cancelled unless I am mistaken? For async bypass jobs, I think `future` should always be non-null during `call()/cancel()`, because it is assigned in `submit()` which also has the synchronized modifier and always runs before `call()` or `cancel()`. I can add a boolean cancelled flag if you prefer, but this feels like duplicating information that is already available in the future. ---