Skip to content

Conversation

tanmaybaid
Copy link

@tanmaybaid tanmaybaid commented Sep 18, 2025

This change adds tests for bug reported in #3930

Following tests are failing as expected due to #3930:

[ERROR]   DatePatternConverterWithLegacyInstantFormatterTest>DatePatternConverterTestBase.testFormatAmericanPatterns:175->DatePatternConverterTestBase.assertDatePattern:187 expected: <11/03/2011 14:15:16.123000> but was: <11/03/2011 14:15:16.000123>
[ERROR]   DatePatternConverterWithThreadLocalsTest>DatePatternConverterTestBase.testFormatAmericanPatterns:178->DatePatternConverterTestBase.assertDatePattern:187 expected: <Fri, 11 Mar 2011 14:15:16 PST> but was: <Fri,' 11 Mar 2011 14:15:16 PST>
[ERROR]   DatePatternConverterWithoutThreadLocalsTest>DatePatternConverterTestBase.testFormatAmericanPatterns:178->DatePatternConverterTestBase.assertDatePattern:187 expected: <Fri, 11 Mar 2011 14:15:16 PST> but was: <Fri,' 11 Mar 2011 14:15:16 PST>

Checklist

Before we can review and merge your changes, please go through the checklist below. If you're still working on some items, feel free to submit your pull request as a draft—our CI will help guide you through the remaining steps.

✅ Required checks

  • License: I confirm that my changes are submitted under the Apache License, Version 2.0.

  • Commit signatures: All commits are signed and verifiable. (See GitHub Docs on Commit Signature Verification).

  • Code formatting: The code is formatted according to the project’s style guide.

    How to check and fix formatting
    • To check formatting: ./mvnw spotless:check
    • To fix formatting: ./mvnw spotless:apply

    See the build instructions for details.

  • Build & Test: I verified that the project builds and all unit tests pass.

    How to build the project

    Run: ./mvnw verify

    See the build instructions for details.

🧪 Tests (select one)

  • I have added or updated tests to cover my changes.

📝 Changelog (select one)

  • This is a trivial change and does not require a changelog entry.

…t class for LegacyInstantFormatter reprodcing bug apache#3667
Copy link
Contributor

@ppkarwasz ppkarwasz left a comment

Choose a reason for hiding this comment

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

Hi @tanmaybaid,

Thank you for the PR!

I am not really convinced we want to test the legacy formatter, but we'll certainly include the part for the new formatter.

assertDatePattern("dd/MM/yyyy HH:mm:ss.SSSSSS", date, "11/03/2011 14:15:16.123000");
assertDatePattern("dd/MM/yy HH:mm:ss.SSS", date, "11/03/11 14:15:16.123");
assertDatePattern("dd/MM/yy HH:mm:ss.SSSSSS", date, "11/03/11 14:15:16.123000");
assertDatePattern("EEE, dd MMM yyyy HH:mm:ss zzz", date, "Fri, 11 Mar 2011 14:15:16 PST");
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the test case, much appreciated! 💯

@SetTestProperty(key = "log4j2.instantFormatter", value = "legacy")
})
@UsingTestProperties
class DatePatternConverterWithLegacyInstantFormatterTest extends DatePatternConverterTestBase {
Copy link
Contributor

Choose a reason for hiding this comment

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

Personally I don't think we want to introduce more tests for the legacy formatter, since it is deprecated and will not change any more. @vy, what do you think?

Copy link

Job Requested goals Build Tool Version Build Outcome Build Scan®
build-macos-latest clean install 3.9.8 Build Scan PUBLISHED
build-ubuntu-latest clean install 3.9.8 Build Scan PUBLISHED
build-windows-latest clean install 3.9.8 Build Scan PUBLISHED
Generated by gradle/develocity-actions

@vy
Copy link
Member

vy commented Sep 18, 2025

I don't think we want to introduce more tests for the legacy formatter, since it is deprecated and will not change any more.

@tanmaybaid, we're grateful for your contribution, but I agree with @ppkarwasz. I am closing this PR in favor of #3932.

@vy vy closed this Sep 18, 2025
@github-project-automation github-project-automation bot moved this from To triage to Done in Log4j bug tracker Sep 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants