sonatype-lift[bot] commented on code in PR #1811: URL: https://github.com/apache/zookeeper/pull/1811#discussion_r1036906141
########## zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java: ########## @@ -1845,7 +1852,116 @@ public String create( return response.getPath().substring(cnxn.chrootPath.length()); } } + + /** + * Create a node with the given path or sets existing node data and returns the Stat of that node. + * The node data will be the given data and node acl will be the given acl. + * <p> + * The flags argument specifies whether the created node will be ephemeral + * or not. + * <p> + * An ephemeral node will be removed by the ZooKeeper automatically when the + * session associated with the creation of the node expires. + * <p> + * The flags argument can also specify to create a sequential node. The + * actual path name of a sequential node will be the given path plus a + * suffix "i" where i is the current sequential number of the node. The sequence + * number is always fixed length of 10 digits, 0 padded. Once + * such a node is created, the sequential number will be incremented by one. + * <p> + * If a node with the same actual path already exists in the ZooKeeper, a + * KeeperException with error code KeeperException.NodeExists will be + * thrown. Note that since a different actual path is used for each + * invocation of creating sequential node with the same path argument, the + * call will never throw "file exists" KeeperException. + * <p> + * If the parent node does not exist in the ZooKeeper, a KeeperException + * with error code KeeperException.NoNode will be thrown. + * <p> + * An ephemeral node cannot have children. If the parent node of the given + * path is ephemeral, a KeeperException with error code + * KeeperException.NoChildrenForEphemerals will be thrown. + * <p> + * This operation, if successful, will trigger all the watches left on the + * node of the given path by exists and getData API calls, and the watches + * left on the parent node by getChildren API calls. + * <p> + * If a node is created successfully, the ZooKeeper server will trigger the + * watches on the path left by exists calls, and the watches on the parent + * of the node by getChildren calls. + * <p> + * The maximum allowable size of the data array is 1 MB (1,048,576 bytes). + * Arrays larger than this will cause a KeeperExecption to be thrown. + * + * @param path + * the path for the node + * @param data + * the initial data for the node + * @param acl + * the acl for the node + * @param createMode + * specifying whether the node to be created is ephemeral + * and/or sequential + * @param version + * @param stat + * The output Stat object. + * @return the actual path of the created node + * @throws KeeperException if the server returns a non-zero error code + * @throws KeeperException.InvalidACLException if the ACL is invalid, null, or empty + * @throws InterruptedException if the transaction is interrupted + * @throws IllegalArgumentException if an invalid path is specified + */ + public String createOrSet( + final String path, + byte[] data, + List<ACL> acl, + CreateMode createMode, + int version, + Stat stat) throws KeeperException, InterruptedException { + return createOrSet(path, data, acl, createMode, version, stat, -1); Review Comment: đŦ 23 similar findings have been found in this PR --- *THREAD_SAFETY_VIOLATION:* Unprotected write. Non-private method `ZooKeeper.createOrSet(...)` indirectly writes to field `this.cnxn.sendThread.clientCnxnSocket.lastHeard` outside of synchronization. Reporting because another access to the same memory occurs on a background thread, although this access may not. --- <details><summary><b>đ Expand here to view all instances of this finding</b></summary><br/> <div align="center"> | **File Path** | **Line Number** | | ------------- | ------------- | | zookeeper-server/src/main/java/org/apache/zookeeper/server/ZKDatabase.java | [597](https://github.com/mobius-software-ltd/zookeeper/blob/455bee29d09634cb001ebad8fd0462203d4a1f08/zookeeper-server/src/main/java/org/apache/zookeeper/server/ZKDatabase.java#L597)| | zookeeper-server/src/main/java/org/apache/zookeeper/server/DataTree.java | [1031](https://github.com/mobius-software-ltd/zookeeper/blob/455bee29d09634cb001ebad8fd0462203d4a1f08/zookeeper-server/src/main/java/org/apache/zookeeper/server/DataTree.java#L1031)| | zookeeper-server/src/main/java/org/apache/zookeeper/server/DataTree.java | [1131](https://github.com/mobius-software-ltd/zookeeper/blob/455bee29d09634cb001ebad8fd0462203d4a1f08/zookeeper-server/src/main/java/org/apache/zookeeper/server/DataTree.java#L1131)| | zookeeper-server/src/main/java/org/apache/zookeeper/server/DataTree.java | [1154](https://github.com/mobius-software-ltd/zookeeper/blob/455bee29d09634cb001ebad8fd0462203d4a1f08/zookeeper-server/src/main/java/org/apache/zookeeper/server/DataTree.java#L1154)| | zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java | [1951](https://github.com/mobius-software-ltd/zookeeper/blob/455bee29d09634cb001ebad8fd0462203d4a1f08/zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java#L1951)| | zookeeper-server/src/main/java/org/apache/zookeeper/server/ZKDatabase.java | [454](https://github.com/mobius-software-ltd/zookeeper/blob/455bee29d09634cb001ebad8fd0462203d4a1f08/zookeeper-server/src/main/java/org/apache/zookeeper/server/ZKDatabase.java#L454)| | zookeeper-server/src/main/java/org/apache/zookeeper/server/DataTree.java | [1082](https://github.com/mobius-software-ltd/zookeeper/blob/455bee29d09634cb001ebad8fd0462203d4a1f08/zookeeper-server/src/main/java/org/apache/zookeeper/server/DataTree.java#L1082)| | zookeeper-server/src/main/java/org/apache/zookeeper/server/PrepRequestProcessor.java | [442](https://github.com/mobius-software-ltd/zookeeper/blob/455bee29d09634cb001ebad8fd0462203d4a1f08/zookeeper-server/src/main/java/org/apache/zookeeper/server/PrepRequestProcessor.java#L442)| | zookeeper-server/src/main/java/org/apache/zookeeper/server/DataTree.java | [449](https://github.com/mobius-software-ltd/zookeeper/blob/455bee29d09634cb001ebad8fd0462203d4a1f08/zookeeper-server/src/main/java/org/apache/zookeeper/server/DataTree.java#L449)| | zookeeper-server/src/main/java/org/apache/zookeeper/server/ZooKeeperServer.java | [1139](https://github.com/mobius-software-ltd/zookeeper/blob/455bee29d09634cb001ebad8fd0462203d4a1f08/zookeeper-server/src/main/java/org/apache/zookeeper/server/ZooKeeperServer.java#L1139)| <p> Showing <b>10</b> of <b>23</b> findings. <a href="https://lift.sonatype.com/results/github.com/apache/zookeeper/01GK6H5X21W2SJXY7ZNPK13NNV?t=Infer|THREAD_SAFETY_VIOLATION" target="_blank">Visit the Lift Web Console</a> to see all.</p></div></details> --- <details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary> You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings. | **Command** | **Usage** | | ------------- | ------------- | | `@sonatype-lift ignore` | Leave out the above finding from this PR | | `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR | | `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file | **Note:** When talking to LiftBot, you need to **refresh** the page to see its response. <sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details> --- Was this a good recommendation? [ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=356968099&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=356968099&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=356968099&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=356968099&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=356968099&lift_comment_rating=5) ] -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@zookeeper.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org