Use pattern matching for instanceof where appropriate
See gh-31475
This commit is contained in:
committed by
Andy Wilkinson
parent
a7b98e7312
commit
5db04da275
@@ -115,8 +115,8 @@ final class ModifiedClassPathClassLoader extends URLClassLoader {
|
||||
}
|
||||
|
||||
private static Stream<URL> doExtractUrls(ClassLoader classLoader) {
|
||||
if (classLoader instanceof URLClassLoader) {
|
||||
return Stream.of(((URLClassLoader) classLoader).getURLs());
|
||||
if (classLoader instanceof URLClassLoader urlClassLoader) {
|
||||
return Stream.of(urlClassLoader.getURLs());
|
||||
}
|
||||
return Stream.of(ManagementFactory.getRuntimeMXBean().getClassPath().split(File.pathSeparator))
|
||||
.map(ModifiedClassPathClassLoader::toURL);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -193,8 +193,8 @@ class OutputCapture implements CapturedOutput {
|
||||
}
|
||||
|
||||
private static PrintStream getSystemStream(PrintStream printStream) {
|
||||
while (printStream instanceof PrintStreamCapture) {
|
||||
printStream = ((PrintStreamCapture) printStream).getParent();
|
||||
while (printStream instanceof PrintStreamCapture printStreamCapture) {
|
||||
printStream = printStreamCapture.getParent();
|
||||
}
|
||||
return printStream;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user