Fix for bug #168064, crash when ~/Library/Logs doesn't exist. r=bnesse, sr=sfraser, a=rjesup@wgate.com.

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_0_BRANCH@129402 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
beard%netscape.com
2002-09-12 19:55:33 +00:00
parent b2fbc6f6a8
commit 90e229ebb8
2 changed files with 27 additions and 14 deletions

View File

@@ -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;
}

View File

@@ -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();
}
}