mirror of https://github.com/apache/lucene.git
SOLR-14153: Return correct isolation level when retrieving it from the SQL Connection
As transactions are not supported a request to getTransactionIsolation() should return TRANSACTION_NONE (https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html#TRANSACTION_NONE) Signed-off-by: Kevin Risden <krisden@apache.org>
This commit is contained in:
parent
4dc761fb60
commit
1b40371d43
|
@ -109,6 +109,8 @@ Improvements
|
|||
hl.fragsizeIsMinimum, with defaults that aim to better center matches in fragments than previously. See the ref guide.
|
||||
Regardless of the settings, the passages may be sized differently than before. (Nándor Mátravölgyi, David Smiley)
|
||||
|
||||
* SOLR-14154: Return correct isolation level when retrieving it from the SQL Connection (Nick Vercammen, Kevin Risden)
|
||||
|
||||
Optimizations
|
||||
---------------------
|
||||
(No changes)
|
||||
|
|
|
@ -181,12 +181,30 @@ class ConnectionImpl implements Connection {
|
|||
|
||||
@Override
|
||||
public void setTransactionIsolation(int level) throws SQLException {
|
||||
throw new UnsupportedOperationException();
|
||||
if(isClosed()) {
|
||||
throw new SQLException("Connection is closed.");
|
||||
}
|
||||
if(Connection.TRANSACTION_NONE == level) {
|
||||
throw new SQLException("Connection.TRANSACTION_NONE cannot be used.");
|
||||
}
|
||||
if(
|
||||
Connection.TRANSACTION_READ_COMMITTED == level ||
|
||||
Connection.TRANSACTION_READ_UNCOMMITTED == level ||
|
||||
Connection.TRANSACTION_REPEATABLE_READ == level ||
|
||||
Connection.TRANSACTION_SERIALIZABLE == level
|
||||
) {
|
||||
throw new SQLException(new UnsupportedOperationException());
|
||||
} else {
|
||||
throw new SQLException("Unsupported transaction type specified.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransactionIsolation() throws SQLException {
|
||||
throw new UnsupportedOperationException();
|
||||
if(isClosed()) {
|
||||
throw new SQLException("Connection is closed.");
|
||||
}
|
||||
return Connection.TRANSACTION_NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -526,7 +526,6 @@ public class JdbcTest extends SolrCloudTestCase {
|
|||
// assertEquals(0, databaseMetaData.getDriverMajorVersion());
|
||||
// assertEquals(0, databaseMetaData.getDriverMinorVersion());
|
||||
|
||||
|
||||
List<String> tableSchemas = new ArrayList<>(Arrays.asList(zkHost, "metadata"));
|
||||
try(ResultSet rs = databaseMetaData.getSchemas()) {
|
||||
assertTrue(rs.next());
|
||||
|
@ -551,10 +550,8 @@ public class JdbcTest extends SolrCloudTestCase {
|
|||
solrClient.connect();
|
||||
ZkStateReader zkStateReader = solrClient.getZkStateReader();
|
||||
|
||||
SortedSet<String> tables = new TreeSet<>();
|
||||
|
||||
Set<String> collectionsSet = zkStateReader.getClusterState().getCollectionsMap().keySet();
|
||||
tables.addAll(collectionsSet);
|
||||
SortedSet<String> tables = new TreeSet<>(collectionsSet);
|
||||
|
||||
Aliases aliases = zkStateReader.getAliases();
|
||||
tables.addAll(aliases.getCollectionAliasListMap().keySet());
|
||||
|
@ -571,6 +568,15 @@ public class JdbcTest extends SolrCloudTestCase {
|
|||
assertFalse(rs.next());
|
||||
}
|
||||
|
||||
assertEquals(Connection.TRANSACTION_NONE, con.getTransactionIsolation());
|
||||
try {
|
||||
con.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
|
||||
fail("should not have been able to set transaction isolation");
|
||||
} catch (SQLException e) {
|
||||
assertEquals(UnsupportedOperationException.class, e.getCause().getClass());
|
||||
}
|
||||
assertEquals(Connection.TRANSACTION_NONE, con.getTransactionIsolation());
|
||||
|
||||
assertTrue(con.isReadOnly());
|
||||
con.setReadOnly(true);
|
||||
assertTrue(con.isReadOnly());
|
||||
|
@ -579,7 +585,6 @@ public class JdbcTest extends SolrCloudTestCase {
|
|||
con.clearWarnings();
|
||||
assertNull(con.getWarnings());
|
||||
|
||||
|
||||
try (Statement statement = con.createStatement()) {
|
||||
checkStatement(con, statement);
|
||||
|
||||
|
|
Loading…
Reference in New Issue