mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-03 23:25:52 +00:00
Migrate code base to Java 21 (#26075)
* Replace if-cascades with switch * Reference to empty collection field replaced with method call (Java 5) * Anonymous type replaced with lambda (Java 8) * Replaced lambda with method reference (Java 8) * Statement lambda replaced with expression lambda (Java 8) * Loop replaced with 'Collection.removeIf()' (Java 8) * Null check replaced with method call (Java 9) * Statement replaced with enhanced 'switch' (Java 14) * Use text blocks (Java 15) * Use pattern variable (Java 16) * Replace if-cascades with switch * Use 'Comparator' combinator * Null check replaced with method call (Java 9) * Use pattern variable (Java 16) * Use record pattern (Java 21) * Use SequencedCollection method (Java 21) * Replaced lambda with method reference (Java 8) * Cleanup unused imports * Cleanup migrations (move comments, formatting, spotbugs...) * Remove duplicate comment Resolve GitHub Copilot review comment * Remove blank line that may confuse Copilot * Inject comments into source line Attempt to satisfy GitHub Copilot Complains about unreachable code * Simplify with return value of switch statement * Use pattern matching instanceof in one more case * Don't lose the NetBeans comment that was there before * Remove TODO for Java 21 pattern use, implemented * Align comments with Unicode character they describe --------- Co-authored-by: Mark Waite <mark.earl.waite@gmail.com>
This commit is contained in:
1 parent
ee64d9950e
commit
4a2f5f24b9
194 files changed
+1010
-1364
No files matched your search
@@ -46,6 +46,7 @@ import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.NavigableSet;
|
||||
import java.util.Objects;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
import java.util.jar.JarFile;
|
||||
@@ -317,13 +318,9 @@ public class Main {
|
||||
try {
|
||||
Field f = cl.loadClass("winstone.WinstoneSession").getField("SESSION_COOKIE_NAME");
|
||||
f.setAccessible(true);
|
||||
if (JSESSIONID_COOKIE_NAME != null) {
|
||||
// Use the user-defined cookie name
|
||||
f.set(null, JSESSIONID_COOKIE_NAME);
|
||||
} else {
|
||||
// Randomize session names by default to prevent collisions when running multiple Jenkins instances on the same host.
|
||||
f.set(null, "JSESSIONID." + UUID.randomUUID().toString().replace("-", "").substring(0, 8));
|
||||
}
|
||||
// Use the user-defined cookie name or
|
||||
// randomized session names as default to prevent collisions when running multiple Jenkins instances on the same host.
|
||||
f.set(null, Objects.requireNonNullElseGet(JSESSIONID_COOKIE_NAME, () -> "JSESSIONID." + UUID.randomUUID().toString().replace("-", "").substring(0, 8)));
|
||||
} catch (ClassNotFoundException | NoSuchFieldException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user