Skip to content

Conversation

@Deigue
Copy link
Contributor

@Deigue Deigue commented Jun 28, 2022

This is a REDO of the Fix that was incompletely implemented earlier:
8285838: Fix for TZ environment variable DST rules

Offset calculation now accounts all the way upto year in order to avoid cross-day miscalculations as well as to calculate always in the correct direction for offset. In situations where there may be multiple days, the excess days of offset will be shaved off by applying mod to seconds_per_day , which will remove the excessive days that might be included in the offset calculation for special scenarios like a leap year / February months and variances between 30 and 31 days.

I have tested this solution with the cases where this fix had failed last time as well, and confirmed it works:
(where 7200 represents 7200 seconds -> +2 hour offset)
Sample output:
image


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8288377: [REDO] DST not applying properly with zone id offset set with TZ env variable

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9312/head:pull/9312
$ git checkout pull/9312

Update a local copy of the PR:
$ git checkout pull/9312
$ git pull https://git.openjdk.org/jdk pull/9312/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9312

View PR using the GUI difftool:
$ git pr show -t 9312

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9312.diff

8288377: Offset calculation fix for DST with custom TZ.
@bridgekeeper
Copy link

bridgekeeper bot commented Jun 28, 2022

👋 Welcome back Deigue! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 28, 2022
@openjdk
Copy link

openjdk bot commented Jun 28, 2022

@Deigue The following labels will be automatically applied to this pull request:

  • core-libs
  • i18n

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org labels Jun 28, 2022
@mlbridge
Copy link

mlbridge bot commented Jun 28, 2022

Webrevs

@naotoj
Copy link
Member

naotoj commented Jun 28, 2022

I just wonder we could simply call strftime with %z conversion, rather than calculating the GMT offset ourselves. Would you like to try it out?

@Deigue
Copy link
Contributor Author

Deigue commented Jun 29, 2022

@naotoj Thanks for letting me know, hadn't tried that function yet. At first look it seems to working exactly as needed, but I will need to parse the result into substrings to put a semi-colon between the hour and minute offset, in order to match the output required. But definitely looks much simpler in comparison ...

@naotoj
Copy link
Member

naotoj commented Jun 29, 2022

I think you could simplify the code further, i.e. there will be no need to separate the function with #if defined(MACOSX). The code can be shared with all Unix platforms.

@Deigue
Copy link
Contributor Author

Deigue commented Jun 30, 2022

I have simplified the implementation and tested that it works on Linux ... I still need to check this on a MAC OS computer and see if it working like before without any issues.

One more thing to note/I'd like to make sure is what the output looks like when TZ is GMT. Want to ensure that the final string being passed down is just "GMT" and that strftime invocation returns an empty result. If the result is coming out to be slightly different, then it could be a problem.

}

#else
strftime(offset, 6, "%z", &localtm);
Copy link
Member

Choose a reason for hiding this comment

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

Return value has to be examined. If it is not 5, then I'd expect falling back to "GMT".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added check to verify output is as expected before proceeding, with fallback

}
sprintf(buf, (const char *)"GMT%c%02d:%02d",
sign, (int)(offset/3600), (int)((offset%3600)/60));
sprintf(buf, (const char *)"GMT%s", gmt_offset);
Copy link
Member

Choose a reason for hiding this comment

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

You could use the format string as "GMT%c%c%c:%c%c" so that the extra gmt_offset variable can be eliminated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adjusted, forgot that the final string returned was able to be formatted itself as well.

@naotoj
Copy link
Member

naotoj commented Jun 30, 2022

One more thing to note/I'd like to make sure is what the output looks like when TZ is GMT. Want to ensure that the final string being passed down is just "GMT" and that strftime invocation returns an empty result. If the result is coming out to be slightly different, then it could be a problem.

You could compare GMT's hour/miute with localtime's. If they are identical, then return "GMT". For that, we may end up reviving #if defined (MACOSX) since macOS's tm struct has tm_gmtoff, but limited to that piece of code.

Copy link
Member

@naotoj naotoj left a comment

Choose a reason for hiding this comment

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

Thanks. Looks good with one minor request.

offset = -offset;
sign = '+';
strftime(offset, 6, "%z", &localtm);
if (strlen(offset) != 5) {
Copy link
Member

Choose a reason for hiding this comment

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

What I meant was the return value from strftime, not the length from strlen, ie, if (strftime(...) != 5). It should be more robust.

Copy link
Member

@naotoj naotoj left a comment

Choose a reason for hiding this comment

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

Looks good.

@openjdk
Copy link

openjdk bot commented Jul 29, 2022

@Deigue This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8288377: [REDO] DST not applying properly with zone id offset set with TZ env variable

Reviewed-by: naoto

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 1271 new commits pushed to the master branch:

  • af529be: 8285836: sun/net/www/http/KeepAliveCache/KeepAliveProperty.java failed with "RuntimeException: Failed in server"
  • b7d2bde: 8291733: Remove JFR events that expose hashtable
  • 0971d34: Merge
  • 54c093a: 8291524: jdk/jfr/event/runtime/TestClassLoaderStatsEvent.java Value not equal to 2, field='hiddenClassCount', value='0'
  • 1d16c91: 8291512: Snippetize modules API examples
  • 0ae8341: 8290908: misc tests fail: assert(!thread->owns_locks()) failed: must release all locks when leaving VM
  • 5acf2d7: 8291578: Remove JMX related tests from ProblemList-svc-vthreads.txt
  • a6564d4: 8291650: Add delay to ClassUnloadEventTest before exiting to give time for JVM to send all events before VMDeath
  • af76c0c: 8291654: AArch64: assert from JDK-8287393 causes crashes
  • a9db5bb: 8291626: Remove Mutex::contains as it is unused
  • ... and 1261 more: https://git.openjdk.org/jdk/compare/41de506ed6c9dc0331c2b6ae99c11623df05f34a...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@naotoj) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 29, 2022
@Deigue
Copy link
Contributor Author

Deigue commented Aug 3, 2022

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Aug 3, 2022
@openjdk
Copy link

openjdk bot commented Aug 3, 2022

@Deigue
Your change (at version b09df3d) is now ready to be sponsored by a Committer.

@naotoj
Copy link
Member

naotoj commented Aug 4, 2022

/sponsor

@openjdk
Copy link

openjdk bot commented Aug 4, 2022

Going to push as commit 3c32564.
Since your change was applied there have been 1295 commits pushed to the master branch:

  • fd9ac62: 8291457: Clean up lifecycle of CDS dump-time data structures
  • 3ba3171: 8285935: Spurious lint warning for static method accessed through instance qualifier
  • 92d2982: 8283232: x86: Improve vector broadcast operations
  • 966ab21: 8291895: Remove PRAGMA_NONNULL_IGNORED from x86 and AArch64
  • aa557b9: 8288327: Executable.hasRealParameterData should not be volatile
  • d4a795d: 8283276: java/io/ObjectStreamClass/ObjectStreamClassCaching.java fails with various GCs
  • a3040fc: 8291360: Create entry points to expose low-level class file information
  • ce61eb6: 8290349: IP_DONTFRAGMENT doesn't set DF bit in IPv4 header
  • 26e5c11: 4890041: Remove TAB and Shift TAB from Popup Menu in Motif Look & Feel
  • 0bc804d: 8291762: Backout JDK-8291757 from jdk/jdk
  • ... and 1285 more: https://git.openjdk.org/jdk/compare/41de506ed6c9dc0331c2b6ae99c11623df05f34a...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 4, 2022
@openjdk openjdk bot closed this Aug 4, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Aug 4, 2022
@openjdk
Copy link

openjdk bot commented Aug 4, 2022

@naotoj @Deigue Pushed as commit 3c32564.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

2 participants