NehanPathan commented on code in PR #1170:
URL: https://github.com/apache/lucenenet/pull/1170#discussion_r2300908188


##########
src/dotnet/Lucene.Net.Replicator.AspNetCore/AspNetCoreReplicationResponse.cs:
##########
@@ -68,5 +70,21 @@ public void Flush()
         {
             response.Body.Flush();
         }
+
+        /// <summary>
+        /// Flushes the response to the underlying response stream 
asynchronously.
+        /// </summary>
+        /// <param name="cancellationToken">Optional cancellation 
token.</param>
+        /// <returns>A task representing the asynchronous operation.</returns>
+        /// <remarks>
+        /// This simply calls <see 
cref="Stream.FlushAsync(CancellationToken)"/> on the <see 
cref="HttpResponse.Body"/>.
+        /// </remarks>
+        public async Task FlushAsync(CancellationToken cancellationToken = 
default)
+        {
+            if (response.Body.CanWrite)

Review Comment:
   The CanWrite check in FlushAsync was added as a precaution to avoid 
potential exceptions if the response stream is already closed or not writable. 
In practice, the synchronous Flush() doesn’t do this check, because in most 
ASP.NET Core scenarios the response stream should always be writable when 
Flush() is called.
   
   We can remove the CanWrite check in FlushAsync to keep consistency with the 
synchronous Flush(), or keep it for added safety — it doesn’t change the normal 
flow for typical use cases.
   
   Which approach would you prefer?



-- 
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]

Reply via email to