Uploaded image for project: 'Clojure'
  1. CLJ-787

transient blows up when passed a vector created by subvec

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects versions: None
    • Fix versions: Release 1.11
    • Labels:
      None
    • Approval:
      Incomplete
    • Patch:
      Code and Test

      Description

      Subvectors created with subvec from a PersistentVector cannot be made transient:

      user=> (transient (subvec [1 2 3 4] 2))
      ClassCastException clojure.lang.APersistentVector$SubVector cannot be cast to clojure.lang.IEditableCollection  clojure.core/transient (core.clj:2864)
      

      Cause: APersistentVector$SubVector does not implement IEditableCollection

      Patch: CLJ-787-p1.patch

      Approach: Create a TransientSubVector based on an underlying TransientVector.

      Two assumptions:

      • It's okay for TransientSubVector to delegate the ensureEditable functionality to the underlying TransientVector (sometimes explicitly, sometimes implicitly) - calling ensureEditable explicitly also requires that the field for the underlying vector be the concrete TransientVector type rather than the ITransientVector interface.
      • When an operation that would throw an exception on a PersistentVector happens from the wrong thread (or after persistent!), we throw that exception rather than the IllegalAccessError that transients throw when accessed inappropriately.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              aredington Alexander Redington
            • Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated: