ErrorContextBuilder should only force embedded H2 databases to be DataStoreType.NOT_SHARED #306
Labels
enhancement
A request for change or improvement to an existing feature
Milestone
The
ErrorContextBuilder#buildWithDataStoreFactory
method forces the data store type to beDataStoreType.NOT_SHARED
for all H2 databases regardless of connection mode, i.e. whether using embedded mode (e.g. local file-based or in-memory) or server mode.Only embedded databases should be forced to
NOT_SHARED
, since server mode H2 databases are client/server applications over TCP/IP and thus are shared.Under the covers the
buildWithDataStoreFactory
method calls the publicApplicationErrorJdbc#isH2DataStore
method, which only checks if the driver class isorg.h2.Driver
. Since this method is public, we can't just modify its behavior in a substantial manner without a major version bump. So, a better option for now is to create a new method, e.g.isEmbeddedH2DataStore
, which checks both the driver class is H2, and that the (H2) JDBC URL is one for an embedded mode database, which encompasses several types of URLs. See Database URL Overview in the H2 documentation.The private
ErrorContextBuilder#forceH2DatabaseToBeNotSharedWithWarning
method should be renamed, and the logged warning should change "in-memory" to be "embedded" or something more generic to indicate an embedded (and thus not shared) database.The javadocs in
ErrorContextBuilder
should also be updated to state that only embedded H2 databases will be automatically set toNOT_SHARED
.The text was updated successfully, but these errors were encountered: