提交 f6940b7f authored 作者: Thomas Mueller's avatar Thomas Mueller

The database now tries to detect if the classloader or virtual machine has almost shut down.

上级 875a893f
......@@ -17,6 +17,19 @@ import org.h2.store.DiskFile;
*/
public abstract class CacheObject {
/**
* Ensure the class is loaded when initialized, so that sorting is possible
* even when loading new classes is not allowed any more. This can occur
* when stopping a web application.
*/
private static final Comparator CACHE_COMPARATOR = new Comparator() {
public int compare(Object a, Object b) {
int pa = ((CacheObject) a).getPos();
int pb = ((CacheObject) b).getPos();
return pa == pb ? 0 : (pa < pb ? -1 : 1);
}
};
/**
* The previous element in the LRU linked list. If the previous element is
* the head, then this element is the most recently used object.
......@@ -62,13 +75,7 @@ public abstract class CacheObject {
* @param recordList the list of cache objects
*/
public static void sort(ObjectArray recordList) {
recordList.sort(new Comparator() {
public int compare(Object a, Object b) {
int pa = ((CacheObject) a).getPos();
int pb = ((CacheObject) b).getPos();
return pa == pb ? 0 : (pa < pb ? -1 : 1);
}
});
recordList.sort(CACHE_COMPARATOR);
}
public void setBlockCount(int size) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论