Revert reloadable message source support

Closes gh-14882
See gh-14699
See gh-13377
This commit is contained in:
Andy Wilkinson
2018-10-29 16:24:59 +00:00
parent 5ac9b972fe
commit 743782de7e
6 changed files with 1 additions and 67 deletions

View File

@@ -33,8 +33,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.AbstractResourceBasedMessageSource;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.core.Ordered;
import org.springframework.core.io.Resource;
@@ -67,9 +65,7 @@ public class MessageSourceAutoConfiguration {
@Bean
public MessageSource messageSource(MessageSourceProperties properties) {
AbstractResourceBasedMessageSource messageSource = (properties.isReloadable()
? new ReloadableResourceBundleMessageSource()
: new ResourceBundleMessageSource());
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
if (StringUtils.hasText(properties.getBasename())) {
messageSource.setBasenames(StringUtils.commaDelimitedListToStringArray(
StringUtils.trimAllWhitespace(properties.getBasename())));

View File

@@ -71,12 +71,6 @@ public class MessageSourceProperties {
*/
private boolean useCodeAsDefaultMessage = false;
/**
* Whether to use a "ReloadableResourceBundleMessageSource" rather than the default
* "ResourceBundleMessageSource". Recommended during development only.
*/
private boolean reloadable = false;
public String getBasename() {
return this.basename;
}
@@ -125,12 +119,4 @@ public class MessageSourceProperties {
this.useCodeAsDefaultMessage = useCodeAsDefaultMessage;
}
public boolean isReloadable() {
return this.reloadable;
}
public void setReloadable(boolean reloadable) {
this.reloadable = reloadable;
}
}

View File

@@ -32,9 +32,6 @@ import org.springframework.context.NoSuchMessageException;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.DelegatingMessageSource;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.context.support.ResourceBundleMessageSource;
import static org.assertj.core.api.Assertions.assertThat;
@@ -223,38 +220,6 @@ public class MessageSourceAutoConfigurationTests {
.isEqualTo("bar")));
}
@Test
public void testDefaultReloadableValueMessageSource() {
testReloadableMessageSource(ResourceBundleMessageSource.class,
"spring.messages.basename:test/messages");
}
@Test
public void testNotReloadableMessageSource() {
testReloadableMessageSource(ResourceBundleMessageSource.class,
"spring.messages.basename:test/messages",
"spring.messages.reloadable:false");
}
@Test
public void testReloadableMessageSource() {
testReloadableMessageSource(ReloadableResourceBundleMessageSource.class,
"spring.messages.basename:test/messages",
"spring.messages.reloadable:true");
}
private void testReloadableMessageSource(Class<?> expectedInstance,
String... propertyValues) {
this.contextRunner.withPropertyValues(propertyValues).run((context) -> {
MessageSource messageSource = context.getBean(MessageSource.class);
if (messageSource instanceof DelegatingMessageSource) {
messageSource = ((DelegatingMessageSource) messageSource)
.getParentMessageSource();
}
assertThat(messageSource).isInstanceOf(expectedInstance);
});
}
@Configuration
@PropertySource("classpath:/switch-messages.properties")
protected static class Config {