JDK-8160540 : [macosx] file chooser removing from end of filename
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8u92
  • Priority: P4
  • Status: Closed
  • Resolution: Incomplete
  • OS: os_x
  • CPU: x86
  • Submitted: 2016-06-27
  • Updated: 2016-07-04
  • Resolved: 2016-07-04
Description
FULL PRODUCT VERSION :
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Darwin johns-air.loctest.gov 13.4.0 Darwin Kernel Version 13.4.0: Mon Jan 11 18:17:34 PST 2016; root:xnu-2422.115.15~1/RELEASE_X86_64 x86_64

A DESCRIPTION OF THE PROBLEM :
The BasicFileChooserUI's inner class ApproveSelectionAction incorrectly strips off a \r from the end of a filename choosen. This is problematic since Mac OS files can sometimes have \r on the end of the filename created by the OS itself.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) create a file with a \r on the end in bash command line
touch "Icon^M"
2) create a java program that uses BasicFileChooserUI
3) select the Icon^M file


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The BasicFileChooserUI does not try to modify the filename
ACTUAL -
The filename gets truncated to Icon

REPRODUCIBILITY :
This bug can be reproduced always.


Comments
Was unable to reproduce. Maybe there is something missing in the steps and also, the description mentioning the steps to reproduce are somewhat contradictory. regarding "\r" and file name being "Icon^M". Tried various combinations with BasicFileChooser but was unable to reproduce any truncation. Also, test case mentioned used some Junit test suit. We will need a test case which proper steps to reproduce and a test case which can be run on mac setup.
04-07-2016

Bug Submitter's reply: **************************** ================================================================ import java.io.File; import javax.swing.Action; import javax.swing.JFileChooser; import javax.swing.plaf.metal.MetalFileChooserUI; import org.junit.Assert; import org.junit.Test; public class BasicFileCHooserUITest{ @Test public void test(){ File expectedFile = new File("Icon\r"); JFileChooser chooser = new JFileChooser(); MetalFileChooserUI chooserUI = new MetalFileChooserUI(chooser); chooserUI.installUI(chooser); chooser.setSelectedFile(expectedFile); Action action = chooserUI.getApproveSelectionAction(); action.actionPerformed(null); Assert.assertEquals(expectedFile, chooser.getSelectedFile()); } ================================================================ Obviously in this case you will need to select a file that has a \r in the filename.
29-06-2016

============================================================================================ For our quick investigation, is it possible for you to send us a simple stand-alone test case to reproduce this issue? Also request you to let us know whether it is reproducible with JDK 9ea latest build or not? ============================================================================================
29-06-2016