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

curth pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git


The following commit(s) were added to refs/heads/main by this push:
     new 2c1e01d32 fix(csharp/src/Drivers/BigQuery): correct unexpected 
ObjectDisposedException (#3613)
2c1e01d32 is described below

commit 2c1e01d321ee6373eb5b18d1a402d8c47cbcf9ff
Author: Bruce Irschick <[email protected]>
AuthorDate: Thu Oct 23 14:00:08 2025 -0700

    fix(csharp/src/Drivers/BigQuery): correct unexpected 
ObjectDisposedException (#3613)
    
    * Removes the internal call to Dispose which inadvertently disposed
    cancel context object.
    * Improve the location of call to `CreateLinkedTokenSource` to further
    avoid possible problems
---
 csharp/src/Drivers/BigQuery/BigQueryStatement.cs | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/csharp/src/Drivers/BigQuery/BigQueryStatement.cs 
b/csharp/src/Drivers/BigQuery/BigQueryStatement.cs
index 91693746e..1034b0f8e 100644
--- a/csharp/src/Drivers/BigQuery/BigQueryStatement.cs
+++ b/csharp/src/Drivers/BigQuery/BigQueryStatement.cs
@@ -688,6 +688,7 @@ namespace Apache.Arrow.Adbc.Drivers.BigQuery
             readonly CancellationContext cancellationContext;
             IEnumerator<IArrowReader>? readers;
             IArrowReader? reader;
+            bool disposed;
 
             public MultiArrowReader(BigQueryStatement statement, Schema 
schema, IEnumerable<IArrowReader> readers, CancellationContext 
cancellationContext) : base(statement)
             {
@@ -706,12 +707,13 @@ namespace Apache.Arrow.Adbc.Drivers.BigQuery
             {
                 return await this.TraceActivityAsync(async activity =>
                 {
-                    using CancellationTokenSource linkedCts = 
CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, 
this.cancellationContext.CancellationToken);
                     if (this.readers == null)
                     {
                         return null;
                     }
 
+                    using CancellationTokenSource linkedCts = 
CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, 
this.cancellationContext.CancellationToken);
+
                     while (true)
                     {
                         linkedCts.Token.ThrowIfCancellationRequested();
@@ -719,7 +721,8 @@ namespace Apache.Arrow.Adbc.Drivers.BigQuery
                         {
                             if (!this.readers.MoveNext())
                             {
-                                Dispose(); // TODO: Remove this line
+                                this.readers.Dispose();
+                                this.readers = null;
                                 return null;
                             }
                             this.reader = this.readers.Current;
@@ -741,11 +744,15 @@ namespace Apache.Arrow.Adbc.Drivers.BigQuery
             {
                 if (disposing)
                 {
-                    if (this.readers != null)
+                    if (!this.disposed)
                     {
-                        this.readers.Dispose();
-                        this.readers = null;
+                        if (this.readers != null)
+                        {
+                            this.readers.Dispose();
+                            this.readers = null;
+                        }
                         this.cancellationContext.Dispose();
+                        this.disposed = true;
                     }
                 }
 

Reply via email to