Commit 8da0ea2c authored by Andrea Aime's avatar Andrea Aime
Browse files

[GEOS-7359] 'Tile layers' page crashes with GWC_DISKQUOTA_DISABLED set to true

parent 0dc89329
......@@ -1065,7 +1065,7 @@ public class GWC implements DisposableBean, InitializingBean, ApplicationContext
*/
public boolean isDiskQuotaEnabled() {
DiskQuotaMonitor diskQuotaMonitor = getDiskQuotaMonitor();
return diskQuotaMonitor.getConfig().isEnabled();
return diskQuotaMonitor.isEnabled() && diskQuotaMonitor.getConfig().isEnabled();
}
/**
......
......@@ -3,17 +3,42 @@ package org.geoserver.gwc.web.layer;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.mock;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang.reflect.FieldUtils;
import org.geoserver.gwc.GWC;
import org.geoserver.platform.GeoServerExtensions;
import org.geoserver.test.GeoServerTestSupport;
import org.geowebcache.config.ConfigurationException;
import org.geowebcache.diskquota.DiskQuotaConfig;
import org.geowebcache.diskquota.DiskQuotaMonitor;
import org.geowebcache.layer.TileLayer;
import org.junit.After;
import org.junit.Test;
public class CachedLayerProviderTest extends GeoServerTestSupport {
@After
public void testQuotaDisabledWithSystemVariable() throws IllegalAccessException {
DiskQuotaMonitor monitor = GeoServerExtensions.bean(DiskQuotaMonitor.class);
// the field is initialized once based on system variable, we use reflection
// to force it to a different value and set it back where it was
Field enabledField = FieldUtils.getField(DiskQuotaMonitor.class, "diskQuotaEnabled", true);
try {
FieldUtils.writeField(enabledField, monitor, false, true);
CachedLayerProvider provider = new CachedLayerProvider();
List<TileLayer> layers = provider.getItems();
for (TileLayer tileLayer : layers) {
// we are not returning the values from the quota subsystem, they are not up to date anyways
assertNull(CachedLayerProvider.QUOTA_USAGE.getPropertyValue(tileLayer));
}
} finally {
FieldUtils.writeField(enabledField, monitor, true, true);
}
}
@Test
public void testQuotaEnabled() throws ConfigurationException, IOException, InterruptedException {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment