2222import com .google .cloud .spanner .SpannerException ;
2323import com .google .cloud .spanner .SpannerExceptionFactory ;
2424import com .google .cloud .spanner .Statement ;
25+ import com .google .cloud .spanner .connection .AbstractBaseUnitOfWork .InterceptorsUsage ;
2526import com .google .cloud .spanner .connection .StatementResult .ClientSideStatementType ;
27+ import com .google .cloud .spanner .connection .UnitOfWork .CallType ;
2628import com .google .common .annotations .VisibleForTesting ;
2729import com .google .common .base .Preconditions ;
2830import com .google .common .cache .Cache ;
3234import com .google .common .collect .ImmutableMap ;
3335import com .google .common .collect .ImmutableSet ;
3436import com .google .spanner .v1 .ExecuteSqlRequest .QueryOptions ;
37+ import java .util .Collection ;
3538import java .util .Collections ;
3639import java .util .HashMap ;
3740import java .util .Map ;
@@ -71,12 +74,7 @@ static void resetParsers() {
7174 }
7275 }
7376
74- /**
75- * Get an instance of {@link AbstractStatementParser} for the specified dialect.
76- *
77- * @param dialect
78- * @return
79- */
77+ /** Get an instance of {@link AbstractStatementParser} for the specified dialect. */
8078 public static AbstractStatementParser getInstance (Dialect dialect ) {
8179 synchronized (lock ) {
8280 if (!INSTANCES .containsKey (dialect )) {
@@ -86,19 +84,19 @@ public static AbstractStatementParser getInstance(Dialect dialect) {
8684 throw SpannerExceptionFactory .newSpannerException (
8785 ErrorCode .INTERNAL , "There is no known statement parser for dialect " + dialect );
8886 }
89- INSTANCES .put (dialect , clazz .newInstance ());
90- } catch (InstantiationException | IllegalAccessException e ) {
87+ INSTANCES .put (dialect , clazz .getDeclaredConstructor (). newInstance ());
88+ } catch (Exception exception ) {
9189 throw SpannerExceptionFactory .newSpannerException (
9290 ErrorCode .INTERNAL ,
9391 "Could not instantiate statement parser for dialect " + dialect .name (),
94- e );
92+ exception );
9593 }
9694 }
9795 return INSTANCES .get (dialect );
9896 }
9997 }
10098
101- /**
99+ /*
102100 * The following fixed pre-parsed statements are used internally by the Connection API. These do
103101 * not need to be parsed using a specific dialect, as they are equal for all dialects, and
104102 * pre-parsing them avoids the need to repeatedly parse statements that are used internally.
@@ -108,30 +106,33 @@ public static AbstractStatementParser getInstance(Dialect dialect) {
108106 static final ParsedStatement BEGIN_STATEMENT ;
109107
110108 /**
111- * Create a COMMIT statement to use with the {@link #commit()} method to allow it to be cancelled,
112- * time out or retried.
109+ * Create a COMMIT statement to use with the {@link Connection #commit()} method to allow it to be
110+ * cancelled, time out or retried.
113111 *
114- * <p>{@link ReadWriteTransaction} uses the generic methods {@link #executeAsync(ParsedStatement,
115- * Callable)} and {@link #runWithRetry(Callable)} to allow statements to be cancelled, to timeout
116- * and to be retried. These methods require a {@link ParsedStatement} as input. When the {@link
117- * #commit()} method is called directly, we do not have a {@link ParsedStatement}, and the method
118- * uses this statement instead in order to use the same logic as the other statements.
112+ * <p>{@link ReadWriteTransaction} uses the generic methods {@link
113+ * ReadWriteTransaction#executeStatementAsync(CallType, ParsedStatement, Callable,
114+ * InterceptorsUsage, Collection)} and {@link ReadWriteTransaction#runWithRetry(Callable)} to
115+ * allow statements to be cancelled, to timeout and to be retried. These methods require a {@link
116+ * ParsedStatement} as input. When the {@link Connection#commit()} method is called directly, we
117+ * do not have a {@link ParsedStatement}, and the method uses this statement instead in order to
118+ * use the same logic as the other statements.
119119 */
120120 static final ParsedStatement COMMIT_STATEMENT ;
121121
122122 /** The {@link Statement} and {@link Callable} for rollbacks */
123123 static final ParsedStatement ROLLBACK_STATEMENT ;
124124
125125 /**
126- * Create a RUN BATCH statement to use with the {@link #executeBatchUpdate(Iterable)} method to
127- * allow it to be cancelled, time out or retried.
126+ * Create a RUN BATCH statement to use with the {@link Connection #executeBatchUpdate(Iterable)}
127+ * method to allow it to be cancelled, time out or retried.
128128 *
129- * <p>{@link ReadWriteTransaction} uses the generic methods {@link #executeAsync(ParsedStatement,
130- * Callable)} and {@link #runWithRetry(Callable)} to allow statements to be cancelled, to timeout
131- * and to be retried. These methods require a {@link ParsedStatement} as input. When the {@link
132- * #executeBatchUpdate(Iterable)} method is called, we do not have one {@link ParsedStatement},
133- * and the method uses this statement instead in order to use the same logic as the other
134- * statements.
129+ * <p>{@link ReadWriteTransaction} uses the generic methods {@link
130+ * ReadWriteTransaction#executeStatementAsync(CallType, ParsedStatement, Callable, Collection)}
131+ * and {@link ReadWriteTransaction#runWithRetry(Callable)} to allow statements to be cancelled, to
132+ * timeout and to be retried. These methods require a {@link ParsedStatement} as input. When the
133+ * {@link Connection#executeBatchUpdate(Iterable)} method is called, we do not have one {@link
134+ * ParsedStatement}, and the method uses this statement instead in order to use the same logic as
135+ * the other statements.
135136 */
136137 static final ParsedStatement RUN_BATCH_STATEMENT ;
137138
0 commit comments