GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(spotless/gradle-plugin): Fix `StringIndexOutOfBoundsException` in scenarios where copyright year is surrounded by whitespace by Maciej-Sitarz-IBM · Pull Request #2973 · diffplug/spotless

Conversation

@Maciej-Sitarz-IBM

@Maciej-Sitarz-IBM Maciej-Sitarz-IBM commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

When the line with Copyright year in the source file matches the one in the license header template, but the year number is surrounded with whitespace the code fails with StringIndexOutOfBoundsException exception:

2 actionable tasks: 2 executed
> Task :spotlessJava
> Task :spotlessJavaApply FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':spotlessJavaApply'.
> There were 1 lint error(s), they must be fixed or suppressed.
  src/main/java/pkg/Test.java:LINE_UNDEFINED com.diffplug.spotless.generic.LicenseHeaderStep(java.lang.StringIndexOutOfBoundsException) begin 8, end 7, length 7 (...)
  Resolve these lints or suppress with `suppressLintsFor`

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':spotlessJavaApply'.
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:149)
	at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:147)

(...)

Caused by: org.gradle.api.GradleException: There were 1 lint error(s), they must be fixed or suppressed.
src/main/java/pkg/Test.java:LINE_UNDEFINED com.diffplug.spotless.generic.LicenseHeaderStep(java.lang.StringIndexOutOfBoundsException) begin 8, end 7, length 7 (...)
Resolve these lints or suppress with `suppressLintsFor`
	at com.diffplug.gradle.spotless.SpotlessApply.performAction(SpotlessApply.java:60)
(...)

Changes

  1. Added unit test cases that test scenarios with year and year ranges having white-space before/after the year string. These tests reproduce the issue (first commit).
  2. Implemented the fix for the failing cases (second commit).
  3. Added info to changelogs (third commit).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Maciej-Sitarz-IBM added 3 commits June 12, 2026 15:28
@Maciej-Sitarz-IBM
Add tests for years surrounded by whitespace in license header
1194289
@Maciej-Sitarz-IBM
Fix handling of years surrounded by whitespace in license header
a427333
@Maciej-Sitarz-IBM
Update CHANGES.md, plugin-gradle/CHANGES.md and plugin-maven/CHANGES.md
4120d3a
@Maciej-Sitarz-IBM

Maciej-Sitarz-IBM commented Jun 12, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

This PR topic needs to be edited, as this fix is not only related to spotless/gradle-plugin.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Maciej-Sitarz-IBM added 3 commits June 12, 2026 15:56
@Maciej-Sitarz-IBM
Add missing . in all CHANGES.md
dbd462d
@Maciej-Sitarz-IBM
Remove unneeded debug comments
787819d
@Maciej-Sitarz-IBM
Revert the changes to assertUnchanged() and use assertTransform()…
b4d9ec0
… when needed
@nedtwigg
nedtwigg merged commit 780f0f6 into diffplug:main Jun 16, 2026
20 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@dongjoon-hyun dongjoon-hyun mentioned this pull request Jun 23, 2026
[SPARK-57629] Upgrade spotless-plugin-gradle to 8.7.0 apache/spark-kubernetes-operator#716
Closed
dongjoon-hyun added a commit to apache/spark-kubernetes-operator that referenced this pull request Jun 23, 2026
@dongjoon-hyun
[SPARK-57629] Upgrade spotless-plugin-gradle to 8.7.0
4779d71
### What changes were proposed in this pull request?

This PR upgrades `spotless-plugin-gradle` to `8.7.0`.

### Why are the changes needed?

To use the latest release (`8.7.0`, released on 2026-06-16).
- https://github.com/diffplug/spotless/releases/tag/gradle/8.7.0
  - diffplug/spotless#2962
  - diffplug/spotless#2940
  - diffplug/spotless#2973

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass the CIs.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Opus 4.8

Closes #716 from dongjoon-hyun/SPARK-57629.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Maciej-Sitarz-IBM @nedtwigg
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.