Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoHostAvailable not caught at bean declaration, but only at initialization [DATACASS-460] #604

Closed
spring-projects-issues opened this issue Jun 8, 2017 · 1 comment
Assignees
Labels
in: core status: duplicate type: bug

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Jun 8, 2017

venkat g opened DATACASS-460 and commented

For the following spring data cassandra configuration

@SpringBootApplication
public class DemoApplication {

	private final CassandraClusterFactoryBean cluster = new CassandraClusterFactoryBean();

	@Bean(name = "clusterFactory")
	public CassandraClusterFactoryBean getCluster() {
		try {
			PoolingOptions poolingOptions = new PoolingOptions();
			cluster.setContactPoints("127.0.0.1");
			cluster.setPoolingOptions(poolingOptions);
			cluster.setPort(9042);
			poolingOptions.setNewConnectionThreshold(HostDistance.LOCAL, 2);
			} catch (BeanCreationException exception) {
			throw exception;
		}
		return cluster;
	}
	@Bean
	@DependsOn("clusterFactory")
	public CassandraSessionFactoryBean getSession() {
		CassandraSessionFactoryBean session = new CassandraSessionFactoryBean();
		try {
			session.setCluster(cluster.getObject());
			session.setKeyspaceName("test");
			session.setConverter(new MappingCassandraConverter(new CassandraMappingContextAware()));
			session.setSchemaAction(SchemaAction.NONE);
		} catch (BeanCreationException exception) {
			throw exception;
		}
		return session;
	}

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}
}

when the cassandra instance is down before application startup, NoHostAvailableException is thrown only in AbstractAutowiredCapableBeanFactory


Affects: 1.5.3 (Ingalls SR3)

Reference URL: https://stackoverflow.com/questions/44428041/spring-boot-data-nohostavailableexception-not-caught

Issue Links:

  • DATACASS-210 Allow application to start if cassandra is unavailable
    ("duplicates")
@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jun 9, 2017

Mark Paluch commented

Duplicate of DATACASS-210

@spring-projects-issues spring-projects-issues added type: bug in: core status: duplicate labels Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core status: duplicate type: bug
Projects
None yet
Development

No branches or pull requests

2 participants