Skip to content

Commit

Permalink
Handle null pointer exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddie Carpenter committed Aug 23, 2024
1 parent 30e437e commit b005c3b
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public <T> T find(Class<T> entityType, Object primaryKey)
Span span = TRACER.spanBuilder("EntityCache::find").setSpanKind(SpanKind.SERVER).startSpan();
try (Scope ignored = span.makeCurrent()) {
long start = System.currentTimeMillis();
if (jpaCache != null) {
if (jpaCache != null && primaryKey != null) {
EntityMetaData<T> metaData = EntityMetaDataManager.getMetaData(entityType);
if (metaData.isCacheable()) {
String key = primaryKey.toString();
Expand Down Expand Up @@ -175,7 +175,7 @@ public boolean contains(Class entityType, Object primaryKey)
Span span = TRACER.spanBuilder("EntityCache::contains").setSpanKind(SpanKind.SERVER).startSpan();
try (Scope ignored = span.makeCurrent()) {
EntityMetaData<?> metaData = EntityMetaDataManager.getMetaData(entityType);
if (jpaCache != null && metaData.isCacheable()) {
if (jpaCache != null && metaData.isCacheable() && primaryKey != null) {
return jpaCache.containsKey(metaData.getName(), primaryKey.toString());
}//if
return false;
Expand All @@ -191,7 +191,7 @@ public void evict(Class entityType, Object primaryKey)
Span span = TRACER.spanBuilder("EntityCache::evict using Primary key").setSpanKind(SpanKind.SERVER).startSpan();
try (Scope ignored = span.makeCurrent()) {
EntityMetaData<?> metaData = EntityMetaDataManager.getMetaData(entityType);
if (jpaCache != null && metaData.isCacheable()) {
if (jpaCache != null && metaData.isCacheable() && primaryKey != null) {
jpaCache.evict(metaData.getName(), primaryKey.toString());
}//if
}//try
Expand Down

0 comments on commit b005c3b

Please sign in to comment.