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

๐Ÿ› ์˜ค๋ฅ˜ ์ˆ˜์ • - @AuthenticationPrincipal User user๋กœ user.getUsername() ์กฐํšŒ์‹œ, null์˜ค๋ฅ˜ #82

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

Aleph-Kim
Copy link
Collaborator

No description provided.

@Aleph-Kim Aleph-Kim self-assigned this Aug 23, 2024
Copy link
Contributor

@parkswon1 parkswon1 left a comment

Choose a reason for hiding this comment

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

LGTM!

@hanseu9839
Copy link
Collaborator

findById ์ธ๋ฐ ์—๋Ÿฌ ์ถœ๋ ฅ ๋ฟœ๋Š”๊ฒŒ ์ด์ƒํ•œ๋ฐ ์–ด๋–ป๊ฒŒ ์ƒ๊ฐํ•˜์‹ค๊นŒ์œ  ๊ทธ๋Œ€๋กœ ์ง„ํ–‰ํ•ด๋„ ๋ฉ๋‹ˆ๋‹ค.
์‹ ๊ฒฝ์“ฐ๊ธฐ ๋ง๊ณ  ๊ฐœ๋ฐœํ• ๊นŒ์š”?
https://creampuffy.tistory.com/162
์ถœ์ฒ˜ ๊ธ€์ž…๋‹ˆ๋‹ค.

@parkswon1
Copy link
Contributor

parkswon1 commented Aug 25, 2024

getById ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜๋ฉด ์—”ํ‹ฐํ‹ฐ ์ฐธ์กฐ๋ฅผ ์ฆ‰์‹œ ๋ฐ˜ํ™˜ํ•˜์ง€๋งŒ ์‹ค์ œ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ ‘๊ทผ์€ ๋‚˜์ค‘์— ์ด๋ฃจ์–ด ์ ธ์„œ EntityNotFoundException ์˜ˆ์ƒ์ด ์ƒ๊ธธ์ˆ˜ ์žˆ๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค ๊ทธ๋ž˜์„œ get๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด getReferenceById๋ฅผ ์‚ฌ์šฉํ•ด์•ผํ•œ๋‹ค๋Š” sonarlint๋ฅผ ๋ดค์Šต๋‹ˆ๋‹ค.
->๋ธ”๋กœ๊ทธ๊ธ€ ์ฝ์–ด๋ดค๋Š”๋ฐ ์ด๋ฏธ getReferenceById๊ฐ€์žˆ๋„ค์š” ์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿผ get์œผ๋กœ ๋ถ„๋ฅ˜ํ•˜๋ฉด getReference๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ์‹์„ ์“ฐ๋‚˜์š”?
image

@Aleph-Kim
Copy link
Collaborator Author

findById ์ธ๋ฐ ์—๋Ÿฌ ์ถœ๋ ฅ ๋ฟœ๋Š”๊ฒŒ ์ด์ƒํ•œ๋ฐ ์–ด๋–ป๊ฒŒ ์ƒ๊ฐํ•˜์‹ค๊นŒ์œ  ๊ทธ๋Œ€๋กœ ์ง„ํ–‰ํ•ด๋„ ๋ฉ๋‹ˆ๋‹ค. ์‹ ๊ฒฝ์“ฐ๊ธฐ ๋ง๊ณ  ๊ฐœ๋ฐœํ• ๊นŒ์š”? https://creampuffy.tistory.com/162 ์ถœ์ฒ˜ ๊ธ€์ž…๋‹ˆ๋‹ค.

