Skip to content

Fix BOOT-INF/classes/ prefix for two-arg openClasspathResource#18292

Merged
trask merged 4 commits into
open-telemetry:mainfrom
trask:spring-boot-resources-bootinf-version-fix
Apr 29, 2026
Merged

Fix BOOT-INF/classes/ prefix for two-arg openClasspathResource#18292
trask merged 4 commits into
open-telemetry:mainfrom
trask:spring-boot-resources-bootinf-version-fix

Conversation

@trask
Copy link
Copy Markdown
Member

@trask trask commented Apr 25, 2026

Extracted out of #18269

When the spring-boot-resources javaagent runs inside a Spring Boot fat jar, SystemHelper detects BOOT-INF/classes/ on the classpath and prepends it to single-arg openClasspathResource lookups. The two-arg overload (used by SpringBootServiceVersionDetector to read META-INF/build-info.properties) was missing the same prefix logic, so service version was not detected for fat-jar deployments.
@trask trask force-pushed the spring-boot-resources-bootinf-version-fix branch from 83bfb2c to 5a2a6e1 Compare April 26, 2026 00:25
Comment on lines +47 to +50
String path =
addBootInfPrefix
? "BOOT-INF/classes/" + directory + "/" + filename
: directory + "/" + filename;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The prefix is added under addBootInfPrefix in the single arg overload above, was just missing here. Didn't find an easy way to add a test for this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The only place where this method is used is in

to read META-INF/build-info.properties which is at the root of the jar not under BOOT-INF/classes
Add

springBoot {
	buildInfo()
}

to generate it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thank you! fixed

@trask trask marked this pull request as ready for review April 26, 2026 00:27
@trask trask requested a review from a team as a code owner April 26, 2026 00:27
trask added 2 commits April 29, 2026 09:36
…es-bootinf-version-fix

# Conflicts:
#	instrumentation/spring/spring-boot-resources/javaagent/src/test/java/io/opentelemetry/instrumentation/spring/resources/SpringBootServiceVersionDetectorTest.java
@trask trask merged commit 095be50 into open-telemetry:main Apr 29, 2026
177 of 179 checks passed
@trask trask deleted the spring-boot-resources-bootinf-version-fix branch April 29, 2026 22:55
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.

2 participants