Skip to content

Commit

Permalink
Merge branch 'master' into update-forms
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Nov 14, 2021
2 parents 1298ce9 + 5bb9fdf commit c282ba2
Show file tree
Hide file tree
Showing 16 changed files with 195 additions and 54 deletions.
2 changes: 0 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ updates:
- dependency-name: "jakarta.servlet.jsp.jstl.jakarta.servlet.jsp.jstl-api"
# see https://github.com/jenkinsci/jenkins/pull/4224 can't be updated without breaking api
- dependency-name: "org.jfree:jfreechart"
# needs guava upgrades first https://github.com/jenkinsci/jenkins/pull/5200#pullrequestreview-579741619
- dependency-name: "com.google.inject:guice"
# the dependency is actually provided by the Web container, hence it is aligned with Jetty. See https://github.com/jenkinsci/jenkins/pull/5211
- dependency-name: "javax.servlet:javax.servlet-api"
# log4j 1.2.17 is the final 1.x release
Expand Down
12 changes: 6 additions & 6 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ THE SOFTWARE.
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.0</version>
<version>5.0.1</version>
</dependency>

<!-- SLF4J used in maven-plugin and core -->
Expand Down Expand Up @@ -176,12 +176,12 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>version-number</artifactId>
<version>1.7</version>
<version>1.8</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>crypto-util</artifactId>
<version>1.5</version>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.connectbot.jbcrypt</groupId>
Expand All @@ -206,7 +206,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>task-reactor</artifactId>
<version>1.5</version>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.jvnet.localizer</groupId>
Expand Down Expand Up @@ -256,12 +256,12 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>memory-monitor</artifactId>
<version>1.9</version>
<version>1.10</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.9.0</version>
<version>5.10.0</version>
</dependency>
<dependency>
<groupId>org.kohsuke</groupId>
Expand Down
4 changes: 1 addition & 3 deletions core/src/main/java/hudson/ClassicPluginStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -641,9 +641,7 @@ protected Class<?> findClass(String name) throws ClassNotFoundException {
if (PluginManager.FAST_LOOKUP) {
for (PluginWrapper pw : getTransitiveDependencies()) {
try {
Class<?> c = ClassLoaderReflectionToolkit._findLoadedClass(pw.classLoader, name);
if (c!=null) return c;
return ClassLoaderReflectionToolkit._findClass(pw.classLoader, name);
return ClassLoaderReflectionToolkit.loadClass(pw.classLoader, name);
} catch (ClassNotFoundException ignored) {
//not found. try next
}
Expand Down
10 changes: 1 addition & 9 deletions core/src/main/java/hudson/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2197,15 +2197,7 @@ protected Class<?> findClass(String name) throws ClassNotFoundException {
if (FAST_LOOKUP) {
for (PluginWrapper p : activePlugins) {
try {
Class<?> c = ClassLoaderReflectionToolkit._findLoadedClass(p.classLoader, name);
if (c != null) {
synchronized (loaded) {
loaded.put(name, c);
}
return c;
}
// calling findClass twice appears to cause LinkageError: duplicate class def
c = ClassLoaderReflectionToolkit._findClass(p.classLoader, name);
Class<?> c = ClassLoaderReflectionToolkit.loadClass(p.classLoader, name);
synchronized (loaded) {
loaded.put(name, c);
}
Expand Down
44 changes: 44 additions & 0 deletions core/src/main/java/jenkins/ClassLoaderReflectionToolkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private static class GetClassLoadingLock {
/**
* Calls {@link ClassLoader#findLoadedClass} while holding {@link ClassLoader#getClassLoadingLock}.
* @since 1.553
* @deprecated use {@link #loadClass(ClassLoader, String)}
*/
public static @CheckForNull Class<?> _findLoadedClass(ClassLoader cl, String name) {
synchronized (getClassLoadingLock(cl, name)) {
Expand Down Expand Up @@ -100,6 +101,7 @@ private static class FindLoadedClass {
/**
* Calls {@link ClassLoader#findClass} while holding {@link ClassLoader#getClassLoadingLock}.
* @since 1.553
* @deprecated use {@link #loadClass(ClassLoader, String)}
*/
public static @NonNull Class<?> _findClass(ClassLoader cl, String name) throws ClassNotFoundException {
synchronized (getClassLoadingLock(cl, name)) {
Expand All @@ -124,6 +126,48 @@ private static class FindClass {
}
}

/**
* Load the class with the specified binary name. This method searches for classes in the
* following order:
*
* <ol>
* <li>
* <p>Invoke {@link ClassLoader#findLoadedClass(String)} to check if the class has already
* been loaded.
* <li>
* <p>Invoke the {@link ClassLoader#findClass(String)} method to find the class.
* </ol>
*
* <p>This method synchronizes on the result of {@link ClassLoader#getClassLoadingLock(String)}
* during the entire class loading process.
*
* @param cl The {@link ClassLoader} to use.
* @param name The binary name of the class.
* @return The resulting {@link Class} object.
* @throws ClassNotFoundException If the class could not be found.
* @since 2.TODO
*/
public static @NonNull Class<?> loadClass(ClassLoader cl, String name) throws ClassNotFoundException {
synchronized (getClassLoadingLock(cl, name)) {
// First, check if the class has already been loaded.
Class<?> c;
if (cl instanceof JenkinsClassLoader) {
c = ((JenkinsClassLoader) cl).findLoadedClass2(name);
} else {
c = (Class) invoke(FindLoadedClass.FIND_LOADED_CLASS, RuntimeException.class, cl, name);
}
if (c != null) {
return c;
}

// Find the class.
if (cl instanceof JenkinsClassLoader) {
return ((JenkinsClassLoader) cl).findClass(name);
} else {
return (Class) invoke(FindClass.FIND_CLASS, ClassNotFoundException.class, cl, name);
}
}
}

/**
* Calls {@link ClassLoader#findResource}.
Expand Down
12 changes: 12 additions & 0 deletions core/src/main/java/jenkins/ProxyInjector.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import com.google.inject.Provider;
import com.google.inject.Scope;
import com.google.inject.TypeLiteral;
import com.google.inject.spi.Element;
import com.google.inject.spi.InjectionPoint;
import com.google.inject.spi.TypeConverterBinding;
import java.lang.annotation.Annotation;
import java.util.List;
Expand Down Expand Up @@ -134,4 +136,14 @@ public Map<Class<? extends Annotation>, Scope> getScopeBindings() {
public Set<TypeConverterBinding> getTypeConverterBindings() {
return resolve().getTypeConverterBindings();
}

@Override
public List<Element> getElements() {
return resolve().getElements();
}

@Override
public Map<TypeLiteral<?>, List<InjectionPoint>> getAllMembersInjectorInjectionPoints() {
return resolve().getAllMembersInjectorInjectionPoints();
}
}
4 changes: 2 additions & 2 deletions core/src/main/java/jenkins/model/InterruptedBuildAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public class InterruptedBuildAction extends InvisibleAction {
private final List<CauseOfInterruption> causes;

public InterruptedBuildAction(Collection<? extends CauseOfInterruption> causes) {
this.causes = Collections.unmodifiableList(new ArrayList<>(causes));
this.causes = new ArrayList<>(causes);
}

@Exported
public List<CauseOfInterruption> getCauses() {
return causes;
return Collections.unmodifiableList(causes);
}
}
32 changes: 28 additions & 4 deletions core/src/main/java/jenkins/model/Jenkins.java
Original file line number Diff line number Diff line change
Expand Up @@ -2239,14 +2239,38 @@ public DescribableList<NodeProperty<?>, NodePropertyDescriptor> getGlobalNodePro
* but we also call this periodically to self-heal any data out-of-sync issue.
*/
/*package*/ void trimLabels() {
trimLabels((Set) null);
}

/**
* Reset labels and remove invalid ones for the given nodes.
* @param nodes the nodes taken as reference to update labels
*/
void trimLabels(Node... nodes) {
Set<LabelAtom> includedLabels = new HashSet<>();
Arrays.asList(nodes).stream().filter(Objects::nonNull).forEach(n -> includedLabels.addAll(n.getAssignedLabels()));
trimLabels(includedLabels);
}

/**
* Reset labels and remove invalid ones for the given nodes.
* @param includedLabels the labels taken as reference to update labels. If {@code null}, all labels are considered.
*/
private void trimLabels(@CheckForNull Set<LabelAtom> includedLabels) {
Set<Label> nodeLabels = new HashSet<>(this.getAssignedLabels());
this.getNodes().forEach(n -> nodeLabels.addAll(n.getAssignedLabels()));
for (Iterator<Label> itr = labels.values().iterator(); itr.hasNext();) {
Label l = itr.next();
if (nodeLabels.contains(l) || this.clouds.stream().anyMatch(c -> c.canProvision(l))) {
resetLabel(l);
} else {
itr.remove();
if (includedLabels == null || includedLabels.contains(l)) {
if (nodeLabels.contains(l) || !l.getClouds().isEmpty()) {
// there is at least one static agent or one cloud that currently claims it can handle the label.
// if the cloud has been removed, or its labels updated such that it can not handle this, this is handle in later calls
// resetLabel will remove the agents, and clouds from the label, and they will be repopulated later.
// not checking `cloud.canProvision()` here prevents a potential call that will only be repeated later
resetLabel(l);
} else {
itr.remove();
}
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions core/src/main/java/jenkins/model/Nodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import hudson.model.Node;
import hudson.model.Queue;
import hudson.model.Saveable;
import hudson.model.labels.LabelAtom;
import hudson.model.listeners.SaveableListener;
import hudson.slaves.EphemeralNode;
import hudson.slaves.OfflineCause;
Expand Down Expand Up @@ -141,7 +142,7 @@ public void addNode(final @NonNull Node node) throws IOException {
AtomicReference<Node> old = new AtomicReference<>();
old.set(nodes.put(node.getNodeName(), node));
jenkins.updateNewComputer(node);
jenkins.trimLabels();
jenkins.trimLabels(node, oldNode);
// TODO there is a theoretical race whereby the node instance is updated/removed after lock release
try {
persistNode(node);
Expand All @@ -153,7 +154,7 @@ public void addNode(final @NonNull Node node) throws IOException {
public void run() {
nodes.compute(node.getNodeName(), (ignoredNodeName, ignoredNode) -> oldNode);
jenkins.updateComputerList();
jenkins.trimLabels();
jenkins.trimLabels(node, oldNode);
}
});
throw e;
Expand Down Expand Up @@ -201,7 +202,7 @@ public boolean updateNode(final @NonNull Node node) throws IOException {
@Override
public Boolean call() throws Exception {
if (node == nodes.get(node.getNodeName())) {
jenkins.trimLabels();
jenkins.trimLabels(node);
return true;
}
return false;
Expand Down Expand Up @@ -242,7 +243,7 @@ public void run() {
Nodes.this.nodes.remove(oldOne.getNodeName());
Nodes.this.nodes.put(newOne.getNodeName(), newOne);
jenkins.updateComputerList();
jenkins.trimLabels();
jenkins.trimLabels(oldOne, newOne);
}
});
updateNode(newOne);
Expand Down Expand Up @@ -276,7 +277,7 @@ public void run() {
}
if (node == nodes.remove(node.getNodeName())) {
jenkins.updateComputerList();
jenkins.trimLabels();
jenkins.trimLabels(node);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/hudson/PluginManager/table.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ THE SOFTWARE.
data-compat-warning="${!p.isCompatible(cache)}" />
</td>
</l:isAdmin>
<td class="pane" data="${h.xmlEscape(p.displayName)}" data-id="${h.xmlEscape(p.name+':'+p.version)}">
<td class="pane details" data="${h.xmlEscape(p.displayName)}" data-id="${h.xmlEscape(p.name+':'+p.version)}">
<div>
<a href="${p.wiki}" rel="noopener noreferrer" target="_blank"><st:out value="${p.displayName}"/></a>
</div>
Expand Down
13 changes: 3 additions & 10 deletions core/src/main/resources/hudson/widgets/HistoryWidget/index.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,9 @@ THE SOFTWARE.
<input type="search" placeholder="${%find}" class="jenkins-search__input" />
<l:svgIcon href="${resURL}/images/material-icons/svg-sprite-action-symbol.svg#ic_search_24px" class="jenkins-search__icon" />
</div>
<j:if test="${page.runs.isEmpty()}">
<div id="no-builds" class="jenkins-pane__information">
No builds
</div>
</j:if>
<j:if test="${!page.runs.isEmpty()}">
<div id="no-builds" class="jenkins-pane__information" style="display: none;">
No builds
</div>
</j:if>
<div id="no-builds" class="jenkins-pane__information" style="${page.runs.isEmpty() ? '' : 'display: none;'}">
${%No builds}
</div>
</td>
</tr>

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
blurb = The selected build discarder with be applied after any build finishes, as well as periodically.
blurb = The selected build discarder will be applied after any build finishes, as well as periodically.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
com.google.common.collect.AbstractListMultimap
com.google.common.collect.AbstractMapBasedMultimap
com.google.common.collect.AbstractMultimap
com.google.common.collect.AbstractSetMultimap
# Artifactory - https://issues.jenkins.io/browse/JENKINS-48991
com.google.common.collect.ArrayListMultimap
com.google.common.collect.ArrayListMultimapGwtSerializationDependencies
com.google.common.collect.EmptyImmutableList
com.google.common.collect.EmptyImmutableSet
com.google.common.collect.EmptyImmutableSortedSet
com.google.common.collect.HashMultimap
com.google.common.collect.HashMultimapGwtSerializationDependencies
# First hit: https://github.com/jenkinsci/pitmutation-plugin/
com.google.common.collect.HashMultiset
com.google.common.collect.ImmutableList
Expand Down
Loading

0 comments on commit c282ba2

Please sign in to comment.