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

Use try-with-resources in X11FontManager.registerFontDir

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P5
    • 20
    • None
    • client-libs
    • 2d
    • b14

    Description

      Method sun.awt.X11FontManager#registerFontDir contains huge try-finally block with big indentation:

              FileReader fr = null;
              try {
                  if (fontsDotDir.canRead()) {
                      fr = new FileReader(fontsDotDir);
                      //...
                      }
                      fr.close();
                  }
              } catch (IOException ioe1) {
              } finally {
                  if (fr != null) {
                      try {
                          fr.close();
                      } catch (IOException ioe2) {
                      }
                  }
              }

      Can be simplified if we move 'if (fontsDotDir.canRead()) {' outside of try-finally. And use try-with-resrouces for FileReader

      Attachments

        Issue Links

          Activity

            People

              aturbanov Andrey Turbanov
              aturbanov Andrey Turbanov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: