Keith Turner created CURATOR-448:
------------------------------------
Summary: Include curator framework state in error messages
Key: CURATOR-448
URL: https://issues.apache.org/jira/browse/CURATOR-448
Project: Apache Curator
Issue Type: Improvement
Reporter: Keith Turner
Assignee: Jordan Zimmerman
While looking into [Apache Fluo #1004|https://github.com/apache/fluo/pull/1004]
I am seeing error messages like the following.
{noformat}
2018-01-22 02:57:23,383 [leader.LeaderSelector] ERROR: The leader threw an
exception
java.lang.IllegalStateException: instance must be started before calling this
method
at com.google.common.base.Preconditions.checkState(Preconditions.java:149)
at
org.apache.curator.framework.imps.CuratorFrameworkImpl.getData(CuratorFrameworkImpl.java:363)
at
org.apache.fluo.core.oracle.OracleServer.takeLeadership(OracleServer.java:426)
TRUNCATED{noformat}
When I see this error message I know the
[CuratorFrameworkState|https://curator.apache.org/apidocs/org/apache/curator/framework/imps/CuratorFrameworkState.html]
is not STARTED. However I don't know if its LATENT or STOPPED. From a
debugging standpoint this information would be very useful. An example of the
code that generates this error messages is at [CuratorFrameworkImpl.java line
408|https://github.com/apache/curator/blob/3f7b610ad5c5a0c6a7b0331f02294bd433a54554/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java#L408].
This code could be changed to call an internal method like the following :
{code:java}
private void checkState() {
CuratorFrameworkState state = getState(); //store state in local var to avoid
race conditions since it may be read twice
Preconditions.checkState(state == CuratorFrameworkState.STARTED, "instance
state must be %s before calling this method, however its %s",
CuratorFrameworkState.STARTED, state);
}
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)