Skip to content

Commit 07422d7

Browse files
committed
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
1 parent 768fc7e commit 07422d7

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
153153

154154
/** The autodetect mode to use for this MBeanExporter. */
155155
@Nullable
156-
private Integer autodetectMode;
156+
Integer autodetectMode;
157157

158158
/** Whether to eagerly initialize candidate beans when autodetecting MBeans. */
159159
private boolean allowEagerInit = false;
@@ -263,19 +263,6 @@ public void setAutodetectMode(int autodetectMode) {
263263
this.autodetectMode = autodetectMode;
264264
}
265265

266-
/**
267-
* Get the autodetect mode to use for this {@code MBeanExporter}.
268-
* @return the configured autodetect mode, or {@code null} if not explicitly
269-
* configured
270-
* @since 6.0.11
271-
* @see #setAutodetectModeName(String)
272-
* @see #setAutodetectMode(int)
273-
*/
274-
@Nullable
275-
public Integer getAutodetectMode() {
276-
return this.autodetectMode;
277-
}
278-
279266
/**
280267
* Specify whether to allow eager initialization of candidate beans
281268
* when autodetecting MBeans in the Spring application context.

spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -446,15 +446,15 @@ void setAutodetectModeToOutOfRangeNegativeValue() {
446446
assertThatIllegalArgumentException()
447447
.isThrownBy(() -> exporter.setAutodetectMode(-1))
448448
.withMessage("Only values of autodetect constants allowed");
449-
assertThat(exporter.getAutodetectMode()).isNull();
449+
assertThat(exporter.autodetectMode).isNull();
450450
}
451451

452452
@Test
453453
void setAutodetectModeToOutOfRangePositiveValue() {
454454
assertThatIllegalArgumentException()
455455
.isThrownBy(() -> exporter.setAutodetectMode(5))
456456
.withMessage("Only values of autodetect constants allowed");
457-
assertThat(exporter.getAutodetectMode()).isNull();
457+
assertThat(exporter.autodetectMode).isNull();
458458
}
459459

460460
/**
@@ -471,39 +471,39 @@ void setAutodetectModeToAllSupportedValues() {
471471
@Test
472472
void setAutodetectModeToSupportedValue() {
473473
exporter.setAutodetectMode(MBeanExporter.AUTODETECT_ASSEMBLER);
474-
assertThat(exporter.getAutodetectMode()).isEqualTo(MBeanExporter.AUTODETECT_ASSEMBLER);
474+
assertThat(exporter.autodetectMode).isEqualTo(MBeanExporter.AUTODETECT_ASSEMBLER);
475475
}
476476

477477
@Test
478478
void setAutodetectModeNameToNull() {
479479
assertThatIllegalArgumentException()
480480
.isThrownBy(() -> exporter.setAutodetectModeName(null))
481481
.withMessage("'constantName' must not be null or blank");
482-
assertThat(exporter.getAutodetectMode()).isNull();
482+
assertThat(exporter.autodetectMode).isNull();
483483
}
484484

485485
@Test
486486
void setAutodetectModeNameToAnEmptyString() {
487487
assertThatIllegalArgumentException()
488488
.isThrownBy(() -> exporter.setAutodetectModeName(""))
489489
.withMessage("'constantName' must not be null or blank");
490-
assertThat(exporter.getAutodetectMode()).isNull();
490+
assertThat(exporter.autodetectMode).isNull();
491491
}
492492

493493
@Test
494494
void setAutodetectModeNameToWhitespace() {
495495
assertThatIllegalArgumentException()
496496
.isThrownBy(() -> exporter.setAutodetectModeName(" \t"))
497497
.withMessage("'constantName' must not be null or blank");
498-
assertThat(exporter.getAutodetectMode()).isNull();
498+
assertThat(exporter.autodetectMode).isNull();
499499
}
500500

501501
@Test
502502
void setAutodetectModeNameToBogusValue() {
503503
assertThatIllegalArgumentException()
504504
.isThrownBy(() -> exporter.setAutodetectModeName("Bogus"))
505505
.withMessage("Only autodetect constants allowed");
506-
assertThat(exporter.getAutodetectMode()).isNull();
506+
assertThat(exporter.autodetectMode).isNull();
507507
}
508508

509509
/**
@@ -520,7 +520,7 @@ void setAutodetectModeNameToAllSupportedValues() {
520520
@Test
521521
void setAutodetectModeNameToSupportedValue() {
522522
exporter.setAutodetectModeName("AUTODETECT_ASSEMBLER");
523-
assertThat(exporter.getAutodetectMode()).isEqualTo(MBeanExporter.AUTODETECT_ASSEMBLER);
523+
assertThat(exporter.autodetectMode).isEqualTo(MBeanExporter.AUTODETECT_ASSEMBLER);
524524
}
525525

526526
@Test

0 commit comments

Comments
 (0)