#1099 Cannot setKey for XYSeries


Below is the SSCCE:

public class XyseriesErrorMain
    public static void main( String[] args )
        XYSeriesCollection collection = new XYSeriesCollection();
        XYSeries series = new XYSeries( "Some Name" );

        collection.addSeries( series );

        series.setKey( "Some Other Name" );

It appears that XYSeriesCollection.vetoableChange function has the following code:

        if (this.getSeries(key) != null) {
            throw new PropertyVetoException("Duplicate key2", e);

which is throwing an exception if the new key is already being used. The problem is that the function used to determine this, XYSeriesCollection.getSeries(Key), throws an exception if the key is not found instead of returning null.

The result is that you can set the key to anything; as long as it's the key that already there. Impressively that works.

Also, please note that after removing the series from the collection and then setting the key, the series still calls the collection VetoableChangeListener because it was not actually removed for the XYSeriesCollection.removeSeries(int) call.


  • David Gilbert

    David Gilbert - 2013-11-21

    Thanks for the report. The main issue seems to have been fixed in the 1.0.15 release, although the removeSeries(int) call is still broken as you point out. I've fixed this for the 1.0.17 release, and added the same key check to the TimeSeriesCollection class.

  • David Gilbert

    David Gilbert - 2013-11-21
    • status: open --> closed-fixed

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks