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) {
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
if (conn != null) {
|
||||
synchronized (conn) {
|
||||
pstmt = conn.prepareStatement("SELECT 1");
|
||||
if (conn != null) {
|
||||
synchronized (conn) {
|
||||
try (PreparedStatement pstmt = conn.prepareStatement("SELECT 1");) {
|
||||
pstmt.executeQuery();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} 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) {
|
||||
} catch (Throwable th) {
|
||||
s_logger.error("Unable to keep the db connection for " + name, th);
|
||||
return th.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue