You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "gianm (via GitHub)" <gi...@apache.org> on 2026/09/09 07:33:42 UTC

Re: [PR] fix: SettableAsyncResource fire callbacks if closed before set (druid)

gianm commented on code in PR #20074:
URL: https://github.com/apache/druid/pull/20074#discussion_r3965210895


##########
processing/src/main/java/org/apache/druid/common/asyncresource/SettableAsyncResource.java:
##########
@@ -180,7 +191,8 @@ public void setException(Throwable t)
   @Override
   public synchronized boolean isReady()
   {
-    return state == State.READY;
+    // a closed resource is complete too (acquisition is over and get() reports why)
+    return state == State.READY || state == State.CLOSED;

Review Comment:
   Behavior is strange here for releasable resources. After `release()`, `isReady()` becomes `false`, and then it can become `true` after after `CLOSED`. I think it'd make more sense for it to be `false` for a `CLOSED` that occurs after a `release()`



##########
processing/src/main/java/org/apache/druid/common/asyncresource/AsyncResourceCanceledException.java:
##########
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.common.asyncresource;
+
+import java.util.concurrent.CancellationException;
+
+/**
+ * Thrown by {@link AsyncResource#get()} when {@link AsyncResource#close()} canceled acquisition before the resource
+ * became available, i.e. the consumer that owned the resource gave up waiting for it. Extends
+ * {@link CancellationException} so that consumers who only care that something was canceled need no special handling.
+ */
+public class AsyncResourceCanceledException extends CancellationException

Review Comment:
   Check for this and block it in `SettableAsyncResource#setException`? Funky stuff may happen if this is explicitly set, and it seems good to not allow that.



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org