Skip to content

Fix IndexOutOfBoundsException when JUL placeholders exceed argument count#284

Merged
timtebeek merged 1 commit into
mainfrom
tim/triage-open-issues
Apr 8, 2026
Merged

Fix IndexOutOfBoundsException when JUL placeholders exceed argument count#284
timtebeek merged 1 commit into
mainfrom
tim/triage-open-issues

Conversation

@timtebeek

Copy link
Copy Markdown
Member

Summary

  • Fixes JUL->slf4j parametrized recipe fails if placeholders doesn't match number of arguments #165: JulParameterizedArguments threw IndexOutOfBoundsException when a JUL format string referenced more placeholders (e.g. {0}, {1}) than arguments provided in the Object[] array.
  • Adds a bounds check to skip the transformation when any placeholder index exceeds the array size, leaving the original code unchanged.
  • Adds a test case reproducing the exact scenario from the issue.

Test plan

  • Added placeholderCountExceedsArgumentCount() test with the reported input ("Elements for {0} are {1}" with one-element array)
  • All 12 tests in JulParameterizedArgumentsTest pass (11 run + 1 pre-existing skip)

@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Apr 8, 2026
@timtebeek timtebeek merged commit dc421ef into main Apr 8, 2026
1 check passed
@timtebeek timtebeek deleted the tim/triage-open-issues branch April 8, 2026 10:26
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Apr 8, 2026
mergify Bot added a commit to robfrank/linklift that referenced this pull request May 3, 2026
…rom 3.26.0 to 3.27.2 [skip ci]

Bumps [org.openrewrite.recipe:rewrite-logging-frameworks](https://github.com/openrewrite/rewrite-logging-frameworks) from 3.26.0 to 3.27.2.
Release notes

*Sourced from [org.openrewrite.recipe:rewrite-logging-frameworks's releases](https://github.com/openrewrite/rewrite-logging-frameworks/releases).*

> 3.27.2
> ------
>
> What's Changed
> --------------
>
> * OpenRewrite v8.81.0: <openrewrite/rewrite@v8.81.0...main>
>
> **Full Changelog**: <https://github.com/openrewrite/rewrite-logging-frameworks>
>
> 3.27.1
> ------
>
> What's Changed
> --------------
>
> * OpenRewrite v8.80.0: <openrewrite/rewrite@v8.80.0...main>
>
> **Full Changelog**: <https://github.com/openrewrite/rewrite-logging-frameworks>
>
> 3.27.0
> ------
>
> What's Changed
> --------------
>
> * Fix IndexOutOfBoundsException when JUL placeholders exceed argument count by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-logging-frameworks#284](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/284)
> * Fix exception consumed by format placeholder in CompleteExceptionLogging by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-logging-frameworks#285](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/285)
>
> **Full Changelog**: <openrewrite/rewrite-logging-frameworks@v3.26.0...v3.27.0>
>
> 3.26.1
> ------
>
> What's Changed
> --------------
>
> * OpenRewrite v8.77.0: <openrewrite/rewrite@v8.77.0...main>
>
> **Full Changelog**: <https://github.com/openrewrite/rewrite-logging-frameworks>


Commits

* [`a33a6f6`](openrewrite/rewrite-logging-frameworks@a33a6f6) Fix exception consumed by format placeholder in CompleteExceptionLogging ([#14](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/issues/14)...
* [`dc421ef`](openrewrite/rewrite-logging-frameworks@dc421ef) Fix IndexOutOfBoundsException when JUL placeholders exceed argument count ([#1](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/issues/1)...
* [`d65ada8`](openrewrite/rewrite-logging-frameworks@d65ada8) Update suppression date from April to May 2026
* [`3dbefb5`](openrewrite/rewrite-logging-frameworks@3dbefb5) Use `JavaTemplate.apply()` static method
* [`86e5a6b`](openrewrite/rewrite-logging-frameworks@86e5a6b) OpenRewrite recipe best practices
* See full diff in [compare view](openrewrite/rewrite-logging-frameworks@v3.26.0...v3.27.2)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=org.openrewrite.recipe:rewrite-logging-frameworks&package-manager=maven&previous-version=3.26.0&new-version=3.27.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
mergify Bot added a commit to robfrank/linklift that referenced this pull request Jun 4, 2026
…rom 3.27.2 to 3.29.0 [skip ci]

Bumps [org.openrewrite.recipe:rewrite-logging-frameworks](https://github.com/openrewrite/rewrite-logging-frameworks) from 3.27.2 to 3.29.0.
Release notes

*Sourced from [org.openrewrite.recipe:rewrite-logging-frameworks's releases](https://github.com/openrewrite/rewrite-logging-frameworks/releases).*

> 3.29.0
> ------
>
> What's Changed
> --------------
>
> * Regenerate recipes.csv by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-logging-frameworks#292](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/292)
> * Fix re-escaping of control characters when rebuilding Java string literals in logging recipes. by [`@​motlin`](https://github.com/motlin) in [openrewrite/rewrite-logging-frameworks#293](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/293)
> * Add Log4j2IsEnabledToSlf4j Refaster recipe to convert isEnabled(Level) level guards to SLF4J isXEnabled() calls. by [`@​motlin`](https://github.com/motlin) in [openrewrite/rewrite-logging-frameworks#294](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/294)
>
> **Full Changelog**: <openrewrite/rewrite-logging-frameworks@v3.28.0...v3.29.0>
>
> 3.28.0
> ------
>
> What's Changed
> --------------
>
> * Renew log4j 1.2.17 reference suppression to 2026-06-01 by [`@​Jenson3210`](https://github.com/Jenson3210) in [openrewrite/rewrite-logging-frameworks#287](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/287)
> * Update log4j-api TypeTable to 2.26.0 by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-logging-frameworks#288](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/288)
> * Preserve formatting when ParameterizedLogging has nothing to parameterize by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-logging-frameworks#290](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/290)
>
> **Full Changelog**: <openrewrite/rewrite-logging-frameworks@v3.27.0...v3.28.0>
>
> v3.27.3
> -------
>
> What's Changed
> --------------
>
> * OpenRewrite [v8.81.6](https://github.com/openrewrite/rewrite/releases/tag/v8.81.6)
> * Fix IndexOutOfBoundsException when JUL placeholders exceed argument count by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-logging-frameworks#284](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/284)
> * Fix exception consumed by format placeholder in CompleteExceptionLogging by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-logging-frameworks#285](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/pull/285)
>
> **Full Changelog**: <openrewrite/rewrite-logging-frameworks@v3.26.0...v3.27.3>


Commits

* [`944b9c2`](openrewrite/rewrite-logging-frameworks@944b9c2) Add Log4j2IsEnabledToSlf4j Refaster recipe to convert isEnabled(Level) level ...
* [`246f4d3`](openrewrite/rewrite-logging-frameworks@246f4d3) Fix re-escaping of control characters when rebuilding Java string literals in...
* [`d5537a4`](openrewrite/rewrite-logging-frameworks@d5537a4) Update Gradle wrapper 9.5.1
* [`58e431b`](openrewrite/rewrite-logging-frameworks@58e431b) Regenerate recipes.csv ([#292](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/issues/292))
* [`28afd35`](openrewrite/rewrite-logging-frameworks@28afd35) Remove explicit test dependencies
* [`14f50ad`](openrewrite/rewrite-logging-frameworks@14f50ad) Preserve formatting when ParameterizedLogging has nothing to parameterize ([#2](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/issues/2)...
* [`32e22cb`](openrewrite/rewrite-logging-frameworks@32e22cb) Update log4j-api TypeTable to 2.26.0 ([#288](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/issues/288))
* [`b7824c6`](openrewrite/rewrite-logging-frameworks@b7824c6) OpenRewrite recipe best practices
* [`43fc6c2`](openrewrite/rewrite-logging-frameworks@43fc6c2) Renew log4j 1.2.17 reference suppression to 2026-06-01 ([#287](https://redirect.github.com/openrewrite/rewrite-logging-frameworks/issues/287))
* See full diff in [compare view](openrewrite/rewrite-logging-frameworks@v3.27.2...v3.29.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

JUL->slf4j parametrized recipe fails if placeholders doesn't match number of arguments

1 participant