Commit 7b2b8dc4 authored by Phillip Webb's avatar Phillip Webb

Merge branch '1.5.x'

parents 2ae39fce dca463c7
......@@ -46,7 +46,6 @@ import org.springframework.core.annotation.AliasFor;
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@AutoConfigurationPackage
@Import(ImportAutoConfigurationImportSelector.class)
public @interface ImportAutoConfiguration {
......
......@@ -49,8 +49,8 @@ class ActiveMQConnectionFactoryConfiguration {
public ActiveMQConnectionFactory jmsConnectionFactory(ActiveMQProperties properties,
ObjectProvider<List<ActiveMQConnectionFactoryCustomizer>> factoryCustomizers) {
return new ActiveMQConnectionFactoryFactory(properties,
factoryCustomizers.getIfAvailable()).createConnectionFactory(
ActiveMQConnectionFactory.class);
factoryCustomizers.getIfAvailable())
.createConnectionFactory(ActiveMQConnectionFactory.class);
}
@ConditionalOnClass(PooledConnectionFactory.class)
......@@ -67,21 +67,21 @@ class ActiveMQConnectionFactoryConfiguration {
ActiveMQConnectionFactory.class));
ActiveMQProperties.Pool pool = properties.getPool();
pooledConnectionFactory.setBlockIfSessionPoolIsFull(pool.isBlockIfFull());
pooledConnectionFactory.setBlockIfSessionPoolIsFullTimeout(
pool.getBlockIfFullTimeout());
pooledConnectionFactory.setCreateConnectionOnStartup(
pool.isCreateConnectionOnStartup());
pooledConnectionFactory
.setBlockIfSessionPoolIsFullTimeout(pool.getBlockIfFullTimeout());
pooledConnectionFactory
.setCreateConnectionOnStartup(pool.isCreateConnectionOnStartup());
pooledConnectionFactory.setExpiryTimeout(pool.getExpiryTimeout());
pooledConnectionFactory.setIdleTimeout(pool.getIdleTimeout());
pooledConnectionFactory.setMaxConnections(pool.getMaxConnections());
pooledConnectionFactory.setMaximumActiveSessionPerConnection(
pool.getMaximumActiveSessionPerConnection());
pooledConnectionFactory.setReconnectOnException(
pool.isReconnectOnException());
pooledConnectionFactory
.setReconnectOnException(pool.isReconnectOnException());
pooledConnectionFactory.setTimeBetweenExpirationCheckMillis(
pool.getTimeBetweenExpirationCheck());
pooledConnectionFactory.setUseAnonymousProducers(
pool.isUseAnonymousProducers());
pooledConnectionFactory
.setUseAnonymousProducers(pool.isUseAnonymousProducers());
return pooledConnectionFactory;
}
......
......@@ -158,8 +158,8 @@ public class ActiveMQProperties {
private boolean blockIfFull = true;
/**
* Blocking period, in milliseconds, before throwing an exception if the pool
* is still full.
* Blocking period, in milliseconds, before throwing an exception if the pool is
* still full.
*/
private long blockIfFullTimeout = -1;
......@@ -265,7 +265,8 @@ public class ActiveMQProperties {
return this.maximumActiveSessionPerConnection;
}
public void setMaximumActiveSessionPerConnection(int maximumActiveSessionPerConnection) {
public void setMaximumActiveSessionPerConnection(
int maximumActiveSessionPerConnection) {
this.maximumActiveSessionPerConnection = maximumActiveSessionPerConnection;
}
......
......@@ -54,7 +54,7 @@ class ActiveMQXAConnectionFactoryConfiguration {
XAConnectionFactoryWrapper wrapper) throws Exception {
ActiveMQXAConnectionFactory connectionFactory = new ActiveMQConnectionFactoryFactory(
properties, factoryCustomizers.getIfAvailable())
.createConnectionFactory(ActiveMQXAConnectionFactory.class);
.createConnectionFactory(ActiveMQXAConnectionFactory.class);
return wrapper.wrapConnectionFactory(connectionFactory);
}
......@@ -64,8 +64,8 @@ class ActiveMQXAConnectionFactoryConfiguration {
ActiveMQProperties properties,
ObjectProvider<List<ActiveMQConnectionFactoryCustomizer>> factoryCustomizers) {
return new ActiveMQConnectionFactoryFactory(properties,
factoryCustomizers.getIfAvailable()).createConnectionFactory(
ActiveMQConnectionFactory.class);
factoryCustomizers.getIfAvailable())
.createConnectionFactory(ActiveMQConnectionFactory.class);
}
}
......@@ -37,6 +37,7 @@ import org.springframework.core.env.Environment;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verifyZeroInteractions;
......@@ -125,7 +126,6 @@ public class ImportAutoConfigurationImportSelectorTests {
public void exclusionsAliasesAreApplied() throws Exception {
AnnotationMetadata annotationMetadata = getAnnotationMetadata(
ImportWithSelfAnnotatingAnnotationExclude.class);
String[] imports = this.importSelector.selectImports(annotationMetadata);
assertThat(imports).isEmpty();
}
......@@ -182,6 +182,19 @@ public class ImportAutoConfigurationImportSelectorTests {
assertThat(set1).isNotEqualTo(set2);
}
@Test
public void determineImportsShouldNotSetPackageImport() throws Exception {
Class<?> packageImportClass = ClassUtils.resolveClassName(
"org.springframework.boot.autoconfigure.AutoConfigurationPackages.PackageImport",
null);
Set<Object> selectedImports = this.importSelector
.determineImports(getAnnotationMetadata(
ImportMetaAutoConfigurationExcludeWithUnrelatedOne.class));
for (Object selectedImport : selectedImports) {
assertThat(selectedImport).isNotInstanceOf(packageImportClass);
}
}
private AnnotationMetadata getAnnotationMetadata(Class<?> source) throws IOException {
return new SimpleMetadataReaderFactory().getMetadataReader(source.getName())
.getAnnotationMetadata();
......
......@@ -40,37 +40,38 @@ public class ActiveMQPropertiesTests {
@Test
public void getBrokerUrlIsInMemoryByDefault() {
assertThat(createFactory(this.properties).determineBrokerUrl()).isEqualTo(
DEFAULT_EMBEDDED_BROKER_URL);
assertThat(createFactory(this.properties).determineBrokerUrl())
.isEqualTo(DEFAULT_EMBEDDED_BROKER_URL);
}
@Test
public void getBrokerUrlUseExplicitBrokerUrl() {
this.properties.setBrokerUrl("vm://foo-bar");
assertThat(createFactory(this.properties).determineBrokerUrl()).isEqualTo(
"vm://foo-bar");
assertThat(createFactory(this.properties).determineBrokerUrl())
.isEqualTo("vm://foo-bar");
}
@Test
public void getBrokerUrlWithInMemorySetToFalse() {
this.properties.setInMemory(false);
assertThat(createFactory(this.properties).determineBrokerUrl()).isEqualTo(
DEFAULT_NETWORK_BROKER_URL);
assertThat(createFactory(this.properties).determineBrokerUrl())
.isEqualTo(DEFAULT_NETWORK_BROKER_URL);
}
@Test
public void getExplicitBrokerUrlAlwaysWins() {
this.properties.setBrokerUrl("vm://foo-bar");
this.properties.setInMemory(false);
assertThat(createFactory(this.properties).determineBrokerUrl()).isEqualTo(
"vm://foo-bar");
assertThat(createFactory(this.properties).determineBrokerUrl())
.isEqualTo("vm://foo-bar");
}
@Test
public void setTrustAllPackages() {
this.properties.getPackages().setTrustAll(true);
assertThat(createFactory(this.properties).createConnectionFactory(
ActiveMQConnectionFactory.class).isTrustAllPackages()).isEqualTo(true);
assertThat(createFactory(this.properties)
.createConnectionFactory(ActiveMQConnectionFactory.class)
.isTrustAllPackages()).isEqualTo(true);
}
@Test
......@@ -84,7 +85,8 @@ public class ActiveMQPropertiesTests {
assertThat(factory.getTrustedPackages().get(0)).isEqualTo("trusted.package");
}
private ActiveMQConnectionFactoryFactory createFactory(ActiveMQProperties properties) {
private ActiveMQConnectionFactoryFactory createFactory(
ActiveMQProperties properties) {
return new ActiveMQConnectionFactoryFactory(properties,
Collections.<ActiveMQConnectionFactoryCustomizer>emptyList());
}
......
......@@ -24,6 +24,7 @@ import org.junit.runner.notification.RunNotifier;
import org.junit.runners.model.InitializationError;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
......@@ -94,8 +95,8 @@ public class ImportsContextCustomizerFactoryWithAutoConfigurationTests {
}
@ContextConfiguration(classes = EmptyConfig.class)
@DataJpaTest
@ContextConfiguration(classes = EmptyConfig.class)
@Unrelated2
public static class DataJpaTest2 {
......@@ -109,8 +110,8 @@ public class ImportsContextCustomizerFactoryWithAutoConfigurationTests {
}
@ContextConfiguration(classes = EmptyConfig.class)
@DataJpaTest
@ContextConfiguration(classes = EmptyConfig.class)
@Unrelated1
public static class DataJpaTest3 {
......@@ -124,8 +125,8 @@ public class ImportsContextCustomizerFactoryWithAutoConfigurationTests {
}
@ContextConfiguration(classes = EmptyConfig.class)
@DataJpaTest(showSql = false)
@ContextConfiguration(classes = EmptyConfig.class)
@Unrelated1
public static class DataJpaTest4 {
......@@ -151,6 +152,7 @@ public class ImportsContextCustomizerFactoryWithAutoConfigurationTests {
@Configuration
@EntityScan(basePackageClasses = ExampleEntity.class)
@AutoConfigurationPackage
static class EmptyConfig {
}
......
......@@ -71,8 +71,6 @@ public class Handler extends URLStreamHandler {
rootFileCache = new SoftReference<>(null);
}
private final Logger logger = Logger.getLogger(getClass().getName());
private final JarFile jarFile;
private URLStreamHandler fallbackHandler;
......@@ -105,10 +103,10 @@ public class Handler extends URLStreamHandler {
}
catch (Exception ex) {
if (reason instanceof IOException) {
this.logger.log(Level.FINEST, "Unable to open fallback handler", ex);
log(false, "Unable to open fallback handler", ex);
throw (IOException) reason;
}
this.logger.log(Level.WARNING, "Unable to open fallback handler", ex);
log(true, "Unable to open fallback handler", ex);
if (reason instanceof RuntimeException) {
throw (RuntimeException) reason;
}
......@@ -116,6 +114,18 @@ public class Handler extends URLStreamHandler {
}
}
private void log(boolean warning, String message, Exception cause) {
try {
Logger.getLogger(getClass().getName())
.log((warning ? Level.WARNING : Level.FINEST), message, cause);
}
catch (Exception ex) {
if (warning) {
System.err.println("WARNING: " + message);
}
}
}
private URLStreamHandler getFallbackHandler() {
if (this.fallbackHandler != null) {
return this.fallbackHandler;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment