GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: Timestamp.of(java.sql.Timestamp) pre-epoch on exact second by olavloite · Pull Request #179 · googleapis/java-core

This repository was archived by the owner on Dec 3, 2023. It is now read-only.

Conversation

@olavloite

@olavloite olavloite commented Mar 12, 2020

Copy link
Copy Markdown
Contributor

The fix for negative timestamps in #160 did not take into account the possibility that the pre-epoch timestamp could be on an exact second value. In that case, the additional correction of the calculated second value should not be applied.

Fixes googleapis/java-spanner-jdbc#85

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@olavloite
fix: Timestamp.of(java.sql.Timestamp) pre-epoch on exact second
e10e4c0
@olavloite
olavloite requested review from chingor13, codyoss and elharo March 12, 2020 07:39
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 12, 2020
@codecov

codecov Bot commented Mar 12, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

Merging #179 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #179   +/-   ##
=========================================
  Coverage     67.76%   67.76%           
- Complexity      378      379    +1     
=========================================
  Files            36       36           
  Lines          1967     1967           
  Branches        259      259           
=========================================
  Hits           1333     1333           
  Misses          526      526           
  Partials        108      108
Impacted Files Coverage Δ Complexity Δ
...core/src/main/java/com/google/cloud/Timestamp.java 90.62% <100%> (ø) 26 <0> (+1) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ae35d0e...b9e2161. Read the comment docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

elharo
elharo reviewed Mar 12, 2020
View reviewed changes
Comment thread google-cloud-core/src/test/java/com/google/cloud/TimestampTest.java Outdated
}

@Test
public void ofSqlTimestampOnExactSecond() {

@elharo elharo Mar 12, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this method name more conventional? e.g. testOf_exactSecond or some such.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@olavloite olavloite Mar 12, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Although this means that the name of this test is not in line with the other test cases in this file, such as for example ofSqlTimestampPreEpoch.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@elharo elharo Mar 12, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Section 8.5.2 of the Google style guide addresses this:

When adding new code to a file that is not in Google Style, reformatting the existing code first is recommended, subject to the advice in Section 8.5.1, Reformatting existing code.

If this reformatting is not done, new code is still required to be added in Google Style, even if this creates inconsistencies.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@olavloite olavloite Mar 12, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated all the test cases for Timestamp.of(java.sql.Timestamp) to use consistent naming and assertEquals instead of assertThat....

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-cloud-core/src/test/java/com/google/cloud/TimestampTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-cloud-core/src/main/java/com/google/cloud/Timestamp.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@olavloite
fix: review comments
9bdd7f1
@olavloite
olavloite requested a review from elharo March 12, 2020 12:37
elharo
elharo reviewed Mar 12, 2020
View reviewed changes
Comment thread google-cloud-core/src/main/java/com/google/cloud/Timestamp.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-cloud-core/src/main/java/com/google/cloud/Timestamp.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-cloud-core/src/main/java/com/google/cloud/Timestamp.java Outdated
// 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.
// seconds value by 1 if the timestamp < 0 and the division by 1000 has a remainder.

@elharo elharo Mar 12, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be technical, a non-zero remainder. Suggest rephrasing as "the timestamp is less than zero and is not divisible by 1000."

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@olavloite olavloite Mar 12, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to fix this by subtracting 1 from the seconds value if the seconds value is less than zero and is not divisible by 1000.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-cloud-core/src/test/java/com/google/cloud/TimestampTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-cloud-core/src/test/java/com/google/cloud/TimestampTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

olavloite added 2 commits March 12, 2020 17:10
@olavloite
fix: review comments
7fb96d8
@olavloite
fix: make all testOf method consistent
b9e2161
@olavloite
olavloite requested a review from elharo March 12, 2020 16:59
codyoss
codyoss approved these changes Mar 12, 2020
View reviewed changes

@codyoss codyoss left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
chingor13
chingor13 approved these changes Mar 12, 2020
View reviewed changes
elharo
elharo approved these changes Mar 12, 2020
View reviewed changes
@chingor13
chingor13 merged commit 9bfb54c into master Mar 12, 2020
@chingor13
chingor13 deleted the fix-sql-timestamp-on-exact-second-pre-epoch branch March 12, 2020 18:07
@skuruppu skuruppu mentioned this pull request Mar 14, 2020
feat: add support for QueryOptions googleapis/java-spanner-jdbc#76
Merged
@olavloite olavloite mentioned this pull request Feb 8, 2021
test: re-enable JDBC converter test googleapis/java-spanner-jdbc#348
Merged
@release-please release-please Bot mentioned this pull request Jan 4, 2022
chore(main): release java-core 2.0.0 #653
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

3 more reviewers
@chingor13 chingor13 chingor13 approved these changes
@elharo elharo elharo approved these changes
@codyoss codyoss codyoss approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

spanner-jdbc: JdbcTypeConverterTest failure

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@olavloite @chingor13 @elharo @codyoss @googlebot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.