Uploaded image for project: 'Apache Curator'
  1. Apache Curator
  2. CURATOR-431

Stat structure not filled when using the idiom create().orSetData()

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.0.0
    • Fix Version/s: 4.0.1
    • Component/s: Client
    • Labels:
      None

      Description

      Hello

      It seems that when using the idiom client.create().orSetData(), the Stat structure set with storingStatIn does not get filled if the path already exists.

      I attached a unit test that exemplifies the behaviour.

      Regards

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user cammckenzie opened a pull request:

          https://github.com/apache/curator/pull/236

          CURATOR-431 - Fixed stat population during create

          -The stat object was not being populated if the create failed due to the node already existing.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/apache/curator CURATOR-431

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/curator/pull/236.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #236


          commit 931f1de5c4f72b71e96ea2071add297194e053bd
          Author: Cam McKenzie <cammckenzie@apache.org>
          Date: 2017-09-11T22:58:47Z

          CURATOR-431 - Fixed stat population during create

          -The stat object was not being populated if the create failed due to the node already existing.


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user cammckenzie opened a pull request: https://github.com/apache/curator/pull/236 CURATOR-431 - Fixed stat population during create -The stat object was not being populated if the create failed due to the node already existing. You can merge this pull request into a Git repository by running: $ git pull https://github.com/apache/curator CURATOR-431 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/curator/pull/236.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #236 commit 931f1de5c4f72b71e96ea2071add297194e053bd Author: Cam McKenzie <cammckenzie@apache.org> Date: 2017-09-11T22:58:47Z CURATOR-431 - Fixed stat population during create -The stat object was not being populated if the create failed due to the node already existing.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user Randgalt commented on a diff in the pull request:

          https://github.com/apache/curator/pull/236#discussion_r138405955

          — Diff: curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java —
          @@ -1212,7 +1212,21 @@ public String call() throws Exception
          {
          if ( setDataIfExists )
          {

          • client.getZooKeeper().setData(path, data, setDataIfExistsVersion);
            + Stat setStat = client.getZooKeeper().setData(path, data, setDataIfExistsVersion);
            + if(storingStat != null)
            + {
            + storingStat.setAversion(setStat.getAversion());
              • End diff –

          Other than that LGTM

          Show
          githubbot ASF GitHub Bot added a comment - Github user Randgalt commented on a diff in the pull request: https://github.com/apache/curator/pull/236#discussion_r138405955 — Diff: curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java — @@ -1212,7 +1212,21 @@ public String call() throws Exception { if ( setDataIfExists ) { client.getZooKeeper().setData(path, data, setDataIfExistsVersion); + Stat setStat = client.getZooKeeper().setData(path, data, setDataIfExistsVersion); + if(storingStat != null) + { + storingStat.setAversion(setStat.getAversion()); End diff – Other than that LGTM
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user cammckenzie commented on a diff in the pull request:

          https://github.com/apache/curator/pull/236#discussion_r138482206

          — Diff: curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java —
          @@ -1212,7 +1212,21 @@ public String call() throws Exception
          {
          if ( setDataIfExists )
          {

          • client.getZooKeeper().setData(path, data, setDataIfExistsVersion);
            + Stat setStat = client.getZooKeeper().setData(path, data, setDataIfExistsVersion);
            + if(storingStat != null)
            + {
            + storingStat.setAversion(setStat.getAversion());
              • End diff –

          Thanks, there was another place in CreateBuilderImpl doing the same thing, and I've replaced that with DataTree#copyStat() also.

          Show
          githubbot ASF GitHub Bot added a comment - Github user cammckenzie commented on a diff in the pull request: https://github.com/apache/curator/pull/236#discussion_r138482206 — Diff: curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java — @@ -1212,7 +1212,21 @@ public String call() throws Exception { if ( setDataIfExists ) { client.getZooKeeper().setData(path, data, setDataIfExistsVersion); + Stat setStat = client.getZooKeeper().setData(path, data, setDataIfExistsVersion); + if(storingStat != null) + { + storingStat.setAversion(setStat.getAversion()); End diff – Thanks, there was another place in CreateBuilderImpl doing the same thing, and I've replaced that with DataTree#copyStat() also.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/curator/pull/236

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/curator/pull/236

            People

            • Assignee:
              cammckenzie Cameron McKenzie
              Reporter:
              andres-pipicello Andrés Pipicello
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development