From 888d4ac39268ca284f9150c44f79f991575eb635 Mon Sep 17 00:00:00 2001 From: Krzysztof Krason Date: Thu, 26 Jan 2023 18:25:35 -0800 Subject: [PATCH 1/2] Use '==' rather than '.equals' with enum value See gh-33987 --- .../WebFluxEndpointManagementContextConfiguration.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/reactive/WebFluxEndpointManagementContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/reactive/WebFluxEndpointManagementContextConfiguration.java index 6d9d5dc3bcf..0181f20717e 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/reactive/WebFluxEndpointManagementContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/reactive/WebFluxEndpointManagementContextConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2023 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. @@ -88,7 +88,7 @@ public class WebFluxEndpointManagementContextConfiguration { private boolean shouldRegisterLinksMapping(WebEndpointProperties properties, Environment environment, String basePath) { return properties.getDiscovery().isEnabled() && (StringUtils.hasText(basePath) - || ManagementPortType.get(environment).equals(ManagementPortType.DIFFERENT)); + || ManagementPortType.get(environment) == ManagementPortType.DIFFERENT); } @Bean From a8958471f641ab970fb217051f3330d96c3978a9 Mon Sep 17 00:00:00 2001 From: Krzysztof Krason Date: Thu, 26 Jan 2023 18:28:13 -0800 Subject: [PATCH 2/2] Switch anonymous inner classes to lambdas See gh-33987 --- .../test/mock/mockito/SpyBeanWithJdkProxyTests.java | 13 ++----------- .../smoketest/flyway/SampleFlywayApplication.java | 11 ++--------- .../jersey/AbstractJerseyManagementPortTests.java | 10 ++-------- 3 files changed, 6 insertions(+), 28 deletions(-) diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithJdkProxyTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithJdkProxyTests.java index 6d3f9893c41..506afd6c415 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithJdkProxyTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithJdkProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2023 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. @@ -16,8 +16,6 @@ package org.springframework.boot.test.mock.mockito; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; import java.lang.reflect.Proxy; import org.junit.jupiter.api.Test; @@ -60,14 +58,7 @@ class SpyBeanWithJdkProxyTests { @Bean ExampleRepository dateService() { return (ExampleRepository) Proxy.newProxyInstance(getClass().getClassLoader(), - new Class[] { ExampleRepository.class }, new InvocationHandler() { - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - return new Example((String) args[0]); - } - - }); + new Class[] { ExampleRepository.class }, (proxy, method, args) -> new Example((String) args[0])); } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-flyway/src/main/java/smoketest/flyway/SampleFlywayApplication.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-flyway/src/main/java/smoketest/flyway/SampleFlywayApplication.java index 792939e74b9..a49c73cfab8 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-flyway/src/main/java/smoketest/flyway/SampleFlywayApplication.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-flyway/src/main/java/smoketest/flyway/SampleFlywayApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2023 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. @@ -30,14 +30,7 @@ public class SampleFlywayApplication { @Bean public CommandLineRunner runner(PersonRepository repository) { - return new CommandLineRunner() { - - @Override - public void run(String... args) throws Exception { - System.err.println(repository.findAll()); - } - - }; + return (args) -> System.err.println(repository.findAll()); } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jersey/src/test/java/smoketest/jersey/AbstractJerseyManagementPortTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jersey/src/test/java/smoketest/jersey/AbstractJerseyManagementPortTests.java index 6a2d7967757..03aad770f93 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jersey/src/test/java/smoketest/jersey/AbstractJerseyManagementPortTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jersey/src/test/java/smoketest/jersey/AbstractJerseyManagementPortTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2023 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. @@ -19,7 +19,6 @@ package smoketest.jersey; import javax.ws.rs.GET; import javax.ws.rs.Path; -import org.glassfish.jersey.server.ResourceConfig; import org.junit.jupiter.api.Test; import smoketest.jersey.AbstractJerseyManagementPortTests.ResourceConfigConfiguration; @@ -90,12 +89,7 @@ class AbstractJerseyManagementPortTests { @Bean ResourceConfigCustomizer customizer() { - return new ResourceConfigCustomizer() { - @Override - public void customize(ResourceConfig config) { - config.register(TestEndpoint.class); - } - }; + return (config) -> config.register(TestEndpoint.class); } @Path("/test")