Skip to content

Return absolute path without leading slash from ClassPathResource#getPath #29099

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

Closed
sbrannen opened this issue Sep 7, 2022 · 1 comment
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Sep 7, 2022

After putting further thought into the semantics for getPath() in ClassPathResource, I realized the following.

  1. Several tests were previously misusing getPath(), and I rectified that in commit 1688bec.
  2. My updates to the Javadoc for getPath() make it clear that the semantics are very inconsistent. See current Javadoc.
  3. If we switch getPath() to return this.absolutePath, the entire test suite passes except ClassPathResourceTests.preserveLeadingSlashForClassRelativeAccess(). Yet, I would argue that's not a valid use case.

In light of the above, I'm wondering if we should:

  1. Switch getPath() to return the absolute path consistently without a leading slash.
  2. Return the Javadoc for getPath() to its previous state (prior to Introduce getAbsolutePath() in ClassPathResource #29094).
  3. Remove the newly introduced getAbsolutePath() method (i.e., revert Introduce getAbsolutePath() in ClassPathResource #29094).
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement theme: aot An issue related to Ahead-of-time processing labels Sep 7, 2022
@sbrannen sbrannen added this to the 6.0.0-M6 milestone Sep 7, 2022
@sbrannen
Copy link
Member Author

sbrannen commented Sep 7, 2022

@jhoeller, I've assigned this one to both of us so that we can discuss it once you're back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants