use of com.mysql.cj.jdbc.result.UpdatableResultSet in project JavaSegundasQuintas by ecteruel.
the class ResultSetRegressionTest method testBug70704.
/**
* Tests fix for Bug#70704 - Deadlock using UpdatableResultSet.
*
* Doesn't actually test the buggy behavior since it is not verifiable since the fix for Bug#59462 (revision 385a151). However, the patch for this fix is
* needed because the synchronization in UpdatableResultSet was dated.
* This test makes sure there is no regression.
*
* WARNING! If this test fails there is no guarantee that the JVM will remain stable and won't affect any other tests. It is imperative that this test
* passes to ensure other tests results.
*
* @throws Exception
*/
@Test
public void testBug70704() throws Exception {
for (int i = 0; i < 100; i++) {
final Statement testStmt = this.conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
final ResultSet testRs = testStmt.executeQuery("SELECT 1");
ExecutorService executorService = Executors.newFixedThreadPool(2);
executorService.submit(new Callable<Void>() {
public Void call() throws Exception {
testStmt.close();
return null;
}
});
executorService.submit(new Callable<Void>() {
public Void call() throws Exception {
testRs.close();
return null;
}
});
executorService.shutdown();
if (!executorService.awaitTermination(2, TimeUnit.SECONDS)) {
ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
long[] threadIds = threadMXBean.findMonitorDeadlockedThreads();
if (threadIds != null) {
System.err.println("Deadlock detected!");
ThreadInfo[] threadInfos = threadMXBean.getThreadInfo(threadIds, Integer.MAX_VALUE);
for (ThreadInfo ti : threadInfos) {
System.err.println();
System.err.println(ti);
System.err.println("Stack trace:");
for (StackTraceElement ste : ti.getStackTrace()) {
System.err.println(" " + ste);
}
}
fail("Unexpected deadlock detected. Consult system output for more details. WARNING: this failure may lead to JVM instability.");
}
}
}
}
use of com.mysql.cj.jdbc.result.UpdatableResultSet in project ABC by RuiPinto96274.
the class ConnectionImpl method initializeResultsMetadataFromCache.
@Override
public void initializeResultsMetadataFromCache(String sql, CachedResultSetMetaData cachedMetaData, ResultSetInternalMethods resultSet) throws SQLException {
if (cachedMetaData == null) {
// read from results
cachedMetaData = new CachedResultSetMetaDataImpl();
// assume that users will use named-based lookups
resultSet.getColumnDefinition().buildIndexMapping();
resultSet.initializeWithMetadata();
if (resultSet instanceof UpdatableResultSet) {
((UpdatableResultSet) resultSet).checkUpdatability();
}
resultSet.populateCachedMetaData(cachedMetaData);
this.resultSetMetadataCache.put(sql, cachedMetaData);
} else {
resultSet.getColumnDefinition().initializeFrom(cachedMetaData);
resultSet.initializeWithMetadata();
if (resultSet instanceof UpdatableResultSet) {
((UpdatableResultSet) resultSet).checkUpdatability();
}
}
}
use of com.mysql.cj.jdbc.result.UpdatableResultSet in project JavaSegundasQuintas by ecteruel.
the class ConnectionImpl method initializeResultsMetadataFromCache.
@Override
public void initializeResultsMetadataFromCache(String sql, CachedResultSetMetaData cachedMetaData, ResultSetInternalMethods resultSet) throws SQLException {
if (cachedMetaData == null) {
// read from results
cachedMetaData = new CachedResultSetMetaDataImpl();
// assume that users will use named-based lookups
resultSet.getColumnDefinition().buildIndexMapping();
resultSet.initializeWithMetadata();
if (resultSet instanceof UpdatableResultSet) {
((UpdatableResultSet) resultSet).checkUpdatability();
}
resultSet.populateCachedMetaData(cachedMetaData);
this.resultSetMetadataCache.put(sql, cachedMetaData);
} else {
resultSet.getColumnDefinition().initializeFrom(cachedMetaData);
resultSet.initializeWithMetadata();
if (resultSet instanceof UpdatableResultSet) {
((UpdatableResultSet) resultSet).checkUpdatability();
}
}
}
use of com.mysql.cj.jdbc.result.UpdatableResultSet in project aws-mysql-jdbc by awslabs.
the class ConnectionImpl method initializeResultsMetadataFromCache.
@Override
public void initializeResultsMetadataFromCache(String sql, CachedResultSetMetaData cachedMetaData, ResultSetInternalMethods resultSet) throws SQLException {
if (cachedMetaData == null) {
// read from results
cachedMetaData = new CachedResultSetMetaDataImpl();
// assume that users will use named-based lookups
resultSet.getColumnDefinition().buildIndexMapping();
resultSet.initializeWithMetadata();
if (resultSet instanceof UpdatableResultSet) {
((UpdatableResultSet) resultSet).checkUpdatability();
}
resultSet.populateCachedMetaData(cachedMetaData);
this.resultSetMetadataCache.put(sql, cachedMetaData);
} else {
resultSet.getColumnDefinition().initializeFrom(cachedMetaData);
resultSet.initializeWithMetadata();
if (resultSet instanceof UpdatableResultSet) {
((UpdatableResultSet) resultSet).checkUpdatability();
}
}
}
use of com.mysql.cj.jdbc.result.UpdatableResultSet in project aws-mysql-jdbc by awslabs.
the class ResultSetRegressionTest method testBug70704.
/**
* Tests fix for Bug#70704 - Deadlock using UpdatableResultSet.
*
* Doesn't actually test the buggy behavior since it is not verifiable since the fix for Bug#59462 (revision 385a151). However, the patch for this fix is
* needed because the synchronization in UpdatableResultSet was dated.
* This test makes sure there is no regression.
*
* WARNING! If this test fails there is no guarantee that the JVM will remain stable and won't affect any other tests. It is imperative that this test
* passes to ensure other tests results.
*
* @throws Exception
*/
@Test
public void testBug70704() throws Exception {
for (int i = 0; i < 100; i++) {
final Statement testStmt = this.conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
final ResultSet testRs = testStmt.executeQuery("SELECT 1");
ExecutorService executorService = Executors.newFixedThreadPool(2);
executorService.submit(new Callable<Void>() {
public Void call() throws Exception {
testStmt.close();
return null;
}
});
executorService.submit(new Callable<Void>() {
public Void call() throws Exception {
testRs.close();
return null;
}
});
executorService.shutdown();
if (!executorService.awaitTermination(2, TimeUnit.SECONDS)) {
ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
long[] threadIds = threadMXBean.findMonitorDeadlockedThreads();
if (threadIds != null) {
System.err.println("Deadlock detected!");
ThreadInfo[] threadInfos = threadMXBean.getThreadInfo(threadIds, Integer.MAX_VALUE);
for (ThreadInfo ti : threadInfos) {
System.err.println();
System.err.println(ti);
System.err.println("Stack trace:");
for (StackTraceElement ste : ti.getStackTrace()) {
System.err.println(" " + ste);
}
}
fail("Unexpected deadlock detected. Consult system output for more details. WARNING: this failure may lead to JVM instability.");
}
}
}
}
Aggregations