#6 NullPointer, if you do not configure all DS

v0.6
open
nobody
5
2009-04-21
2009-04-21
Anonymous
No

by stefan-isele@gmx.de

if you do not configure all existing Spring dataSource-beans ifor jdbclogger, you will get a NullpointerException in line 63
because the dataSourceConfiguration is null !!
you may check in 56 if dataSourceConfiguration == null and do nothing to just prevent the NullpointerException in this case.
So if a datasource-bean exists but was not configured for jdbclogger its jdbc-statements will just not be logged, which is quite ok

54 public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
55 JdbcLoggerDataSourceConfiguration dataSourceConfiguration = getDataSourceConfiguration(beanName);
56
57 if (!isEnabled()) {
58 log.info("Configuring data source ["+beanName+"] skipped, disabled by configuration.");
59 return bean;
60 }
61
62 if (bean instanceof DataSource) {
63 replaceDataSourceDriverClassName((DataSource)bean, beanName, dataSourceConfiguration.getDriverClassNamePropertyName());
64 }
65 else log.warn("Configured data source bean ["+beanName+"] is not a javax.sql.DataSource instance, ignored.");
66
67 return bean;
68 }

Discussion

  • Is this project still Active, Even I have the same problem. I guess we can modify and use the code, but it would be nice if you do that, and can show that this project is still active, so more people can use it. And any plans to support 11g ?