Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8114052

Setting an empty stop list on a gradient builder causes a NPE.

XMLWordPrintable

      Running the following code results in a NullPointerException. An attempt to set an empty stop list should probably either be ignored or cause the stops to be reset to their default values. RadialGradientBuilder exhibits the same behavior.

      public class TestEmptyStrokeList extends Application {
          @Override
          public void start(Stage stage) throws Exception {
              Rectangle r = new Rectangle(200, 200);
              r.setFill(new LinearGradientBuilder().stops(new ArrayList<Stop>()).build());

              Scene s = new Scene(new Group(r), 220, 220);
              stage.setScene(s);
              stage.setVisible(true);
          }

          public static void main(String[] args) {
              Application.launch(args);
          }
      }

      Output:
      java.lang.NullPointerException
      at com.sun.prism.impl.ps.PaintHelper.getGradientTexture(PaintHelper.java:91)
      at com.sun.prism.impl.ps.BaseShaderContext.validatePaintOp(BaseShaderContext.java:346)
      at com.sun.prism.impl.ps.BaseShaderContext.validatePaintOp(BaseShaderContext.java:246)
      at com.sun.prism.impl.ps.BaseShaderGraphics.fillQuad(BaseShaderGraphics.java:559)
      at com.sun.prism.impl.shape.BasicRoundRectRep.fillRoundRect(BasicRoundRectRep.java:35)
      at com.sun.prism.impl.shape.BasicRoundRectRep.fill(BasicRoundRectRep.java:21)
      at com.sun.javafx.sg.prism.NGShape.renderContent(NGShape.java:130)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:103)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:34)
      at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1000)
      at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:179)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:103)
      at com.sun.javafx.sg.prism.NGGroup.doRender(NGGroup.java:290)
      at com.sun.javafx.sg.prism.NGGroup.doRender(NGGroup.java:27)
      at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1000)
      at com.sun.javafx.tk.quantum.PaintRunnable.paintImpl(PaintRunnable.java:137)
      at com.sun.javafx.tk.quantum.PaintRunnable.run(PaintRunnable.java:236)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
      at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
      at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
      at com.sun.prism.render.RenderJob.run(RenderJob.java:29)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at com.sun.javafx.tk.quantum.QuantumRenderer$ObservedRunnable.run(QuantumRenderer.java:70)
      at java.lang.Thread.run(Thread.java:619)

            jgodinez Jennifer Godinez (Inactive)
            diversonjfx Dean Iverson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: