ome / omero-gateway-java

Gradle project containing OMERO Java Client Library
https://www.openmicroscopy.org/omero
GNU General Public License v2.0
1 stars 9 forks source link

Fix bug when connecting to multiple servers #86

Closed Rdornier closed 6 months ago

Rdornier commented 10 months ago

Hello @dominikl, @jburel

I have an unexpected behavior when I'm connecting to 2 different omero servers. First, I'm connecting to one server (e.g server1) ; the gateway and context are initialized correctly. Then, I get for the AdminFacilityand BrowseFacility instance to retreive some images and check if the current user is admin or not.

Then, I'm connecting to the second server (e.g server2). A new gateway is initiliazed, as well as a new Security context. Everything is fine until I get the AdminFacility. At that point, a connection error is raised, which is a bit unexpected as the gateway.connect(cred) works fine.

The cause of the connection error seems to be the hostname. When connecting to server2,

It takes me quite some time to understand why the swapping is happening but I finally manage to find what causes this issue. On this line, the requested facilities are got from the cache (which is a good thing by the way) but they are got only based on their name ; there is no information about the server from which they come from. So, by default, when I request the AdminFacility on server2, it returns me the AdminFacility from server1 i.e. the first cached object.

So, I just added, in the key, the hostname of the server and everything worked correctly. I also added a public method to get the hostname from the Gateway object.

Rémy

dominikl commented 10 months ago

Thank you very much for your contributions @Rdornier . I'd just slightly change the error message, apart from that I think it's good to merge? Any objections @jburel ?

Rdornier commented 10 months ago

Thanks for your quick validation !

imagesc-bot commented 2 weeks ago

This pull request has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/omero-java-gateway-changes-between-5-9-0-and-5-9-3/105052/2