src/solaris/classes/java/util/prefs/FileSystemPreferences.java

Print this page
rev 3509 : 7021209: convert lang, math, util to use try-with-resources
Reviewed-by: XXX

*** 569,581 **** public Void run() throws BackingStoreException { Map<String, String> m = new TreeMap<>(); long newLastSyncTime = 0; try { newLastSyncTime = prefsFile.lastModified(); ! FileInputStream fis = new FileInputStream(prefsFile); XmlSupport.importMap(fis, m); ! fis.close(); } catch(Exception e) { if (e instanceof InvalidPreferencesFormatException) { getLogger().warning("Invalid preferences format in " + prefsFile.getPath()); prefsFile.renameTo( new File( --- 569,581 ---- public Void run() throws BackingStoreException { Map<String, String> m = new TreeMap<>(); long newLastSyncTime = 0; try { newLastSyncTime = prefsFile.lastModified(); ! try (FileInputStream fis = new FileInputStream(prefsFile)) { XmlSupport.importMap(fis, m); ! } } catch(Exception e) { if (e instanceof InvalidPreferencesFormatException) { getLogger().warning("Invalid preferences format in " + prefsFile.getPath()); prefsFile.renameTo( new File(
*** 616,628 **** public Void run() throws BackingStoreException { try { if (!dir.exists() && !dir.mkdirs()) throw new BackingStoreException(dir + " create failed."); ! FileOutputStream fos = new FileOutputStream(tmpFile); XmlSupport.exportMap(fos, prefsCache); ! fos.close(); if (!tmpFile.renameTo(prefsFile)) throw new BackingStoreException("Can't rename " + tmpFile + " to " + prefsFile); } catch(Exception e) { if (e instanceof BackingStoreException) --- 616,628 ---- public Void run() throws BackingStoreException { try { if (!dir.exists() && !dir.mkdirs()) throw new BackingStoreException(dir + " create failed."); ! try (FileOutputStream fos = new FileOutputStream(tmpFile)) { XmlSupport.exportMap(fos, prefsCache); ! } if (!tmpFile.renameTo(prefsFile)) throw new BackingStoreException("Can't rename " + tmpFile + " to " + prefsFile); } catch(Exception e) { if (e instanceof BackingStoreException)