Skip to content
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

FileUrlResource isWritable method returns true if URL protocol is not indicating a file #25584

Conversation

yilianhuaixiao
Copy link
Contributor

if add testcase
@Test void test() throws IOException { Resource resource = new FileUrlResource(new URL("https://spring.io/")); assertThat(resource.isReadable()).isFalse(); }
the former code cannot pass.
Then I restricted FileUrlResource must be contructed with a URL about file.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 14, 2020
@jhoeller jhoeller self-assigned this Sep 8, 2020
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 8, 2020
@jhoeller jhoeller added this to the 5.2.9 milestone Sep 8, 2020
@jhoeller jhoeller changed the title Fix FileUrlResource isWritable method returns true if URL's protocol is not about file bug FileUrlResource isWritable method returns true if URL protocol is not indicating a file Sep 8, 2020
@jhoeller
Copy link
Contributor

jhoeller commented Sep 8, 2020

I've addressed this somewhat differently, exclusively relying on getFile() resolution (which could be overridden in subclasses) and not checking the URL protocol in the isWritable() implementation at all anymore.

Thanks for spotting this - and thanks for the pull request, in any case!

@jhoeller jhoeller added the for: backport-to-5.1.x Marks an issue as a candidate for backport to 5.1.x label Sep 8, 2020
@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-5.1.x Marks an issue as a candidate for backport to 5.1.x labels Sep 8, 2020
@jhoeller jhoeller closed this in c6cc670 Sep 8, 2020
jhoeller added a commit that referenced this pull request Sep 8, 2020
jhoeller added a commit that referenced this pull request Sep 8, 2020
engimatic pushed a commit to engimatic/spring-framework that referenced this pull request Sep 29, 2020
zx20110729 pushed a commit to zx20110729/spring-framework that referenced this pull request Feb 18, 2022
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) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants