File tree 2 files changed +22
-5
lines changed
core/src/main/java/com/google/cloud/sql
2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,6 @@ public static void reset() {
64
64
* @throws IllegalStateException if the SQLAdmin client has already been initialized
65
65
*/
66
66
public static void addArtifactId (String artifactId ) {
67
- InternalConnectorRegistry .getInstance (). addArtifactId (artifactId );
67
+ InternalConnectorRegistry .addArtifactId (artifactId , false );
68
68
}
69
69
}
Original file line number Diff line number Diff line change @@ -231,16 +231,33 @@ private static String getVersion() {
231
231
* Internal use only: Sets the default string which is appended to the SQLAdmin API client
232
232
* User-Agent header.
233
233
*
234
- * <p>This is used by the specific database connector socket factory implementations to append
235
- * their database name to the user agent .
234
+ * @param artifactId is the Artifact ID.
235
+ * @param addVersion whether the version should be appended to the ID .
236
236
*/
237
- public static void addArtifactId (String artifactId ) {
238
- String userAgent = artifactId + "/" + version ;
237
+ public static void addArtifactId (String artifactId , boolean addVersion ) {
238
+ String userAgent = artifactId ;
239
+
240
+ if (addVersion ) {
241
+ userAgent += "/" + version ;
242
+ }
239
243
if (!userAgents .contains (userAgent )) {
240
244
userAgents .add (userAgent );
241
245
}
242
246
}
243
247
248
+ /**
249
+ * Internal use only: Sets the default string which is appended to the SQLAdmin API client
250
+ * User-Agent header.
251
+ *
252
+ * <p>This is used by the specific database connector socket factory implementations to append
253
+ * their database name to the user agent. The version is appended to the ID.
254
+ *
255
+ * @param artifactId is the Artifact ID.
256
+ */
257
+ public static void addArtifactId (String artifactId ) {
258
+ addArtifactId (artifactId , true );
259
+ }
260
+
244
261
/** Resets the values of User Agent fields for unit tests. */
245
262
@ VisibleForTesting
246
263
static void resetUserAgent () {
You can’t perform that action at this time.
0 commit comments