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

FIX: Return the value when failed to put value got from valueLoader if wantToGetException is false. #87

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

uhm0311
Copy link
Collaborator

@uhm0311 uhm0311 commented Jun 14, 2024

๐Ÿ”— Related Issue

  • NullValue ์ง€์›์„ ์œ„ํ•ด ์ถ”๊ฐ€ํ•œ ArcusCache.loadValue() ๋ฉ”์†Œ๋“œ์—์„œ ์ƒํ™ฉ์— ๋”ฐ๋ผ ValueRetrievalException์„ ๋ฐœ์ƒ์‹œํ‚จ๋‹ค.
  • ๊ธฐ์กด ๊ตฌ์กฐ์—์„œ๋Š” ValueRetrievalException ๋ฐœ์ƒ ์‹œ catchํ•˜๋Š” ๊ตฌ๊ฐ„์ด ์—†์–ด wantToGetException ๊ฐ’์„ ๋ฌด์‹œํ•˜๊ณ  ํ•ญ์ƒ ์ „ํŒŒ๋˜๋Š”๋ฐ, ์ด๋Š” ์˜๋„ํ•˜์ง€ ์•Š์€ ์‚ฌํ•ญ์ด๋ผ๊ณ  ํ•œ๋‹ค.

โŒจ๏ธ What I did

  • ValueRetrievalException ๋ฐœ์ƒ ์‹œ wantToGetException ํ•„๋“œ๋ฅผ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.

