Hi again
I have a follow up question 
This is not really a big problem, just a little anoying.
In the example below, one can see that just because the configuration method throws IOException all methods calling that one also have to throw IOException and so on...
I think this really clutterns up the code when a lot of metods depend on the first one. What do you guys think?
Example:
Code:
@Bean
public DataSource dataSource() throws IOException
{
DriverManagerDataSource dataSource = new DriverManagerDataSource(url(), username(), password());
dataSource.setDriverClassName(driverClassName());
return dataSource;
}
protected String url() throws IOException {
return getConfiguredProperty("jdbc.url");
}
private String getConfiguredProperty(String aPropertyName) throws IOException {
return configuration().getString(aPropertyName);
}
// This method throws IOException because it accesses a configuration file.
@Bean
public PersistentConfiguration configuration() throws IOException {
ClassPathResource propertiesResource = ....
....
return configuration;
}
Would it perhaps be better, in this case, to get rid of the throws clause by re-throwing the IOException as a RuntimeException?
The application would still fail fast right?
Code:
@Bean
public PersistentConfiguration configuration() {
try {
ClassPathResource propertiesResource = ....
....
return configuration;
} catch (IOException e) {
throw new RuntimeException(e);
}
}