์ง€๊ธˆ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค๋Š” ๋ง์”€์ด์‹ ๊ฐ€์š” ์•„๋‹ˆ๋ฉด ์ถ”ํ›„์— ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ• ๋งŒํ•œ ๋ถ€๋ถ„์ด ์žˆ๋‹ค๋Š” ๋ง์”€์ด์‹ ๊ฐ€์šฉ
์ด๋ฉ”์ผ์— ํ•ด๋‹นํ•˜๋Š” ์œ ์ €๊ฐ€ ์—†์„ ๊ฒฝ์šฐ๋ฅผ ๋Œ€๋น„ํ•ด์„œ getReferenceById๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๊ฒŒ ์ข‹์•„๋ณด์ธ๋‹ค๋Š” ๋ง์”€์ด์‹œ๋ฉด orElseThrow๋กœ ์˜ˆ์™ธ์ฒ˜๋ฆฌ๋ฅผ ํ•ด๋†จ์œผ๋‹ˆ ํฌ๊ฒŒ ๋ฌธ์ œ๋  ๋ถ€๋ถ„์€ ์—†์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์ง€์—ฐ ๋กœ๋”ฉ๋„ ๊ตณ์ด ํ•„์š” ์—†์„ ๊ฒƒ ๊ฐ™๊ตฌ์šฉ

@hanseu9839
Copy link
Collaborator

findById ์ธ๋ฐ ์—๋Ÿฌ ์ถœ๋ ฅ ๋ฟœ๋Š”๊ฒŒ ์ด์ƒํ•œ๋ฐ ์–ด๋–ป๊ฒŒ ์ƒ๊ฐํ•˜์‹ค๊นŒ์œ  ๊ทธ๋Œ€๋กœ ์ง„ํ–‰ํ•ด๋„ ๋ฉ๋‹ˆ๋‹ค. ์‹ ๊ฒฝ์“ฐ๊ธฐ ๋ง๊ณ  ๊ฐœ๋ฐœํ• ๊นŒ์š”? https://creampuffy.tistory.com/162 ์ถœ์ฒ˜ ๊ธ€์ž…๋‹ˆ๋‹ค.

์ง€๊ธˆ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค๋Š” ๋ง์”€์ด์‹ ๊ฐ€์š” ์•„๋‹ˆ๋ฉด ์ถ”ํ›„์— ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ• ๋งŒํ•œ ๋ถ€๋ถ„์ด ์žˆ๋‹ค๋Š” ๋ง์”€์ด์‹ ๊ฐ€์šฉ ์ด๋ฉ”์ผ์— ํ•ด๋‹นํ•˜๋Š” ์œ ์ €๊ฐ€ ์—†์„ ๊ฒฝ์šฐ๋ฅผ ๋Œ€๋น„ํ•ด์„œ getReferenceById๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๊ฒŒ ์ข‹์•„๋ณด์ธ๋‹ค๋Š” ๋ง์”€์ด์‹œ๋ฉด orElseThrow๋กœ ์˜ˆ์™ธ์ฒ˜๋ฆฌ๋ฅผ ํ•ด๋†จ์œผ๋‹ˆ ํฌ๊ฒŒ ๋ฌธ์ œ๋  ๋ถ€๋ถ„์€ ์—†์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์ง€์—ฐ ๋กœ๋”ฉ๋„ ๊ตณ์ด ํ•„์š” ์—†์„ ๊ฒƒ ๊ฐ™๊ตฌ์šฉ

find -> ๋ผ๋Š” ์˜๋ฏธ๊ฐ€ ์ฐพ๋‹ค๋ผ๋Š” ์˜๋ฏธ๊ฐ€ ๊ฐ•ํ•œ ๋‚ด์šฉ์ธ๋ฐ findById์—์„œ ์—๋Ÿฌ๊ฐ€ ๋‚˜์˜ค๋‹ˆ๊น ์ฐพ์„์ˆ˜๋„ ์žˆ๊ณ  ์—†์„์ˆ˜๋„ ์žˆ๋Š”๋ฐ ์ด๋Ÿด ๋•Œ๋Š” get์„ ์‚ฌ์šฉํ•˜๋Š” ํ‘œํ˜„์ด ๋ฉ”์†Œ๋“œ ์˜๋ฏธ๋กœ๋Š” "์กฐ๊ธˆ ๋” ์ง๊ด€์ ์ด์ง€ ์•Š๋‚˜?" ๋ผ๋Š” ์ƒ๊ฐ์ด ๋“ค์—ˆ์–ด์š”

@hanseu9839 hanseu9839 merged commit 95ca672 into main Aug 26, 2024
1 check passed
@Aleph-Kim Aleph-Kim deleted the Feature/security-user-context-hold branch August 26, 2024 00:10
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.

3 participants