Browse Source

Merge pull request #8821 in CORE/base-third from feature/x to bugfix/11.0

* commit '152ec648e98065b6e24359fd98e4d6551a479929':
  REPORT-94814 备份还原报错npe
  REPORT-93688 REPORT-94439 创建hsql连接超时
  REPORT-93688 REPORT-94439 创建hsql连接超时
bugfix/11.0
superman 2 years ago
parent
commit
7178540ccd
  1. 2
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/engine/internal/StatefulPersistenceContext.java
  2. 71
      fine-hsqldb/src/main/java/com/fr/third/org/hsqldb/lib/FrameworkLogger.java

2
fine-hibernate/src/main/java/com/fr/third/org/hibernate/engine/internal/StatefulPersistenceContext.java

@ -223,7 +223,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
for ( Entry<Object, EntityEntry> objectEntityEntryEntry : entityEntryContext.reentrantSafeEntityEntries() ) { for ( Entry<Object, EntityEntry> objectEntityEntryEntry : entityEntryContext.reentrantSafeEntityEntries() ) {
// todo : I dont think this need be reentrant safe // todo : I dont think this need be reentrant safe
if ( objectEntityEntryEntry.getKey() instanceof PersistentAttributeInterceptable ) { if ( objectEntityEntryEntry != null && objectEntityEntryEntry.getKey() instanceof PersistentAttributeInterceptable ) {
final PersistentAttributeInterceptor interceptor = ( (PersistentAttributeInterceptable) objectEntityEntryEntry.getKey() ).$$_hibernate_getInterceptor(); final PersistentAttributeInterceptor interceptor = ( (PersistentAttributeInterceptable) objectEntityEntryEntry.getKey() ).$$_hibernate_getInterceptor();
if ( interceptor instanceof LazyAttributeLoadingInterceptor ) { if ( interceptor instanceof LazyAttributeLoadingInterceptor ) {
( (LazyAttributeLoadingInterceptor) interceptor ).unsetSession(); ( (LazyAttributeLoadingInterceptor) interceptor ).unsetSession();

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

@ -50,35 +50,35 @@ import java.lang.reflect.InvocationTargetException;
/** /**
* A logging framework wrapper that supports java.util.logging and log4j. * A logging framework wrapper that supports java.util.logging and log4j.
* <P/> * <p/>
* Logger hierarchies are stored at the Class level. * Logger hierarchies are stored at the Class level.
* Log4j will be used if the Log4j system (not necessarily config files) are * Log4j will be used if the Log4j system (not necessarily config files) are
* found in the runtime classpath. * found in the runtime classpath.
* Otherwise, java.util.logging will be used. * Otherwise, java.util.logging will be used.
* <P/> * <p/>
* This is pretty safe because for use cases where multiple hierarchies * This is pretty safe because for use cases where multiple hierarchies
* are desired, classloader hierarchies will effectively isolate multiple * are desired, classloader hierarchies will effectively isolate multiple
* class-level Logger hierarchies. * class-level Logger hierarchies.
* <P/> * <p/>
* Sad as it is, the java.util.logging facility lacks the most basic * Sad as it is, the java.util.logging facility lacks the most basic
* developer-side and configuration-side capabilities. * developer-side and configuration-side capabilities.
* Besides having a non-scalable discovery system, the designers didn't * Besides having a non-scalable discovery system, the designers didn't
* comprehend the need for a level between WARNING and SEVERE! * comprehend the need for a level between WARNING and SEVERE!
* Since we don't want to require log4j in Classpath, we have to live * Since we don't want to require log4j in Classpath, we have to live
* with these constraints. * with these constraints.
* <P/> * <p/>
* As with all the popular logging frameworks, if you want to capture a * As with all the popular logging frameworks, if you want to capture a
* stack trace, you must use the two-parameters logging methods. * stack trace, you must use the two-parameters logging methods.
* I.e., you must also pass a String, or only toString() from your * I.e., you must also pass a String, or only toString() from your
* throwable will be captured. * throwable will be captured.
* <P/> * <p/>
* Usage example:<CODE><PRE> * Usage example:<CODE><PRE>
* private static FrameworkLogger logger = * private static FrameworkLogger logger =
* FrameworkLogger.getLog(SqlTool.class); * FrameworkLogger.getLog(SqlTool.class);
* ... * ...
* logger.finer("Doing something log-worthy"); * logger.finer("Doing something log-worthy");
* </PRE> </CODE> * </PRE> </CODE>
* * <p>
* <p/> * <p/>
* The system level property <code>hsqldb.reconfig_logging=false</code> is * The system level property <code>hsqldb.reconfig_logging=false</code> is
* required to avoid configuration of java.util.logging. Otherwise * required to avoid configuration of java.util.logging. Otherwise
@ -131,7 +131,8 @@ public class FrameworkLogger {
static { static {
try { try {
reconfigure(); reconfigure();
} catch (SecurityException e) {} } catch (SecurityException e) {
}
} }
/** /**
@ -169,32 +170,32 @@ public class FrameworkLogger {
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 +220,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,15 +233,15 @@ 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
// Log4j or Jdk Logger objects (to wrap). // Log4j or Jdk Logger objects (to wrap).
@ -272,7 +273,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,15 +285,15 @@ 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
// Log4j or Jdk Logger objects (to wrap). // Log4j or Jdk Logger objects (to wrap).
callerFqcnAvailable = true; callerFqcnAvailable = true;
@ -350,7 +351,7 @@ public class FrameworkLogger {
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);
@ -397,7 +398,7 @@ 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);
@ -412,7 +413,7 @@ public class FrameworkLogger {
/** /**
* User's entry-point into this logging system. * User's entry-point into this logging system.
* <P/> * <p/>
* You normally want to work with static (class-level) pointers to * You normally want to work with static (class-level) pointers to
* logger instances, for performance efficiency. * logger instances, for performance efficiency.
* See the class-level JavaDoc for a usage example. * See the class-level JavaDoc for a usage example.
@ -508,10 +509,10 @@ 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) {
@ -539,10 +540,10 @@ public class FrameworkLogger {
} else { } else {
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}
); );
@ -679,7 +680,7 @@ public class FrameworkLogger {
/** /**
* Whether this JVM is configured with java.util.logging defaults. * Whether this JVM is configured with java.util.logging defaults.
* * <p>
* If the JRE-provided config file is not in the expected place, then * If the JRE-provided config file is not in the expected place, then
* we return false. * we return false.
*/ */

Loading…
Cancel
Save