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

JENKINS-31932: getJDKs/setJDKs synchronization done using a lock object #1947

Closed

Conversation

lukaszkarnasiewicz
Copy link

@oleg-nenashev
Copy link
Member

Sounds reasonable. 👍

@oleg-nenashev oleg-nenashev added the needs-more-reviews Complex change, which would benefit from more eyes label Dec 7, 2015
@daniel-beck
Copy link
Member

@daspilker FYI

@daniel-beck
Copy link
Member

LGTM.

@oleg-nenashev oleg-nenashev added ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback and removed needs-more-reviews Complex change, which would benefit from more eyes labels Dec 10, 2015
@daspilker
Copy link
Member

Hm, I still don't see why this needs to be synchronized at all. See the original discussion at #1692 (comment)

@jtnord
Copy link
Member

jtnord commented Dec 22, 2015

I think I agree with @daspilker - all that is needed is the jdks to be volatile AFAICT.

@lukaszkarnasiewicz
Copy link
Author

Well, you have a mutable field jdks *in the *Jenkins *class so you have to
make sure that access to it is "synchronized" in some way. I agree that in
this case for the time being *volatile *would be sufficient. Would you like
me to modify this pull request to use *volatile
instead of a synchronised
block?

wt., 22.12.2015 o 11:55 użytkownik James Nord notifications@github.com
napisał:

I think I agree with @daspilker https://github.com/daspilker - all that
is needed is the jdks to be volatile AFAICT.


Reply to this email directly or view it on GitHub
#1947 (comment).

Pozdrawiam,
Łukasz Karnasiewicz

@jtnord
Copy link
Member

jtnord commented Dec 22, 2015

I have a feeling that volatile should perform better than locking - but it is only a feeling. I would wait to see if others have any opinion on this.
Personally I would prefer that the List is replaced by a thread safe implementation but there is not one that has an atomic clearAndSet operation that I am aware of.

return jdks;
public List<JDK> getJDKs() {
synchronized (jdksLock) {
return Collections.unmodifiableList(jdks);
Copy link
Member

Choose a reason for hiding this comment

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

This will break any existing code that modifies the list returned by getJDKs(), e.g. https://github.com/jenkinsci/jenkins/blob/jenkins-1.643/test/src/test/java/hudson/model/ProjectTest.java#L332

Why hasn't this been tested by the pull request builder? This is not ready for merge.

Copy link
Member

Choose a reason for hiding this comment

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

given ArrayList is not thread safe - you can consider that "a good thing(tm)"

@oleg-nenashev oleg-nenashev added needs-more-reviews Complex change, which would benefit from more eyes and removed ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback labels Dec 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-more-reviews Complex change, which would benefit from more eyes
Projects
None yet
5 participants