GeoTools
  1. GeoTools
  2. GEOT-1605

WorldImage plugin not stable if any ImageIO extentions are missing DLLs

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.5-M0
    • Fix Version/s: 2.5-M1
    • Component/s: None
    • Labels:
      None

      Description

      WorldImageFormat is not set up to protect against bad mojo at the ImageIO level...

      java.lang.NoClassDefFoundError
      	at it.geosolutions.imageio.gdalframework.GDALImageReaderSpi.canDecodeInput(GDALImageReaderSpi.java:216)
      	at it.geosolutions.imageio.plugins.mrsid.MrSIDImageReaderSpi.canDecodeInput(MrSIDImageReaderSpi.java:105)
      	at javax.imageio.ImageIO$CanDecodeInputFilter.filter(ImageIO.java:526)
      	at javax.imageio.spi.FilterIterator.advance(ServiceRegistry.java:793)
      	at javax.imageio.spi.FilterIterator.next(ServiceRegistry.java:811)
      	at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:487)
      	at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:472)
      	at org.geotools.gce.image.WorldImageReader.getHRInfo(WorldImageReader.java:262)
      	at org.geotools.gce.image.WorldImageReader.<init>(WorldImageReader.java:231)
      	at org.geotools.gce.image.WorldImageFormat.getReader(WorldImageFormat.java:341)
      	at org.geotools.gce.image.WorldImageFormat.getReader(WorldImageFormat.java:162)
      

      The code was grabbing the first format off the iterator and hoping for the best; it was not set up tohandle a ClassNotFound exception
      (or indeed catch any exception).

      I have patched the getHRInfo method as follows:

      		final Iterator it = ImageIO.getImageReaders(inStream);
      		ImageReader r = null;
      		while( r == null && it.hasNext() ){
      		    try {
      		        r = (ImageReader) it.next();
      		    }
      		    catch( NoClassDefFoundError probablyMissingDLLs ){
      		        LOGGER.log(Level.FINE, probablyMissingDLLs.getLocalizedMessage(), probablyMissingDLLs);
      		    }
      		}
      		if( r == null ){
      		    throw new DataSourceException("No reader avalaible for this source");
      		}
      		final ImageReader reader = (ImageReader) r;
      

      What do you think?

        Activity

        Hide
        Jody Garnett added a comment -
        Okay that patch did not work ... looks to be a mistake in GDALImageReader .. the code is protected with a try / catch (Exception ) ....
        But since NoClassDefFoundError is an Error we need to try / catch (Exception ) / catch (Error ) ...

        I will patch over there...
        Jody
        Show
        Jody Garnett added a comment - Okay that patch did not work ... looks to be a mistake in GDALImageReader .. the code is protected with a try / catch (Exception ) .... But since NoClassDefFoundError is an Error we need to try / catch (Exception ) / catch (Error ) ... I will patch over there... Jody
        Hide
        Jody Garnett added a comment -
        Make use of the latest imageio-ext plugin and you should not be able to have this issue; canResolve will return false like a good extention (rather than fail with a class not found exception)
        Show
        Jody Garnett added a comment - Make use of the latest imageio-ext plugin and you should not be able to have this issue; canResolve will return false like a good extention (rather than fail with a class not found exception)

          People

          • Assignee:
            Simone Giannecchini
            Reporter:
            Jody Garnett
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: