Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2605

DelegatingConnection.unwrap() doesn't adhere to java.sql.Wrapper.unwrap() contract

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.2, 2.4.0
    • Fix Version/s: 2.2.3, 2.4.1
    • Component/s: lib
    • Labels:
      None

      Description

      The implementation of DelegatingConnection.unwrap() checks if the delegate is assignable to the class type provided in the unwrap argument() and returns null if it is not. The negative result is not consistent with the unwrap() contract as specified by the Wrapper.unwrap() contract, as specified:

      "Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy. If the receiver implements the interface then the result is the receiver or a proxy for the receiver. If the receiver is a wrapper and the wrapped object implements the interface then the result is the wrapped object or a proxy for the wrapped object. Otherwise return the the result of calling unwrap recursively on the wrapped object or a proxy for that result. If the receiver is not a wrapper and does not implement the interface, then an SQLException is thrown."

      Since DelegatingConnection is effectively a wrapper, it should check if the delegate is assignable to the type specified by the argument and return the delegate if it is, otherwise it should call the delegate's unwrap() method with the type argument provided as the argument to the underlying unwrap() call.

        Activity

        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1713509 from Jody Grassel in branch 'openjpa/trunk'
        [ https://svn.apache.org/r1713509 ]

        OPENJPA-2605: DelegatingConnection.unwrap() doesn't adhere to java.sql.Wrapper.unwrap() contract

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1713509 from Jody Grassel in branch 'openjpa/trunk' [ https://svn.apache.org/r1713509 ] OPENJPA-2605 : DelegatingConnection.unwrap() doesn't adhere to java.sql.Wrapper.unwrap() contract
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1713475 from Jody Grassel in branch 'openjpa/branches/2.2.x'
        [ https://svn.apache.org/r1713475 ]

        OPENJPA-2605: DelegatingConnection.unwrap() doesn't adhere to java.sql.Wrapper.unwrap() contract

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1713475 from Jody Grassel in branch 'openjpa/branches/2.2.x' [ https://svn.apache.org/r1713475 ] OPENJPA-2605 : DelegatingConnection.unwrap() doesn't adhere to java.sql.Wrapper.unwrap() contract
        Hide
        fyrewyld Jody Grassel added a comment -

        Proposed patch.

        Show
        fyrewyld Jody Grassel added a comment - Proposed patch.

          People

          • Assignee:
            fyrewyld Jody Grassel
            Reporter:
            fyrewyld Jody Grassel
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development