From 07422d709e728635bf387e04902abe2973c3a876 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 12 Jul 2023 10:30:38 +0200 Subject: [PATCH 1/2] Remove getAutodetectMode() in MBeanExporter After further consideration, the team has decided to remove the getAutodetectMode() method since its return type conflicts with the parameter type in setAutodetectMode(int), making it an invalid bean property. See gh-30855 --- .../jmx/export/MBeanExporter.java | 15 +-------------- .../jmx/export/MBeanExporterTests.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java b/spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java index c4f1718cd4d..7af91337929 100644 --- a/spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java +++ b/spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java @@ -153,7 +153,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo /** The autodetect mode to use for this MBeanExporter. */ @Nullable - private Integer autodetectMode; + Integer autodetectMode; /** Whether to eagerly initialize candidate beans when autodetecting MBeans. */ private boolean allowEagerInit = false; @@ -263,19 +263,6 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo this.autodetectMode = autodetectMode; } - /** - * Get the autodetect mode to use for this {@code MBeanExporter}. - * @return the configured autodetect mode, or {@code null} if not explicitly - * configured - * @since 6.0.11 - * @see #setAutodetectModeName(String) - * @see #setAutodetectMode(int) - */ - @Nullable - public Integer getAutodetectMode() { - return this.autodetectMode; - } - /** * Specify whether to allow eager initialization of candidate beans * when autodetecting MBeans in the Spring application context. diff --git a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java index 28b65622503..695c760d6f8 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java @@ -446,7 +446,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { assertThatIllegalArgumentException() .isThrownBy(() -> exporter.setAutodetectMode(-1)) .withMessage("Only values of autodetect constants allowed"); - assertThat(exporter.getAutodetectMode()).isNull(); + assertThat(exporter.autodetectMode).isNull(); } @Test @@ -454,7 +454,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { assertThatIllegalArgumentException() .isThrownBy(() -> exporter.setAutodetectMode(5)) .withMessage("Only values of autodetect constants allowed"); - assertThat(exporter.getAutodetectMode()).isNull(); + assertThat(exporter.autodetectMode).isNull(); } /** @@ -471,7 +471,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { @Test void setAutodetectModeToSupportedValue() { exporter.setAutodetectMode(MBeanExporter.AUTODETECT_ASSEMBLER); - assertThat(exporter.getAutodetectMode()).isEqualTo(MBeanExporter.AUTODETECT_ASSEMBLER); + assertThat(exporter.autodetectMode).isEqualTo(MBeanExporter.AUTODETECT_ASSEMBLER); } @Test @@ -479,7 +479,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { assertThatIllegalArgumentException() .isThrownBy(() -> exporter.setAutodetectModeName(null)) .withMessage("'constantName' must not be null or blank"); - assertThat(exporter.getAutodetectMode()).isNull(); + assertThat(exporter.autodetectMode).isNull(); } @Test @@ -487,7 +487,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { assertThatIllegalArgumentException() .isThrownBy(() -> exporter.setAutodetectModeName("")) .withMessage("'constantName' must not be null or blank"); - assertThat(exporter.getAutodetectMode()).isNull(); + assertThat(exporter.autodetectMode).isNull(); } @Test @@ -495,7 +495,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { assertThatIllegalArgumentException() .isThrownBy(() -> exporter.setAutodetectModeName(" \t")) .withMessage("'constantName' must not be null or blank"); - assertThat(exporter.getAutodetectMode()).isNull(); + assertThat(exporter.autodetectMode).isNull(); } @Test @@ -503,7 +503,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { assertThatIllegalArgumentException() .isThrownBy(() -> exporter.setAutodetectModeName("Bogus")) .withMessage("Only autodetect constants allowed"); - assertThat(exporter.getAutodetectMode()).isNull(); + assertThat(exporter.autodetectMode).isNull(); } /** @@ -520,7 +520,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { @Test void setAutodetectModeNameToSupportedValue() { exporter.setAutodetectModeName("AUTODETECT_ASSEMBLER"); - assertThat(exporter.getAutodetectMode()).isEqualTo(MBeanExporter.AUTODETECT_ASSEMBLER); + assertThat(exporter.autodetectMode).isEqualTo(MBeanExporter.AUTODETECT_ASSEMBLER); } @Test From a6dc020dc41d04f20897d39c2cfead8119f9857c Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 12 Jul 2023 10:33:24 +0200 Subject: [PATCH 2/2] Remove since tag --- .../main/java/org/springframework/jmx/export/MBeanExporter.java | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java b/spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java index 7af91337929..b56efe6635c 100644 --- a/spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java +++ b/spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java @@ -137,7 +137,6 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo /** * Map of constant names to constant values for the autodetect constants defined * in this class. - * @since 6.0.11 */ private static final Map constants = Map.of( "AUTODETECT_NONE", AUTODETECT_NONE,