Sorting JTable provoca NullPointerException

Tengo una JTable que, cuando se hace clic en el botón correspondiente, comienza a llenarse con los resultados de un recorrido del árbol de archivos que se realiza en segundo plano. Esto funciona bien.

Entonces decidí que quiero que se ordene la mesa. Después de leer un poco, creé un TableRowSorter y configuré la tabla para usarlo. Parecía funcionar, pero después de una inspección más cercana noté que varios de los resultados del archivo estaban ausentes. Inhabilité el clasificador y ejecuté el programa nuevamente y todos los archivos estaban presentes, al volver a habilitar el clasificador nuevamente se perdieron algunos, pero parecían ser archivos diferentes cada vez que se soltaban.

Para examinar esto, creé un bloque de código autónomo como prueba (ver más abajo), que debía ser representativo del código JTable (de hecho, se levantaron grandes fragmentos directamente del código del programa existente). El recorrido del árbol de archivos está representado por un bucle for. De nuevo, funcionó perfectamente sin el clasificador. Sin embargo, cuando habilité el clasificador (al descomentar la línea 29) todo el programa se congeló y me dijeron que había una NullPointerException.

No tengo idea de qué está causando ninguno de estos problemas, ni si están, de hecho, incluso relacionados. Cualquier idea sobre lo que está mal es bienvenida.

import javax.swing.table.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class Sort extends JFrame{

    private JTable table;
    private DefaultTableModel model;
    private TableRowSorter<DefaultTableModel> sorter;

    private JButton go;

    public Sort(){
        super("Sort");

        // Create table and model
        model = new DefaultTableModel(0, 4);
        table = new JTable(model);

        // Setup sorting
        sorter = new TableRowSorter<DefaultTableModel>(model);
        ArrayList<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>();
        sortKeys.add(new RowSorter.SortKey(2, SortOrder.ASCENDING));
        sortKeys.add(new RowSorter.SortKey(3, SortOrder.ASCENDING));
        sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
        sorter.setSortKeys(sortKeys); 
        //table.setRowSorter(sorter);

        // Create Scroll Pane
        JScrollPane tableScroller = new JScrollPane(table);
        table.setFillsViewportHeight(true);
        tableScroller.setPreferredSize(new Dimension(500, 200));

        // Setup button
        go = new JButton("Go");
        go.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>(){
                    public Void doInBackground(){
                        for(int i = 0; i < 200; i++){
                            model.addRow( new Object[] { (new Integer(i)), String.valueOf(i), String.valueOf(i%50), String.valueOf(i%10) } );
                        }
                        return null;
                    }
                };
                worker.execute();
            }
        });

        // Assemble GUI
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(tableScroller, BorderLayout.CENTER);
        panel.add(go, BorderLayout.SOUTH);

        setContentPane(panel);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        pack();
        setVisible(true);

    }

    public static void main(String[] args){
        SwingUtilities.invokeLater(new Runnable(){
            public void run(){
                new Sort();
            }
        });
    }

}
Stacktrace

Esto es parte del seguimiento de la pila, se repite ..

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at javax.swing.DefaultRowSorter.convertRowIndexToModel(DefaultRowSorter.java:518)
    at javax.swing.JTable.convertRowIndexToModel(JTable.java:2645)
    at javax.swing.JTable.getValueAt(JTable.java:2720)
    at javax.swing.JTable.prepareRenderer(JTable.java:5718)
    at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2114)
    at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:2016)
    at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1812)
    at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
    at javax.swing.JComponent.paintComponent(JComponent.java:778)
    at javax.swing.JComponent.paint(JComponent.java:1054)
    at javax.swing.JComponent.paintToOffscreen(JComponent.java:5221)
    at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:295)
    at javax.swing.RepaintManager.paint(RepaintManager.java:1206)
    at javax.swing.JComponent._paintImmediately(JComponent.java:5169)
    at javax.swing.JComponent.paintImmediately(JComponent.java:4980)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:770)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:728)
    at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:677)
    at javax.swing.RepaintManager.access$700(RepaintManager.java:59)
    at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1621)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
    at java.awt.EventQueue.access$000(EventQueue.java:101)
    at java.awt.EventQueue$3.run(EventQueue.java:666)
    at java.awt.EventQueue$3.run(EventQueue.java:664)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    ...

Respuestas a la pregunta(1)

Su respuesta a la pregunta