1
0

Formatting of try/catch blocks.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/logging/trunk@1432686 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Neidhart
2013-01-13 18:10:17 +00:00
parent 3a6a6f49ad
commit ea228ebb43

View File

@@ -319,7 +319,7 @@ public abstract class LogFactory {
String storeImplementationClass; String storeImplementationClass;
try { try {
storeImplementationClass = getSystemProperty(HASHTABLE_IMPLEMENTATION_PROPERTY, null); storeImplementationClass = getSystemProperty(HASHTABLE_IMPLEMENTATION_PROPERTY, null);
} catch(SecurityException ex) { } catch (SecurityException ex) {
// Permissions don't allow this to be accessed. Default to the "modern" // Permissions don't allow this to be accessed. Default to the "modern"
// weak hashtable implementation if it is available. // weak hashtable implementation if it is available.
storeImplementationClass = null; storeImplementationClass = null;
@@ -477,7 +477,7 @@ public abstract class LogFactory {
"]. Trying alternative implementations..."); "]. Trying alternative implementations...");
} }
// ignore // ignore
} catch(RuntimeException e) { } catch (RuntimeException e) {
// This is not consistent with the behaviour when a bad LogFactory class is // This is not consistent with the behaviour when a bad LogFactory class is
// specified in a services file. // specified in a services file.
// //
@@ -534,7 +534,7 @@ public abstract class LogFactory {
logDiagnostic("[LOOKUP] No resource file with name '" + SERVICE_ID + "' found."); logDiagnostic("[LOOKUP] No resource file with name '" + SERVICE_ID + "' found.");
} }
} }
} catch( Exception ex ) { } catch (Exception ex) {
// note: if the specified LogFactory class wasn't compatible with LogFactory // note: if the specified LogFactory class wasn't compatible with LogFactory
// for some reason, a ClassCastException will be caught here, and attempts will // for some reason, a ClassCastException will be caught here, and attempts will
// continue to find a compatible class. // continue to find a compatible class.
@@ -737,7 +737,7 @@ public abstract class LogFactory {
protected static ClassLoader getClassLoader(Class clazz) { protected static ClassLoader getClassLoader(Class clazz) {
try { try {
return clazz.getClassLoader(); return clazz.getClassLoader();
} catch(SecurityException ex) { } catch (SecurityException ex) {
if (isDiagnosticsEnabled()) { if (isDiagnosticsEnabled()) {
logDiagnostic("Unable to get classloader for class '" + clazz + logDiagnostic("Unable to get classloader for class '" + clazz +
"' due to security restrictions - " + ex.getMessage()); "' due to security restrictions - " + ex.getMessage());
@@ -1085,7 +1085,7 @@ public abstract class LogFactory {
throw e; throw e;
} }
// ignore exception, continue // ignore exception, continue
} catch(ClassCastException e) { } catch (ClassCastException e) {
if (classLoader == thisClassLoader) { if (classLoader == thisClassLoader) {
// There's no point in falling through to the code below that // There's no point in falling through to the code below that
// tries again with thisClassLoader, because we've just tried // tries again with thisClassLoader, because we've just tried
@@ -1283,13 +1283,13 @@ public abstract class LogFactory {
} else { } else {
return ClassLoader.getSystemResources(name); return ClassLoader.getSystemResources(name);
} }
} catch(IOException e) { } catch (IOException e) {
if (isDiagnosticsEnabled()) { if (isDiagnosticsEnabled()) {
logDiagnostic("Exception while trying to find configuration file " + logDiagnostic("Exception while trying to find configuration file " +
name + ":" + e.getMessage()); name + ":" + e.getMessage());
} }
return null; return null;
} catch(NoSuchMethodError e) { } catch (NoSuchMethodError e) {
// we must be running on a 1.1 JVM which doesn't support // we must be running on a 1.1 JVM which doesn't support
// ClassLoader.getSystemResources; just return null in // ClassLoader.getSystemResources; just return null in
// this case. // this case.
@@ -1328,7 +1328,7 @@ public abstract class LogFactory {
stream = null; stream = null;
return props; return props;
} }
} catch(IOException e) { } catch (IOException e) {
if (isDiagnosticsEnabled()) { if (isDiagnosticsEnabled()) {
logDiagnostic("Unable to read URL " + url); logDiagnostic("Unable to read URL " + url);
} }
@@ -1336,7 +1336,7 @@ public abstract class LogFactory {
if (stream != null) { if (stream != null) {
try { try {
stream.close(); stream.close();
} catch(Throwable t) { } catch (Throwable t) {
// ignore exception; this should not happen // ignore exception; this should not happen
if (isDiagnosticsEnabled()) { if (isDiagnosticsEnabled()) {
logDiagnostic("Unable to close stream for URL " + url); logDiagnostic("Unable to close stream for URL " + url);
@@ -1478,7 +1478,7 @@ public abstract class LogFactory {
if (dest == null) { if (dest == null) {
return null; return null;
} }
} catch(SecurityException ex) { } catch (SecurityException ex) {
// We must be running in some very secure environment. // We must be running in some very secure environment.
// We just have to assume output is not wanted.. // We just have to assume output is not wanted..
return null; return null;
@@ -1493,7 +1493,7 @@ public abstract class LogFactory {
// open the file in append mode // open the file in append mode
FileOutputStream fos = new FileOutputStream(dest, true); FileOutputStream fos = new FileOutputStream(dest, true);
return new PrintStream(fos); return new PrintStream(fos);
} catch(IOException ex) { } catch (IOException ex) {
// We should report this to the user - but how? // We should report this to the user - but how?
return null; return null;
} }
@@ -1580,7 +1580,7 @@ public abstract class LogFactory {
// these variables then we do not want to output them to the diagnostic stream. // these variables then we do not want to output them to the diagnostic stream.
logDiagnostic("[ENV] Extension directories (java.ext.dir): " + System.getProperty("java.ext.dir")); logDiagnostic("[ENV] Extension directories (java.ext.dir): " + System.getProperty("java.ext.dir"));
logDiagnostic("[ENV] Application classpath (java.class.path): " + System.getProperty("java.class.path")); logDiagnostic("[ENV] Application classpath (java.class.path): " + System.getProperty("java.class.path"));
} catch(SecurityException ex) { } catch (SecurityException ex) {
logDiagnostic("[ENV] Security setting prevent interrogation of system classpaths."); logDiagnostic("[ENV] Security setting prevent interrogation of system classpaths.");
} }
@@ -1589,7 +1589,7 @@ public abstract class LogFactory {
try { try {
classLoader = getClassLoader(clazz); classLoader = getClassLoader(clazz);
} catch(SecurityException ex) { } catch (SecurityException ex) {
// not much useful diagnostics we can print here! // not much useful diagnostics we can print here!
logDiagnostic("[ENV] Security forbids determining the classloader for " + className); logDiagnostic("[ENV] Security forbids determining the classloader for " + className);
return; return;
@@ -1618,7 +1618,7 @@ public abstract class LogFactory {
try { try {
systemClassLoader = ClassLoader.getSystemClassLoader(); systemClassLoader = ClassLoader.getSystemClassLoader();
} catch(SecurityException ex) { } catch (SecurityException ex) {
logDiagnostic(prefix + "Security forbids determining the system classloader."); logDiagnostic(prefix + "Security forbids determining the system classloader.");
return; return;
} }
@@ -1632,7 +1632,7 @@ public abstract class LogFactory {
try { try {
classLoader = classLoader.getParent(); classLoader = classLoader.getParent();
} catch(SecurityException ex) { } catch (SecurityException ex) {
buf.append(" --> SECRET"); buf.append(" --> SECRET");
break; break;
} }
@@ -1707,7 +1707,7 @@ public abstract class LogFactory {
} else { } else {
classLoaderName = objectId(classLoader); classLoaderName = objectId(classLoader);
} }
} catch(SecurityException e) { } catch (SecurityException e) {
classLoaderName = "UNKNOWN"; classLoaderName = "UNKNOWN";
} }
diagnosticPrefix = "[LogFactory from " + classLoaderName + "] "; diagnosticPrefix = "[LogFactory from " + classLoaderName + "] ";