Repository: curator Updated Branches: refs/heads/master ba8ade007 -> 129ef5e31
CURATOR-448 - Include curator framework state in error messages Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/49485b8f Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/49485b8f Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/49485b8f Branch: refs/heads/master Commit: 49485b8fa40c5d5fa95e60ffea3514acf548964b Parents: 9383aa3 Author: Christopher McTague <[email protected]> Authored: Mon Jun 11 12:41:58 2018 -0400 Committer: Christopher McTague <[email protected]> Committed: Mon Jun 11 12:41:58 2018 -0400 ---------------------------------------------------------------------- .../framework/imps/CuratorFrameworkImpl.java | 44 +++++++++----------- 1 file changed, 19 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/49485b8f/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index 2bd5c7c..4c66ff6 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java @@ -402,75 +402,72 @@ public class CuratorFrameworkImpl implements CuratorFramework return (str != null) ? str : ""; } + private void checkState() + { + CuratorFrameworkState state = getState(); + Preconditions.checkState(state == CuratorFrameworkState.STARTED, "instance state must be %s before calling this method, however its %s", CuratorFrameworkState.STARTED, state); + } + @Override public CuratorFramework usingNamespace(String newNamespace) { - Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method"); - + checkState(); return namespaceFacadeCache.get(newNamespace); } @Override public CreateBuilder create() { - Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method"); - + checkState(); return new CreateBuilderImpl(this); } @Override public DeleteBuilder delete() { - Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method"); - + checkState(); return new DeleteBuilderImpl(this); } @Override public ExistsBuilder checkExists() { - Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method"); - + checkState(); return new ExistsBuilderImpl(this); } @Override public GetDataBuilder getData() { - Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method"); - + checkState(); return new GetDataBuilderImpl(this); } @Override public SetDataBuilder setData() { - Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method"); - + checkState(); return new SetDataBuilderImpl(this); } @Override public GetChildrenBuilder getChildren() { - Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method"); - + checkState(); return new GetChildrenBuilderImpl(this); } @Override public GetACLBuilder getACL() { - Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method"); - + checkState(); return new GetACLBuilderImpl(this); } @Override public SetACLBuilder setACL() { - Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method"); - + checkState(); return new SetACLBuilderImpl(this); } @@ -491,24 +488,21 @@ public class CuratorFrameworkImpl implements CuratorFramework @Override public CuratorTransaction inTransaction() { - Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method"); - + checkState(); return new CuratorTransactionImpl(this); } @Override public CuratorMultiTransaction transaction() { - Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method"); - + checkState(); return new CuratorMultiTransactionImpl(this); } @Override public TransactionOp transactionOp() { - Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method"); - + checkState(); return new TransactionOpImpl(this); } @@ -533,7 +527,7 @@ public class CuratorFrameworkImpl implements CuratorFramework @Override public void sync(String path, Object context) { - Preconditions.checkState(getState() == CuratorFrameworkState.STARTED, "instance must be started before calling this method"); + checkState(); path = fixForNamespace(path);
