src/share/classes/sun/rmi/log/ReliableLog.java

Print this page

        

*** 116,126 **** * sun.rmi.log.class is non-null and the class specified by this * property a) can be loaded, b) is a subclass of LogFile, and c) has a * public two-arg constructor (String, String), ReliableLog uses the * constructor to construct the LogFile. **/ ! private static final Constructor<? extends LogFile> logClassConstructor = getLogClassConstructor(); /** * Creates a ReliableLog to handle checkpoints and logging in a * stable storage directory. --- 116,126 ---- * sun.rmi.log.class is non-null and the class specified by this * property a) can be loaded, b) is a subclass of LogFile, and c) has a * public two-arg constructor (String, String), ReliableLog uses the * constructor to construct the LogFile. **/ ! private static final Constructor<?> logClassConstructor = getLogClassConstructor(); /** * Creates a ReliableLog to handle checkpoints and logging in a * stable storage directory.
*** 342,355 **** new PrivilegedAction<ClassLoader>() { public ClassLoader run() { return ClassLoader.getSystemClassLoader(); } }); ! Class cl = loader.loadClass(logClassName); ! if (LogFile.class.isAssignableFrom(cl)) { return cl.getConstructor(String.class, String.class); - } } catch (Exception e) { System.err.println("Exception occurred:"); e.printStackTrace(); } } --- 342,354 ---- new PrivilegedAction<ClassLoader>() { public ClassLoader run() { return ClassLoader.getSystemClassLoader(); } }); ! Class<? extends LogFile> cl = ! loader.loadClass(logClassName).asSubclass(LogFile.class); return cl.getConstructor(String.class, String.class); } catch (Exception e) { System.err.println("Exception occurred:"); e.printStackTrace(); } }
*** 543,553 **** logName = versionName(logfilePrefix); try { log = (logClassConstructor == null ? new LogFile(logName, "rw") : ! logClassConstructor.newInstance(logName, "rw")); } catch (Exception e) { throw (IOException) new IOException( "unable to construct LogFile instance").initCause(e); } --- 542,552 ---- logName = versionName(logfilePrefix); try { log = (logClassConstructor == null ? new LogFile(logName, "rw") : ! (LogFile)logClassConstructor.newInstance(logName, "rw")); } catch (Exception e) { throw (IOException) new IOException( "unable to construct LogFile instance").initCause(e); }
*** 593,607 **** if (newVersion) { name = newVersionFile; } else { name = versionFile; } ! DataOutputStream out = ! new DataOutputStream(new FileOutputStream(fName(name))); writeInt(out, version); - out.close(); } /** * Creates the initial version file * * @exception IOException If an I/O error has occurred. --- 592,606 ---- if (newVersion) { name = newVersionFile; } else { name = versionFile; } ! try (FileOutputStream fos = new FileOutputStream(fName(name)); ! DataOutputStream out = new DataOutputStream(fos)) { writeInt(out, version); } + } /** * Creates the initial version file * * @exception IOException If an I/O error has occurred.
*** 627,641 **** * @param name the name of the version file * @return the version * @exception IOException If an I/O error has occurred. */ private int readVersion(String name) throws IOException { ! DataInputStream in = new DataInputStream(new FileInputStream(name)); ! try { return in.readInt(); - } finally { - in.close(); } } /** * Sets the version. If version file does not exist, the initial --- 626,638 ---- * @param name the name of the version file * @return the version * @exception IOException If an I/O error has occurred. */ private int readVersion(String name) throws IOException { ! try (DataInputStream in = new DataInputStream ! (new FileInputStream(name))) { return in.readInt(); } } /** * Sets the version. If version file does not exist, the initial