Uploaded image for project: 'Couchbase Lite'
  1. Couchbase Lite
  2. CBL-1718

Handle db close in inBatch

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.7.0
    • 3.0
    • Java, Java-Android
    • Security Level: Public
    • None
    • 3

    Description

      Currently Platform code attempts to free the Core companion object in methods that guarantee that the companion will not be needed again: `close()`, `delete()` and perhaps others.

      These methods, though, are public API methods and can be called by client code in an `inBatch` block. On some platforms this will crash Core. On others it will leak the database.

      Platform code should explicitly disallow calling methods that could free the Core companion object, from within an `inBatch` block.

      Core currently forbids closing or deleting the database, from within a transaction, but cannot, effectively check for operations that would free it (release). Platform code should do this.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          blake.meike Blake Meike added a comment -

          There is a funky solution to this, in Java.

          The code now frees the native db companion object only after calling the native close or delete methods. Those methods fail by throwing and exception if the call is in a transaction. That means that, in a transaction, the call to free will never be reached.

          This does not result in leaking the companion object since it will be freed, last resort, in the finalizer. Since this is a wildly corner case, that's good enough

          blake.meike Blake Meike added a comment - There is a funky solution to this, in Java. The code now frees the native db companion object only after calling the native close or delete methods. Those methods fail by throwing and exception if the call is in a transaction. That means that, in a transaction, the call to free will never be reached. This does not result in leaking the companion object since it will be freed, last resort, in the finalizer. Since this is a wildly corner case, that's good enough
          blake.meike Blake Meike added a comment -

          fixed in couchbase-lite-java-common @ 4a36eaf819db8862848

          blake.meike Blake Meike added a comment - fixed in couchbase-lite-java-common @ 4a36eaf819db8862848

          People

            The Lite The Lite
            blake.meike Blake Meike
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 6h
                6h

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty