Skip to content

Commit

Permalink
refactor: initialize the concurrent hashset first instead of populati…
Browse files Browse the repository at this point in the history
…ng the map first
  • Loading branch information
karenc-bq committed Mar 16, 2023
1 parent e324efb commit cc73378
Showing 1 changed file with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import java.io.EOFException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -95,22 +96,26 @@ public class FailoverConnectionPlugin implements IConnectionPlugin {
static final String METHOD_CLOSE = "close";
static final String METHOD_IS_CLOSED = "isClosed";

private final static Set<String> METHODS_REQUIRE_UPDATED_TOPOLOGY = new ConcurrentHashMap<String, String>() {{
put(METHOD_COMMIT, METHOD_COMMIT);
put("connect", "connect");
put("isValid", "isValid");
put("rollback", "rollback");
put("setAutoCommit", "setAutoCommit");
put("setReadOnly", "setReadOnly");
put("execute", "execute");
put("executeBatch", "executeBatch");
put("executeLargeBatch", "executeLargeBatch");
put("executeLargeUpdate", "executeLargeUpdate");
put("executeQuery", "executeQuery");
put("executeUpdate", "executeUpdate");
put("executeWithFlags", "executeWithFlags");
put("getParameterMetaData", "getParameterMetaData");
}}.newKeySet();
private final static Set<String> METHODS_REQUIRE_UPDATED_TOPOLOGY = ConcurrentHashMap.newKeySet();

static {
METHODS_REQUIRE_UPDATED_TOPOLOGY.addAll(Arrays.asList(
METHOD_COMMIT,
"connect",
"isValid",
"rollback",
"setAutoCommit",
"setReadOnly",
"execute",
"executeBatch",
"executeLargeBatch",
"executeLargeUpdate",
"executeQuery",
"executeUpdate",
"executeWithFlags",
"getParameterMetaData"
));
}

private static final String METHOD_GET_TRANSACTION_ISOLATION =
"getTransactionIsolation";
Expand Down

0 comments on commit cc73378

Please sign in to comment.