pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/flowable/flowable-engine/pull/4175

obal-68dd150ce6c8e711.css" /> Disable lenient parsing in DateFormType by gilisd · Pull Request #4175 · flowable/flowable-engine · GitHub
Skip to content

Disable lenient parsing in DateFormType#4175

Open
gilisd wants to merge 2 commits intoflowable:mainfrom
gilisd:fix/date-form-type-lenient-parsing
Open

Disable lenient parsing in DateFormType#4175
gilisd wants to merge 2 commits intoflowable:mainfrom
gilisd:fix/date-form-type-lenient-parsing

Conversation

@gilisd
Copy link

@gilisd gilisd commented Mar 4, 2026

FastDateFormat.parseObject() silently accepted invalid dates by rolling over values (e.g. month 13 became month 1 of the next year). Use SimpleDateFormat with setLenient(false) to reject invalid dates.

Check List:

  • Unit tests: YES
  • Documentation: NA

FastDateFormat.parseObject() silently accepted invalid dates by rolling
over values (e.g. month 13 became month 1 of the next year).
Use SimpleDateFormat with setLenient(false) to reject invalid dates.
@jbarrez
Copy link
Contributor

jbarrez commented Mar 18, 2026

Thanks @gilisd,

Good catch.

Looking at the existing code, there is now the dateFormat field which gets initialized in the constructor. However, it's now only used in the other method. Isn't there anything in the FastDateFormat class that can be used to reuse the field?

FastDateFormat does not support lenient=false. Using local SimpleDateFormat
instances in both methods avoids shared state and is thread-safe. The overhead
of creating a new instance per call is acceptable as these methods are not
expected to be called frequently on the same object.
@gilisd
Copy link
Author

gilisd commented Mar 18, 2026

Thanks @gilisd,

Good catch.

Looking at the existing code, there is now the dateFormat field which gets initialized in the constructor. However, it's now only used in the other method. Isn't there anything in the FastDateFormat class that can be used to reuse the field?

Good point. FastDateFormat does not support setLenient(false) — it is explicitly lenient by default, so it cannot be used for strict parsing.

We addressed your concern by removing the dateFormat field entirely. Both methods now use a local SimpleDateFormat instance, which keeps the code consistent and avoids shared state.

Thread-safety is preserved since local variables are per-thread. The overhead of creating a new instance per call is acceptable as these methods are not expected to be called frequently on the same object.

@filiphr
Copy link
Contributor

filiphr commented Mar 18, 2026

@gilisd in order to avoid the creation of the date pattern on every conversion, can't we create 2 fields? Thread safety is fine since we are not going to change those 2 fields at any time.

@filiphr
Copy link
Contributor

filiphr commented Mar 18, 2026

@gilisd, thinking a bit more about this. This PR now fully disables lenient parsing and we switch the date format from FastDateFormat to SimpleDateFormat.

Looking at the Javadoc of FastDateFormat it says:

Javadoc cites for the year pattern: For formatting, if the number of pattern letters is 2, the year is truncated to 2 digits; otherwise it is interpreted as a number. Starting with Java 1.7 a pattern of 'Y' or 'YYY' will be formatted as '2003', while it was '03' in former Java versions. FastDateFormat implements the behavior of Java 7.

Perhaps we need to keep the FastDateFormat for the formatting, otherwise it could be a behaviour change. Additionally, we perhaps need to offer lenientDateFormat or lenientDateFormatParse as a boolean flag to FormProperty and DateFormType in order to allow for backwards compatibility in case someone relied on the lenient parsing.

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.

4 participants

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy