diff --git a/src/Dapr.Client/DaprClientGrpc.cs b/src/Dapr.Client/DaprClientGrpc.cs index 02991174d..6ad2dc7ba 100644 --- a/src/Dapr.Client/DaprClientGrpc.cs +++ b/src/Dapr.Client/DaprClientGrpc.cs @@ -1414,9 +1414,9 @@ private async Task> EncryptDataAsync(string vaultResourceNa var receiveResult = Task.FromResult(RetrieveEncryptedStreamAsync(duplexStream, cancellationToken)); await Task.WhenAll( //Stream the plaintext data to the sidecar in chunks - Task.FromResult(SendPlaintextStreamAsync(plaintextStream, + SendPlaintextStreamAsync(plaintextStream, encryptionOptions.StreamingBlockSizeInBytes, duplexStream, encryptRequestOptions, - cancellationToken)), + cancellationToken), //At the same time, retrieve the encrypted response from the sidecar receiveResult); @@ -1478,8 +1478,8 @@ public override async IAsyncEnumerable> EncryptAsync(string var receiveResult = Task.FromResult(RetrieveEncryptedStreamAsync(duplexStream, cancellationToken)); await Task.WhenAll( //Stream the plaintext data to the sidecar in chunks - Task.FromResult(SendPlaintextStreamAsync(plaintextStream, encryptionOptions.StreamingBlockSizeInBytes, - duplexStream, encryptRequestOptions, cancellationToken)), + SendPlaintextStreamAsync(plaintextStream, encryptionOptions.StreamingBlockSizeInBytes, + duplexStream, encryptRequestOptions, cancellationToken), //At the same time, retrieve the encrypted response from the sidecar receiveResult); @@ -1493,11 +1493,11 @@ await Task.WhenAll( /// /// Sends the plaintext bytes in chunks to the sidecar to be encrypted. /// - private async IAsyncEnumerable SendPlaintextStreamAsync(Stream plaintextStream, + private async Task SendPlaintextStreamAsync(Stream plaintextStream, int streamingBlockSizeInBytes, AsyncDuplexStreamingCall duplexStream, Autogenerated.EncryptRequestOptions encryptRequestOptions, - [EnumeratorCancellation] CancellationToken cancellationToken) + CancellationToken cancellationToken) { //Start with passing the metadata about the encryption request itself in the first message await duplexStream.RequestStream.WriteAsync( @@ -1525,15 +1525,11 @@ await duplexStream.RequestStream.WriteAsync( //Increment the sequence number sequenceNumber++; - - //Yield an empty byte array to satisfy the return type though it's unused - yield return Array.Empty(); } } //Send the completion message await duplexStream.RequestStream.CompleteAsync(); - yield break; //End the async enumeration } /// @@ -1571,8 +1567,8 @@ public override async IAsyncEnumerable> DecryptAsync(string var receiveResult = Task.FromResult(RetrieveDecryptedStreamAsync(duplexStream, cancellationToken)); await Task.WhenAll( //Stream the ciphertext data to the sidecar in chunks - Task.FromResult(SendCiphertextStreamAsync(ciphertextStream, decryptionOptions.StreamingBlockSizeInBytes, - duplexStream, decryptRequestOptions, cancellationToken)), + SendCiphertextStreamAsync(ciphertextStream, decryptionOptions.StreamingBlockSizeInBytes, + duplexStream, decryptRequestOptions, cancellationToken), //At the same time, retrieve the decrypted response from the sidecar receiveResult ); @@ -1594,11 +1590,11 @@ public override IAsyncEnumerable> DecryptAsync(string vault /// /// Sends the ciphertext bytes in chunks to the sidecar to be decrypted. /// - private async IAsyncEnumerable> SendCiphertextStreamAsync(Stream ciphertextStream, + private async Task SendCiphertextStreamAsync(Stream ciphertextStream, int streamingBlockSizeInBytes, AsyncDuplexStreamingCall duplexStream, Autogenerated.DecryptRequestOptions decryptRequestOptions, - [EnumeratorCancellation] CancellationToken cancellationToken) + CancellationToken cancellationToken) { //Start with passing the metadata about the decryption request itself in the first message await duplexStream.RequestStream.WriteAsync( @@ -1624,15 +1620,11 @@ await duplexStream.RequestStream.WriteAsync(new Autogenerated.DecryptRequest //Increment the sequence number sequenceNumber++; - - //Yield an empty byte array to satisfy the return type through it's unused - yield return Array.Empty(); } } //Send the completion message await duplexStream.RequestStream.CompleteAsync(); - yield break; // End the async enumeration } /// @@ -1691,8 +1683,8 @@ private async Task> DecryptDataAsync(string vaultResourceNa var receiveResult = Task.FromResult(RetrieveDecryptedStreamAsync(duplexStream, cancellationToken)); await Task.WhenAll( //Stream the ciphertext data to the sidecar in chunks - Task.FromResult(SendCiphertextStreamAsync(ciphertextStream, decryptionOptions.StreamingBlockSizeInBytes, - duplexStream, decryptRequestOptions, cancellationToken)), + SendCiphertextStreamAsync(ciphertextStream, decryptionOptions.StreamingBlockSizeInBytes, + duplexStream, decryptRequestOptions, cancellationToken), //At the same time, retrieve the encrypted response from the sidecar receiveResult);