Skip to content

Refactor ContentDisposition type check #34573

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

Conversation

Tussle0410
Copy link
Contributor

@Tussle0410 Tussle0410 commented Mar 11, 2025

I noticed that there was duplicated logic when checking the definitions of DispositionType in ContentDisposition.java, so I extracted this logic into a private method.

After that, I realized there weren't any tests to verify this code was working properly, so I went ahead and added test code for it.

    public boolean isAttachment() {
	return (this.type != null && this.type.equalsIgnoreCase("attachment"));
    }
    ...

I've modified the existing code to follow the format shown below.

    public boolean isAttachment() {
	return isDispositionType("attachment");
    }

    private boolean isDispositionType(String type) {
	return this.type != null && this.type.equalsIgnoreCase(type);
    }

Signed-off-by: ChanHyeongLee <cksgud410@gmail.com>
Signed-off-by: ChanHyeongLee <cksgud410@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 11, 2025
@@ -555,6 +555,10 @@ private static char hexDigit(int b) {
return Character.toUpperCase(Character.forDigit(b & 0xF, 16));
}

private boolean isDepositionType(String type) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this a typo? Did you mean isDispositionType?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made a mistake. There's a typo. I meant isDispositionType. I'll fix it.

Signed-off-by: ChanHyeongLee <cksgud410@gmail.com>
@bclozel bclozel changed the title Separate commonly used logic into methods and add test code Refactor ContentDisposition type check Mar 17, 2025
@bclozel bclozel added in: web Issues in web modules (web, webmvc, webflux, websocket) type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 17, 2025
@bclozel bclozel added this to the 7.0.0-M4 milestone Mar 17, 2025
@bclozel bclozel closed this in 8ee09e5 Mar 17, 2025
@bclozel
Copy link
Member

bclozel commented Mar 17, 2025

Thanks for your contribution @Tussle0410 , this is now merged in the main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: task A general task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants