Skip to content

Conversation

@srowen
Copy link
Member

@srowen srowen commented Jan 8, 2024

What changes were proposed in this pull request?

Simplify code and fix new use of DateTimeFormat.withZone introduced in #44613 ; need to use the new object copy this creates.

Why are the changes needed?

Describing on mailing list from Janda Martin:

DateTimeFormatter is thread-safe and immutable according to JavaDoc so method DateTimeFormatter::withZone returns new instance when zone is changed.

Following code has no effect:
  val oldTimezones = (batchTimeFormat.getZone, batchTimeFormatWithMilliseconds.getZone)
  if (timezone != null) {
      val zoneId = timezone.toZoneId
      batchTimeFormat.withZone(zoneId)
      batchTimeFormatWithMilliseconds.withZone(zoneId)
    }

Suggested fix:
introduce local variables for "batchTimeFormat" and "batchTimeFormatWithMilliseconds" and remove "oldTimezones" and "finally" block.

Does this PR introduce any user-facing change?

Unlikely, the path in question is apparently test-only

How was this patch tested?

Existing tests

Was this patch authored or co-authored using generative AI tooling?

No

@HyukjinKwon
Copy link
Member

Copy link
Contributor

@beliefer beliefer left a comment

Choose a reason for hiding this comment

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

LGTM if tests passed.

@HyukjinKwon
Copy link
Member

Merged to master.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants