NullpointerException in ImageWorker when showing/hiding layers in SwtMapPane

Description

Since GeoTools version 20.2 certain actions in the SwtMapPane cause a NullpointerException to be thrown by the rendering framework for WMS map layers. When the error occurs the map view is emptied and is blank until another rendering event is triggered that forces a redraw


Showing/hiding WMS layers, or zooming to the extent of the layers more than once result in the following error:
Mar 29, 2019 2:22:10 PM org.geotools.renderer.lite.StreamingRenderer fireErrorEvent
SEVERE: null
java.lang.NullPointerException
at javax.media.jai.RenderedImageAdapter.getProperty(RenderedImageAdapter.java:189)
at org.geotools.image.ImageWorker.extractNoDataProperty(ImageWorker.java:502)
at org.geotools.image.ImageWorker.setImage(ImageWorker.java:521)
at org.geotools.image.ImageWorker.<init>(ImageWorker.java:498)
at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.affine(GridCoverageRenderer.java:675)
at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.symbolize(GridCoverageRenderer.java:457)
at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.renderImage(GridCoverageRenderer.java:1021)
at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.paint(GridCoverageRenderer.java:1279)
at org.geotools.renderer.lite.StreamingRenderer$RenderCoverageReaderRequest.execute(StreamingRenderer.java:3650)
at org.geotools.renderer.lite.StreamingRenderer$PainterThread.run(StreamingRenderer.java:3744)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

The easiest way to reproduce the bug:

I used the attached code in a small RCP project to reproduce the bug.

Environment

Windows 8.1
Java 1.8

Assignee

Unassigned

Reporter

Roland Teichert

Triage

None

Components

Affects versions

Priority

Medium
Configure