Weird Mac vs Windows issue with Thread sub-class property

I have a sub-classed thread that handles getting a lot of data from a REST API. The API requires an access token for all calls, so I store the token as a property of the thread. Tokens expire after 1 hour, so I have code that requests a new token when time is up, and that new token is stored in the thread property.

Now for the weirdness - the mac versions works fine, but the windows version will continue to use the old token even after executing all the same code the mac version does. It’s like the property does not accept the new value.

Has anyone come across something like this before?

UPDATE: so it’s not the thread property, it’s the URLConnection.RequestHeader that is not being updated. It seems that once set, RequestHeader(“Authorization”) cannot be reset on Windows. It works on Mac.

You can best re-create the entire instance using New URLConnection
Or as an alternative, did you try URLConn.ClearRequestHeaders() ?

my work-around is to make a New URLConnection with each pass, but it seems to add a speed penalty. I did not see ClearRequestHeaders(), so I will give that a shot. Thanks!

1 Like