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