Skip to content

Conversation

@haacked
Copy link
Contributor

@haacked haacked commented Jul 18, 2012

If someone sets BaseUrl to null, it shouldn't throw a NullReferenceException. Either it's an InvalidOperationException or it should just set the value to null and not complain.

I took the latter approach.

@ayoung
Copy link
Contributor

ayoung commented Jul 18, 2012

Just curious, but what would you expect a request to hit when a baseUrl is null? Haven't tested it myself but I think the underlying HttpWebRequest would throw a NotSupportedException if it doesn't find a supported URI scheme.

@haacked
Copy link
Contributor Author

haacked commented Jul 18, 2012

@ayoung: I'd probably expect that someone else is going to set it later. It's not any different than calling the default empty RestClient constructor. That doesn't set the BaseUrl to anything so I assume it remains null and the exception is thrown later when you try to do something.

If you don't want the object to ever be in an invalid state, you'd have to remove the empty ctor and perhaps throw an InvalidOperationException on the BaseUrl setter.

ayoung added a commit that referenced this pull request Jul 18, 2012
Avoid potential NullReferenceException
@ayoung ayoung merged commit cbf2f4c into restsharp:master Jul 18, 2012
@ayoung
Copy link
Contributor

ayoung commented Jul 18, 2012

@haacked meh!

thanks.

@haacked
Copy link
Contributor Author

haacked commented Jul 18, 2012

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants