Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c58f4eaa
提交
c58f4eaa
authored
9月 11, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid catching Throwable.
上级
d8c3a8fb
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
92 行增加
和
28 行删除
+92
-28
Command.java
h2/src/main/org/h2/command/Command.java
+3
-4
Database.java
h2/src/main/org/h2/engine/Database.java
+22
-9
SessionRemote.java
h2/src/main/org/h2/engine/SessionRemote.java
+3
-1
LogFile.java
h2/src/main/org/h2/log/LogFile.java
+1
-1
LogSystem.java
h2/src/main/org/h2/log/LogSystem.java
+3
-4
Message.java
h2/src/main/org/h2/message/Message.java
+36
-4
TcpServer.java
h2/src/main/org/h2/server/TcpServer.java
+3
-1
TcpServerThread.java
h2/src/main/org/h2/server/TcpServerThread.java
+6
-1
TableData.java
h2/src/main/org/h2/table/TableData.java
+8
-2
MemoryUtils.java
h2/src/main/org/h2/util/MemoryUtils.java
+7
-1
没有找到文件。
h2/src/main/org/h2/command/Command.java
浏览文件 @
c58f4eaa
...
...
@@ -206,9 +206,6 @@ public abstract class Command implements CommandInterface {
database
.
checkPowerOff
();
try
{
return
update
();
}
catch
(
OutOfMemoryError
e
)
{
MemoryUtils
.
freeReserveMemory
();
throw
Message
.
convert
(
e
);
}
catch
(
SQLException
e
)
{
if
(
e
.
getErrorCode
()
==
ErrorCode
.
CONCURRENT_UPDATE_1
)
{
long
now
=
System
.
currentTimeMillis
();
...
...
@@ -227,8 +224,10 @@ public abstract class Command implements CommandInterface {
continue
;
}
throw
e
;
}
catch
(
Throwable
e
)
{
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
catch
(
Throwable
e
)
{
throw
Message
.
convertThrowable
(
e
);
}
}
}
catch
(
SQLException
e
)
{
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
c58f4eaa
...
...
@@ -60,6 +60,7 @@ import org.h2.util.BitField;
import
org.h2.util.ByteUtils
;
import
org.h2.util.ClassUtils
;
import
org.h2.util.FileUtils
;
import
org.h2.util.MemoryUtils
;
import
org.h2.util.NetUtils
;
import
org.h2.util.New
;
import
org.h2.util.ObjectArray
;
...
...
@@ -218,6 +219,7 @@ public class Database implements DataHandler {
private
void
openDatabase
(
int
traceLevelFile
,
int
traceLevelSystemOut
,
boolean
closeAtVmShutdown
)
throws
SQLException
{
try
{
MemoryUtils
.
allocateReserveMemory
();
open
(
traceLevelFile
,
traceLevelSystemOut
);
if
(
closeAtVmShutdown
)
{
try
{
...
...
@@ -234,6 +236,10 @@ public class Database implements DataHandler {
}
}
}
catch
(
Throwable
e
)
{
if
(
e
instanceof
OutOfMemoryError
)
{
MemoryUtils
.
freeReserveMemory
();
e
.
fillInStackTrace
();
}
if
(
traceSystem
!=
null
)
{
if
(
e
instanceof
SQLException
)
{
SQLException
e2
=
(
SQLException
)
e
;
...
...
@@ -245,7 +251,10 @@ public class Database implements DataHandler {
traceSystem
.
close
();
}
closeOpenFilesAndUnlock
(
false
);
throw
Message
.
convert
(
e
);
if
(
e
instanceof
Error
)
{
throw
(
Error
)
e
;
}
throw
Message
.
convert
((
Exception
)
e
);
}
}
...
...
@@ -1157,19 +1166,23 @@ public class Database implements DataHandler {
}
try
{
if
(
systemSession
!=
null
)
{
for
(
Table
table
:
getAllTablesAndViews
())
{
table
.
close
(
systemSession
);
}
for
(
SchemaObject
obj
:
getAllSchemaObjects
(
DbObject
.
SEQUENCE
))
{
Sequence
sequence
=
(
Sequence
)
obj
;
sequence
.
close
();
if
(
powerOffCount
!=
-
1
)
{
for
(
Table
table
:
getAllTablesAndViews
())
{
table
.
close
(
systemSession
);
}
for
(
SchemaObject
obj
:
getAllSchemaObjects
(
DbObject
.
SEQUENCE
))
{
Sequence
sequence
=
(
Sequence
)
obj
;
sequence
.
close
();
}
}
for
(
SchemaObject
obj
:
getAllSchemaObjects
(
DbObject
.
TRIGGER
))
{
TriggerObject
trigger
=
(
TriggerObject
)
obj
;
trigger
.
close
();
}
meta
.
close
(
systemSession
);
systemSession
.
commit
(
true
);
if
(
powerOffCount
!=
-
1
)
{
meta
.
close
(
systemSession
);
systemSession
.
commit
(
true
);
}
indexSummaryValid
=
true
;
}
}
catch
(
SQLException
e
)
{
...
...
h2/src/main/org/h2/engine/SessionRemote.java
浏览文件 @
c58f4eaa
...
...
@@ -314,8 +314,10 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
className
=
StringUtils
.
trim
(
className
,
true
,
true
,
"'"
);
try
{
eventListener
=
(
DatabaseEventListener
)
ClassUtils
.
loadUserClass
(
className
).
newInstance
();
}
catch
(
Throwable
e
)
{
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
catch
(
Throwable
e
)
{
throw
Message
.
convertThrowable
(
e
);
}
}
}
...
...
h2/src/main/org/h2/log/LogFile.java
浏览文件 @
c58f4eaa
...
...
@@ -386,7 +386,7 @@ public class LogFile {
// this is not necessarily at the end of the log file
// set the log system to read only so the current log file stays when closing
logSystem
.
setReadOnly
(
true
);
throw
Message
.
convert
(
e
);
throw
Message
.
convert
Throwable
(
e
);
}
catch
(
Throwable
e
)
{
database
.
getTrace
(
Trace
.
LOG
).
error
(
"Error reading log file (non-fatal)"
,
e
);
// on power loss, sometime there is garbage at the end of the file
...
...
h2/src/main/org/h2/log/LogSystem.java
浏览文件 @
c58f4eaa
...
...
@@ -187,11 +187,10 @@ public class LogSystem {
if
(!
containsInDoubtTransactions
()
&&
checkpoint
)
{
checkpoint
();
}
}
catch
(
SQLException
e
)
{
closeException
=
e
;
}
catch
(
Throwable
e
)
{
// for example out of memory exception
}
catch
(
Exception
e
)
{
closeException
=
Message
.
convert
(
e
);
}
catch
(
Throwable
e
)
{
closeException
=
Message
.
convertThrowable
(
e
);
}
for
(
int
i
=
0
;
i
<
activeLogs
.
size
();
i
++)
{
LogFile
l
=
activeLogs
.
get
(
i
);
...
...
h2/src/main/org/h2/message/Message.java
浏览文件 @
c58f4eaa
...
...
@@ -17,6 +17,7 @@ import java.util.Map.Entry;
import
org.h2.constant.ErrorCode
;
import
org.h2.jdbc.JdbcSQLException
;
import
org.h2.util.MemoryUtils
;
import
org.h2.util.Resources
;
import
org.h2.util.StringUtils
;
...
...
@@ -239,7 +240,7 @@ public class Message {
* @param sql the SQL statement or null if it is not known
* @return the SQL exception object
*/
public
static
SQLException
convert
(
Throwable
e
,
String
sql
)
{
public
static
SQLException
convert
(
Exception
e
,
String
sql
)
{
SQLException
e2
=
convert
(
e
);
if
(
e2
instanceof
JdbcSQLException
)
{
((
JdbcSQLException
)
e2
).
setSQL
(
sql
);
...
...
@@ -247,20 +248,28 @@ public class Message {
return
e2
;
}
/**
* Convert a stack overflow error.
*
* @param e the root cause
* @return the SQL exception object
*/
public
static
SQLException
convert
(
StackOverflowError
e
)
{
return
getSQLException
(
ErrorCode
.
GENERAL_ERROR_1
,
e
);
}
/**
* Convert an exception to a SQL exception using the default mapping.
*
* @param e the root cause
* @return the SQL exception object
*/
public
static
SQLException
convert
(
Throwable
e
)
{
public
static
SQLException
convert
(
Exception
e
)
{
if
(
e
instanceof
InternalException
)
{
e
=
((
InternalException
)
e
).
getOriginalCause
();
}
if
(
e
instanceof
SQLException
)
{
return
(
SQLException
)
e
;
}
else
if
(
e
instanceof
OutOfMemoryError
)
{
return
getSQLException
(
ErrorCode
.
OUT_OF_MEMORY
,
e
);
}
else
if
(
e
instanceof
InvocationTargetException
)
{
InvocationTargetException
te
=
(
InvocationTargetException
)
e
;
Throwable
t
=
te
.
getTargetException
();
...
...
@@ -274,6 +283,29 @@ public class Message {
return
getSQLException
(
ErrorCode
.
GENERAL_ERROR_1
,
e
,
e
.
toString
());
}
/**
* Convert a throwable to an SQL exception using the default mapping. For
* out of memory errors, this will first try to free up some memory, and if
* not possible it will re-throw the error. All errors except the following
* are re-thrown: StackOverflowError, LinkageError.
*
* @param e the root cause
* @return the SQL exception object
*/
public
static
SQLException
convertThrowable
(
Throwable
e
)
{
if
(
e
instanceof
OutOfMemoryError
)
{
if
(
MemoryUtils
.
freeReserveMemory
())
{
return
getSQLException
(
ErrorCode
.
OUT_OF_MEMORY
,
e
);
}
throw
(
OutOfMemoryError
)
e
;
}
else
if
(
e
instanceof
StackOverflowError
||
e
instanceof
LinkageError
)
{
return
getSQLException
(
ErrorCode
.
GENERAL_ERROR_1
,
e
,
e
.
toString
());
}
else
if
(
e
instanceof
Error
)
{
throw
(
Error
)
e
;
}
return
getSQLException
(
ErrorCode
.
GENERAL_ERROR_1
,
e
,
e
.
toString
());
}
/**
* Convert an IO exception to a SQL exception.
*
...
...
h2/src/main/org/h2/server/TcpServer.java
浏览文件 @
c58f4eaa
...
...
@@ -405,8 +405,10 @@ public class TcpServer implements Service {
String
db
=
getManagementDbName
(
port
);
try
{
org
.
h2
.
Driver
.
load
();
}
catch
(
Throwable
e
)
{
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
catch
(
Throwable
e
)
{
throw
Message
.
convertThrowable
(
e
);
}
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
Connection
conn
=
null
;
...
...
h2/src/main/org/h2/server/TcpServerThread.java
浏览文件 @
c58f4eaa
...
...
@@ -184,7 +184,12 @@ public class TcpServerThread implements Runnable {
private
void
sendError
(
Throwable
e
)
{
try
{
SQLException
s
=
Message
.
convert
(
e
);
SQLException
s
;
if
(
e
instanceof
Exception
)
{
s
=
Message
.
convert
((
Exception
)
e
);
}
else
{
s
=
Message
.
convertThrowable
(
e
);
}
StringWriter
writer
=
new
StringWriter
();
e
.
printStackTrace
(
new
PrintWriter
(
writer
));
String
trace
=
writer
.
toString
();
...
...
h2/src/main/org/h2/table/TableData.java
浏览文件 @
c58f4eaa
...
...
@@ -140,7 +140,10 @@ public class TableData extends Table implements RecordReader {
trace
.
error
(
"Could not undo operation"
,
e
);
throw
e2
;
}
throw
Message
.
convert
(
e
);
if
(
e
instanceof
Exception
)
{
throw
Message
.
convert
((
Exception
)
e
);
}
throw
Message
.
convertThrowable
(
e
);
}
}
...
...
@@ -380,7 +383,10 @@ public class TableData extends Table implements RecordReader {
trace
.
error
(
"Could not undo operation"
,
e
);
throw
e2
;
}
throw
Message
.
convert
(
e
);
if
(
e
instanceof
Exception
)
{
throw
Message
.
convert
((
Exception
)
e
);
}
throw
Message
.
convertThrowable
(
e
);
}
}
...
...
h2/src/main/org/h2/util/MemoryUtils.java
浏览文件 @
c58f4eaa
...
...
@@ -90,9 +90,15 @@ public class MemoryUtils {
/**
* Free up the reserve memory.
*
* @return if memory could be freed up.
*/
public
static
void
freeReserveMemory
()
{
public
static
boolean
freeReserveMemory
()
{
if
(
reserveMemory
==
null
)
{
return
false
;
}
reserveMemory
=
null
;
return
true
;
}
/**
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论