src/share/classes/sun/rmi/log/ReliableLog.java
Print this page
*** 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();
}
}
*** 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 (FileInputStream fis = new FileInputStream(name);
! DataInputStream in = new DataInputStream(fis)) {
return in.readInt();
}
}
/**
* Sets the version. If version file does not exist, the initial