GeoTools
  1. GeoTools
  2. GEOT-1403

DataStoreFinder hides exception from DataStoreFactory.createDataStore(...)

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5-M0
    • Component/s: main
    • Labels:
      None

      Description

      The problem is in org.geotools.data.DataStoreFinder and org.geotools.data.FileDataStoreFinder.

      In the SVN HEAD version of them the whole canProcess(...), createDataStore(...) cycle is in a try {} catch(Throwable t) block. This way if a DataStore can handle a type of database, but fails to open it (e.g. corrupt db file) no exception is thrown, only a debug message is logged. This contradicts with the javadoc, which says that an IOException is thrown "If a suitable loader can be found, but it can not be attached to the specified resource without errors." And even the comment in the catch block states that it "Protect against DataStores that don't carefully code canProcess".

      I've already posted this bug on geotools-user in may, and Jody responded to it positively, but since then it got forgotten. I also have a patch for DataStoreFinder, FileDataStoreFinder may be modified the same way.

      1. DataStoreFactory.patch
        3 kB
        Peter Bolla
      2. DataStoreFinder.patch
        1 kB
        Peter Bolla

        Activity

        Hide
        Peter Bolla added a comment -
        I would add, that the DataStoreFinders should be modified in a way, that they call canProcess() for ALL datastores (not only available ones), and report an error if a datastore could process a connection, but it is not available.
        Show
        Peter Bolla added a comment - I would add, that the DataStoreFinders should be modified in a way, that they call canProcess() for ALL datastores (not only available ones), and report an error if a datastore could process a connection, but it is not available.
        Hide
        Peter Bolla added a comment -
        Patch extended with the additional check order change (canProcess <-> isAvailable)
        Show
        Peter Bolla added a comment - Patch extended with the additional check order change (canProcess <-> isAvailable)
        Hide
        Jody Garnett added a comment -
        Fix applied to trunk, someone can back port to 2.4.x if interested.
        Show
        Jody Garnett added a comment - Fix applied to trunk, someone can back port to 2.4.x if interested.

          People

          • Assignee:
            Jody Garnett
            Reporter:
            Peter Bolla
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: