diff --git a/deegree-core/deegree-core-gdal/src/main/java/org/deegree/commons/gdal/GdalDatasetPool.java b/deegree-core/deegree-core-gdal/src/main/java/org/deegree/commons/gdal/GdalDatasetPool.java index f57e3ae6fa..3a4295110d 100644 --- a/deegree-core/deegree-core-gdal/src/main/java/org/deegree/commons/gdal/GdalDatasetPool.java +++ b/deegree-core/deegree-core-gdal/src/main/java/org/deegree/commons/gdal/GdalDatasetPool.java @@ -105,4 +105,8 @@ void shutdown() { } } + public void removeAndClose(File file) throws IOException { + pool.removeAndClose(file.getCanonicalFile().toString()); + } + } diff --git a/deegree-core/deegree-core-gdal/src/main/java/org/deegree/commons/gdal/pool/LimitedKeyedResourcePool.java b/deegree-core/deegree-core-gdal/src/main/java/org/deegree/commons/gdal/pool/LimitedKeyedResourcePool.java index 0f6daf7e1a..8cb6fefdab 100644 --- a/deegree-core/deegree-core-gdal/src/main/java/org/deegree/commons/gdal/pool/LimitedKeyedResourcePool.java +++ b/deegree-core/deegree-core-gdal/src/main/java/org/deegree/commons/gdal/pool/LimitedKeyedResourcePool.java @@ -27,6 +27,7 @@ ----------------------------------------------------------------------------*/ package org.deegree.commons.gdal.pool; +import static org.apache.commons.io.IOUtils.closeQuietly; import static org.slf4j.LoggerFactory.getLogger; import java.io.Closeable; @@ -153,4 +154,12 @@ private synchronized BlockingQueue getQueue(final String key) { return queue; } + public void removeAndClose(final String key) { + LOG.debug("Destroying resource, key: " + key); + BlockingQueue queue = getQueue(key); + T resource = queue.poll(); + closeQuietly(resource); + keyTracker.remove(key); + } + } diff --git a/deegree-datastores/deegree-tilestores/deegree-tilestore-gdal/src/main/java/org/deegree/tile/persistence/gdal/GdalTileDataLevel.java b/deegree-datastores/deegree-tilestores/deegree-tilestore-gdal/src/main/java/org/deegree/tile/persistence/gdal/GdalTileDataLevel.java index b28cde5fda..60821afdc5 100644 --- a/deegree-datastores/deegree-tilestores/deegree-tilestore-gdal/src/main/java/org/deegree/tile/persistence/gdal/GdalTileDataLevel.java +++ b/deegree-datastores/deegree-tilestores/deegree-tilestore-gdal/src/main/java/org/deegree/tile/persistence/gdal/GdalTileDataLevel.java @@ -28,6 +28,7 @@ package org.deegree.tile.persistence.gdal; import java.io.File; +import java.io.IOException; import java.util.List; import org.deegree.commons.gdal.GdalDataset; @@ -47,7 +48,7 @@ * @author Markus Schneider * @since 3.4 */ -class GdalTileDataLevel implements TileDataLevel { +public class GdalTileDataLevel implements TileDataLevel { private final TileMatrix metadata; @@ -120,4 +121,8 @@ public List getStyles() { return null; } + public void clearPool() throws IOException { + gdalSettings.getDatasetPool().removeAndClose(file); + } + }