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: When cache key already exists in putIfAbsent, convert NullValue to null if allow null values. #89

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

uhm0311
Copy link
Collaborator

@uhm0311 uhm0311 commented Jun 14, 2024

๐Ÿ”— Related Issue

  • putIfAbsent() ๋ฉ”์†Œ๋“œ ๋‚ด์—์„œ ์บ์‹œ ํ‚ค๊ฐ€ ์ด๋ฏธ ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ ํ•ด๋‹น ์บ์‹œ ์•„์ดํ…œ์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
  • ์ด ๊ณผ์ •์—์„œ ์ง€๋‚œ๋ฒˆ์— ์ ์šฉ๋œ NullValue๋ฅผ ์ฝ๋Š” ๊ธฐ๋Šฅ์ด ์ ์šฉ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.

โŒจ๏ธ What I did

  • putIfAbsent() ๋ฉ”์†Œ๋“œ์—์„œ๋„ NullValue๋ฅผ ์ฝ๋Š” ๊ธฐ๋Šฅ์„ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • toValueWrapper() ๋ฉ”์†Œ๋“œ๋Š” ๋ถ€๋ชจ ํด๋ž˜์Šค์ธ AbstractValueAdaptingCache์— ํฌํ•จ๋˜์–ด ์žˆ์œผ๋ฉฐ, Spring Framework v4.3.10์„ ํฌํ•จํ•œ ์ดํ›„์˜ ๊ตฌํ˜„์€ ํ•ญ์ƒ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
protected Object fromStoreValue(Object storeValue) {
  if (this.allowNullValues && storeValue == NullValue.INSTANCE) {
    return null;
  }
  return storeValue;
}

protected Cache.ValueWrapper toValueWrapper(Object storeValue) {
  return (storeValue != null ? new SimpleValueWrapper(fromStoreValue(storeValue)) : null);
}

@uhm0311 uhm0311 requested review from jhpark816 and oliviarla June 14, 2024 09:47
@uhm0311 uhm0311 changed the title FIX: When cache key already exists in putIfAbsent, convert null to NullValue if allow NullValue. FIX: When cache key already exists in putIfAbsent, convert NullValue to null if allow null values. Jun 14, 2024
@@ -237,7 +236,7 @@ public ValueWrapper putIfAbsent(Object key, Object value) {
}

// FIXME: maybe returned with a different value.
Copy link
Collaborator

Choose a reason for hiding this comment

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

์œ„ ์ฃผ์„์€ ์ œ๊ฑฐํ•ด๋„ ๋˜๋‚˜์š”?

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 force-pushed the uhm0311/develop3 branch from 6950d94 to b2093ee Compare June 18, 2024 05:40
@jhpark816 jhpark816 merged commit 5940090 into naver:develop Jun 18, 2024
1 check passed
@uhm0311 uhm0311 deleted the uhm0311/develop3 branch June 20, 2024 01:11
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