Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-10247

Scala ClassLoader breaks nio FileSystemProvider API

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: Scala 2.11.8, Scala 2.12.1
    • Fix Version/s: None
    • Labels:
      None

      Description

      java.nio.file.spi.FileSystemProvider loads implementations using ClassLoader.getSystemClassLoader().

      However, Scala uses a system ClassLoader that doesn't search among JARs on the classpath, resulting in it being impossible to use custom FileSystemProvider implementations.

      As an example, try running the google-cloud-nio example; here is a gist showing shell cmds and output.

      When the same example JAR is run with java -cp … and scala -cp …, the former finds the custom FileSystemProvider (gs scheme) but the latter doesn't.

      I'm currently planning to use this workaround to call FileSystemProvider.loadInstalledProviders while the system classloader is temporarily overwritten to Thread.currentThread().getContextClassLoader, which properly finds FileSystemProvider implementations in user-supplied JARs.

      This SO provides basically the same analysis and diagnosis.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              rdub Ryan Williams
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: