Exemplo n.º 1
0
  // Can't throw.
  private void reconfigureAllConnectionsLocked() {
    if (mAvailablePrimaryConnection != null) {
      try {
        mAvailablePrimaryConnection.reconfigure(mConfiguration); // might throw
      } catch (RuntimeException ex) {
        Log.e(
            TAG,
            "Failed to reconfigure available primary connection, closing it: "
                + mAvailablePrimaryConnection,
            ex);
        closeConnectionAndLogExceptionsLocked(mAvailablePrimaryConnection);
        mAvailablePrimaryConnection = null;
      }
    }

    int count = mAvailableNonPrimaryConnections.size();
    for (int i = 0; i < count; i++) {
      final SQLiteConnection connection = mAvailableNonPrimaryConnections.get(i);
      try {
        connection.reconfigure(mConfiguration); // might throw
      } catch (RuntimeException ex) {
        Log.e(
            TAG,
            "Failed to reconfigure available non-primary connection, closing it: " + connection,
            ex);
        closeConnectionAndLogExceptionsLocked(connection);
        mAvailableNonPrimaryConnections.remove(i--);
        count -= 1;
      }
    }

    markAcquiredConnectionsLocked(AcquiredConnectionStatus.RECONFIGURE);
  }
Exemplo n.º 2
0
 // Can't throw.
 private boolean recycleConnectionLocked(
     SQLiteConnection connection, AcquiredConnectionStatus status) {
   if (status == AcquiredConnectionStatus.RECONFIGURE) {
     try {
       connection.reconfigure(mConfiguration); // might throw
     } catch (RuntimeException ex) {
       Log.e(TAG, "Failed to reconfigure released connection, closing it: " + connection, ex);
       status = AcquiredConnectionStatus.DISCARD;
     }
   }
   if (status == AcquiredConnectionStatus.DISCARD) {
     closeConnectionAndLogExceptionsLocked(connection);
     return false;
   }
   return true;
 }