[ome-users] OMERO: No exceptions thrown upon missing images

Chris Allan callan at blackcat.ca
Wed Jul 15 09:29:54 BST 2009


On Tue, 2009-07-14 at 14:14 +0200, b.gerritsen at nki.nl wrote:
> Dear omero developers,

Hello Bram.

> 
> OMERO Beta 4.0.3 does not throw an exception when trying to access an image that does exist in the database but does NOT exist in the omero data directory. In fact the missing image will be generated and look like a black canvas.

Correct, this is expected behaviour. OMERO creates files in the binary
repository on demand.

> 
> I traced this behavior back to line 92 in ome.io.nio.RomioPixelBuffer private method "getFileChannel()": "RandomAccessFile file = new RandomAccessFile(getPath(), "rw");". If a file is opened as read-write ("rw") the RandomAccessFile class will not throw a FileNotFoundException. It would have when it is instructed to open a file as "r". The code below will duplicate the omero behavior:
> 
> ---
> try {
>     RandomAccessFile f = new RandomAccessFile ("myNonExistentFile", "rw"); // This creates the file if it doesn't exist
>     FileChannel fc = f.getChannel();
>     fc.map(MapMode.READ_ONLY, 0, 1000); // Map 1000 bytes from a file into memory... in case of a non-existent file there will be 1000 bytes written to the file.
> } catch (Exception e) {
>     e.printStackTrace();
> }
> ---
> 
> A solution might be to add the following lines before line 92 in ome.io.nio.RomioPixelBuffer:
> 
> ---
> if (!new File(getPath()).exists()) {
>     throw new FileNotFoundException(getPath());
> }

If that code was in place you wouldn't be able to create the "pixel
buffer" except explicity. These are not the calling semantics of the
OMERO I/O API.

Is there something specific that you would like to happen if there is no
pixel data available for an image?

> ---
> 
> Kind Regards,
> Bram Gerritsen

Thanks for the ideas.

-Chris




More information about the ome-users mailing list