Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DynamicDatasources throwing RuntimeExceptions

    We use DynamicDSGenerators quite a lot in our project and had a case where they could sometimes throw a runtimeException in

    Code:
    public DataSource getDataSource(String name, DSRequest dsRequest)
    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

    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;
    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

    #2
    This suggestion was implemented and will be available in next nightly build.

    Comment

    Working...
    X