Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt plugin for Java 21 #258

Merged
merged 5 commits into from
Aug 13, 2023
Merged

Commits on Aug 11, 2023

  1. Test with Java 21 on Linux

    MarkEWaite committed Aug 11, 2023
    Configuration menu
    Copy the full SHA
    813c21b View commit details
    Browse the repository at this point in the history

Commits on Aug 13, 2023

  1. Adapt tests to Java 21 date format change

    Java 21 changed the date format to use a narrow no-break space, so the
    regular expression used in the tests now fails to match. Changed the
    test to use the '\h' character class, which matches.
    
    jenkinsci/token-macro-plugin#191 uses the same
    technique to handle test compatibility between Java 11, Java 17, and
    Java 21.
    MarkEWaite committed Aug 13, 2023
    Configuration menu
    Copy the full SHA
    6e547b4 View commit details
    Browse the repository at this point in the history
  2. Use DateTimeFormatter if DateFormat does not parse

    Java 21 changed the behavior of the DateFormat parsing to no longer
    accept strings that contain only a time.  Previous versions of Java
    would default to January 1, 1970 if no date value was specified.
    
    The Java 21 behavior is quite reasonable, since a Date specifies a number
    of milliseconds since the epoch, not an offset since the start of the day.
    The plugin misuses a Date object to represent what Java 8 declared as
    LocalTime, a representation of time within a day.
    
    This change continues with the previous behavior, checking a DateFormat
    first.  If the DateFormat parse fails, then it iterates through a series
    of DateTimeFormatter patterns to check if the passed string matches one
    of those formats.
    
    I've not detected any case in the typical use of the plugin where the
    new Java 21 behavior affects plugin behavior.  It seems that there should
    be cases where the change is relevant, but I was not able to detect any
    of those cases.
    MarkEWaite committed Aug 13, 2023
    Configuration menu
    Copy the full SHA
    330e929 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    17f51ad View commit details
    Browse the repository at this point in the history
  4. Add additional time format parsers

    Same parsers are needed in the action class, but there are not yet any
    failing tests to show how they might help.
    MarkEWaite committed Aug 13, 2023
    Configuration menu
    Copy the full SHA
    6ada418 View commit details
    Browse the repository at this point in the history