Hello

In the method:  
org.geotools.gce.imagemosaic.GranuleDescriptor.loadRaster(ImageReadParam, int, 
ReferencedEnvelope, MathTransform2D, RasterLayerRequest, Hints),

Starting at line 1031, there is a block of code as below:

        // eventually gets closed in finally block, if possible (not deferred 
loading)
        @SuppressWarnings("PMD.CloseResource")
        ImageInputStream inStream = null;
        ImageReader reader = null;
        boolean cleanupInFinally = request.getReadType() != 
ReadType.JAI_IMAGEREAD;

The cleanupInFinally variable gets set to

  *   true when the request.getReadType() is NOT of ReadType.JAI_IMAGEREAD
  *   false when the request.getReadType() is of ReadType.JAI_IMAGEREAD

The finally block of the method is as below:

finally {
            try {
                if (cleanupInFinally && inStream != null) {
                    inStream.close();
                }
            } finally {
                if (cleanupInFinally && reader != null) {
                    reader.dispose();
                }
            }
}


When request.getReadType() is of ReadType.JAI_IMAGEREAD and therefore 
cleanupInFinally gets set to false, the inStream and the reader do not get 
closed that would indicate resource leak.

Does the code rely on Garbage Collection to clean up these opened resources?



Dominique Bessette
Senior Software Engineer


_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this 
list:
- Earning your support instead of buying it, but Ian Turton: 
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: 
http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: 
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to