mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-06 08:36:01 +00:00
Merged revisions 24110-24112 via svnmerge from
https://svn.dev.java.net/svn/hudson/branches/rc ........ r24110 | kohsuke | 2009-11-25 17:14:49 -0800 (Wed, 25 Nov 2009) | 22 lines On my production server I started seeing a strange NPE like this: java.lang.NullPointerException at hudson.model.Label.contains(Label.java:277) at hudson.model.Queue$JobOffer.canTake(Queue.java:177) at hudson.model.Queue$ApplicableJobOfferList.(Queue.java:767) at hudson.model.Queue$ApplicableJobOfferList.(Queue.java:759) at hudson.model.Queue.pop(Queue.java:684) at hudson.model.Executor.grabJob(Executor.java:161) at hudson.model.Executor.run(Executor.java:103) The only possibility is that the getNodes() is returning null, and that's only possible if Label.getNodes() returns null, which in turn is only possible if the assignment to nodes is overwritten by the reset method before it's used as a return value. This fix should eliminate the possibility that the getNodes() method return null. ........ r24111 | kohsuke | 2009-11-25 17:15:45 -0800 (Wed, 25 Nov 2009) | 2 lines Actually, getNodes() has another possibility of such a data race. ........ r24112 | kohsuke | 2009-11-25 17:24:27 -0800 (Wed, 25 Nov 2009) | 1 line typo ........ git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@24127 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
2d38b33630
commit
bd775698b9
1 file changed
+11
-11
@@ -106,18 +106,18 @@ public class Label implements Comparable<Label>, ModelObject {
|
||||
*/
|
||||
@Exported
|
||||
public Set<Node> getNodes() {
|
||||
if(nodes==null) {
|
||||
Set<Node> r = new HashSet<Node>();
|
||||
Hudson h = Hudson.getInstance();
|
||||
if(h.getAssignedLabels().contains(this))
|
||||
r.add(h);
|
||||
for (Node n : h.getNodes()) {
|
||||
if(n.getAssignedLabels().contains(this))
|
||||
r.add(n);
|
||||
}
|
||||
nodes = Collections.unmodifiableSet(r);
|
||||
Set<Node> nodes = this.nodes;
|
||||
if(nodes!=null) return nodes;
|
||||
|
||||
Set<Node> r = new HashSet<Node>();
|
||||
Hudson h = Hudson.getInstance();
|
||||
if(h.getAssignedLabels().contains(this))
|
||||
r.add(h);
|
||||
for (Node n : h.getNodes()) {
|
||||
if(n.getAssignedLabels().contains(this))
|
||||
r.add(n);
|
||||
}
|
||||
return nodes;
|
||||
return this.nodes = Collections.unmodifiableSet(r);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user