This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new d1aff011fe1 [SPARK-45499][CORE][TESTS] Replace `Reference#isEnqueued` 
with `Reference#refersTo(null)`
d1aff011fe1 is described below

commit d1aff011fe1e78788fb5cb00d41a28e5925e4572
Author: yangjie01 <yangji...@baidu.com>
AuthorDate: Wed Oct 11 08:11:52 2023 -0700

    [SPARK-45499][CORE][TESTS] Replace `Reference#isEnqueued` with 
`Reference#refersTo(null)`
    
    ### What changes were proposed in this pull request?
    This pr just replace `Reference#isEnqueued` with `Reference#refersTo` in 
`CompletionIteratorSuite`, the solution refer to
    
    
https://github.com/openjdk/jdk/blob/dfacda488bfbe2e11e8d607a6d08527710286982/src/java.base/share/classes/java/lang/ref/Reference.java#L436-L454
    
    ```
         * deprecated
         * This method was originally specified to test if a reference object 
has
         * been cleared and enqueued but was never implemented to do this test.
         * This method could be misused due to the inherent race condition
         * or without an associated {code ReferenceQueue}.
         * An application relying on this method to release critical resources
         * could cause serious performance issue.
         * An application should use {link ReferenceQueue} to reliably determine
         * what reference objects that have been enqueued or
         * {link #refersTo(Object) refersTo(null)} to determine if this 
reference
         * object has been cleared.
         *
         * return   {code true} if and only if this reference object is
         *           in its associated queue (if any).
         */
        Deprecated(since="16")
        public boolean isEnqueued() {
            return (this.queue == ReferenceQueue.ENQUEUED);
        }
    ```
    
    ### Why are the changes needed?
    Clean up deprecated api usage.
    
    ### Does this PR introduce _any_ user-facing change?
    No.
    
    ### How was this patch tested?
    Pass GitHub Actions
    
    ### Was this patch authored or co-authored using generative AI tooling?
    No
    
    Closes #43325 from LuciferYang/SPARK-45499.
    
    Authored-by: yangjie01 <yangji...@baidu.com>
    Signed-off-by: Dongjoon Hyun <dh...@apple.com>
---
 .../test/scala/org/apache/spark/util/CompletionIteratorSuite.scala  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/core/src/test/scala/org/apache/spark/util/CompletionIteratorSuite.scala 
b/core/src/test/scala/org/apache/spark/util/CompletionIteratorSuite.scala
index 29421f7aa9e..297e4fd53ab 100644
--- a/core/src/test/scala/org/apache/spark/util/CompletionIteratorSuite.scala
+++ b/core/src/test/scala/org/apache/spark/util/CompletionIteratorSuite.scala
@@ -57,13 +57,13 @@ class CompletionIteratorSuite extends SparkFunSuite {
     sub = null
     iter.toArray
 
-    for (_ <- 1 to 100 if !ref.isEnqueued) {
+    for (_ <- 1 to 100 if !ref.refersTo(null)) {
       System.gc()
-      if (!ref.isEnqueued) {
+      if (!ref.refersTo(null)) {
         Thread.sleep(10)
       }
     }
-    assert(ref.isEnqueued)
+    assert(ref.refersTo(null))
     assert(refQueue.poll() === ref)
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to