Search in sources :

Example 21 with SQLTransientException

use of java.sql.SQLTransientException in project sis by apache.

the class AuthorityFactories method failure.

/**
 * Notifies that a factory is unavailable, but without giving a fallback and without logging.
 * The caller is responsible for throwing an exception, or for logging a warning and provide its own fallback.
 *
 * @return {@code false} if the caller can try again, or {@code true} if the failure can be considered final.
 */
static boolean failure(final UnavailableFactoryException e) {
    if (!(e.getCause() instanceof SQLTransientException)) {
        final AuthorityFactory unavailable = e.getUnavailableFactory();
        synchronized (EPSG) {
            final GeodeticAuthorityFactory factory = EPSG[0];
            if (factory == EPSGFactoryFallback.INSTANCE) {
                // May have been set in another thread.
                return false;
            }
            if (unavailable == factory) {
                ALL.reload();
                EPSG[0] = EPSGFactoryFallback.INSTANCE;
                return false;
            }
        }
    }
    return true;
}
Also used : SQLTransientException(java.sql.SQLTransientException) AuthorityFactory(org.opengis.referencing.AuthorityFactory) CoordinateOperationAuthorityFactory(org.opengis.referencing.operation.CoordinateOperationAuthorityFactory) GeodeticAuthorityFactory(org.apache.sis.referencing.factory.GeodeticAuthorityFactory) CSAuthorityFactory(org.opengis.referencing.cs.CSAuthorityFactory) DatumAuthorityFactory(org.opengis.referencing.datum.DatumAuthorityFactory) CRSAuthorityFactory(org.opengis.referencing.crs.CRSAuthorityFactory) GeodeticAuthorityFactory(org.apache.sis.referencing.factory.GeodeticAuthorityFactory)

Aggregations

SQLTransientException (java.sql.SQLTransientException)21 Test (org.testng.annotations.Test)16 BaseTest (util.BaseTest)16 SQLException (java.sql.SQLException)6 GeodeticAuthorityFactory (org.apache.sis.referencing.factory.GeodeticAuthorityFactory)2 AuthorityFactory (org.opengis.referencing.AuthorityFactory)2 CRSAuthorityFactory (org.opengis.referencing.crs.CRSAuthorityFactory)2 CSAuthorityFactory (org.opengis.referencing.cs.CSAuthorityFactory)2 DatumAuthorityFactory (org.opengis.referencing.datum.DatumAuthorityFactory)2 CoordinateOperationAuthorityFactory (org.opengis.referencing.operation.CoordinateOperationAuthorityFactory)2 Duration (io.airlift.units.Duration)1 SQLNonTransientException (java.sql.SQLNonTransientException)1 SQLTimeoutException (java.sql.SQLTimeoutException)1 SQLTransactionRollbackException (java.sql.SQLTransactionRollbackException)1 SQLTransientConnectionException (java.sql.SQLTransientConnectionException)1 Random (java.util.Random)1 FieldValue (org.firebirdsql.gds.ng.fields.FieldValue)1 RowDescriptor (org.firebirdsql.gds.ng.fields.RowDescriptor)1 Handle (org.skife.jdbi.v2.Handle)1 UnableToObtainConnectionException (org.skife.jdbi.v2.exceptions.UnableToObtainConnectionException)1