Return-Path: X-Original-To: apmail-curator-dev-archive@minotaur.apache.org Delivered-To: apmail-curator-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 14B4118CEB for ; Tue, 29 Mar 2016 02:08:26 +0000 (UTC) Received: (qmail 26079 invoked by uid 500); 29 Mar 2016 02:08:25 -0000 Delivered-To: apmail-curator-dev-archive@curator.apache.org Received: (qmail 26025 invoked by uid 500); 29 Mar 2016 02:08:25 -0000 Mailing-List: contact dev-help@curator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@curator.apache.org Delivered-To: mailing list dev@curator.apache.org Received: (qmail 25996 invoked by uid 99); 29 Mar 2016 02:08:25 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Mar 2016 02:08:25 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 7B4642C033A for ; Tue, 29 Mar 2016 02:08:25 +0000 (UTC) Date: Tue, 29 Mar 2016 02:08:25 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@curator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CURATOR-310) Race in PersistentNode startup MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CURATOR-310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15215261#comment-15215261 ] ASF GitHub Bot commented on CURATOR-310: ---------------------------------------- Github user Randgalt commented on a diff in the pull request: https://github.com/apache/curator/pull/140#discussion_r57663645 --- Diff: curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentNode.java --- @@ -317,6 +317,7 @@ public String getActualPath() public void setData(byte[] data) throws Exception { data = Preconditions.checkNotNull(data, "data cannot be null"); + Preconditions.checkState(nodePath.get() != null, "initial create has not been processed. Call waitForInitialCreate() to ensure."); this.data.set(Arrays.copyOf(data, data.length)); --- End diff -- The current behavior is undefined. I can't imagine anyone is dependent on an NPE. Right? > Race in PersistentNode startup > ------------------------------ > > Key: CURATOR-310 > URL: https://issues.apache.org/jira/browse/CURATOR-310 > Project: Apache Curator > Issue Type: Bug > Components: Recipes > Affects Versions: 2.10.0 > Reporter: Gerd Behrmann > > We ran into what looks like a race in PersisentNode startup: > java.lang.IllegalArgumentException: Path cannot be null > at org.apache.curator.utils.PathUtils.validatePath(PathUtils.java:48) ~[curator-client-2.10.0.jar:na] > at org.apache.curator.utils.PathUtils.validatePath(PathUtils.java:37) ~[curator-client-2.10.0.jar:na] > at org.apache.curator.utils.ZKPaths.fixForNamespace(ZKPaths.java:105) ~[curator-client-2.10.0.jar:na] > at org.apache.curator.framework.imps.NamespaceImpl.fixForNamespace(NamespaceImpl.java:104) ~[curator-framework-2.10.0.jar:na] > at org.apache.curator.framework.imps.CuratorFrameworkImpl.fixForNamespace(CuratorFrameworkImpl.java:594) ~[curator-framework-2.10.0.jar:na] > at org.apache.curator.framework.imps.SetDataBuilderImpl.forPath(SetDataBuilderImpl.java:244) ~[curator-framework-2.10.0.jar:na] > at org.apache.curator.framework.imps.SetDataBuilderImpl.forPath(SetDataBuilderImpl.java:41) ~[curator-framework-2.10.0.jar:na] > at dmg.cells.zookeeper.CellCuratorFramework$PathAndBytesableDecorator.forPath(CellCuratorFramework.java:1369) ~[cells-2.16.0-SNAPSHOT.jar:2.16.0-SNAPSHOT] > at org.apache.curator.framework.recipes.nodes.PersistentNode.setData(PersistentNode.java:323) ~[curator-recipes-2.10.0.jar:na] > The problem here is that PersistentNode#setData calls PersistentNode#getActualPath, however the nodePath field accessed by PersistentNode#getActualPath isn't set until PersistentNode#processBackgroundCallback is called as a result of the createNode call in PersistentNode#start. > I.e. if one calls PersistentNode#setData right after calling start, there is a race between the node creation initializing the actual path and PersistentNode#setData accessing it. -- This message was sent by Atlassian JIRA (v6.3.4#6332)