[jboss-dev-forums] [Design of JBossCache] - Re: Classloader leak via CacheImpl.invocationContextContaine
jason.greene@jboss.com
do-not-reply at jboss.com
Fri Jun 8 12:24:29 EDT 2007
A one shot option that is not associated with a method is error prone and verbose for calling code.
Consider this code
| cache.getOptions().setForceWriteLock(true);
| String atomicUserCounter = cache.get("/user/123", "counter");
|
Later someone assumes this is a persisting option and updates it
| cache.getOptions().setForceWriteLock(true);
| String atomicUserCounter = cache.get("/user/123", "counter");
| String atomicGroupCounter = cache.get("/group/456", "counter");
|
The fix is overly verbose:
| cache.getOptions().setForceWriteLock(true);
| String atomicUserCounter = cache.get("/user/123", "counter");
| cache.getOptions().setForceWriteLock(true);
| String atomicGroupCounter = cache.get("/group/456", "counter");
|
That said persistent options could lead to problems as well.
An overloaded parameter is neither error prone, nor overly verbose, and is intuitive:
| Options options = new Options();
| options.setForceWriteLock(true);
| String atomicUserCounter = cache.get("/user/123", "counter", options);
| String atomicGroupCounter = cache.get("/group/456", "counter", options);
| String regularReadValue = cache.get("/foo", "foo");
|
You could even offer constant options (via an immutable extension):
| String atomicUserCounter = cache.get("/user/123", "counter", Options.FORCE_WRITE_LOCK);
| String atomicGroupCounter = cache.get("/group/456", "counter", Options.FORCE_WRITE_LOCK);
| String regularReadValue = cache.get("/foo", "foo");
|
-Jason
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4052667#4052667
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4052667
More information about the jboss-dev-forums
mailing list