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
timja committed Dec 1, 2021
2 parents 62a8614 + da7935d commit 7e5f10c
Show file tree
Hide file tree
Showing 102 changed files with 639 additions and 1,090 deletions.
5 changes: 0 additions & 5 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,6 @@ THE SOFTWARE.
<artifactId>jna</artifactId>
<version>5.10.0</version>
</dependency>
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>libpam4j</artifactId>
<version>1.11</version>
</dependency>
<dependency>
<groupId>com.sun.solaris</groupId>
<artifactId>embedded_su4j</artifactId>
Expand Down
3 changes: 3 additions & 0 deletions cli/src/main/java/hudson/util/QuotedStringTokenizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ else if (c=='\\')
else
_token.append(c);
continue;

default:
break;
}
}

Expand Down
4 changes: 0 additions & 4 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,6 @@ THE SOFTWARE.
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
</dependency>
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>libpam4j</artifactId>
</dependency>
<dependency>
<groupId>com.sun.solaris</groupId>
<artifactId>embedded_su4j</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/FilePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,7 @@ public FilePath createTempDir(final String prefix, final String suffix) throws I
} else {
s = new String[]{prefix, suffix};
}
String name = StringUtils.join(s, ".");
String name = String.join(".", s);
return new FilePath(this, act(new CreateTempDir(name)));
} catch (IOException e) {
throw new IOException("Failed to create a temp directory on "+remote,e);
Expand Down Expand Up @@ -3076,7 +3076,7 @@ class Cancel extends RuntimeException {}
if (ds.getIncludedFilesCount()!=0 || ds.getIncludedDirsCount()!=0) {
return true;
} else {
throw new InterruptedException("no matches found within " + bound);
throw (InterruptedException)new InterruptedException("no matches found within " + bound).initCause(c);
}
}
return ds.getIncludedFilesCount()!=0 || ds.getIncludedDirsCount()!=0;
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ private static String[] logRecordPreformat(LogRecord r) {
String.format("%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp", new Date(r.getMillis())),
source,
r.getLevel().getLocalizedName(),
x == null ? message : message + printThrowable(x) + "\n"
x == null ? message : message + printThrowable(x) + "\n",
};
}

Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/hudson/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ private boolean containsHpiJpi(Collection<String> bundledPlugins, String name) {

/**
* Returns the manifest of a bundled but not-extracted plugin.
* @deprecated removed without replacement
*/
@Deprecated // See https://groups.google.com/d/msg/jenkinsci-dev/kRobm-cxFw8/6V66uhibAwAJ
public @CheckForNull Manifest getBundledPluginManifest(String shortName) {
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/hudson/PluginWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@ public void enable() throws IOException {
/**
* Disables this plugin next time Jenkins runs. As it doesn't check anything, it's recommended to use the method
* {@link #disable(PluginDisableStrategy)}
* @deprecated use {@link #disable(PluginDisableStrategy)}
*/
@Deprecated //see https://issues.jenkins.io/browse/JENKINS-27177
public void disable() throws IOException {
Expand Down Expand Up @@ -1190,6 +1191,7 @@ public String getBackupVersion() {

/**
* Checks if this plugin is pinned and that's forcing us to use an older version than the bundled one.
* @deprecated removed without replacement
*/
@Deprecated // See https://groups.google.com/d/msg/jenkinsci-dev/kRobm-cxFw8/6V66uhibAwAJ
public boolean isPinningForcingOldVersion() {
Expand Down
5 changes: 2 additions & 3 deletions core/src/main/java/hudson/TcpSlaveAgentListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
import jenkins.util.SystemProperties;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.Symbol;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
Expand Down Expand Up @@ -159,7 +158,7 @@ public String getIdentityPublicKey() {
* @since 2.16
*/
public String getAgentProtocolNames() {
return StringUtils.join(Jenkins.get().getAgentProtocols(), ", ");
return String.join(", ", Jenkins.get().getAgentProtocols());
}

/**
Expand Down Expand Up @@ -429,7 +428,7 @@ public boolean connect(Socket socket) throws IOException {
new String(ping, StandardCharsets.UTF_8),
responseLength > 0 && responseLength <= response.length ?
new String(response, 0, responseLength, StandardCharsets.UTF_8) :
"bad response length " + responseLength
"bad response length " + responseLength,
});
return false;
}
Expand Down
35 changes: 2 additions & 33 deletions core/src/main/java/hudson/WebAppMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,49 +202,18 @@ public Locale get() {
throw new IncompatibleVMDetected(); // nope
}

// JNA is no longer a hard requirement. It's just nice to have. See JENKINS-4820 for more context.
// // make sure JNA works. this can fail if
// // - platform is unsupported
// // - JNA is already loaded in another classloader
// // see http://wiki.jenkins-ci.org/display/JENKINS/JNA+is+already+loaded
// // TODO: or shall we instead modify Hudson to work gracefully without JNA?
// try {
// /*
// java.lang.UnsatisfiedLinkError: Native Library /builds/apps/glassfish/domains/hudson-domain/generated/jsp/j2ee-modules/hudson-1.309/loader/com/sun/jna/sunos-sparc/libjnidispatch.so already loaded in another classloader
// at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1743)
// at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1674)
// at java.lang.Runtime.load0(Runtime.java:770)
// at java.lang.System.load(System.java:1005)
// at com.sun.jna.Native.loadNativeLibraryFromJar(Native.java:746)
// at com.sun.jna.Native.loadNativeLibrary(Native.java:680)
// at com.sun.jna.Native.<clinit>(Native.java:108)
// at hudson.util.jna.GNUCLibrary.<clinit>(GNUCLibrary.java:86)
// at hudson.Util.createSymlink(Util.java:970)
// at hudson.model.Run.run(Run.java:1174)
// at hudson.matrix.MatrixBuild.run(MatrixBuild.java:149)
// at hudson.model.ResourceController.execute(ResourceController.java:88)
// at hudson.model.Executor.run(Executor.java:123)
// */
// String.valueOf(Native.POINTER_SIZE); // this meaningless operation forces the classloading and initialization
// } catch (LinkageError e) {
// if (e.getMessage().contains("another classloader"))
// context.setAttribute(APP,new JNADoublyLoaded(e));
// else
// context.setAttribute(APP,new HudsonFailedToLoad(e));
// }

// make sure this is servlet 2.4 container or above
try {
ServletResponse.class.getMethod("setCharacterEncoding",String.class);
} catch (NoSuchMethodException e) {
throw new IncompatibleServletVersionDetected(ServletResponse.class);
throw (IncompatibleServletVersionDetected)new IncompatibleServletVersionDetected(ServletResponse.class).initCause(e);
}

// make sure that we see Ant 1.7
try {
FileSet.class.getMethod("getDirectoryScanner");
} catch (NoSuchMethodException e) {
throw new IncompatibleAntVersionDetected(FileSet.class);
throw (IncompatibleAntVersionDetected)new IncompatibleAntVersionDetected(FileSet.class).initCause(e);
}

// make sure AWT is functioning, or else JFreeChart won't even load.
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/cli/ConsoleCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ protected int run() throws Exception {
if (p!=null) {
run = p.resolve(job);
if (run==null)
throw new IllegalStateException("Permalink "+build+" produced no build");
throw new IllegalStateException("Permalink "+build+" produced no build", e);
} else {
Permalink nearest = job.getPermalinks().findNearest(build);
throw new IllegalArgumentException(nearest == null ?
String.format("Not sure what you meant by \"%s\".", build) :
String.format("Not sure what you meant by \"%s\". Did you mean \"%s\"?",
build, nearest.getId()));
build, nearest.getId()), e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/cli/DisablePluginCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected int run() throws Exception {
try {
strategyToUse = PluginWrapper.PluginDisableStrategy.valueOf(strategy.toUpperCase());
} catch (IllegalArgumentException iae) {
throw new IllegalArgumentException(hudson.cli.Messages.DisablePluginCommand_NoSuchStrategy(strategy, String.format("%s, %s, %s", PluginWrapper.PluginDisableStrategy.NONE, PluginWrapper.PluginDisableStrategy.MANDATORY, PluginWrapper.PluginDisableStrategy.ALL)));
throw new IllegalArgumentException(hudson.cli.Messages.DisablePluginCommand_NoSuchStrategy(strategy, String.format("%s, %s, %s", PluginWrapper.PluginDisableStrategy.NONE, PluginWrapper.PluginDisableStrategy.MANDATORY, PluginWrapper.PluginDisableStrategy.ALL)), iae);
}

// disable...
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/hudson/cli/ListChangesCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ protected int act(List<Run<?, ?>> builds) throws IOException {
}
}
break;
default:
throw new AssertionError("Unknown format: " + format);
}

return 0;
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/hudson/console/ConsoleAnnotator.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ public static <T> ConsoleAnnotator<T> combine(Collection<? extends ConsoleAnnota
switch (all.size()) {
case 0: return null; // none
case 1: return cast(all.iterator().next()); // just one
default: return new ConsoleAnnotatorAggregator<>(all);
}

return new ConsoleAnnotatorAggregator<>(all);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/hudson/logging/LogRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
import javax.servlet.ServletException;
import jenkins.security.MasterToSlaveCallable;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.DataBoundConstructor;
Expand Down Expand Up @@ -169,7 +168,7 @@ public static Set<String> getAutoCompletionCandidates(List<String> loggerNamesLi

String longerPrefix = null;
for (int i = loggerNameParts.length; i > 0; i--) {
String loggerNamePrefix = StringUtils.join(Arrays.copyOf(loggerNameParts, i), ".");
String loggerNamePrefix = String.join(".", Arrays.copyOf(loggerNameParts, i));
seenPrefixes.put(loggerNamePrefix, seenPrefixes.getOrDefault(loggerNamePrefix, 0) + 1);
if (longerPrefix == null) {
relevantPrefixes.add(loggerNamePrefix); // actual logger name
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/model/AbstractProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,7 @@ public int getDelay(StaplerRequest req) throws ServletException {
if(delay.endsWith("secs")) delay=delay.substring(0,delay.length()-4);
return Integer.parseInt(delay);
} catch (NumberFormatException e) {
throw new ServletException("Invalid delay parameter value: "+delay);
throw new ServletException("Invalid delay parameter value: "+delay, e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public List<String> getChoices() {
}

public String getChoicesText() {
return StringUtils.join(choices, "\n");
return String.join("\n", choices);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/model/Descriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ protected Descriptor() {
throw new AssertionError(getClass()+" must be assignable to "+getd.getReturnType());
}
} catch (NoSuchMethodException e) {
throw new AssertionError(getClass()+" is missing getDescriptor method.");
throw new AssertionError(getClass()+" is missing getDescriptor method.", e);
}

}
Expand Down
9 changes: 5 additions & 4 deletions core/src/main/java/hudson/model/Fingerprint.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.BulkChange;
import hudson.Extension;
import hudson.ExtensionList;
import hudson.Util;
import hudson.model.listeners.ItemListener;
import hudson.security.ACL;
Expand Down Expand Up @@ -745,7 +746,7 @@ public static RangeSet fromString(String list, boolean skipError) {
} catch (NumberFormatException e) {
if (!skipError)
throw new IllegalArgumentException(
String.format("Unable to parse '%s', expected number", list));
String.format("Unable to parse '%s', expected number", list), e);
// ignore malformed text
}
}
Expand Down Expand Up @@ -1252,7 +1253,7 @@ public synchronized void save() throws IOException {
start = System.currentTimeMillis();

FingerprintStorage configuredFingerprintStorage = FingerprintStorage.get();
FingerprintStorage fileFingerprintStorage = FingerprintStorage.getFileFingerprintStorage();
FingerprintStorage fileFingerprintStorage = ExtensionList.lookupSingleton(FileFingerprintStorage.class);

// Implementations are expected to invoke SaveableListener on their own if relevant
// TODO: Consider improving Saveable Listener API: https://issues.jenkins.io/browse/JENKINS-62543
Expand Down Expand Up @@ -1339,7 +1340,7 @@ public Api getApi() {
}

FingerprintStorage configuredFingerprintStorage = FingerprintStorage.get();
FingerprintStorage fileFingerprintStorage = FingerprintStorage.getFileFingerprintStorage();
FingerprintStorage fileFingerprintStorage = ExtensionList.lookupSingleton(FileFingerprintStorage.class);

Fingerprint loaded = configuredFingerprintStorage.load(id);

Expand Down Expand Up @@ -1392,7 +1393,7 @@ public Api getApi() {
*/
public static void delete(@NonNull String id) throws IOException {
FingerprintStorage configuredFingerprintStorage = FingerprintStorage.get();
FingerprintStorage fileFingerprintStorage = FingerprintStorage.getFileFingerprintStorage();
FingerprintStorage fileFingerprintStorage = ExtensionList.lookupSingleton(FileFingerprintStorage.class);

configuredFingerprintStorage.delete(id);

Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/hudson/model/FingerprintCleanupThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ public void execute(TaskListener listener) {
}
FingerprintStorage.get().iterateAndCleanupFingerprints(listener);

final FileFingerprintStorage fileFingerprintStorage = ExtensionList.lookupSingleton(FileFingerprintStorage.class);
if (!(FingerprintStorage.get() instanceof FileFingerprintStorage) &&
FingerprintStorage.getFileFingerprintStorage().isReady()) {
FingerprintStorage.getFileFingerprintStorage().iterateAndCleanupFingerprints(listener);
fileFingerprintStorage.isReady()) {
fileFingerprintStorage.iterateAndCleanupFingerprints(listener);
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/model/Items.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public static String getCanonicalName(ItemGroup context, String path) {
}
name.push(p[i]);
}
return StringUtils.join(name, '/');
return String.join("/", name);
}

/**
Expand Down Expand Up @@ -312,7 +312,7 @@ public static String computeRelativeNamesAfterRenaming(String oldFullName, Strin
newValue.add(relativeName);
}
}
return StringUtils.join(newValue, ",");
return String.join(",", newValue);
}

// Had difficulty adapting the version in Functions to use no live items, so rewrote it:
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/model/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ public RunT getBuildForCLI(@Argument(required=true,metaVar="BUILD#",usage="Build
throw new CmdLineException(null, "No such build '#"+n+"' exists");
return r;
} catch (NumberFormatException e) {
throw new CmdLineException(null, id+ "is not a number");
throw new CmdLineException(null, id+ "is not a number", e);
}
}

Expand Down
Loading

0 comments on commit 7e5f10c

Please sign in to comment.