Polish
This commit is contained in:
parent
89173bd227
commit
07462be090
|
|
@ -61,7 +61,8 @@ public class Token {
|
|||
private Map<String, Object> parseJson(String base64) {
|
||||
try {
|
||||
byte[] bytes = Base64Utils.decodeFromUrlSafeString(base64);
|
||||
return JsonParserFactory.getJsonParser().parseMap(new String(bytes, StandardCharsets.UTF_8));
|
||||
return JsonParserFactory.getJsonParser()
|
||||
.parseMap(new String(bytes, StandardCharsets.UTF_8));
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
throw new CloudFoundryAuthorizationException(Reason.INVALID_TOKEN,
|
||||
|
|
|
|||
|
|
@ -50,16 +50,20 @@ public class CompositeHandlerExceptionResolverTests {
|
|||
@Test
|
||||
public void resolverShouldDelegateToOtherResolversInContext() throws Exception {
|
||||
load(TestConfiguration.class);
|
||||
CompositeHandlerExceptionResolver resolver = (CompositeHandlerExceptionResolver) this.context.getBean(DispatcherServlet.HANDLER_EXCEPTION_RESOLVER_BEAN_NAME);
|
||||
ModelAndView resolved = resolver.resolveException(this.request, this.response, null, new HttpRequestMethodNotSupportedException("POST"));
|
||||
CompositeHandlerExceptionResolver resolver = (CompositeHandlerExceptionResolver) this.context
|
||||
.getBean(DispatcherServlet.HANDLER_EXCEPTION_RESOLVER_BEAN_NAME);
|
||||
ModelAndView resolved = resolver.resolveException(this.request, this.response,
|
||||
null, new HttpRequestMethodNotSupportedException("POST"));
|
||||
assertThat(resolved.getViewName()).isEqualTo("test-view");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolverShouldAddDefaultResolverIfNonePresent() throws Exception {
|
||||
load(BaseConfiguration.class);
|
||||
CompositeHandlerExceptionResolver resolver = (CompositeHandlerExceptionResolver) this.context.getBean(DispatcherServlet.HANDLER_EXCEPTION_RESOLVER_BEAN_NAME);
|
||||
ModelAndView resolved = resolver.resolveException(this.request, this.response, null, new HttpRequestMethodNotSupportedException("POST"));
|
||||
CompositeHandlerExceptionResolver resolver = (CompositeHandlerExceptionResolver) this.context
|
||||
.getBean(DispatcherServlet.HANDLER_EXCEPTION_RESOLVER_BEAN_NAME);
|
||||
ModelAndView resolved = resolver.resolveException(this.request, this.response,
|
||||
null, new HttpRequestMethodNotSupportedException("POST"));
|
||||
assertThat(resolved).isNotNull();
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +98,8 @@ public class CompositeHandlerExceptionResolverTests {
|
|||
static class TestHandlerExceptionResolver implements HandlerExceptionResolver {
|
||||
|
||||
@Override
|
||||
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
|
||||
public ModelAndView resolveException(HttpServletRequest request,
|
||||
HttpServletResponse response, Object handler, Exception ex) {
|
||||
return new ModelAndView("test-view");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -150,8 +150,8 @@ public class SpringIntegrationMetrics implements MeterBinder, SmartInitializingS
|
|||
private <T> void registerFunctionCounter(MeterRegistry registry, T object,
|
||||
Iterable<Tag> tags, String name, String description,
|
||||
ToDoubleFunction<T> value) {
|
||||
FunctionCounter.builder(name, object, value).tags(tags)
|
||||
.description(description).register(registry);
|
||||
FunctionCounter.builder(name, object, value).tags(tags).description(description)
|
||||
.register(registry);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ public class ConditionEvaluationReportLoggingListener
|
|||
@Override
|
||||
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
applicationContext.addApplicationListener(new ConditionEvaluationReportListener());
|
||||
applicationContext
|
||||
.addApplicationListener(new ConditionEvaluationReportListener());
|
||||
if (applicationContext instanceof GenericApplicationContext) {
|
||||
// Get the report early in case the context fails to load
|
||||
this.report = ConditionEvaluationReport
|
||||
|
|
|
|||
|
|
@ -147,8 +147,7 @@ public class ConditionEvaluationReportLoggingListenerTests {
|
|||
private void withDebugLogging(Runnable runnable) {
|
||||
LoggerContext context = (LoggerContext) StaticLoggerBinder.getSingleton()
|
||||
.getLoggerFactory();
|
||||
Logger logger = context
|
||||
.getLogger(ConditionEvaluationReportLoggingListener.class);
|
||||
Logger logger = context.getLogger(ConditionEvaluationReportLoggingListener.class);
|
||||
Level currentLevel = logger.getLevel();
|
||||
logger.setLevel(Level.DEBUG);
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -203,10 +203,10 @@ public class DefaultErrorWebExceptionHandlerIntegrationTest {
|
|||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Import({ReactiveWebServerAutoConfiguration.class,
|
||||
@Import({ ReactiveWebServerAutoConfiguration.class,
|
||||
HttpHandlerAutoConfiguration.class, WebFluxAutoConfiguration.class,
|
||||
ErrorWebFluxAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class})
|
||||
PropertyPlaceholderAutoConfiguration.class })
|
||||
private @interface MinimalWebConfiguration {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ public class TestPropertyValuesTests {
|
|||
|
||||
@Test
|
||||
public void applyToSystemPropertySource() throws Exception {
|
||||
TestPropertyValues.of("FOO_BAR=BAZ").applyTo(this.environment, Type.SYSTEM_ENVIRONMENT);
|
||||
TestPropertyValues.of("FOO_BAR=BAZ").applyTo(this.environment,
|
||||
Type.SYSTEM_ENVIRONMENT);
|
||||
assertThat(this.environment.getProperty("foo.bar")).isEqualTo("BAZ");
|
||||
assertThat(this.environment.getPropertySources().contains(
|
||||
"test-" + StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME));
|
||||
|
|
@ -72,8 +73,8 @@ public class TestPropertyValuesTests {
|
|||
throws Exception {
|
||||
TestPropertyValues.of("foo.bar=baz", "hello.world=hi").applyTo(this.environment,
|
||||
Type.MAP, "other");
|
||||
TestPropertyValues.of("FOO_BAR=BAZ").applyTo(this.environment, Type.SYSTEM_ENVIRONMENT,
|
||||
"other");
|
||||
TestPropertyValues.of("FOO_BAR=BAZ").applyTo(this.environment,
|
||||
Type.SYSTEM_ENVIRONMENT, "other");
|
||||
assertThat(this.environment.getPropertySources().get("other"))
|
||||
.isInstanceOf(SystemEnvironmentPropertySource.class);
|
||||
assertThat(this.environment.getProperty("foo.bar")).isEqualTo("BAZ");
|
||||
|
|
|
|||
|
|
@ -155,8 +155,8 @@ class OriginTrackedPropertiesLoader {
|
|||
private int character;
|
||||
|
||||
CharacterReader(Resource resource) throws IOException {
|
||||
this.reader = new LineNumberReader(
|
||||
new InputStreamReader(resource.getInputStream(), StandardCharsets.ISO_8859_1));
|
||||
this.reader = new LineNumberReader(new InputStreamReader(
|
||||
resource.getInputStream(), StandardCharsets.ISO_8859_1));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -197,9 +197,8 @@ public class JettyWebServer implements WebServer {
|
|||
|
||||
private String getContextPath() {
|
||||
return Arrays.stream(this.server.getHandlers())
|
||||
.filter(ContextHandler.class::isInstance)
|
||||
.map(handler -> ((ContextHandler) handler).getContextPath())
|
||||
.collect(Collectors.joining(" "));
|
||||
.filter(ContextHandler.class::isInstance).map(ContextHandler.class::cast)
|
||||
.map(ContextHandler::getContextPath).collect(Collectors.joining(" "));
|
||||
}
|
||||
|
||||
private void handleDeferredInitialize(Handler... handlers) throws Exception {
|
||||
|
|
|
|||
|
|
@ -91,7 +91,8 @@ public class NettyReactiveWebServerFactory extends AbstractReactiveWebServerFact
|
|||
return HttpServer.builder().options((options) -> {
|
||||
options.listenAddress(getListenAddress());
|
||||
if (getSsl() != null && getSsl().isEnabled()) {
|
||||
SslServerCustomizer sslServerCustomizer = new SslServerCustomizer(getSsl(), getSslStoreProvider());
|
||||
SslServerCustomizer sslServerCustomizer = new SslServerCustomizer(
|
||||
getSsl(), getSslStoreProvider());
|
||||
sslServerCustomizer.customize(options);
|
||||
}
|
||||
applyCustomizers(options);
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ import org.springframework.boot.web.server.SslStoreProvider;
|
|||
import org.springframework.util.ResourceUtils;
|
||||
|
||||
/**
|
||||
* {@link NettyServerCustomizer} that configures SSL for the
|
||||
* given Reactor Netty server instance.
|
||||
* {@link NettyServerCustomizer} that configures SSL for the given Reactor Netty server
|
||||
* instance.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
|
|
@ -66,7 +66,8 @@ public class SslServerCustomizer implements NettyServerCustomizer {
|
|||
}
|
||||
}
|
||||
|
||||
protected KeyManagerFactory getKeyManagerFactory(Ssl ssl, SslStoreProvider sslStoreProvider) {
|
||||
protected KeyManagerFactory getKeyManagerFactory(Ssl ssl,
|
||||
SslStoreProvider sslStoreProvider) {
|
||||
try {
|
||||
KeyStore keyStore = getKeyStore(ssl, sslStoreProvider);
|
||||
KeyManagerFactory keyManagerFactory = KeyManagerFactory
|
||||
|
|
@ -84,7 +85,8 @@ public class SslServerCustomizer implements NettyServerCustomizer {
|
|||
}
|
||||
}
|
||||
|
||||
private KeyStore getKeyStore(Ssl ssl, SslStoreProvider sslStoreProvider) throws Exception {
|
||||
private KeyStore getKeyStore(Ssl ssl, SslStoreProvider sslStoreProvider)
|
||||
throws Exception {
|
||||
if (sslStoreProvider != null) {
|
||||
return sslStoreProvider.getKeyStore();
|
||||
}
|
||||
|
|
@ -92,7 +94,8 @@ public class SslServerCustomizer implements NettyServerCustomizer {
|
|||
ssl.getKeyStorePassword());
|
||||
}
|
||||
|
||||
protected TrustManagerFactory getTrustManagerFactory(Ssl ssl, SslStoreProvider sslStoreProvider) {
|
||||
protected TrustManagerFactory getTrustManagerFactory(Ssl ssl,
|
||||
SslStoreProvider sslStoreProvider) {
|
||||
try {
|
||||
KeyStore store = getTrustStore(ssl, sslStoreProvider);
|
||||
TrustManagerFactory trustManagerFactory = TrustManagerFactory
|
||||
|
|
@ -105,7 +108,8 @@ public class SslServerCustomizer implements NettyServerCustomizer {
|
|||
}
|
||||
}
|
||||
|
||||
private KeyStore getTrustStore(Ssl ssl, SslStoreProvider sslStoreProvider) throws Exception {
|
||||
private KeyStore getTrustStore(Ssl ssl, SslStoreProvider sslStoreProvider)
|
||||
throws Exception {
|
||||
if (sslStoreProvider != null) {
|
||||
return sslStoreProvider.getTrustStore();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFac
|
|||
|
||||
private String protocol = DEFAULT_PROTOCOL;
|
||||
|
||||
private List<LifecycleListener> contextLifecycleListeners = new ArrayList<LifecycleListener>(
|
||||
private List<LifecycleListener> contextLifecycleListeners = new ArrayList<>(
|
||||
Collections.singleton(new AprLifecycleListener()));
|
||||
|
||||
private List<TomcatContextCustomizer> tomcatContextCustomizers = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -224,7 +224,8 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
|
|||
|
||||
private void configureTldSkipPatterns(TomcatEmbeddedContext context) {
|
||||
StandardJarScanFilter filter = new StandardJarScanFilter();
|
||||
filter.setTldSkip(StringUtils.collectionToCommaDelimitedString(this.tldSkipPatterns));
|
||||
filter.setTldSkip(
|
||||
StringUtils.collectionToCommaDelimitedString(this.tldSkipPatterns));
|
||||
context.getJarScanner().setJarScanFilter(filter);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -329,8 +329,8 @@ public class TomcatWebServer implements WebServer {
|
|||
private String getContextPath() {
|
||||
return Arrays.stream(this.tomcat.getHost().findChildren())
|
||||
.filter(TomcatEmbeddedContext.class::isInstance)
|
||||
.map(context -> ((TomcatEmbeddedContext) context).getPath())
|
||||
.collect(Collectors.joining(" "));
|
||||
.map(TomcatEmbeddedContext.class::cast)
|
||||
.map(TomcatEmbeddedContext::getPath).collect(Collectors.joining(" "));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -398,7 +398,8 @@ public class TomcatServletWebServerFactoryTests
|
|||
Tomcat tomcat = ((TomcatWebServer) this.webServer).getTomcat();
|
||||
Context context = (Context) tomcat.getHost().findChildren()[0];
|
||||
JarScanFilter jarScanFilter = context.getJarScanner().getJarScanFilter();
|
||||
Set<String> tldSkipSet = (Set<String>) ReflectionTestUtils.getField(jarScanFilter, "tldSkipSet");
|
||||
Set<String> tldSkipSet = (Set<String>) ReflectionTestUtils.getField(jarScanFilter,
|
||||
"tldSkipSet");
|
||||
assertThat(tldSkipSet).contains("foo.jar", "bar.jar");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
package sample.tomcat;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
package sample.undertow;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue