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.
|
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)
|
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
|
Optimizations
|
||||||
---------------------
|
---------------------
|
||||||
(No changes)
|
(No changes)
|
||||||
|
|
|
@ -181,12 +181,30 @@ class ConnectionImpl implements Connection {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTransactionIsolation(int level) throws SQLException {
|
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
|
@Override
|
||||||
public int getTransactionIsolation() throws SQLException {
|
public int getTransactionIsolation() throws SQLException {
|
||||||
throw new UnsupportedOperationException();
|
if(isClosed()) {
|
||||||
|
throw new SQLException("Connection is closed.");
|
||||||
|
}
|
||||||
|
return Connection.TRANSACTION_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -526,7 +526,6 @@ public class JdbcTest extends SolrCloudTestCase {
|
||||||
// assertEquals(0, databaseMetaData.getDriverMajorVersion());
|
// assertEquals(0, databaseMetaData.getDriverMajorVersion());
|
||||||
// assertEquals(0, databaseMetaData.getDriverMinorVersion());
|
// assertEquals(0, databaseMetaData.getDriverMinorVersion());
|
||||||
|
|
||||||
|
|
||||||
List<String> tableSchemas = new ArrayList<>(Arrays.asList(zkHost, "metadata"));
|
List<String> tableSchemas = new ArrayList<>(Arrays.asList(zkHost, "metadata"));
|
||||||
try(ResultSet rs = databaseMetaData.getSchemas()) {
|
try(ResultSet rs = databaseMetaData.getSchemas()) {
|
||||||
assertTrue(rs.next());
|
assertTrue(rs.next());
|
||||||
|
@ -551,10 +550,8 @@ public class JdbcTest extends SolrCloudTestCase {
|
||||||
solrClient.connect();
|
solrClient.connect();
|
||||||
ZkStateReader zkStateReader = solrClient.getZkStateReader();
|
ZkStateReader zkStateReader = solrClient.getZkStateReader();
|
||||||
|
|
||||||
SortedSet<String> tables = new TreeSet<>();
|
|
||||||
|
|
||||||
Set<String> collectionsSet = zkStateReader.getClusterState().getCollectionsMap().keySet();
|
Set<String> collectionsSet = zkStateReader.getClusterState().getCollectionsMap().keySet();
|
||||||
tables.addAll(collectionsSet);
|
SortedSet<String> tables = new TreeSet<>(collectionsSet);
|
||||||
|
|
||||||
Aliases aliases = zkStateReader.getAliases();
|
Aliases aliases = zkStateReader.getAliases();
|
||||||
tables.addAll(aliases.getCollectionAliasListMap().keySet());
|
tables.addAll(aliases.getCollectionAliasListMap().keySet());
|
||||||
|
@ -571,6 +568,15 @@ public class JdbcTest extends SolrCloudTestCase {
|
||||||
assertFalse(rs.next());
|
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());
|
assertTrue(con.isReadOnly());
|
||||||
con.setReadOnly(true);
|
con.setReadOnly(true);
|
||||||
assertTrue(con.isReadOnly());
|
assertTrue(con.isReadOnly());
|
||||||
|
@ -579,7 +585,6 @@ public class JdbcTest extends SolrCloudTestCase {
|
||||||
con.clearWarnings();
|
con.clearWarnings();
|
||||||
assertNull(con.getWarnings());
|
assertNull(con.getWarnings());
|
||||||
|
|
||||||
|
|
||||||
try (Statement statement = con.createStatement()) {
|
try (Statement statement = con.createStatement()) {
|
||||||
checkStatement(con, statement);
|
checkStatement(con, statement);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue