Fix for bug #168064, crash when ~/Library/Logs doesn't exist. r=bnesse, sr=sfraser
git-svn-id: svn://10.0.0.236/trunk@129323 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -254,10 +254,16 @@ OSStatus MRJSession::open(const char* consolePath)
|
||||
jstring path = env->NewStringUTF(consolePath);
|
||||
if (path) {
|
||||
env->CallStaticVoidMethod(session, openMethod, path);
|
||||
if (env->ExceptionCheck())
|
||||
env->ExceptionClear();
|
||||
env->DeleteLocalRef(path);
|
||||
}
|
||||
} else {
|
||||
env->ExceptionClear();
|
||||
}
|
||||
env->DeleteLocalRef(session);
|
||||
} else {
|
||||
env->ExceptionClear();
|
||||
}
|
||||
|
||||
if (mStatus == noErr)
|
||||
@@ -266,11 +272,9 @@ OSStatus MRJSession::open(const char* consolePath)
|
||||
#if REDIRECT_VFPRINTF
|
||||
// XXX test the vfprintf function.
|
||||
jclass notThere = env->FindClass("class/not/Found");
|
||||
jobject throwable = env->ExceptionOccurred();
|
||||
if (throwable) {
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionDescribe();
|
||||
env->ExceptionClear();
|
||||
env->DeleteLocalRef(throwable);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -294,6 +298,8 @@ OSStatus MRJSession::close()
|
||||
jmethodID closeMethod = env->GetStaticMethodID(session, "close", "()V");
|
||||
if (closeMethod)
|
||||
env->CallStaticVoidMethod(session, closeMethod);
|
||||
else
|
||||
env->ExceptionClear();
|
||||
env->DeleteGlobalRef(mSession);
|
||||
mSession = NULL;
|
||||
}
|
||||
|
||||
@@ -50,10 +50,10 @@ import java.net.URL;
|
||||
* integrating with the Netscape 6 security system.
|
||||
*/
|
||||
public class MRJSession {
|
||||
// Save primordial System streams.
|
||||
private static PrintStream out;
|
||||
private static PrintStream err;
|
||||
private static PrintStream console;
|
||||
// Save primordial System streams.
|
||||
private static PrintStream out;
|
||||
private static PrintStream err;
|
||||
private static PrintStream console;
|
||||
|
||||
private static Properties loadProperties(String pluginHome) {
|
||||
Properties props = new Properties();
|
||||
@@ -71,12 +71,19 @@ public class MRJSession {
|
||||
Properties props = loadProperties(pluginHome);
|
||||
boolean append = Boolean.valueOf(props.getProperty("netscape.oji.plugin.console.append")).booleanValue();
|
||||
|
||||
// redirect I/O to specified file.
|
||||
MRJSession.out = System.out;
|
||||
MRJSession.err = System.err;
|
||||
// Make sure the parent directories exist.
|
||||
File consoleFile = new File(consolePath);
|
||||
File parentFile = consoleFile.getParentFile();
|
||||
if (!parentFile.exists()) {
|
||||
parentFile.mkdirs();
|
||||
}
|
||||
|
||||
// redirect console I/O to specified file.
|
||||
MRJSession.out = System.out;
|
||||
MRJSession.err = System.err;
|
||||
console = new PrintStream(new FileOutputStream(consolePath, append));
|
||||
System.setOut(console);
|
||||
System.setErr(console);
|
||||
System.setOut(console);
|
||||
System.setErr(console);
|
||||
|
||||
Date date = new Date();
|
||||
String version = props.getProperty("netscape.oji.plugin.version");
|
||||
@@ -98,8 +105,8 @@ public class MRJSession {
|
||||
}
|
||||
|
||||
public static void close() throws IOException {
|
||||
System.setOut(MRJSession.out);
|
||||
System.setErr(MRJSession.err);
|
||||
System.setOut(MRJSession.out);
|
||||
System.setErr(MRJSession.err);
|
||||
console.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user