mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-8656: reorganise sychronized block
This commit is contained in:
parent
07bee3149c
commit
882de20e1c
|
|
@ -142,26 +142,17 @@ public class ConnectionConcierge {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String testValidity(String name, Connection conn) {
|
protected String testValidity(String name, Connection conn) {
|
||||||
PreparedStatement pstmt = null;
|
if (conn != null) {
|
||||||
try {
|
synchronized (conn) {
|
||||||
if (conn != null) {
|
try (PreparedStatement pstmt = conn.prepareStatement("SELECT 1");) {
|
||||||
synchronized (conn) {
|
|
||||||
pstmt = conn.prepareStatement("SELECT 1");
|
|
||||||
pstmt.executeQuery();
|
pstmt.executeQuery();
|
||||||
}
|
} catch (Throwable th) {
|
||||||
}
|
s_logger.error("Unable to keep the db connection for " + name, th);
|
||||||
return null;
|
return th.toString();
|
||||||
} catch (Throwable th) {
|
|
||||||
s_logger.error("Unable to keep the db connection for " + name, th);
|
|
||||||
return th.toString();
|
|
||||||
} finally {
|
|
||||||
if (pstmt != null) {
|
|
||||||
try {
|
|
||||||
pstmt.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue