Accumulo
  1. Accumulo
  2. ACCUMULO-2966

ZooReaderWriter.getInstance ignores changes in params

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.5.0, 1.5.1, 1.6.0
    • Fix Version/s: 1.8.0
    • Component/s: fate
    • Labels:

      Description

      the factory methods on ZooReaderWriter take parameters for servers, timeout, and authentication, but ignores if those parameters are different from the first invocation.

      
        public static synchronized ZooReaderWriter getInstance(String zookeepers, int timeInMillis, String scheme, byte[] auth) {
          if (instance == null)
            instance = new ZooReaderWriter(zookeepers, timeInMillis, scheme, auth);
          return instance;
        }
      
        /**
         * get an instance that retries when zookeeper connection errors occur
         * 
         * @return an instance that retries when Zookeeper connection errors occur.
         */
        public static synchronized IZooReaderWriter getRetryingInstance(String zookeepers, int timeInMillis, String scheme, byte[] auth) {
      
          if (retryingInstance == null) {
            IZooReaderWriter inst = getInstance(zookeepers, timeInMillis, scheme, auth);
            InvocationHandler ih = new RetryingInvocationHandler(inst);
            retryingInstance = (IZooReaderWriter) Proxy.newProxyInstance(ZooReaderWriter.class.getClassLoader(), new Class[] {IZooReaderWriter.class}, ih);
          }
      
          return retryingInstance;
        }
      

      It should either keep a cache keyed on the parameter values or it should throw an exception when they differ from the existing instance.

      Which one depends on wether the intent is to reuse objects or to have ZooReaderWriter be a proper singleton. I'm not sure from context, but I think the cache is the way to go.

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Unassigned
              Reporter:
              Sean Busbey
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:

                Development