Browse Source

REPORT-93688 REPORT-94439 创建hsql连接超时

release/10.0
lidongy 2 years ago
parent
commit
77c4157e27
  1. 110
      fine-hsqldb/src/main/java/com/fr/third/org/hsqldb/lib/FrameworkLogger.java

110
fine-hsqldb/src/main/java/com/fr/third/org/hsqldb/lib/FrameworkLogger.java

@ -113,8 +113,8 @@ public class FrameworkLogger {
public static synchronized String report() { public static synchronized String report() {
return new StringBuilder().append(loggerInstances.size()).append( return new StringBuilder().append(loggerInstances.size()).append(
" logger instances: ").append( " logger instances: ").append(
loggerInstances.keySet()).toString(); loggerInstances.keySet()).toString();
} }
static private Map loggerInstances = new HashMap(); static private Map loggerInstances = new HashMap();
@ -165,36 +165,36 @@ public class FrameworkLogger {
} }
private static synchronized void private static synchronized void
populateJdkToLog4jLevels(String classString) populateJdkToLog4jLevels(String classString)
throws ClassNotFoundException, IllegalAccessException, throws ClassNotFoundException, IllegalAccessException,
NoSuchMethodException, InvocationTargetException { NoSuchMethodException, InvocationTargetException {
Method log4jToLevel = Class.forName(classString).getMethod( Method log4jToLevel = Class.forName(classString).getMethod(
"toLevel", new Class[]{ String.class }); "toLevel", new Class[]{ String.class });
jdkToLog4jLevels.put(Level.ALL, jdkToLog4jLevels.put(Level.ALL,
log4jToLevel.invoke(null, log4jToLevel.invoke(null,
new Object[]{ "ALL" })); new Object[]{ "ALL" }));
jdkToLog4jLevels.put(Level.FINER, jdkToLog4jLevels.put(Level.FINER,
log4jToLevel.invoke(null, log4jToLevel.invoke(null,
new Object[]{ "DEBUG" })); new Object[]{ "DEBUG" }));
jdkToLog4jLevels.put(Level.WARNING, jdkToLog4jLevels.put(Level.WARNING,
log4jToLevel.invoke(null, log4jToLevel.invoke(null,
new Object[]{ "ERROR" })); new Object[]{ "ERROR" }));
jdkToLog4jLevels.put(Level.SEVERE, jdkToLog4jLevels.put(Level.SEVERE,
log4jToLevel.invoke(null, log4jToLevel.invoke(null,
new Object[]{ "FATAL" })); new Object[]{ "FATAL" }));
jdkToLog4jLevels.put(Level.INFO, jdkToLog4jLevels.put(Level.INFO,
log4jToLevel.invoke(null, log4jToLevel.invoke(null,
new Object[]{ "INFO" })); new Object[]{ "INFO" }));
jdkToLog4jLevels.put(Level.OFF, jdkToLog4jLevels.put(Level.OFF,
log4jToLevel.invoke(null, log4jToLevel.invoke(null,
new Object[]{ "OFF" })); new Object[]{ "OFF" }));
jdkToLog4jLevels.put(Level.FINEST, jdkToLog4jLevels.put(Level.FINEST,
log4jToLevel.invoke(null, log4jToLevel.invoke(null,
new Object[]{ "TRACE" })); new Object[]{ "TRACE" }));
jdkToLog4jLevels.put(Level.WARNING, jdkToLog4jLevels.put(Level.WARNING,
log4jToLevel.invoke(null, log4jToLevel.invoke(null,
new Object[]{ "WARN" })); new Object[]{ "WARN" }));
} }
static void reconfigure() { static void reconfigure() {
@ -219,9 +219,9 @@ public class FrameworkLogger {
try { try {
// log4j v2 available? // log4j v2 available?
log4jLoggerClass = Class.forName( log4jLoggerClass = Class.forName(
"org.apache.logging.log4j.Logger"); "com.fr.third.apache.logging.log4j.Logger");
log4jManagerClass = Class.forName( log4jManagerClass = Class.forName(
"org.apache.logging.log4j.LogManager"); "com.fr.third.apache.logging.log4j.LogManager");
} catch (Exception e) { } catch (Exception e) {
// The class will only load successfully if Log4j v2 thinks it is // The class will only load successfully if Log4j v2 thinks it is
@ -232,13 +232,13 @@ public class FrameworkLogger {
// Attempt to configure log4j v2 // Attempt to configure log4j v2
if (log4jLoggerClass != null) { if (log4jLoggerClass != null) {
try { try {
populateJdkToLog4jLevels("org.apache.logging.log4j.Level"); populateJdkToLog4jLevels("com.fr.third.apache.logging.log4j.Level");
log4jLogMethod = log4jLoggerClass.getMethod("log", log4jLogMethod = log4jLoggerClass.getMethod("log",
new Class[] { new Class[] {
Class.forName("org.apache.logging.log4j.Level"), Class.forName("com.fr.third.apache.logging.log4j.Level"),
Object.class, Throwable.class Object.class, Throwable.class
}); });
log4jGetLogger = log4jManagerClass.getMethod("getLogger", log4jGetLogger = log4jManagerClass.getMethod("getLogger",
new Class[]{ String.class }); new Class[]{ String.class });
// This last object is what we toggle on to generate either // This last object is what we toggle on to generate either
@ -251,8 +251,8 @@ public class FrameworkLogger {
// successfully initialized with warnings due to bad config). // successfully initialized with warnings due to bad config).
try { try {
System.err.println( System.err.println(
"<clinit> failure " "<clinit> failure "
+ "instantiating configured Log4j v2 system: " + e); + "instantiating configured Log4j v2 system: " + e);
// It's possible we don't have write access to System.err. // It's possible we don't have write access to System.err.
} catch (Throwable t) { } catch (Throwable t) {
@ -272,7 +272,7 @@ public class FrameworkLogger {
try { try {
// log4j v1 available? // log4j v1 available?
log4jLoggerClass = Class.forName("org.apache.log4j.Logger"); log4jLoggerClass = Class.forName("com.fr.third.apache.log4j.Logger");
log4jManagerClass = log4jLoggerClass; log4jManagerClass = log4jLoggerClass;
} catch (Exception e) { } catch (Exception e) {
@ -284,13 +284,13 @@ public class FrameworkLogger {
// Attempt to configure log4j v1 // Attempt to configure log4j v1
if (log4jLoggerClass != null) { if (log4jLoggerClass != null) {
try { try {
populateJdkToLog4jLevels("org.apache.log4j.Level"); populateJdkToLog4jLevels("com.fr.third.apache.log4j.Level");
log4jLogMethod = log4jLoggerClass.getMethod("log", log4jLogMethod = log4jLoggerClass.getMethod("log",
new Class[] { new Class[] {
String.class, Class.forName("org.apache.log4j.Priority"), String.class, Class.forName("com.fr.third.apache.log4j.Priority"),
Object.class, Throwable.class Object.class, Throwable.class
}); });
log4jGetLogger = log4jManagerClass.getMethod("getLogger", log4jGetLogger = log4jManagerClass.getMethod("getLogger",
new Class[]{ String.class }); new Class[]{ String.class });
// This last object is what we toggle on to generate either // This last object is what we toggle on to generate either
@ -304,8 +304,8 @@ public class FrameworkLogger {
// successfully initialized with warnings due to bad config). // successfully initialized with warnings due to bad config).
try { try {
System.err.println( System.err.println(
"<clinit> failure " "<clinit> failure "
+ "instantiating configured Log4j v1 system: " + e); + "instantiating configured Log4j v1 system: " + e);
// It's possible we don't have write access to System.err. // It's possible we don't have write access to System.err.
} catch (Throwable t) { } catch (Throwable t) {
@ -343,14 +343,14 @@ public class FrameworkLogger {
ConsoleHandler consoleHandler = new ConsoleHandler(); ConsoleHandler consoleHandler = new ConsoleHandler();
consoleHandler.setFormatter( consoleHandler.setFormatter(
new BasicTextJdkLogFormatter(false)); new BasicTextJdkLogFormatter(false));
consoleHandler.setLevel(Level.INFO); consoleHandler.setLevel(Level.INFO);
istream = FrameworkLogger.class.getResourceAsStream(path); istream = FrameworkLogger.class.getResourceAsStream(path);
lm.readConfiguration(istream); lm.readConfiguration(istream);
Logger cmdlineLogger = Logger.getLogger("org.hsqldb.cmdline"); Logger cmdlineLogger = Logger.getLogger("com.fr.third.org.hsqldb.cmdline");
cmdlineLogger.addHandler(consoleHandler); cmdlineLogger.addHandler(consoleHandler);
cmdlineLogger.setUseParentHandlers(false); cmdlineLogger.setUseParentHandlers(false);
@ -371,8 +371,8 @@ public class FrameworkLogger {
noopMode = true; noopMode = true;
System.err.println( System.err.println(
"<clinit> failure initializing JDK logging system. " "<clinit> failure initializing JDK logging system. "
+ "Continuing without Application logging."); + "Continuing without Application logging.");
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
if (istream != null) { if (istream != null) {
@ -380,7 +380,7 @@ public class FrameworkLogger {
istream.close(); istream.close();
} catch (IOException ioe) { } catch (IOException ioe) {
System.err.println("Failed to close logging input stream: " System.err.println("Failed to close logging input stream: "
+ ioe); + ioe);
} }
} }
} }
@ -397,10 +397,10 @@ public class FrameworkLogger {
} else { } else {
try { try {
log4jLogger = log4jGetLogger.invoke(null, log4jLogger = log4jGetLogger.invoke(null,
new Object[]{ s }); new Object[]{ s });
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException( throw new RuntimeException(
"Failed to instantiate Log4j Logger", e); "Failed to instantiate Log4j Logger", e);
} }
} }
} }
@ -431,7 +431,7 @@ public class FrameworkLogger {
*/ */
public static FrameworkLogger getLog(Class c, String contextId) { public static FrameworkLogger getLog(Class c, String contextId) {
return (contextId == null) ? getLog(c) return (contextId == null) ? getLog(c)
: getLog(contextId + '.' + c.getName()); : getLog(contextId + '.' + c.getName());
} }
/** /**
@ -442,7 +442,7 @@ public class FrameworkLogger {
*/ */
public static FrameworkLogger getLog(String baseId, String contextId) { public static FrameworkLogger getLog(String baseId, String contextId) {
return (contextId == null) ? getLog(baseId) return (contextId == null) ? getLog(baseId)
: getLog(contextId + '.' + baseId); : getLog(contextId + '.' + baseId);
} }
/** /**
@ -508,15 +508,15 @@ public class FrameworkLogger {
} else { } else {
try { try {
log4jLogMethod.invoke(log4jLogger, callerFqcnAvailable log4jLogMethod.invoke(log4jLogger, callerFqcnAvailable
? new Object[] { ? new Object[] {
skipClass.getName(), jdkToLog4jLevels.get(level), skipClass.getName(), jdkToLog4jLevels.get(level),
message, t} message, t}
: new Object[] { : new Object[] {
jdkToLog4jLevels.get(level), message, t} jdkToLog4jLevels.get(level), message, t}
); );
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException( throw new RuntimeException(
"Logging failed when attempting to log: " + message, e); "Logging failed when attempting to log: " + message, e);
} }
} }
} }
@ -540,16 +540,16 @@ public class FrameworkLogger {
try { try {
log4jLogMethod.invoke(log4jLogger, callerFqcnAvailable log4jLogMethod.invoke(log4jLogger, callerFqcnAvailable
? new Object[] { ? new Object[] {
FrameworkLogger.class.getName(), FrameworkLogger.class.getName(),
jdkToLog4jLevels.get(level), message, null} jdkToLog4jLevels.get(level), message, null}
: new Object[] { : new Object[] {
jdkToLog4jLevels.get(level), message, null} jdkToLog4jLevels.get(level), message, null}
); );
// Test where SqlFile correct here. // Test where SqlFile correct here.
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException( throw new RuntimeException(
"Logging failed when attempting to log: " + message, e); "Logging failed when attempting to log: " + message, e);
} }
} }
} }
@ -686,7 +686,7 @@ public class FrameworkLogger {
public static boolean isDefaultJdkConfig() { public static boolean isDefaultJdkConfig() {
File globalCfgFile = new File(System.getProperty("java.home"), File globalCfgFile = new File(System.getProperty("java.home"),
"lib/logging.properties"); "lib/logging.properties");
if (!globalCfgFile.isFile()) { if (!globalCfgFile.isFile()) {
return false; return false;

Loading…
Cancel
Save