@uhm0311 uhm0311 requested a review from oliviarla June 14, 2024 08:57
@uhm0311 uhm0311 force-pushed the uhm0311/develop branch 2 times, most recently from 9ac68a0 to 9b7b1e5 Compare June 14, 2024 09:07
@@ -172,8 +172,13 @@ private <T> T loadValue(String arcusKey, Callable<T> valueLoader) {
T value;
try {
value = valueLoader.call();
} catch (Exception e) {
throw new ValueRetrievalException(arcusKey, valueLoader, e);
} catch (Exception originalException) {
Copy link
Collaborator

@oliviarla oliviarla Jun 14, 2024

Choose a reason for hiding this comment

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

์—ฌ๊ธฐ์„œ catchํ•˜์ง€ ๋ง๊ณ  getSynchronized ๋ฉ”์„œ๋“œ์—์„œ Exception์„ catchํ•˜๋Š”๊ฒƒ์ด ์ข‹์ง€ ์•Š์„๊นŒ์š”?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

๊ทธ๋Ÿฌ๋ฉด super.get(key);์—์„œ ๋ฐœ์ƒํ•˜๋Š” Exception์— wantToGetException์„ 2๋ฒˆ ์ ์šฉํ•˜๊ฒŒ ๋˜์–ด์„œ loadValue() ๋ฉ”์†Œ๋“œ์— ๋„ฃ๋Š” ๊ฒƒ์œผ๋กœ ๋Œ€์ฒดํ–ˆ์Šต๋‹ˆ๋‹ค.

@uhm0311 uhm0311 requested a review from jhpark816 June 14, 2024 09:18
@uhm0311 uhm0311 changed the title INTERNAL: Add forgotten catch block to ArcusCache.getSynchronized() method. INTERNAL: Add forgotten catch block for ValueRetrievalException. Jun 14, 2024
RuntimeException e = new ValueRetrievalException(arcusKey, valueLoader, originalException);
if (wantToGetException) {
throw e;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

์ด ๊ฒฝ์šฐ๋Š” cache miss๋กœ ์ธํ•ด ์›๋ž˜ ๋กœ์ง์„ ์ˆ˜ํ–‰ํ•˜์—ฌ ๊ฒฐ๊ณผ๋ฅผ ์–ป๋Š” ๋ถ€๋ถ„์ž…๋‹ˆ๋‹ค.
์ด ๋ถ€๋ถ„์—์„œ๋Š” wantToGetException ์ ์šฉํ•˜์ง€ ์•Š๋Š” ๊ฒƒ์ด ๋งž๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

์ถ”๊ฐ€์ ์œผ๋กœ, ์•„๋ž˜์— ์žˆ๋Š” putValue() ์ˆ˜ํ–‰ ์‹œ์˜ ์ฒ˜๋ฆฌ๊ฐ€ ์ž˜๋ชป๋œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

  • Exception ๋ฐœ์ƒ์„ catchํ•  ๊ฒฝ์šฐ, ๊ทธ exception์„ throwํ•˜์ง€ ์•Š์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  • ๋‹จ์ˆœํžˆ info logging๋งŒ ์ˆ˜ํ–‰ํ•˜๊ณ  null๋„ ๋ฆฌํ„ดํ•˜์ง€ ์•Š์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ํ•ด๋‹น ๋ฐฉ์•ˆ์œผ๋กœ ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

@uhm0311 uhm0311 changed the title INTERNAL: Add forgotten catch block for ValueRetrievalException. FIX: Log info level when failed to put value got from valueLoader. Jun 14, 2024
@jhpark816 jhpark816 requested a review from oliviarla June 14, 2024 10:46
}
logger.info("failed to loadValue. error: {}, key: {}", e.getMessage(), arcusKey);
return null;
logger.info("failed to put value got from valueLoader. error: {}, key: {}", e.getMessage(), arcusKey);
Copy link
Collaborator

Choose a reason for hiding this comment

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

์—ฌ๊ธฐ์„œ wantToGetException ์ฒ˜๋ฆฌ๋ฅผ ์ œ์™ธํ•œ ์ด์œ ๊ฐ€ ๋ฌด์—‡์ธ๊ฐ€์š”?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@oliviarla oliviarla Jun 18, 2024

Choose a reason for hiding this comment

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

public void put(final Object key, final Object value) ๋‚ด๋ถ€์—์„œ ํ˜ธ์ถœ๋˜๋Š” putValue์— ๋Œ€ํ•ด์„œ๋Š” ์œ„ ์‚ฌํ•ญ ์ ์šฉํ•˜์ง€ ์•Š์•„๋„ ๋˜๋‚˜์š”? (ํ˜„์žฌ ๊ธฐ์ค€ line 189)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jhpark816 @uhm0311
๋‹ค์‹œ ์ƒ๊ฐํ•ด๋ณด๋‹ˆ ์ด ๋ถ€๋ถ„์€ ๊ผญ ๋ณ€๊ฒฝํ•ด์•ผ ๋  ์ด์œ ๊ฐ€ ์—†์–ด๋ณด์ž…๋‹ˆ๋‹ค. get(Object key, Callable<T> valueLoader) ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ DB/์™ธ๋ถ€ ์„œ๋น„์Šค๋กœ๋ถ€ํ„ฐ ๊ฐ€์ ธ์˜จ ๋ฐ์ดํ„ฐ๋ฅผ arcus์— putํ•˜๋Š” ๊ณผ์ •์—์„œ ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด ์ด ์—ญ์‹œ wantToGetException์ด ์ ์šฉ๋˜์–ด์•ผ ํ•˜์ง€ ์•Š๋‚˜์š”?

Copy link
Contributor

Choose a reason for hiding this comment

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

์•„๋ž˜ 2 ์—ฐ์‚ฐ์—์„œ wantToGetException ์ฒ˜๋ฆฌ๋ฅผ ๋‹ค๋ฅด๊ฒŒ ๊ฐ€์ ธํ•  ์ด์œ ๊ฐ€ ์—†๋‹ค๋Š” ๊ฒƒ์ด๊ตฐ์š”.

  • cache get ๊ณผ์ •์—์„œ exception ๋ฐœ์ƒํ•˜๋Š” ๊ฒฝ์šฐ
  • cache miss๋กœ db ์กฐํšŒํ•˜์—ฌ cache put ๊ณผ์ •์—์„œ exception ๋ฐœ์ƒํ•˜๋Š” ๊ฒฝ์šฐ

OK. ๊ทธ๋ ‡๊ฒŒ ํ•ฉ์‹œ๋‹ค.

๊ทธ๋Ÿฌ๋ฉด, ํ˜„์žฌ PR ์ฒ˜๋Ÿผ wantToGetException = false์—์„œ null ๋ฆฌํ„ดํ•˜๋Š” ๊ฒƒ๋งŒ ์ œ๊ฑฐํ•˜๋ฉด ๋˜๊ฒ ๋„ค์š”.

@jhpark816 jhpark816 requested a review from oliviarla June 18, 2024 10:29
@uhm0311 uhm0311 force-pushed the uhm0311/develop branch 2 times, most recently from 5b69404 to b1325c2 Compare June 18, 2024 10:37
@uhm0311 uhm0311 changed the title FIX: Log info level when failed to put value got from valueLoader. FIX: Return the value when failed to put value got from valueLoader if wantToGetException is false. Jun 18, 2024
@jhpark816 jhpark816 merged commit f6894fd into naver:develop Jun 18, 2024
1 check passed
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