Closed Rdornier closed 6 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 ?
Thanks for your quick validation !
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
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 theAdminFacility
andBrowseFacility
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 theAdminFacility
. At that point, a connection error is raised, which is a bit unexpected as thegateway.connect(cred)
works fine.The cause of the connection error seems to be the hostname. When connecting to
server2
,gateway.getFacility(AdminFacility.class)
, the hostname in the attached security context isserver2
gateway.getFacility(AdminFacility.class)
, the hostname in the attached security context isserver1
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
onserver2
, it returns me theAdminFacility
fromserver1
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