geode-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Smith (JIRA)" <>
Subject [jira] [Created] (GEODE-1816) CacheServerLauncher uses static threadlocals to launch server
Date Wed, 24 Aug 2016 23:57:21 GMT
Dan Smith created GEODE-1816:

             Summary: CacheServerLauncher uses static threadlocals to launch server
                 Key: GEODE-1816
             Project: Geode
          Issue Type: Bug
          Components: management
            Reporter: Dan Smith

The CacheServerLauncher class has 3 static threadlocals 

  public static ThreadLocal<Integer> serverPort = new ThreadLocal<Integer>();

  public static ThreadLocal<String> serverBindAddress = new ThreadLocal<String>();

  public static ThreadLocal<Boolean> disableDefaultServer = new ThreadLocal<Boolean>();


These get set when a server is launched. Then down in CacheCreation.create, it reads these
thread locals and uses them to add a cache server.

Unfortunately this causes lots of pain writing unit tests, because tests can end up setting
these thread locals and they are never cleared. Statics and thread locals should pretty much
never be used. Especially in this case it seems like there are several easy ways to create
a cache server after the cache is created, or pass properties in while creating the cache.

This message was sent by Atlassian JIRA

View raw message