From ec974c7b99b0d436189fa31046c6fe00d5c78b03 Mon Sep 17 00:00:00 2001 From: "beard%netscape.com" Date: Thu, 12 Sep 2002 06:33:49 +0000 Subject: [PATCH] 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 --- .../MRJCarbon/plugin/Source/MRJSession.cpp | 12 ++++++-- .../MRJCarbon/plugin/Source/MRJSession.java | 29 ++++++++++++------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/mozilla/plugin/oji/MRJCarbon/plugin/Source/MRJSession.cpp b/mozilla/plugin/oji/MRJCarbon/plugin/Source/MRJSession.cpp index be998bfe315..d18c09fc05b 100644 --- a/mozilla/plugin/oji/MRJCarbon/plugin/Source/MRJSession.cpp +++ b/mozilla/plugin/oji/MRJCarbon/plugin/Source/MRJSession.cpp @@ -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; } diff --git a/mozilla/plugin/oji/MRJCarbon/plugin/Source/MRJSession.java b/mozilla/plugin/oji/MRJCarbon/plugin/Source/MRJSession.java index 183384925ed..1f43ed18d3b 100644 --- a/mozilla/plugin/oji/MRJCarbon/plugin/Source/MRJSession.java +++ b/mozilla/plugin/oji/MRJCarbon/plugin/Source/MRJSession.java @@ -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(); } }