Skip to content

Commit

Permalink
Fixing Audit
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso committed Oct 30, 2023
1 parent b739782 commit 67816d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public List<AuditEntry> searchEntries(
index(ElasticsearchUtils.getAuditIndex(AuthContextUtils.getDomain())).
searchType(SearchType.QueryThenFetch).
query(getQuery(entityKey, type, category, subcategory, events, result, before, after)).
fields(f -> f.field("message")).
from(itemsPerPage * (page <= 0 ? 0 : page - 1)).
size(itemsPerPage < 0 ? indexMaxResultWindow : itemsPerPage).
sort(sortBuilders(orderBy)).
Expand All @@ -193,13 +194,13 @@ public List<AuditEntry> searchEntries(
try {
esResult = client.search(request, ObjectNode.class).hits().hits();
} catch (Exception e) {
LOG.error("While searching in OpenSearch", e);
LOG.error("While searching in Elasticsearch", e);
}

return CollectionUtils.isEmpty(esResult)
? List.of()
: esResult.stream().
map(hit -> POJOHelper.convertValue(hit.source().get("message").asText(), AuditEntry.class)).
map(hit -> POJOHelper.convertValue(hit.source().get("message"), AuditEntry.class)).
filter(Objects::nonNull).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public List<AuditEntry> searchEntries(
index(OpenSearchUtils.getAuditIndex(AuthContextUtils.getDomain())).
searchType(SearchType.QueryThenFetch).
query(getQuery(entityKey, type, category, subcategory, events, result, before, after)).
fields(f -> f.field("message")).
from(itemsPerPage * (page <= 0 ? 0 : page - 1)).
size(itemsPerPage < 0 ? indexMaxResultWindow : itemsPerPage).
sort(sortBuilders(orderBy)).
Expand All @@ -202,7 +203,7 @@ public List<AuditEntry> searchEntries(
return CollectionUtils.isEmpty(esResult)
? List.of()
: esResult.stream().

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
esResult
may be null at this access because of
this
assignment.
map(hit -> POJOHelper.convertValue(hit.source().get("message").asText(), AuditEntry.class)).
map(hit -> POJOHelper.convertValue(hit.source().get("message"), AuditEntry.class)).
filter(Objects::nonNull).collect(Collectors.toList());
}
}

0 comments on commit 67816d9

Please sign in to comment.