#1122 infinite loop in writeChartAsPNG

1.0.x
closed-fixed
David Gilbert
None
5
2014-08-17
2014-01-21
Serkan Bozyigit
No

When trying to call writeChartAsPNG with a width and height that is rather small (1), writeChartAsPNG loops and eventually ends up in a OutOfMemory exception. Of course 1 is a useless size, but it should return with an exception or do something else than looping.
Might be related to ticket 27.

Example code:

public class Test {

    public static void main(String[] args) {
        OutputStream output = new ByteArrayOutputStream();

        XYDataset dataset = new TimeSeriesCollection();
        JFreeChart chart = ChartFactory.createTimeSeriesChart("chart", "a", "b", dataset);

        int width = 1;
        int height = 1;

        try {
            ChartUtilities.writeChartAsPNG(output, chart, width, height, null);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Discussion

  • David Gilbert
    David Gilbert
    2014-03-10

    I think you are probably running into this issue:

    http://www.jfree.org/forum/viewtopic.php?f=7&t=116818

    If you download the latest JCommon version (1.0.22) the issue should be gone. Your test case is working for me with JCommon 1.0.22. I will close the bug, please reopen it if the issue is not resolved for you.

     
  • David Gilbert
    David Gilbert
    2014-03-10

    • status: open --> closed-fixed
    • assigned_to: David Gilbert
     
  • David Gilbert
    David Gilbert
    2014-03-10

    Fixed in JCommon version 1.0.22.