gs:DownloadEstimator should check size is less than Integer.MAX_VALUE

Description

The gsownloadEstimator process only checks the requested size against the configured raster size limit, without worrying to check that it is also a valid Integer value.

If one raises the raster size limit above Integer.MAX_VALUE in the configuration and tries to download a huge image (e.g. 100,000 * 60,000), the estimator will say the request is ok, but the actual download will throw an exception:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 org.geotools.process.ProcessException: java.lang.IllegalArgumentException: Dimensions (width=98899 height=60354) are too large at org.geoserver.wps.gs.download.DownloadProcess.execute(DownloadProcess.java:294) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.geotools.process.factory.AnnotationDrivenProcessFactory$InvokeMethodProcess.execute(AnnotationDrivenProcessFactory.java:549) at org.geoserver.wps.executor.DefaultProcessManager$ProcessCallable.call(DefaultProcessManager.java:201) at org.geoserver.wps.executor.DefaultProcessManager$ProcessCallable.call(DefaultProcessManager.java:169) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalArgumentException: Dimensions (width=XXX height=YYY) are too large at java.awt.image.SampleModel.<init>(SampleModel.java:130) at java.awt.image.MultiPixelPackedSampleModel.<init>(MultiPixelPackedSampleModel.java:147) at java.awt.image.MultiPixelPackedSampleModel.<init>(MultiPixelPackedSampleModel.java:107) at java.awt.image.Raster.createPackedRaster(Raster.java:846) at java.awt.image.Raster.createPackedRaster(Raster.java:588) at java.awt.image.BufferedImage.<init>(BufferedImage.java:450) at javax.media.jai.ROIShape.getAsImage(ROIShape.java:1129) at org.geotools.image.ImageWorker.mosaic(ImageWorker.java:4381) at org.geotools.coverage.processing.operation.Crop.buildResult(Crop.java:680) at org.geotools.coverage.processing.operation.Crop.doOperation(Crop.java:439) at org.geotools.coverage.processing.CoverageProcessor.doOperation(CoverageProcessor.java:605) at org.geotools.coverage.processing.CoverageProcessor.doOperation(CoverageProcessor.java:627) at org.geotools.process.raster.CropCoverage.execute(CropCoverage.java:81) at org.geoserver.wps.gs.download.RasterDownload.execute(RasterDownload.java:244) at org.geoserver.wps.gs.download.DownloadProcess.execute(DownloadProcess.java:204) ... 11 more

At the very least, the estimator should return false if the requested image size is above Integer.MAX_VALUE.

Environment

None

Status

Assignee

Stefano Costa

Reporter

Stefano Costa

Triage

None

Fix versions

Affects versions

2.7.2
2.9-M0
2.8.0

Components

Priority

Medium
Configure