Question details
Yellow warning when using stringRedisTemplate.hasKey(**)
Warning message: IDEA Unboxing of ‘stringRedisTemplate.hasKey(xx)’ may produce ‘NullPointerException’ warning
Possible null pointer exception when unboxing
Look through the hasKey source code
Looking at the hasKey source code, the hasKey method returns an object wrapper, but using it inside the if condition implicitly unboxes it (ie, converts the result of the call to the original value). If for some reason the hasKey method might return null, an error will occur. For security, you can check if the key exists by following the steps below
solution:
if ( Boolean.TRUE.equals ( redisTemplate.hasKey ( XXXX)) { }
Similar Posts:
- [Solved] Mybatis error: attempted to return null from a method with a primitive return type (int)
- Leet code 44 wildcard matching – wildcard matching – Java
- How to Solve JAVA Error: “error: bad operand types for binary operator ”
- Fatal error: Call-time pass-by-reference has be…
- 140. Word Break II
- Python uses decorator and reports error typeerror: ‘nonetype’ object is not callable ‘
- Unable to return file stream in Python 3, uwsgi report error
- [Solved] Android O Error: Error inflating class android.webkit.WebView/For security reasons, WebView is not allowed in privileged processes
- [Five Method to Solve] android webpage err_unknown_url_scheme
- How to Use Array.prototype.slice.call(arguments)