Table expand ratio setting ignored when reset

This appears to be a bug in Vaadin v6.8.9, but maybe I’m just missing something. I created a short sample app, source code below and running at http://fanello.jelastic.servint.net/tableratio/ (try it!).

As named, the table columns flex1 and flex2 don’t have any sizing set - they’re free to be sized by Vaadin. Column “fixed” has a set width, and column “expanded” has the expand ratio set to 1, which makes it use all available free space. These values are stored upon creation, so you can resize columns and collapse them, and then click the “Reset Layout” button to restore the default layout.

It works fine for the unset size columns and the fixed width column, and for restoring collapsed columns. If you manually resize the “expanded” column though, when the layout is reset the expand ratio is reset, but it is ignored. Empty space is distributed evenly among it and the two flex columns.

package com.example.vaadintest;

import java.util.HashSet;
import java.util.Random;
import java.util.Set;

import com.vaadin.Application;
import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickEvent;

@SuppressWarnings("serial")
public class VaadinTestApplication extends Application
{
  /** 
   * Storage of table column properties 
   * */
  public static class ColumnProps
  {
    Object  id;
    int     width;
    float   ratio;
    boolean collapsed;
  }

  private Random    rnd = new Random();
  private Table     table;
  private Set<ColumnProps> saved = new HashSet<ColumnProps>();
  
  public void init()
  {
    Window mainWindow = new Window("Vaadin Test Application");
    setMainWindow(mainWindow);

    VerticalLayout mainLayout = new VerticalLayout();
    mainWindow.setContent(mainLayout);
    
    table = new Table();
    table.setWidth("40em");
    table.setHeight("200px");
    table.setColumnReorderingAllowed(true);
    table.setColumnCollapsingAllowed(true);
    table.setSelectable(true);
    table.setImmediate(true);
    table.addContainerProperty("flex1", String.class, null);
    table.addContainerProperty("flex2", Integer.class, null);
    table.addContainerProperty("expanded", String.class, null);
    table.addContainerProperty("fixed", String.class, null);
    table.setColumnExpandRatio("expanded", 1f);
    table.setColumnWidth("fixed", 84);
    table.setColumnAlignment("fixed", Table.ALIGN_CENTER);
    for (int i=0; i < 10; ++i)
      table.addItem(new Object[] { randomStr(10), i, randomStr(16), randomStr(5) }, i);
    saved = getColumnProps(table);
    mainLayout.addComponent(table);
    
    Button btn = new Button("Reset Layout");
    btn.addListener(new Button.ClickListener() {
      @Override
      public void buttonClick(ClickEvent event)
      {
        setColumnProps(table, saved);
      }
    });
    mainLayout.addComponent(btn);
  }
  
  /**
   * @return the current column properties
   */
  private Set<ColumnProps> getColumnProps(Table t)
  {
    HashSet<ColumnProps> props = new HashSet<ColumnProps>();
    for (Object id : t.getVisibleColumns())
    {
      ColumnProps p = new ColumnProps();
      p.id = id;
      p.width = t.getColumnWidth(id);
      p.ratio = t.getColumnExpandRatio(id);
      p.collapsed = t.isColumnCollapsed(id);
      props.add(p);
    }
    return props;
  }
  
  /**
   * Apply the given column properties to the table.
   */
  private void setColumnProps(Table t, Set<ColumnProps> props)
  {
    boolean collapsable = t.isColumnCollapsingAllowed();
    for (ColumnProps p : props)
    {
      if (collapsable && t.isColumnCollapsible(p.id))
        t.setColumnCollapsed(p.id, p.collapsed);

      // These are mutually exclusive - each function clears the other
      if (p.ratio < 0f)
        t.setColumnWidth(p.id, p.width);
      else
        t.setColumnExpandRatio(p.id, p.ratio);
    }
  }

  private String randomStr(int max)
  {
    StringBuilder s = new StringBuilder();
    for (int len = rnd.nextInt(max)+1; len >= 0; --len)
      s.append(Character.forDigit(rnd.nextInt(36), 36));
    return s.toString();
  }
}

Bump.