Skip to content

Commit

Permalink
Remove getAutodetectMode() in MBeanExporter
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sbrannen committed Jul 12, 2023
1 parent 768fc7e commit 07422d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -263,19 +263,6 @@ public void setAutodetectMode(int autodetectMode) {
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,15 +446,15 @@ void setAutodetectModeToOutOfRangeNegativeValue() {
assertThatIllegalArgumentException()
.isThrownBy(() -> exporter.setAutodetectMode(-1))
.withMessage("Only values of autodetect constants allowed");
assertThat(exporter.getAutodetectMode()).isNull();
assertThat(exporter.autodetectMode).isNull();
}

@Test
void setAutodetectModeToOutOfRangePositiveValue() {
assertThatIllegalArgumentException()
.isThrownBy(() -> exporter.setAutodetectMode(5))
.withMessage("Only values of autodetect constants allowed");
assertThat(exporter.getAutodetectMode()).isNull();
assertThat(exporter.autodetectMode).isNull();
}

/**
Expand All @@ -471,39 +471,39 @@ void setAutodetectModeToAllSupportedValues() {
@Test
void setAutodetectModeToSupportedValue() {
exporter.setAutodetectMode(MBeanExporter.AUTODETECT_ASSEMBLER);
assertThat(exporter.getAutodetectMode()).isEqualTo(MBeanExporter.AUTODETECT_ASSEMBLER);
assertThat(exporter.autodetectMode).isEqualTo(MBeanExporter.AUTODETECT_ASSEMBLER);
}

@Test
void setAutodetectModeNameToNull() {
assertThatIllegalArgumentException()
.isThrownBy(() -> exporter.setAutodetectModeName(null))
.withMessage("'constantName' must not be null or blank");
assertThat(exporter.getAutodetectMode()).isNull();
assertThat(exporter.autodetectMode).isNull();
}

@Test
void setAutodetectModeNameToAnEmptyString() {
assertThatIllegalArgumentException()
.isThrownBy(() -> exporter.setAutodetectModeName(""))
.withMessage("'constantName' must not be null or blank");
assertThat(exporter.getAutodetectMode()).isNull();
assertThat(exporter.autodetectMode).isNull();
}

@Test
void setAutodetectModeNameToWhitespace() {
assertThatIllegalArgumentException()
.isThrownBy(() -> exporter.setAutodetectModeName(" \t"))
.withMessage("'constantName' must not be null or blank");
assertThat(exporter.getAutodetectMode()).isNull();
assertThat(exporter.autodetectMode).isNull();
}

@Test
void setAutodetectModeNameToBogusValue() {
assertThatIllegalArgumentException()
.isThrownBy(() -> exporter.setAutodetectModeName("Bogus"))
.withMessage("Only autodetect constants allowed");
assertThat(exporter.getAutodetectMode()).isNull();
assertThat(exporter.autodetectMode).isNull();
}

/**
Expand All @@ -520,7 +520,7 @@ void setAutodetectModeNameToAllSupportedValues() {
@Test
void setAutodetectModeNameToSupportedValue() {
exporter.setAutodetectModeName("AUTODETECT_ASSEMBLER");
assertThat(exporter.getAutodetectMode()).isEqualTo(MBeanExporter.AUTODETECT_ASSEMBLER);
assertThat(exporter.autodetectMode).isEqualTo(MBeanExporter.AUTODETECT_ASSEMBLER);
}

@Test
Expand Down

0 comments on commit 07422d7

Please sign in to comment.