Even if all code that is calling the list() function always closes the returned CloseableIterator, the final CloseableIteratorAdapter instance that is created in SecureCatalogImpl.list() does not contain the reference to close the filteredWrapped CloseableIterator so filteredWrapped is left unclosed when the garbage collector gets to it. The code change in my previous messages fixes that so closing the CloseableIterator that is returned by SecureCatalogImpl.list() will close the filteredWrapped instance.
This does not generate the warning message in most cases because CloseableIteratorAdapter.hasNext() will call close() on itself before returning false but calling hasNext() until it returns false is not a requirement. I was able to find an instance in the WMS 1.3.0 GetCapabilities code where hasNext() may not be called until it returns false although this is likely to happen anywhere where an exception is thrown while processing the iterator. This is a portion of the code from Capabilities_1_3_0_Transformer: private void handleRootBbox(Iterator<LayerInfo> layers) { ... while(layers.hasNext()) { ... if(latlonBbox.contains(world)){ break; } } ... } I did not see a JIRA ticket about this. I can reproduce this with a WMS 1.3.0 GetCapabilities request although the warning message won't appear until the garbage collector runs which may not always happen with a single request. -- View this message in context: http://osgeo-org.1560.x6.nabble.com/Code-not-closing-CloseableIterator-tp5073066p5219096.html Sent from the GeoServer - User mailing list archive at Nabble.com. ------------------------------------------------------------------------------ _______________________________________________ Geoserver-users mailing list Geoserver-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geoserver-users