|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
LeakCheckConnection.java | 0% | 0% | 0% | 0% |
|
1 |
/*
|
|
2 |
* Joey and its relative products are published under the terms
|
|
3 |
* of the Apache Software License.
|
|
4 |
*/
|
|
5 |
package org.asyrinx.brownie.jdbc;
|
|
6 |
|
|
7 |
import java.sql.Connection;
|
|
8 |
|
|
9 |
import org.apache.commons.logging.Log;
|
|
10 |
import org.apache.commons.logging.LogFactory;
|
|
11 |
import org.asyrinx.brownie.jdbc.wrapper.ConnectionWrapper;
|
|
12 |
|
|
13 |
/**
|
|
14 |
* このクラスのインスタンス生成時に例外をthrowしないで生成だけ行い、
|
|
15 |
* finalize時にリークしていたら、生成しておいた例外のスタックトレースを出力します。
|
|
16 |
*
|
|
17 |
* @author Akima
|
|
18 |
*/
|
|
19 |
public class LeakCheckConnection extends ConnectionWrapper { |
|
20 |
|
|
21 |
/**
|
|
22 |
* Constructor for LeakCheckConnection.
|
|
23 |
*
|
|
24 |
* @param source
|
|
25 |
*/
|
|
26 | 0 |
public LeakCheckConnection(Connection source) {
|
27 | 0 |
super(source);
|
28 | 0 |
connectionCreate = new TraceException(MSG);
|
29 |
} |
|
30 |
|
|
31 |
static private final String MSG = "コネクションリークが発生してます!" |
|
32 |
+ "connectDatabaseとdisconnectDatabaseがtry...finallyによって"
|
|
33 |
+ "正しく使用されているかどうかを確認してください。";
|
|
34 |
|
|
35 |
private final TraceException connectionCreate;
|
|
36 |
|
|
37 |
class TraceException extends Exception { |
|
38 | 0 |
public TraceException(String msg) {
|
39 | 0 |
super(msg);
|
40 |
} |
|
41 |
} |
|
42 |
|
|
43 |
/**
|
|
44 |
* @see java.lang.Object#finalize()
|
|
45 |
*/
|
|
46 | 0 |
protected void finalize() throws Throwable { |
47 | 0 |
if (!getSource().isClosed()) {
|
48 | 0 |
final Log log = LogFactory.getLog(getCore().getClass()); |
49 | 0 |
log.error(connectionCreate); |
50 |
} |
|
51 | 0 |
super.finalize();
|
52 |
} |
|
53 |
|
|
54 |
} |
|