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

client.GetClients() returns invalid information #150

Closed
boyvinall opened this issue Jul 21, 2016 · 5 comments
Closed

client.GetClients() returns invalid information #150

boyvinall opened this issue Jul 21, 2016 · 5 comments
Labels
bug Something is not working.

Comments

@boyvinall
Copy link
Contributor

boyvinall commented Jul 21, 2016

Looks like client.GetClients() is returning a map with all map values set to the same value. The actual value can vary each time you call it.

e.g.

Got 4 clients:
client [0c21e5d8-9340-4f35-a356-eed0da7d7192] = [Dev Proxy][0c21e5d8-9340-4f35-a356-eed0da7d7192]
client [85e7beb7-42b4-4aec-8ade-a865c28fb859] = [Dev Proxy][0c21e5d8-9340-4f35-a356-eed0da7d7192]
client [e0b7bd4d-acef-491a-a3da-f9e35c4118c0] = [Dev Proxy][0c21e5d8-9340-4f35-a356-eed0da7d7192]
client [06573bd3-4908-4621-af56-83efc675c992] = [Dev Proxy][0c21e5d8-9340-4f35-a356-eed0da7d7192]

where "Dev Proxy" is one of my clients.

Looks like the problem is https://github.com/ory-am/hydra/blob/9b51600/client/manager_rethinkdb.go#L84, although the implementation is the same in the memory storage too.

I think the best thing is actually to change the signature of GetClients, from:

func (m *MemoryManager) GetClients() (clients map[string]*Client, err error)

to

func (m *MemoryManager) GetClients() (clients map[string]Client, err error)

i.e. not returning a pointer. This saves on garbage collection slightly.

Happy to submit a PR if you agree this signature change @arekkas.

@aeneasr aeneasr added the bug Something is not working. label Jul 21, 2016
@aeneasr
Copy link
Member

aeneasr commented Jul 21, 2016

@aeneasr
Copy link
Member

aeneasr commented Jul 21, 2016

I think ladon is safe from this issue (both memory manager and rethinkdb manager) as they aren't taking an address of a variable in a loop. Would still be good to check that with tests though. I'll look into it.

@aeneasr
Copy link
Member

aeneasr commented Jul 21, 2016

Switching to (clients map[string]Client, err error) is a good idea IMHO. I will do the same in the connection managers

boyvinall added a commit to boyvinall/hydra that referenced this issue Jul 21, 2016
@boyvinall
Copy link
Contributor Author

I've tested this change with my use-case, but not yet added anything to the regressions tests, sorry.

aeneasr pushed a commit that referenced this issue Jul 21, 2016
@aeneasr
Copy link
Member

aeneasr commented Jul 21, 2016

solved by #151

@aeneasr aeneasr closed this as completed Jul 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

2 participants