Skip to content

Commit

Permalink
Fix subtle WCF bug (#6131)
Browse files Browse the repository at this point in the history
## Summary of changes

Fix the precedence bug

## Reason for change

The order of precedence is wrong with the use of `?? false`, so the
second condition is never checked


![image](https://github.com/user-attachments/assets/87f60037-972f-47b9-a2b8-936691178089)

## Implementation details

Make the null check explicit

## Test coverage

Meh, this seems like a tricky case to check so YOLO?
  • Loading branch information
andrewlock authored Oct 9, 2024
1 parent 88badd0 commit 1900fea
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ internal class WcfCommon
WebHeadersCollection? headers = null;

IDictionary<string, object?>? requestProperties = requestMessage.Properties;
if (requestProperties?.TryGetValue("httpRequest", out var httpRequestProperty) ?? false
&& httpRequestProperty.GetType().FullName.Equals(HttpRequestMessagePropertyTypeName, StringComparison.OrdinalIgnoreCase))
if (requestProperties is not null
&& requestProperties.TryGetValue("httpRequest", out var httpRequestProperty)
&& httpRequestProperty?.GetType().FullName != null
&& httpRequestProperty.GetType().FullName!.Equals(HttpRequestMessagePropertyTypeName, StringComparison.OrdinalIgnoreCase))
{
var httpRequestPropertyProxy = httpRequestProperty.DuckCast<HttpRequestMessagePropertyStruct>();
var webHeaderCollection = httpRequestPropertyProxy.Headers;
Expand Down

0 comments on commit 1900fea

Please sign in to comment.