cachedValue may be null at this point
862 return false;
863 }
864 V cachedValue = cache.get(key);
865 return (cachedValue != null) && cachedValue.equals(value); 866 }
867
868 @Override
buffer may be null at this point
129 if ((buffers == null)
130 || ((mask = buffers.length - 1) < 0)
131 || ((buffer = buffers[h & mask]) == null)
132 || !(uncontended = ((result = buffer.offer(e)) != Buffer.FAILED))) {133 return expandOrRetry(e, h, increment, uncontended);
134 }
135 return result;
buffer may be null at this point
129 if ((buffers == null)
130 || ((mask = buffers.length - 1) < 0)
131 || ((buffer = buffers[h & mask]) == null)
132 || !(uncontended = ((result = buffer.offer(e)) != Buffer.FAILED))) {133 return expandOrRetry(e, h, increment, uncontended);
134 }
135 return result;
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
238 var result = (prior == null) ? future : prior;
239 result.whenComplete((r, e) -> asyncCache.cache().refreshes().remove(keyReference, result));
240 return result;
241 } else if (!oldValueFuture.isDone()) {242 // no-op if load is pending
243 return oldValueFuture;
244 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
238 var result = (prior == null) ? future : prior;
239 result.whenComplete((r, e) -> asyncCache.cache().refreshes().remove(keyReference, result));
240 return result;
241 } else if (!oldValueFuture.isDone()) {242 // no-op if load is pending
243 return oldValueFuture;
244 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
238 var result = (prior == null) ? future : prior;
239 result.whenComplete((r, e) -> asyncCache.cache().refreshes().remove(keyReference, result));
240 return result;
241 } else if (!oldValueFuture.isDone()) {242 // no-op if load is pending
243 return oldValueFuture;
244 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
238 var result = (prior == null) ? future : prior;
239 result.whenComplete((r, e) -> asyncCache.cache().refreshes().remove(keyReference, result));
240 return result;
241 } else if (!oldValueFuture.isDone()) {242 // no-op if load is pending
243 return oldValueFuture;
244 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
oldValueFuture may be null at this point
227 // If the entry is absent then perform a new load, else if in-flight then return it
228 var oldValueFuture = asyncCache.cache().getIfPresentQuietly(key);
229 if ((oldValueFuture == null)
230 || (oldValueFuture.isDone() && oldValueFuture.isCompletedExceptionally())) {231 if (oldValueFuture != null) {
232 asyncCache.cache().remove(key, oldValueFuture);
233 }
Description
This code contains a possible null pointer dereference. Double-check the code to ensure that the concerned variable always has a non-null value when accessed.
Bad Practice
In the example below, if someCondition
is true, it is possible for value
to be null when it reaches the assignment
of valLen
.
String value = "something";
if (someCondition) {
value = null;
}
// ...
int valLen = value.length; // Null pointer exception!
Recommended
Check for null before you use the value at the vulnerable point in code.
int valLen = value != null ? value.length : 0;
If value
was instead never intended to be null, consider changing the preceding logic to ensure that value
is at
least set to a safe default wherever possible:
if (someCondition) {
value = "";
}
int valLen = value.length; // No exception thrown.
References
- CWE-476 - Null Pointer Dereference