From 669909efc0762629ad76a9381f145ab4ca598e10 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 29 Apr 2025 12:54:42 +0100 Subject: [PATCH] Remove use of Security's FieldUtils Closes gh-45322 --- .../WebSocketMessagingAutoConfigurationTests.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java index 59c8046c66a..5ee1889c7b2 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-2025 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. @@ -48,7 +48,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.core.task.SimpleAsyncTaskExecutor; -import org.springframework.core.task.TaskExecutor; import org.springframework.messaging.converter.CompositeMessageConverter; import org.springframework.messaging.converter.MessageConverter; import org.springframework.messaging.converter.SimpleMessageConverter; @@ -61,7 +60,6 @@ import org.springframework.messaging.simp.stomp.StompHeaders; import org.springframework.messaging.simp.stomp.StompSession; import org.springframework.messaging.simp.stomp.StompSessionHandler; import org.springframework.messaging.simp.stomp.StompSessionHandlerAdapter; -import org.springframework.security.util.FieldUtils; import org.springframework.stereotype.Controller; import org.springframework.web.client.RestTemplate; import org.springframework.web.socket.client.standard.StandardWebSocketClient; @@ -139,27 +137,25 @@ class WebSocketMessagingAutoConfigurationTests { } @Test - void predefinedThreadExecutorIsSelectedForInboundChannel() throws Throwable { + void predefinedThreadExecutorIsSelectedForInboundChannel() { AsyncTaskExecutor expectedExecutor = new SimpleAsyncTaskExecutor(); ChannelRegistration registration = new ChannelRegistration(); WebSocketMessagingAutoConfiguration.WebSocketMessageConverterConfiguration configuration = new WebSocketMessagingAutoConfiguration.WebSocketMessageConverterConfiguration( new ObjectMapper(), Map.of(TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME, expectedExecutor)); configuration.configureClientInboundChannel(registration); - TaskExecutor executor = (TaskExecutor) FieldUtils.getFieldValue(registration, "executor"); - assertThat(executor).isEqualTo(expectedExecutor); + assertThat(registration).extracting("executor").isEqualTo(expectedExecutor); } @Test - void predefinedThreadExecutorIsSelectedForOutboundChannel() throws Throwable { + void predefinedThreadExecutorIsSelectedForOutboundChannel() { AsyncTaskExecutor expectedExecutor = new SimpleAsyncTaskExecutor(); ChannelRegistration registration = new ChannelRegistration(); WebSocketMessagingAutoConfiguration.WebSocketMessageConverterConfiguration configuration = new WebSocketMessagingAutoConfiguration.WebSocketMessageConverterConfiguration( new ObjectMapper(), Map.of(TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME, expectedExecutor)); configuration.configureClientOutboundChannel(registration); - TaskExecutor executor = (TaskExecutor) FieldUtils.getFieldValue(registration, "executor"); - assertThat(executor).isEqualTo(expectedExecutor); + assertThat(registration).extracting("executor").isEqualTo(expectedExecutor); } private List getCustomizedConverters() {