Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8140479

Improve DriverManager's usage of ServiceLoader in case of errors

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 9
    • core-libs
    • x86_64
    • windows_7

      A DESCRIPTION OF THE REQUEST :
      When DriverManager loads Drivers using the ServiceLoader, any ServiceConfigurationErrors thrown by ServiceLoader are ignored. There are two issues with this code as it is:
      1.) Bogus/Incomplete Drivers are very hard to diagnose, as the ServiceConfigurationError doesn't show up anywhere.
      2.) Driver initialization is aborted immediately, i.e. Drivers that would be loaded after a bogus Driver aren't loaded at all.




      JUSTIFICATION :
      Issues with Driver initialization are right now VERY hard to diagnose, as the corresponding ServiceConfigurationError can only be seen within a debugger. With the ServiceConfigurationError logged properly, it would be immediately obvious what's wrong with that Driver, e.g. missing dependencies or the like.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I propose to improve DriverManager by
      a) logging the ServiceConfigurationError using the existing logWriter
      b) to keep going with initialization of remaining Drivers after a ServiceConfigurationError


      Note that in Java 8 (and also 7), logging from the #loadInitialDrivers method is essentially broken, as that method is called from DriverManager's static initializier and there's no way to set a log writer (using DriverManager#setLogWriter) before that. In Java 9, initialization seems to have been tweaked to be performed lazily (again) (see JDK-8067904), so logging the initialization process should work fine again.


            lancea Lance Andersen
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: