github-advanced-security[bot] commented on code in PR #16372:
URL: https://github.com/apache/druid/pull/16372#discussion_r1591517740
##########
processing/src/main/java/org/apache/druid/query/groupby/GroupByResourcesReservationPool.java:
##########
@@ -125,17 +153,35 @@
@Nullable
public GroupByQueryResources fetch(QueryResourceId queryResourceId)
{
- return pool.get(queryResourceId);
+ AtomicReference<GroupByQueryResources> resourcesReference =
pool.get(queryResourceId);
+ if (resourcesReference == null) {
+ // There weren't any resources allocated corresponding to the provided
resource id
+ return null;
+ }
+ GroupByQueryResources resource = resourcesReference.get();
+ if (resource == null) {
+ throw DruidException.defensive(
+ "Query id [%s] had a non-null reference in the resource reservation
pool, but no resources were found"
+ );
+ }
+ return resource;
}
/**
* Removes the entry corresponding to the unique id from the map, and cleans
up the resources.
*/
public void clean(QueryResourceId queryResourceId)
{
- GroupByQueryResources resources = pool.remove(queryResourceId);
- if (resources != null) {
- resources.close();
+ AtomicReference<GroupByQueryResources> resourcesReference =
pool.remove(queryResourceId);
+ if (resourcesReference != null) {
+ GroupByQueryResources resource = resourcesReference.get();
+ // Reference should refer to a non-empty resource
+ if (resource == null) {
+ throw DruidException.defensive(
+ "Query id [%s] had a non-null reference in the resource
reservation pool, but no resources were found"
+ );
Review Comment:
## Missing format argument
This format call refers to 1 argument(s) but only supplies 0 argument(s).
[Show more
details](https://github.com/apache/druid/security/code-scanning/7346)
##########
processing/src/main/java/org/apache/druid/query/groupby/GroupByResourcesReservationPool.java:
##########
@@ -125,17 +153,35 @@
@Nullable
public GroupByQueryResources fetch(QueryResourceId queryResourceId)
{
- return pool.get(queryResourceId);
+ AtomicReference<GroupByQueryResources> resourcesReference =
pool.get(queryResourceId);
+ if (resourcesReference == null) {
+ // There weren't any resources allocated corresponding to the provided
resource id
+ return null;
+ }
+ GroupByQueryResources resource = resourcesReference.get();
+ if (resource == null) {
+ throw DruidException.defensive(
+ "Query id [%s] had a non-null reference in the resource reservation
pool, but no resources were found"
+ );
Review Comment:
## Missing format argument
This format call refers to 1 argument(s) but only supplies 0 argument(s).
[Show more
details](https://github.com/apache/druid/security/code-scanning/7345)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]