JDK-4997165 : REGRESSION:JFileChooser throws NPE
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0,5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 2004-02-19
  • Updated: 2004-09-01
  • Resolved: 2004-04-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 b47Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Name: apR10229			Date: 02/19/2004


Filed By      : SPB JCK team (###@###.###)
JDK           : JDK15-beta2-b37
JCK           : 1.5
Platform[s]   : SunOS 5.8
switch/Mode   : 
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] :
    api/javax_swing/plaf/metal/MetalFileChooserUI/FilterComboBoxModel/index.html#Public[FilterComboBoxModel2003]


Problem description
===================
JCK API test
api/javax_swing/plaf/metal/MetalFileChooserUI/FilterComboBoxModel/index.html#Public[FilterComboBoxModel2003]
failed with JDK1.5-beta2-b37 with NPE on SunOS-5.8-sparc. Below is the minimized code that can help to reproduce this failure.
    
Minimized test:
===============
------- Test.java -------
import javax.swing.JFileChooser;
import javax.swing.plaf.metal.*;
import javax.swing.filechooser.FileFilter;
import java.io.File;

public class Test {
    public static void main(String[] argv) {
      for (int j=0; j<50; j++) {
	JFileChooser fileChooser = new JFileChooser();
	StubMetFCUI outer = new StubMetFCUI(fileChooser);
	outer.installUI(fileChooser);
	StubMetFCUI.StubFCBMod c = outer.new StubFCBMod();
	FileFilter filter = new CustomFilter();
	fileChooser.addChoosableFileFilter(filter);
	c.setSelectedItem(fileChooser.getChoosableFileFilters()[1]);
      }
    }
}

class StubMetFCUI extends MetalFileChooserUI {
  public class StubFCBMod extends FilterComboBoxModel {
    public StubFCBMod() {
      super();
    }
  }
  StubMetFCUI(JFileChooser fc) {
    super(fc);
  }
}

class CustomFilter extends FileFilter {
  public boolean accept(File f) {
    return true;
  }
  public String getDescription() {
    return "Custom filter";
  }
}; 

------- end-of-Test.java -------

Minimized test output:
======================
<pav@volvo(pts/24).257> java Test
Warning: Cannot convert string "-monotype-arial-regular-r-normal--*-140-*-*-p-*-iso8859-1" to type FontStruct
Exception in thread "main" java.lang.NullPointerException
        at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1116)
        at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1059)
        at javax.swing.plaf.basic.BasicListUI$Handler.valueChanged(BasicListUI.java:2171)
        at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:187)
        at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167)
        at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:214)
        at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:408)
        at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:417)
        at javax.swing.DefaultListSelectionModel.removeSelectionIntervalImpl(DefaultListSelectionModel.java:510)
        at javax.swing.DefaultListSelectionModel.clearSelection(DefaultListSelectionModel.java:422)
        at sun.swing.FilePane.clearSelection(FilePane.java:1244)
        at sun.swing.FilePane.doFilterChanged(FilePane.java:1166)
        at sun.swing.FilePane.propertyChange(FilePane.java:1202)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:305)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:242)
        at java.awt.Component.firePropertyChange(Component.java:7106)
        at javax.swing.JFileChooser.setFileFilter(JFileChooser.java:1406)
        at javax.swing.JFileChooser.addChoosableFileFilter(JFileChooser.java:1103)
        at Test.main(Test.java:14)
<pav@volvo(pts/24).258> 


JCK test source location:
==========================
/java/re/jck/1.5/promoted/latest/JCK-runtime-15/tests

Specific Machine Info:
=====================
SunOS volvo 5.8 Generic_108528-18 sun4u sparc SUNW,Sun-Blade-1000

Additional comments:
====================
This bug was reproduced on SunOS 5.8/sparc/jdk15-beta2-b37,38


======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta2 FIXED IN: tiger-beta2 INTEGRATED IN: tiger-b47 tiger-beta2 VERIFIED IN: tiger-rc
13-09-2004

EVALUATION Name: keR10081 Date: 02/20/2004 This issue does not seem to be related to bug 4980406. Need to fix this. ###@###.### ====================================================================== Name: keR10081 Date: 03/04/2004 There is a threading problem here which we need to resolve. It is also described in bug 4990234. ###@###.### ====================================================================== Name: keR10081 Date: 03/16/2004 To resolve threading problem we need to hold off DelayedSelectionUpdater until JFileChooser is realized. See suggested fix for details. ###@###.### ======================================================================
13-09-2004

SUGGESTED FIX Name: keR10081 Date: 03/16/2004 *** /net/diablo/export2/swing/kve/dragon/webrev/src/share/classes/sun/swing/FilePane.java- Fri Mar 5 16:31:40 2004 --- FilePane.java Fri Mar 5 15:39:22 2004 *************** *** 413,422 **** updateListRowCount(list); } public void contentsChanged(ListDataEvent e) { ! if (list != null && (!(((File)list.getModel().getElementAt(0)).equals(fileChooser.getCurrentDirectory())))) { list.setSelectedIndex(0); } ! listSelectionModel.clearSelection(); updateListRowCount(list); } }); --- 413,422 ---- updateListRowCount(list); } public void contentsChanged(ListDataEvent e) { ! if (list != null && (!(((File)list.getModel().getElementAt(0)).equals(fileChooser.getCurrentDirectory())))&&(isShowing())) { list.setSelectedIndex(0); } ! if (isShowing()) listSelectionModel.clearSelection(); updateListRowCount(list); } }); *************** *** 838,844 **** DelayedSelectionUpdater(File editFile) { this.editFile = editFile; ! SwingUtilities.invokeLater(this); } public void run() { --- 838,846 ---- DelayedSelectionUpdater(File editFile) { this.editFile = editFile; ! if (isShowing()) { ! SwingUtilities.invokeLater(this); ! } } public void run() { ======================================================================
13-09-2004