Skip to content

Conversation

@Marcono1234
Copy link
Contributor

Purpose

Validate GsonBuilder.setDateFormat style arguments & extend tests

Description

As side note: DateFormat validates these arguments as well, but it is currently not documented, see https://bugs.openjdk.org/browse/JDK-8319628.

Also moves the other tests for setDateFormat(String) from DefaultTypeAdaptersTest to GsonBuilderTest because they just test functionality of GsonBuilder.setDateFormat would testing any type adapter functionality.
(Acts a bit as follow-up for #2538.)

Checklist

  • New code follows the Google Java Style Guide
    This is automatically checked by mvn verify, but can also be checked on its own using mvn spotless:check.
    Style violations can be fixed using mvn spotless:apply; this can be done in a separate commit to verify that it did not cause undesired changes.
  • If necessary, new public API validates arguments, for example rejects null
  • New public API has Javadoc
    • Javadoc uses @since $next-version$
      ($next-version$ is a special placeholder which is automatically replaced during release)
  • If necessary, new unit tests have been added
    • Assertions in unit tests use Truth, see existing tests
    • No JUnit 3 features are used (such as extending class TestCase)
    • If this pull request fixes a bug, a new test was added for a situation which failed previously and is now fixed
  • mvn clean verify javadoc:jar passes without errors

`DateFormat` validates these arguments as well, but it is currently not
documented, see https://bugs.openjdk.org/browse/JDK-8319628.

Also moves the other tests for `setDateFormat(String)` from
DefaultTypeAdaptersTest to GsonBuilderTest.
Copy link
Member

@eamonnmcmanus eamonnmcmanus left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@eamonnmcmanus eamonnmcmanus merged commit 6684726 into google:main Nov 18, 2023
@unicornsavior42
Copy link

unicornsavior42 commented Nov 18, 2023 via email

@Marcono1234 Marcono1234 deleted the marcono1234/GsonBuilder-setDateFormat-style-validation branch November 18, 2023 23:26
@Marcono1234
Copy link
Contributor Author

As side note: Even though this extends the tests, it does not cover all use cases; #1529 is most likely still unresolved.

tibor-universe pushed a commit to getuniverse/gson that referenced this pull request Sep 14, 2024
…oogle#2545)

`DateFormat` validates these arguments as well, but it is currently not
documented, see https://bugs.openjdk.org/browse/JDK-8319628.

Also moves the other tests for `setDateFormat(String)` from
DefaultTypeAdaptersTest to GsonBuilderTest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants