Repository: googleapis/java-spanner-jdbc
Pull request #1575 (2024-04-20 19:10:43)

chore(deps): update dependency com.google.cloud:google-cloud-spanner-jdbc to v2.16.3
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.cloud:google-cloud-spanner-jdbc](https://togithub.com/googleapis/java-spanner-jdbc) | `2.16.1` -> `2.16.3` | [![age](https://developer.mend.io/api/mc/badges/age/maven/com.google.cloud:google-cloud-spanner-jdbc/2.16.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/com.google.cloud:google-cloud-spanner-jdbc/2.16.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/com.google.cloud:google-cloud-spanner-jdbc/2.16.1/2.16.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/com.google.cloud:google-cloud-spanner-jdbc/2.16.1/2.16.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>googleapis/java-spanner-jdbc (com.google.cloud:google-cloud-spanner-jdbc)</summary>

### [`v2.16.3`](https://togithub.com/googleapis/java-spanner-jdbc/blob/HEAD/CHANGELOG.md#2163-2024-04-20)

[Compare Source](https://togithub.com/googleapis/java-spanner-jdbc/compare/v2.16.2...v2.16.3)

##### Dependencies

-   Update dependency com.google.cloud:google-cloud-spanner-bom to v6.65.0 ([#&#8203;1573](https://togithub.com/googleapis/java-spanner-jdbc/issues/1573)) ([ecc18f1](https://togithub.com/googleapis/java-spanner-jdbc/commit/ecc18f1307933bb0f4f576ce2df81af226f8a2cb))

### [`v2.16.2`](https://togithub.com/googleapis/java-spanner-jdbc/blob/HEAD/CHANGELOG.md#2162-2024-04-19)

[Compare Source](https://togithub.com/googleapis/java-spanner-jdbc/compare/v2.16.1...v2.16.2)

##### Bug Fixes

-   Release ResultSet on Statement#close()  ([#&#8203;1567](https://togithub.com/googleapis/java-spanner-jdbc/issues/1567)) ([2258ae3](https://togithub.com/googleapis/java-spanner-jdbc/commit/2258ae3331a7e89036a202f243b9284108301fc0))

##### Dependencies

-   Update actions/checkout action to v4 ([#&#8203;1547](https://togithub.com/googleapis/java-spanner-jdbc/issues/1547)) ([736e3af](https://togithub.com/googleapis/java-spanner-jdbc/commit/736e3afa54149dd11803bd715569afd9ec8e87f2))
-   Update actions/checkout action to v4 ([#&#8203;1561](https://togithub.com/googleapis/java-spanner-jdbc/issues/1561)) ([6053d79](https://togithub.com/googleapis/java-spanner-jdbc/commit/6053d79816546130eca7a7016dc9299c079e411f))
-   Update actions/checkout digest to [`b4ffde6`](https://togithub.com/googleapis/java-spanner-jdbc/commit/b4ffde6) ([#&#8203;1546](https://togithub.com/googleapis/java-spanner-jdbc/issues/1546)) ([18c5ad4](https://togithub.com/googleapis/java-spanner-jdbc/commit/18c5ad4d4124f095547d50c0d2e154bc06380642))
-   Update actions/github-script action to v7 ([#&#8203;1548](https://togithub.com/googleapis/java-spanner-jdbc/issues/1548)) ([d1d422c](https://togithub.com/googleapis/java-spanner-jdbc/commit/d1d422cdf0a74231c468262662fdf5ce4d27b8ef))
-   Update actions/setup-java action to v4 ([#&#8203;1549](https://togithub.com/googleapis/java-spanner-jdbc/issues/1549)) ([cb2b911](https://togithub.com/googleapis/java-spanner-jdbc/commit/cb2b911b0b332e97f85974ec880a5ab7a12a7578))
-   Update actions/setup-java action to v4 ([#&#8203;1563](https://togithub.com/googleapis/java-spanner-jdbc/issues/1563)) ([01d4de1](https://togithub.com/googleapis/java-spanner-jdbc/commit/01d4de1df21144e9c3bcf0b4e5192b12cd19dc82))
-   Update dependency com.google.cloud:google-cloud-spanner-bom to v6.63.0 ([#&#8203;1552](https://togithub.com/googleapis/java-spanner-jdbc/issues/1552)) ([ac75b9f](https://togithub.com/googleapis/java-spanner-jdbc/commit/ac75b9faf0eaeb499428ecefda1f3285b3d28e67))
-   Update dependency com.google.cloud:google-cloud-spanner-bom to v6.64.0 ([#&#8203;1565](https://togithub.com/googleapis/java-spanner-jdbc/issues/1565)) ([b57662f](https://togithub.com/googleapis/java-spanner-jdbc/commit/b57662fb65b74b329103ef63265192d7026b2c2d))
-   Update dependency com.google.cloud:sdk-platform-java-config to v3.28.1 ([#&#8203;1560](https://togithub.com/googleapis/java-spanner-jdbc/issues/1560)) ([afcbe5e](https://togithub.com/googleapis/java-spanner-jdbc/commit/afcbe5ea5701a799729543c9564759570f05feb8))
-   Update dependency com.google.cloud:sdk-platform-java-config to v3.29.0 ([#&#8203;1572](https://togithub.com/googleapis/java-spanner-jdbc/issues/1572)) ([3d43707](https://togithub.com/googleapis/java-spanner-jdbc/commit/3d437076f2c699e261daf7dcb470085765dba14f))
-   Update dependency io.opentelemetry:opentelemetry-bom to v1.37.0 ([#&#8203;1562](https://togithub.com/googleapis/java-spanner-jdbc/issues/1562)) ([22f766f](https://togithub.com/googleapis/java-spanner-jdbc/commit/22f766f098944c23084776c70dbd9dba21efa59c))
-   Update dependency org.springframework.boot:spring-boot-starter-data-jdbc to v3.2.5 ([#&#8203;1569](https://togithub.com/googleapis/java-spanner-jdbc/issues/1569)) ([784ac1e](https://togithub.com/googleapis/java-spanner-jdbc/commit/784ac1e68ac29628fe55d7b9e772326f10ffeaec))
-   Update dependency org.springframework.boot:spring-boot-starter-parent to v3.2.5 ([#&#8203;1570](https://togithub.com/googleapis/java-spanner-jdbc/issues/1570)) ([f54d4dd](https://togithub.com/googleapis/java-spanner-jdbc/commit/f54d4dd1211508785cb899e0a3c9b585c0908421))
-   Update dependency org.springframework.data:spring-data-bom to v2023.1.5 ([#&#8203;1564](https://togithub.com/googleapis/java-spanner-jdbc/issues/1564)) ([dbbcca3](https://togithub.com/googleapis/java-spanner-jdbc/commit/dbbcca342a83476b1f942aab23f21469cf6c8304))
-   Update stcarolas/setup-maven action to v5 ([#&#8203;1550](https://togithub.com/googleapis/java-spanner-jdbc/issues/1550)) ([121d08e](https://togithub.com/googleapis/java-spanner-jdbc/commit/121d08e16db0bbb1f6041a201d620829e7121f4d))

##### Documentation

-   Create samples for quickstart guide ([#&#8203;1536](https://togithub.com/googleapis/java-spanner-jdbc/issues/1536)) ([194c820](https://togithub.com/googleapis/java-spanner-jdbc/commit/194c8205dee9cc4144b18e219df43027b9f15cf2))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/googleapis/java-spanner-jdbc).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMDEuNCIsInVwZGF0ZWRJblZlciI6IjM3LjMwMS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->



Patch:
diff --git a/pom.xml b/pom.xml
index 48ce6da..644108c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -171,6 +171,12 @@
       <type>test-jar</type>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.testcontainers</groupId>
+      <artifactId>testcontainers</artifactId>
+      <version>1.19.7</version>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>com.google.truth</groupId>
       <artifactId>truth</artifactId>
diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml
index a2537a7..0be1c77 100644
--- a/samples/install-without-bom/pom.xml
+++ b/samples/install-without-bom/pom.xml
@@ -29,7 +29,7 @@
     <dependency>
       <groupId>com.google.cloud</groupId>
       <artifactId>google-cloud-spanner-jdbc</artifactId>
-      <version>2.16.1</version>
+      <version>2.16.3</version>
     </dependency>
     <!-- [END spanner-jdbc_install_without_bom] -->
 


Test patch:
diff --git a/src/test/java/com/google/cloud/spanner/jdbc/ConcurrentTransactionOnEmulatorTest.java b/src/test/java/com/google/cloud/spanner/jdbc/ConcurrentTransactionOnEmulatorTest.java
new file mode 100644
index 0000000..e9931e6
--- /dev/null
+++ b/src/test/java/com/google/cloud/spanner/jdbc/ConcurrentTransactionOnEmulatorTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2024 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.spanner.jdbc;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
+
+import com.google.cloud.spanner.connection.SpannerPool;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Properties;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import org.testcontainers.DockerClientFactory;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.utility.DockerImageName;
+
+@RunWith(JUnit4.class)
+public class ConcurrentTransactionOnEmulatorTest {
+  private static GenericContainer<?> emulator;
+
+  private static Properties properties;
+
+  @BeforeClass
+  public static void startEmulator() {
+    assumeTrue(DockerClientFactory.instance().isDockerAvailable());
+
+    emulator =
+        new GenericContainer<>(
+                DockerImageName.parse("gcr.io/cloud-spanner-emulator/emulator:latest"))
+            .withExposedPorts(9010)
+            .waitingFor(Wait.forListeningPort());
+    emulator.start();
+    properties = new Properties();
+    properties.setProperty("autoConfigEmulator", "true");
+    properties.setProperty(
+        "endpoint", String.format("%s:%d", emulator.getHost(), emulator.getMappedPort(9010)));
+  }
+
+  @AfterClass
+  public static void cleanup() {
+    SpannerPool.closeSpannerPool();
+    if (emulator != null) {
+      emulator.stop();
+    }
+  }
+
+  @Test
+  public void testRunConcurrentTransactions() throws SQLException {
+    String connectionUrl =
+        String.format(
+            "jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s",
+            "emulator-project", "test-instance", "test-database");
+    try (Connection connection1 = DriverManager.getConnection(connectionUrl, properties);
+        Connection connection2 = DriverManager.getConnection(connectionUrl, properties)) {
+      // Create a test table.
+      connection1
+          .createStatement()
+          .execute("create table test (id int64, value string(max)) primary key (id)");
+
+      // Put both connections into autoCommit=false mode and verify that both connections can run
+      // a transaction using a single thread.
+      connection1.setAutoCommit(false);
+      connection2.setAutoCommit(false);
+
+      connection1.createStatement().executeUpdate("insert into test (id, value) values (1, 'One')");
+      connection2.createStatement().executeUpdate("insert into test (id, value) values (2, 'Two')");
+      connection1.commit();
+      connection2.commit();
+
+      // Verify that both transactions succeeded.
+      connection1.setAutoCommit(true);
+      try (ResultSet resultSet =
+          connection1.createStatement().executeQuery("select * from test order by id")) {
+        assertTrue(resultSet.next());
+        assertEquals("One", resultSet.getString("value"));
+        assertTrue(resultSet.next());
+        assertEquals("Two", resultSet.getString("value"));
+        assertFalse(resultSet.next());
+      }
+    }
+  }
+}