Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISPN-1154, ISPN-1167, ISPN-1166 #367

Closed
wants to merge 5 commits into from
Closed

Conversation

Sanne
Copy link
Member

@Sanne Sanne commented Jun 8, 2011

(are all related)

Sanne added 5 commits June 8, 2011 21:01
code change is one, hence a single commit but two issues to track them:

ISPN-1167 Eviction acquires locks even if it doesn't need them
ISPN-1166 Eviction might release locks it didn't acquire
*
* @author Sanne Grinovero <sanne@infinispan.org> (C) 2011 Red Hat Inc.
*/
public final class ImmutableContext implements InvocationContext {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to create a singleton, using an enum is more elegant, for example: http://stackoverflow.com/questions/70689/efficient-way-to-implement-singleton-pattern-in-java

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@galderz, it seems that converting it to an enum could lead to some trouble: "clone()" on enum is declared final, and throws unsupported operation, while Infinispan redefines the clone() on the interface. it seems we could convert it to an enum nevertheless as it looks like clone() would not be invoked on the cases this implementation is used, but it seems to me that we would be safer keeping the patch as-is. WDYT ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, actually it's just not possible to do it, as the return type of an enum is different than what our signature requires. So we're stuck with the singleton constant.

Anyway, it seems the beautiful pattern of the enum is mostly useful to make sure there's really only one instance (including serialized clones), but we don't really need strong guarantees on it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine Sanne. It's always worth looking an alternatives. Great job investigating it.

@galderz
Copy link
Member

galderz commented Jun 9, 2011

p.s. If you add links to the JIRAs, it makes it easier for the reviewer :)

@galderz
Copy link
Member

galderz commented Jun 9, 2011

Btw, just to clarify as per the dev thread, there's still a change missing where the passivaition will occur before the eviction, right?

@Sanne
Copy link
Member Author

Sanne commented Jun 9, 2011

hi @galderz, many thanks for the review. Yes this is not including a pull request for https://issues.jboss.org/browse/ISPN-1169 , as that will require some more discussing and a lot of testing so I wanted to get this in as a stable starting point, as these issues need to be solved too.
I'll soon update this with the enum, good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants