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

Use try-with-resources in X11FontManager.registerFontDir

XMLWordPrintable

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

      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

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

              Created:
              Updated:
              Resolved: