Skip to content

Commit b9c9473

Browse files
committed
Preventing a Thread Leak
1 parent 3eff78a commit b9c9473

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/org/apache/ibatis/executor/loader/ResultLoader.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2012 the original author or authors.
2+
* Copyright 2009-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ public class ResultLoader {
4545
protected final CacheKey cacheKey;
4646
protected final BoundSql boundSql;
4747
protected final ResultExtractor resultExtractor;
48-
protected final Thread creatorThread;
48+
protected final String creatorThread;
4949

5050
protected boolean loaded;
5151
protected Object resultObject;
@@ -60,7 +60,7 @@ public ResultLoader(Configuration config, Executor executor, MappedStatement map
6060
this.cacheKey = cacheKey;
6161
this.boundSql = boundSql;
6262
this.resultExtractor = new ResultExtractor(configuration, objectFactory);
63-
this.creatorThread = Thread.currentThread();
63+
this.creatorThread = Thread.currentThread().getName();
6464
}
6565

6666
public Object loadResult() throws SQLException {
@@ -71,7 +71,7 @@ public Object loadResult() throws SQLException {
7171

7272
private <E> List<E> selectList() throws SQLException {
7373
Executor localExecutor = executor;
74-
if (Thread.currentThread() != this.creatorThread || localExecutor.isClosed()) {
74+
if (localExecutor.isClosed() || !Thread.currentThread().getName().equals(this.creatorThread)) {
7575
localExecutor = newExecutor();
7676
}
7777
try {

0 commit comments

Comments
 (0)