Uploaded image for project: 'Spring Data for Apache Cassandra'
  1. Spring Data for Apache Cassandra
  2. DATACASS-460

NoHostAvailable not caught at bean declaration, but only at initialization

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 1.5.3 (Ingalls SR3)
    • Fix Version/s: None
    • Component/s: Configuration, Core
    • Labels:
      None

      Description

      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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mp911de Mark Paluch
              Reporter:
              venkatg venkat g
              Last updater:
              Mark Paluch
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                3 years, 16 weeks, 3 days ago