Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set Configuration property after instantiating since 5.0.0 #122

Open
jebax opened this issue Apr 14, 2022 · 4 comments
Open

Unable to set Configuration property after instantiating since 5.0.0 #122

jebax opened this issue Apr 14, 2022 · 4 comments
Labels

Comments

@jebax
Copy link

jebax commented Apr 14, 2022

General information

  • SDK/Library version: 5.0.0
  • Environment: N/A
  • Language, language version, and OS: .NET framework 4.7.2

Issue description

Hi,

Our previous method of instantiating BraintreeGateway was to do something like this:

new BraintreeGateway()
{
  Configuration = new CustomBraintreeConfiguration()
}

Where CustomBraintreeConfiguration inherits from Braintree.Configuration.

Since 5.0.0, instantiating BraintreeGateway like this causes all HTTP calls to break with a NullReferenceException (from trying to access Environment.GatewayURL here).

I can see in the 5.0.0 commit that many classes now use the static property gateway.Service instead of instantiating a new service using gateway.Configuration. Since gateway.Service is assigned during the BraintreeGateway constructor, setting Configuration on the gateway after instantiation will always mean Environment is null.

Spent quite a while debugging this, and I think more people could run into this issue unless you either make the Configuration read-only or throw a more descriptive error. This breaking change also wasn't in the 5.0.0 changelog or the v5 migration guide.

Thanks!

@hollabaq86
Copy link
Contributor

👋 @jebax thanks for the issue, and apologies that our CHANGELOG wasn't more clear. We moved to an entirely static HTTPClient in v5 which is you're encountering issues, now. I just want to confirm, you're not encountering this issue when creating a Configuration class object outside of constructing a BraintreeGateway?

We have another issue open that's related (#123), so we'll be taking another look at gateway and config construction in future versions for sure.

@jebax
Copy link
Author

jebax commented Apr 25, 2022

👋 @jebax thanks for the issue, and apologies that our CHANGELOG wasn't more clear. We moved to an entirely static HTTPClient in v5 which is you're encountering issues, now. I just want to confirm, you're not encountering this issue when creating a Configuration class object outside of constructing a BraintreeGateway?

We have another issue open that's related (#123), so we'll be taking another look at gateway and config construction in future versions for sure.

Thanks for the reply.

Yeah there's no issues now that I'm passing a configuration object into the constructor. Sounds like it's just an issue with the changelog then, IMO it's pretty hard to know that a static HTTP client is going to affect the way you instantiate the gateway without looking at the source code!

@hollabaq86
Copy link
Contributor

Sounds like it's just an issue with the changelog then

💯 We can make this more clear in the CHANGELOG and our migration guides, too. I'll keep this issue open until we have that fixed up.

@hollabaq86
Copy link
Contributor

for internal notekeeping, ticket 1615

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants