geoserver-cloud icon indicating copy to clipboard operation
geoserver-cloud copied to clipboard

wms's LegendSampleImpl.clean() fix

Open groldan opened this issue 4 years ago • 0 comments

org.geoserver.wms.capabilities.LegendSampleImpl.clean(), called by the constructor:

private void clean() {
        for (StyleInfo style : catalog.getStyles()) {
            synchronized (style) {
                Resource styleResource = getStyleResource(style);
                Resource sampleFile;
                try {
                    // remove old samples
                    sampleFile = getSampleFile(style);
                    if (isStyleNewerThanSample(styleResource, sampleFile)) {
                        sampleFile.delete();
                    }
                } catch (IOException e) {
                    LOGGER.log(
                            Level.SEVERE,
                            "Error cleaning invalid legend sample for " + style.getName(),
                            e);
                }
            }
        }
        invalidated = new HashSet<String>();
    }
  • there's no point in synchronizing on the StyleInfo, you get a new one on each call, lock the styleResource instead
  • if (isStyleNewerThanSample(styleResource, sampleFile)) tries to delete sampleFile even if it doesn't exist

groldan avatar Oct 01 '20 17:10 groldan