diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 0bd0ee0620..940d477efc 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1 +1,7 @@ -Fixes # (it's a good idea to open an issue first for context and/or discussion) \ No newline at end of file +Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: +- [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/java-core/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea +- [ ] Ensure the tests and linter pass +- [ ] Code coverage does not decrease (if any source code was changed) +- [ ] Appropriate docs were updated (if necessary) + +Fixes # ☕️ diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bf02ff519..5218a786fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +### [1.93.3](https://www.github.com/googleapis/java-core/compare/v1.93.2...v1.93.3) (2020-03-16) + + +### Bug Fixes + +* fix Timestamp.of(java.sql.Timestamp) pre-epoch on exact second ([#179](https://www.github.com/googleapis/java-core/issues/179)) ([9bfb54c](https://www.github.com/googleapis/java-core/commit/9bfb54c5a88c906bebcf90f81ed19aeece09befd)) +* retry SSLException ([#183](https://www.github.com/googleapis/java-core/issues/183)) ([775a848](https://www.github.com/googleapis/java-core/commit/775a84877ef69d22ca7a4392edd0d3680df2256e)) + + +### Dependencies + +* revert gRPC updates ([#181](https://www.github.com/googleapis/java-core/issues/181)) ([f5ba782](https://www.github.com/googleapis/java-core/commit/f5ba782fe7078bd2e02d27d8770ad20a459c73f3)) +* update dependency io.grpc:grpc-bom to v1.28.0 ([#178](https://www.github.com/googleapis/java-core/issues/178)) ([6d5632c](https://www.github.com/googleapis/java-core/commit/6d5632c22507d1d3d36a90778291a6fa25b4788b)) + ### [1.93.2](https://www.github.com/googleapis/java-core/compare/v1.93.1...v1.93.2) (2020-03-10) diff --git a/google-cloud-core-bom/pom.xml b/google-cloud-core-bom/pom.xml index e31862e0b9..e819095707 100644 --- a/google-cloud-core-bom/pom.xml +++ b/google-cloud-core-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-core-bom - 1.93.2 + 1.93.3 pom com.google.cloud @@ -63,17 +63,17 @@ com.google.cloud google-cloud-core - 1.93.2 + 1.93.3 com.google.cloud google-cloud-core-grpc - 1.93.2 + 1.93.3 com.google.cloud google-cloud-core-http - 1.93.2 + 1.93.3 diff --git a/google-cloud-core-grpc/pom.xml b/google-cloud-core-grpc/pom.xml index b6d2e6707a..b6bb373c38 100644 --- a/google-cloud-core-grpc/pom.xml +++ b/google-cloud-core-grpc/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-core-grpc - 1.93.2 + 1.93.3 jar Google Cloud Core gRPC https://github.com/googleapis/java-core @@ -13,7 +13,7 @@ com.google.cloud google-cloud-core-parent - 1.93.2 + 1.93.3 google-cloud-core-grpc diff --git a/google-cloud-core-http/pom.xml b/google-cloud-core-http/pom.xml index c933ff67e6..fd7d2bfbd0 100644 --- a/google-cloud-core-http/pom.xml +++ b/google-cloud-core-http/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-core-http - 1.93.2 + 1.93.3 jar Google Cloud Core HTTP https://github.com/googleapis/java-core @@ -13,7 +13,7 @@ com.google.cloud google-cloud-core-parent - 1.93.2 + 1.93.3 google-cloud-core-http diff --git a/google-cloud-core/pom.xml b/google-cloud-core/pom.xml index ef98cf5d64..445fd81908 100644 --- a/google-cloud-core/pom.xml +++ b/google-cloud-core/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-core - 1.93.2 + 1.93.3 jar Google Cloud Core https://github.com/googleapis/java-core @@ -13,7 +13,7 @@ com.google.cloud google-cloud-core-parent - 1.93.2 + 1.93.3 google-cloud-core diff --git a/google-cloud-core/src/main/java/com/google/cloud/BaseServiceException.java b/google-cloud-core/src/main/java/com/google/cloud/BaseServiceException.java index e9e9e2aa63..29396d6d58 100644 --- a/google-cloud-core/src/main/java/com/google/cloud/BaseServiceException.java +++ b/google-cloud-core/src/main/java/com/google/cloud/BaseServiceException.java @@ -26,6 +26,7 @@ import java.util.Objects; import java.util.Set; import java.util.concurrent.ExecutionException; +import javax.net.ssl.SSLException; import javax.net.ssl.SSLHandshakeException; /** Base class for all service exceptions. */ @@ -256,6 +257,8 @@ public static boolean isRetryable(boolean idempotent, IOException exception) { boolean exceptionIsRetryable = exception instanceof SocketTimeoutException || exception instanceof SocketException + || (exception instanceof SSLException + && exception.getMessage().contains("Connection has been shutdown: ")) || (exception instanceof SSLHandshakeException && !(exception.getCause() instanceof CertificateException)) || "insufficient data written".equals(exception.getMessage()) diff --git a/google-cloud-core/src/main/java/com/google/cloud/Timestamp.java b/google-cloud-core/src/main/java/com/google/cloud/Timestamp.java index df111d3503..c2cf20a3e2 100644 --- a/google-cloud-core/src/main/java/com/google/cloud/Timestamp.java +++ b/google-cloud-core/src/main/java/com/google/cloud/Timestamp.java @@ -121,13 +121,13 @@ public static Timestamp now() { public static Timestamp of(java.sql.Timestamp timestamp) { int nanos = timestamp.getNanos(); - // A pre-epoch timestamp will be off by one second because of the way that integer division - // works. For example, -1001 / 1000 == -1. In this case of timestamps, we want this result to be - // -2. This causes any pre-epoch timestamp to be off by 1 second - fix this by adjusting the - // seconds value by 1 if the timestamp < 0. + // A pre-epoch timestamp can be off by one second because of the way that integer division + // works. For example, -1001 / 1000 == -1. In this case, we want this result to be -2. This + // causes any pre-epoch timestamp to be off by 1 second - fix this by subtracting 1 from the + // seconds value if the seconds value is less than zero and is not divisible by 1000. // TODO: replace with Math.floorDiv when we drop Java 7 support long seconds = timestamp.getTime() / 1000; - if (seconds < 0) { + if (seconds < 0 && timestamp.getTime() % 1000 != 0) { --seconds; } diff --git a/google-cloud-core/src/test/java/com/google/cloud/TimestampTest.java b/google-cloud-core/src/test/java/com/google/cloud/TimestampTest.java index 12e13ef5b9..26bf9f2f8d 100644 --- a/google-cloud-core/src/test/java/com/google/cloud/TimestampTest.java +++ b/google-cloud-core/src/test/java/com/google/cloud/TimestampTest.java @@ -18,6 +18,7 @@ import static com.google.common.testing.SerializableTester.reserializeAndAssert; import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import com.google.common.testing.EqualsTester; @@ -81,27 +82,43 @@ public void ofDate() { } @Test - public void ofSqlTimestamp() { + public void testOf() { String expectedTimestampString = "1970-01-01T00:00:12.345000000Z"; java.sql.Timestamp input = new java.sql.Timestamp(12345); Timestamp timestamp = Timestamp.of(input); - assertThat(timestamp.toString()).isEqualTo(expectedTimestampString); + assertEquals(timestamp.toString(), expectedTimestampString); } @Test - public void ofSqlTimestampPreEpoch() { + public void testOf_exactSecond() { + String expectedTimestampString = "1970-01-01T00:00:12Z"; + java.sql.Timestamp input = new java.sql.Timestamp(12000); + Timestamp timestamp = Timestamp.of(input); + assertEquals(timestamp.toString(), expectedTimestampString); + } + + @Test + public void testOf_preEpoch() { String expectedTimestampString = "1969-12-31T23:59:47.655000000Z"; java.sql.Timestamp input = new java.sql.Timestamp(-12345); Timestamp timestamp = Timestamp.of(input); - assertThat(timestamp.toString()).isEqualTo(expectedTimestampString); + assertEquals(timestamp.toString(), expectedTimestampString); } @Test - public void ofSqlTimestampOnEpoch() { + public void testOf_onEpoch() { String expectedTimestampString = "1970-01-01T00:00:00Z"; java.sql.Timestamp input = new java.sql.Timestamp(0); Timestamp timestamp = Timestamp.of(input); - assertThat(timestamp.toString()).isEqualTo(expectedTimestampString); + assertEquals(timestamp.toString(), expectedTimestampString); + } + + @Test + public void testOf_preEpochExactSecond() { + String expectedTimestampString = "1969-12-31T23:59:59Z"; + java.sql.Timestamp input = new java.sql.Timestamp(-1000); + Timestamp timestamp = Timestamp.of(input); + assertEquals(timestamp.toString(), expectedTimestampString); } @Test diff --git a/pom.xml b/pom.xml index 5d1525e917..22a6a778ed 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-core-parent pom - 1.93.2 + 1.93.3 Google Cloud Core Parent https://github.com/googleapis/java-core @@ -385,7 +385,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.1.1 + 3.2.0 html diff --git a/synth.metadata b/synth.metadata index 99a64e1760..06bf95877b 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,5 +1,5 @@ { - "updateTime": "2020-02-24T23:14:57.546329Z", + "updateTime": "2020-03-14T09:16:31.108382Z", "sources": [ { "template": { diff --git a/versions.txt b/versions.txt index acbf6e6ef4..6a76ae69ca 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,4 @@ # Format: # module:released-version:current-version -google-cloud-core:1.93.2:1.93.2 \ No newline at end of file +google-cloud-core:1.93.3:1.93.3 \ No newline at end of file