-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Bug report
Describe the bug
This is similar to #98 but the process and the error are different so I created another issue.
When using a session ID to connect to an OMERO server, a NoSuchElementException exception occurs when getting the ImageData of an image after getting the ImageData of another image that is owned by a different group.
However, when a username/password combination is used instead of the session ID, everything works correctly.
To Reproduce
Steps to reproduce the behavior:
- Create an OMERO server with a user belonging to two groups, and upload one image in each group.
- Login to the server and get the session ID. I use this request to OMERO.web.
- Run the following code (replace the parameters):
String serverAddress = "localhost";
int firstGroupId = 4;
int firstImageId = 46;
int secondGroupId = 5;
int secondImageId = 45;
String sessionId = "83424cb3-ebb9-4ebe-979b-d9ec190e5992";
String username = "user";
String password = "password_user";
Gateway gateway = new Gateway(new SimpleLogger());
LoginCredentials loginCredential = new LoginCredentials(sessionId, sessionId, serverAddress);
//LoginCredentials loginCredential = new LoginCredentials(username, password, serverAddress);
gateway.connect(loginCredential);
SecurityContext context1 = new SecurityContext(firstGroupId);
BrowseFacility browser1 = gateway.getFacility(BrowseFacility.class);
ImageData imageData1 = browser1.getImage(context1, firstImageId);
SecurityContext context2 = new SecurityContext(secondGroupId);
BrowseFacility browser2 = gateway.getFacility(BrowseFacility.class);
ImageData imageData2 = browser2.getImage(context2, secondImageId);
SecurityContext context3 = new SecurityContext(firstGroupId);
BrowseFacility browser3 = gateway.getFacility(BrowseFacility.class);
ImageData imageData3 = browser3.getImage(context3, firstImageId);This code gets the ImageData of an image, then gets the ImageData of another image, then gets the ImageData of the first image. This is where the error happens.
You will get the following exception:
Exception in thread "main" java.util.NoSuchElementException
at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1052)
at omero.gateway.facility.BrowseFacility.getImage(BrowseFacility.java:1157)
at qupath.ext.Main.yo(Main.java:61)
at qupath.ext.Main.main(Main.java:27)
- Run the following code:
String serverAddress = "localhost";
int firstGroupId = 4;
int firstImageId = 46;
int secondGroupId = 5;
int secondImageId = 45;
String sessionId = "1c128ef4-cc12-4c45-965a-6bbee7d3c526";
String username = "user";
String password = "password_user";
Gateway gateway = new Gateway(new SimpleLogger());
//LoginCredentials loginCredential = new LoginCredentials(sessionId, sessionId, serverAddress);
LoginCredentials loginCredential = new LoginCredentials(username, password, serverAddress);
gateway.connect(loginCredential);
SecurityContext context1 = new SecurityContext(firstGroupId);
BrowseFacility browser1 = gateway.getFacility(BrowseFacility.class);
ImageData imageData1 = browser1.getImage(context1, firstImageId);
SecurityContext context2 = new SecurityContext(secondGroupId);
BrowseFacility browser2 = gateway.getFacility(BrowseFacility.class);
ImageData imageData2 = browser2.getImage(context2, secondImageId);
SecurityContext context3 = new SecurityContext(firstGroupId);
BrowseFacility browser3 = gateway.getFacility(BrowseFacility.class);
ImageData imageData3 = browser3.getImage(context3, firstImageId);No exception is thrown here. The only difference is that a username/password were used to connect instead of a session ID.
Expected behavior
No exception thrown.
Version:
- omero-gateway 5.10.0
- The OMERO server was created from the latest versions of https://hub.docker.com/r/openmicroscopy/omero-server and https://hub.docker.com/r/openmicroscopy/omero-web-standalone