We use DynamicDSGenerators quite a lot in our project and had a case where they could sometimes throw a runtimeException in
If this happens dynamic datasource generation will never recover. All consequent tries to generate that dynamic datasource will fail due to this piece of code in com.isomorphic.datasource.DataSource
If ddsg.getDataSource(id, dsRequest) throws a runtimeexception then gettingDynamic.pop() will not be called. This causes the datasource id to stay in the gettingDynamic stack. This then causes subsequent calls to the method to return null due to the first if condition.
Obviously from our side this was easy to fix (catch the runtimeexception before it enters your code), but it would be safer if you just encapsulate that gettinDynamic.pop() in a finally block
Code:
public DataSource getDataSource(String name, DSRequest dsRequest)
Code:
public static synchronized DataSource getDynamicDataSource(String id, DSRequest dsRequest) { if ((!gettingDynamic.empty()) && (gettingDynamic.peek().equals(id))) return null; gettingDynamic.push(id); DynamicDSGenerator ddsg = ... //getting generator if (ddsg != null) { ds = ddsg.getDataSource(id, dsRequest); } gettingDynamic.pop(); return ds;
Obviously from our side this was easy to fix (catch the runtimeexception before it enters your code), but it would be safer if you just encapsulate that gettinDynamic.pop() in a finally block
Comment