Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-5126

Replace use of Subject#doAs with Subject#callAs when available

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Deprecations, JDK
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

    Description

      The driver uses Subject#doAs in SaslAuthenticator.

      However, Subject#doAs was deprecated for removal in Java 18, and Subject#callAs was added in the same release. This is related to the deprecation of the Security Manager.

      To protect against the driver breaking when used against a future version of Java where Subject#doAs has actually been removed, we should replace the usage with Subject#callAs. However, we can't do that simply given that we have to run against Java release prior to Java 18. To work around this, we need to detect dynamically whether Subject#callAs is available, and then call it reflectively if it is. We should probably call Subject#doAs reflectively as well to avoid a compile- or link-time dependency on it.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: