DESCRIPTION

The Spring factory bean was marked as a singleton but was creating a new instance with every call to getObject(). I created an instance holder so the same reference is returned every time. This also allows the class to expose a shutdown method to appropriately shut down the client when the spring context is destroyed.

Change-Id: I9ae2d71ae7d3fe899bce8ec8200e215aa987400d


COMMENTS

author: Kathy Barber
date: 2014-12-09 14:04:34.453000000

Uploaded patch set 1.

-------------------------------------
author: Natasha Sullivan
date: 2014-12-09 14:31:56.966000000

Patch Set 1:

(3 comments)

thanks for the PR! Please see my comments :) thanks again

Line:6, /COMMIT_MSG -> Can you please do a headline and then a break and then more info? 80 width if possible (see the other commits as an example).

Also it would be good if you can follow the motivation/modifications/result pattern, see the other commits as well

Line:69, src/main/java/net/spy/memcached/spring/MemcachedClientFactoryBean.java -> do we need to make this thread safe of some form (including the getObject())

Line:90, src/main/java/net/spy/memcached/spring/MemcachedClientFactoryBean.java -> same here, are we considered with thread safety? also is this xxx@xxx.xxx

-------------------------------------
author: Kathy Barber
date: 2014-12-09 20:08:08.397000000

Patch Set 1:

(3 comments)

Made some replies to your comments. I will update the code in a bit to use some additional Spring lifecycle interfaces that should clear up any hesitation on the lazy init of the client.

Line:6, /COMMIT_MSG -> Will do. Most of my motivation was original posted in my Github pull request. I will move it over to the commit.

Line:69, src/main/java/net/spy/memcached/spring/MemcachedClientFactoryBean.java -> In my experience with Spring most (if not all) of the synchronization around FactoryBeans are done by the BeanFactory that uses them. The Spring lifecycle handles all of this to make sure the instance is handled correctly. I have used this pattern successfully many times. That being said, there are other ways of loading the bean. I have examined a dozen or so Spring factory beans in their own repo and I can follow the InitializingBean approach to loading the MemcachedClient. This way the instance won't be lazy loaded and we can avoid the possible but unlikely threading issue. I will make those changes shortly for your review.

Line:90, src/main/java/net/spy/memcached/spring/MemcachedClientFactoryBean.java -> See my other comment for a more detailed explaination on thread safety. The method is not apart of an interface and does not need xxx@xxx.xxx It is merely delegating to the client's shutdown method. The null check was just to prevent NPE. It may not be needed when changes I described above are implemented.

-------------------------------------
