-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8319938: TestFileChooserSingleDirectorySelection.java fails with "getSelectedFiles returned empty array" #16674
Conversation
👋 Welcome back abhiscxk! A progress list of the required criteria for merging this PR into |
@kumarabhi006 The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
* is enabled for JFileChooser. | ||
* @run main TestFileChooserSingleDirectorySelection | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why it was necessary to move all around all the above lines.
And whilst import java.io sorts after java.awt, it is long standing convention that the "core"
packages (easily distinguished these days as those in the java.base module) are listed before the desktop / AWT / Swing ones. This is true of product source as well as tests.
So you should just undo all of the above except for adding the new bug id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And whilst import java.io sorts after java.awt, it is long standing convention that the "core"
packages (easily distinguished these days as those in the java.base module) are listed before the desktop / AWT / Swing ones. This is true of product source as well as tests.
@prrace This is the first time I hear this. In all the classes I've seen in AWT and Swing, the imports are sorted alphabetically with java.io
after java.awt
.
I just looked at JComponent
, Component
, Font, and
jdk/src/java.desktop/share/classes/sun/font/FontManager.java
Lines 28 to 30 in 6ce0ebb
import java.awt.Font; | |
import java.awt.FontFormatException; | |
import java.io.File; |
jdk/src/java.desktop/share/classes/sun/font/Font2D.java
Lines 28 to 36 in 6ce0ebb
import java.awt.Font; | |
import java.awt.font.FontRenderContext; | |
import java.awt.geom.AffineTransform; | |
import java.lang.ref.Reference; | |
import java.lang.ref.SoftReference; | |
import java.lang.ref.WeakReference; | |
import java.util.concurrent.ConcurrentHashMap; | |
import java.util.Locale; | |
import java.util.Set; |
Sun/Oracle Code Conventions for Java Programming Language say nothing about the order of imports. (The HTML version has absolutely broken formatting now.) Google Java Style Guide states, …the imported names appear in ASCII sort order.
Andreas Lundblad's draft for Java Style Guidelines, which is more or less followed by the OpenJDK project, defines the following order:
Import statements should be sorted…
- …primarily by non-static / static with non-static imports first.
- …secondarily by package origin according to the following order
java
packagesjavax
packages- external packages (e.g.
org.xml
)- internal packages (e.g.
com.sun
)- …tertiary by package and class identifier in lexicographical order
Andreas opened PR 14 to incorporate it into OpenJDK Developers' Guide, but there are objections to making the Java Code Conventions part of the developers' guide.
I believe it's not even the first time such a discussion happens in the clientlibs. There are no guidelines…
Personally, I think putting java.awt
classes above java.io
or java.util
makes perfect sense for clientlibs classes — it is what we care the most, it is what we're developing and maintaining, so java.awt
is more relevant to us. And it automatically sorts this way in IDE; manually sorting imports is tedious and error-prone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why it was necessary to move all around all the above lines.
@prrace I nearly always ask to move the jtreg tags to the class declaration, especially for new tests. When you open the test file in IDE, the copyright block above imports is collapsed, so is the jtreg tags if they're placed above the imports.
If the jtreg tags are placed in a comment that precedes the class declaration, after the imports, they're not collapsed — you can see them right away without scrolling or clicking. I consider the jtreg tags quite relevant to see them easily.
Most older tests place the jtreg tags above the imports; it could've been the requirement or limitation of jtreg at that time. It's not a limitation any more.
As for moving the jtreg tags in existing tests when the test is modified, I also do it occasionally for the reasons outlined above: the jtreg tags describe the test and belong to the class declaration, akin a javadoc comment. (Yet I am against using the javadoc syntax, starting with two asterisks, for the jtreg tasks because it is not a javadoc and because it removes the IDE warnings for the unknown javadoc tasks.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And whilst import java.io sorts after java.awt, it is long standing convention that the "core"
packages (easily distinguished these days as those in the java.base module) are listed before the desktop / AWT / Swing ones. This is true of product source as well as tests.@prrace This is the first time I hear this. In all the classes I've seen in AWT and Swing, the imports are sorted alphabetically with
java.io
afterjava.awt
.
Today I've stumbled upon a few files where java.io
and java.util
come before java.awt
, such as DialogOwnerTest.java
, CustomFont.java
, DeviceScale.java
,
jdk/test/jdk/java/awt/print/PrinterJob/DrawImage.java
Lines 32 to 36 in 3789983
import java.util.*; | |
import java.text.*; | |
import java.io.*; | |
import java.net.*; | |
import java.awt.*; |
It's a handful of files out of more than a hundred modified files in #16785; it doesn't look as a convention. Do wildcard imports even count?
|
||
// create temporary files inside testDir | ||
tempFile = new File[5]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this test HAVE to use the home dir to create the temporary folders and files ?
Is there some reason some part of the test absolutely requires the home directory ?
It isn't obvious to me.
Why can't you instead use System.getProperty("java.io.tmpdir");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to have the home dir
to create the temporary folders and files. Since I was testing in my local mahine to create temp folders in home directory, I kept it as it is.
Changed home dir
to java.io.tmpdir
for creating temporary folders and files.
// Create a test directory that contains only files | ||
testFile = new File(tmpDir, "testFile"); | ||
if (!testFile.exists()) { | ||
testFile.mkdir(); | ||
} | ||
testFile.deleteOnExit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is confusing: testFile
is actually a directory.
You could improve the readability of the test by using methods: createFoldersOnlyDir
, createFilesOnlyDir
, populateDirs
, populateFiles
or something similar — it would make the comments in the code unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test updated.
|
||
// create temporary files inside testDir | ||
tempFile = new File[5]; | ||
String tmpDir = System.getProperty("java.io.tmpdir"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the purpose of the scratch directory in jtreg, and it's automatically cleaned up after the test: jtreg will automatically clean up any files written in the scratch directory.
The test is designed for jtreg, so the simplest solution is to use the current directory.
If someone runs the test directly, without using jtreg, then it's their task to set up the current directory or clean up after the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reasons when I used the current directory i.e. scratch
, test failed in my local machine.
String tmpDir = System.getProperty(".");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reasons when I used the
current directory i.e. scratch
, test failed in my local machine.String tmpDir = System.getProperty(".");
How does it fail?
Is it because System.getProperty(".")
returns null
? The property "."
doesn't exist, does it?
Use new File(".")
which resolves to the current directory. Alternatively, remove references to paths, just create directories and files, they will be created in the current directory if you don't specify an absolute path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it fail? Is it because
System.getProperty(".")
returnsnull
? The property"."
doesn't exist, does it?
No, temp files and directories are created in scratch
directory. But the files gets deselected after selection which returns as no file selected and test failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the files gets deselected after selection which returns as no file selected and test failed.
How is it? It sounds like magic… The working directory shouldn't matter; if it does, the test isn't as stable as it should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surprise to me also. It failed every single time when temporary files are created in scratch
.
The test isn't as stable as it should be.
Unable to trace what is missing in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took a long while for me to figure it out. What matters is whether the File
object is created with an absolute path or not. By using System.getProperty("java.io.tmpdir")
as the base path, you create an absolute path for the parent directory.
Yet if you use pass null
as the first parameter (as I said, there's no system property named ".", so tmpDir
is null
) or use the constructor with one parameter new File("testDir")
, the file has relative path. This causes some issues…
When you create JFileChooser
object, you always pass testDir
as its starting directory. Then, for each case, you set it once again. Here's what I see in a PropertyChangeListener
:
>> setCurrentDirectory
directoryChanged: /home/aivanov/jdk-dev/testDir/testDir -> testDir
<< setCurrentDirectory
SelectedFileChangedProperty: /home/aivanov/jdk-dev/testDir/subDir_3 -> null
SelectedFilesChangedProperty: [Ljava.io.File;@3fed803b -> null
directoryChanged: testDir -> /home/aivanov/jdk-dev/testDir
SelectedFileChangedProperty: null -> null
SelectedFilesChangedProperty: null -> [Ljava.io.File;@1bf88ed6
This is why see a directory gets selected but then becomes unselected again.
Getting the absolute file — testDir = new File("testDir").getAbsoluteFile()
— resolves this problem, and the test starts to work in the current directory. I tested it by running with jtreg, then the current directory is the scratch
directory, and as a stand-alone app, in this case the current directory is whatever the current directory is.
So either way works as long as the starting File
object is created with an absolute path.
} catch (Exception e) { | ||
e.printStackTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exception should've been propagated: if an exception is thrown, test setup code has failed to prepare the expected environment — the test would likely fail too, then let it fail quickly and report the real reason.
@@ -23,7 +23,7 @@ | |||
|
|||
/* | |||
* @test | |||
* @bug 6972078 | |||
* @bug 6972078 8319938 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a test bug, no code in JDK is changed as the result — the bugid shouldn't be added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
private static File[] SubDirs; | ||
private static File[] subFiles; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't use these arrays, they could be local variables; but even there they're not needed — a local variable for a current file or directory is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
createFoldersOnlyDir(); | ||
createFilesOnlyDir(); | ||
populateDirs(); | ||
populateFiles(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning and passing the File
object would make code flow clearer:
createFoldersOnlyDir(); | |
createFilesOnlyDir(); | |
populateDirs(); | |
populateFiles(); | |
testDir = createFoldersOnlyDir(); | |
populateDirs(testDir); | |
testFile = createFilesOnlyDir(); | |
populateFiles(testFile); |
I still find testFile
confusing because it represents a directory. What about testDirDirs
, testDirFiles
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the var names.
SubDirs = new File[10]; | ||
for (int i = 0; i < 10; ++i) { | ||
SubDirs[i] = new File(testDir, "subDir_" + (i+1)); | ||
SubDirs[i].mkdir(); | ||
SubDirs[i].deleteOnExit(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The array is redundant:
SubDirs = new File[10]; | |
for (int i = 0; i < 10; ++i) { | |
SubDirs[i] = new File(testDir, "subDir_" + (i+1)); | |
SubDirs[i].mkdir(); | |
SubDirs[i].deleteOnExit(); | |
} | |
for (int i = 0; i < 10; ++i) { | |
File subDir = new File(testDir, "subDir_" + (i+1)); | |
subDir.mkdir(); | |
subDir.deleteOnExit(); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
subFiles = new File[10]; | ||
for (int i = 0; i < 10; ++i) { | ||
subFiles[i] = File.createTempFile("subFiles_" + (i+1), | ||
".txt", new File(testFile.getAbsolutePath())); | ||
subFiles[i].deleteOnExit(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The array is redundant. I also suggest following the same pattern for creating files:
subFiles = new File[10]; | |
for (int i = 0; i < 10; ++i) { | |
subFiles[i] = File.createTempFile("subFiles_" + (i+1), | |
".txt", new File(testFile.getAbsolutePath())); | |
subFiles[i].deleteOnExit(); | |
} | |
for (int i = 0; i < 10; ++i) { | |
File subFile = new File(testFile, "subFiles_" + (i+1)); | |
subFile.createNewFile(); | |
subFile.deleteOnExit(); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
fileChooser.setCurrentDirectory(testDir); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fileChooser.setFileSelectionMode
that you call below should be called on EDT, I suggest moving it into this block.
This applies to all check-*
methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To eliminate duplicating code for disposing of the frame, create a helper method and call it from the finally
block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fileChooser.setFileSelectionMode
that you call below should be called on EDT, I suggest moving it into this block.This applies to all
check-*
methods.
Accessed on EDT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To eliminate duplicating code for disposing of the frame, create a helper method and call it from the
finally
block.
Updated, looks cleaner code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since GitHub doesn't allow adding comments to lines which aren't modified:
In doTesting
, you should get the location and dimensions of the frame on EDT (and for the button too).
The passed
field is to be declared volatile
: you modify it on EDT in the button listener but you read its value on main thread.
Basically, you don't need the button, you can run the code in the button action listener directly. Be sure to run it on EDT though.
The listener code can be modified to perform only one volatile write:
public void actionPerformed(ActionEvent evt) {
File files[] = fileChooser.getSelectedFiles();
passed = files.length != 0;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Button
and passed
field are removed since it may not be required. The selected files are fetched in checkResult
method.
return dirsDir; | ||
} | ||
|
||
private static void populateDirs(File dirsDir) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static void populateDirs(File dirsDir) { | |
private static void populateDirs(File parent) { |
It better conveys the meaning of the parameter.
File SubDirs = new File(dirsDir, "subDir_" + (i+1)); | ||
SubDirs.mkdir(); | ||
SubDirs.deleteOnExit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File SubDirs = new File(dirsDir, "subDir_" + (i+1)); | |
SubDirs.mkdir(); | |
SubDirs.deleteOnExit(); | |
File subDir = new File(dirsDir, "subDir_" + (i+1)); | |
subDir.mkdir(); | |
subDir.deleteOnExit(); |
It's one subdirectory; local variable names start with lower-case letter in Java.
return filesDir; | ||
} | ||
|
||
private static void populateFiles(File filesDir) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static void populateFiles(File filesDir) throws Exception { | |
private static void populateFiles(File parent) throws Exception { |
Or parentDir
.
} | ||
|
||
private static void checkFileOnlyTest(UIManager.LookAndFeelInfo laf, | ||
File crntDir) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File crntDir) throws Exception { | |
File dir) throws Exception { |
Alternatively, spell out current
; if you prefer to abbreviate, curr
is rather standard abbreviation for ‘current’. However, I think dir
is enough, its meaning is easily inferred as it's passed to fileChooser.setCurrentDirectory
.
private static void checkDirectoriesOnlyTest(UIManager.LookAndFeelInfo laf, | ||
File crntDir) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static void checkDirectoriesOnlyTest(UIManager.LookAndFeelInfo laf, | |
File crntDir) throws Exception { | |
private static void checkDirectoriesOnlyTest(UIManager.LookAndFeelInfo laf, | |
File crntDir) throws Exception { |
Align the parameters, if you follow this style.
frameLocation = fileChooser.getLocationOnScreen(); | ||
frameWidth = frame.getWidth(); | ||
frameHeight = frame.getHeight(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
frameLocation = fileChooser.getLocationOnScreen(); | |
frameWidth = frame.getWidth(); | |
frameHeight = frame.getHeight(); | |
bounds = new Rectangle(fileChooser.getLocationOnScreen(), | |
frame.getSize()); |
Isn't one variable enough? Moreover frameLocation
stores the location of fileChooser
.
Since now there's only one click location, this can be simplified further:
frameLocation = fileChooser.getLocationOnScreen(); | |
frameWidth = frame.getWidth(); | |
frameHeight = frame.getHeight(); | |
Point fileChooserLocation = fileChooser.getLocationOnScreen(); | |
fileChooserLocation.y += frame.getHeight() / 3; | |
clickLocation = new Point(fileChooserLocation); |
Then you modify your clickMouse
method to accept two parameters: Point
and xOffset
.
private static void checkResult(UIManager.LookAndFeelInfo laf) { | ||
if (!passed) | ||
File files[] = fileChooser.getSelectedFiles(); | ||
if (files.length == 0) { | ||
throw new RuntimeException("getSelectedFiles returned " + | ||
"empty array for LAF: "+laf.getClassName()); | ||
"empty array for LAF: " + laf.getClassName()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And you ignored Be sure to run it on EDT
: fileChooser.getSelectedFiles()
is to be called on EDT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed here to access fileChooser.getSelectedFiles()
on EDT.
checkFilesAndDirectoriesTest(laf); | ||
checkFileOnlyTest(laf, testDirFiles); | ||
checkDirectoriesOnlyTest(laf, testDirDirs); | ||
checkFilesAndDirectoriesTest(laf, testDirDirs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, FILES_AND_DIRECTORIES
mode is tested with directories only. Is it intentional? It's the problem in JDK-6972078… that directories can't be selected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So,
FILES_AND_DIRECTORIES
mode is tested with directories only. Is it intentional? It's the problem in JDK-6972078… that directories can't be selected.
Yes, it is tested with directories only.
Is it intentional? It's the problem in JDK-6972078… that directories can't be selected.
Not intentional though. Thought of creating a single folder with the mix of files and directories initially but getting the location of files in FILES_ONLY
mode was an issue in different LAF. So, created separate folders for directories
and files
and tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intentional? It's the problem in JDK-6972078… that directories can't be selected.
Not intentional though. Thought of creating a single folder with the mix of files and directories initially but getting the location of files in
FILES_ONLY
mode was an issue in different LAF. So, created separate folders fordirectories
andfiles
and tested.
It's fine as long as the original issue is reproducible with directories only too.
Is it possible to shorten the subject of the issue? It is too long and wordy, yet it doesn't add valuable context. Ideally, the summary should be concise. |
@aivanov-jdk Updated the suggested changes, |
Yeah sure, it can be changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ActionEvent
and ActionListener
aren't used any more, remove them, please.
Could you also update the copyright year in the file?
} | ||
private static void checkResult(UIManager.LookAndFeelInfo laf) throws Exception { | ||
SwingUtilities.invokeAndWait(() -> { | ||
File files[] = fileChooser.getSelectedFiles(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File files[] = fileChooser.getSelectedFiles(); | |
File[] files = fileChooser.getSelectedFiles(); |
Let's use Java-style array declaration.
@kumarabhi006 This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 726 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
@@ -1,5 +1,5 @@ | |||
/* | |||
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. | |||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. | |
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. |
You always preserve the first year.
Pay attention to the warning displayed by the bot: retarget the bug in JBS to 22 if you're going to integrate before the fork occurs. |
robot.waitForIdle(); | ||
} | ||
|
||
private static void checkResult(UIManager.LookAndFeelInfo laf) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of passing the laf through all the methods, can't we create and use a class variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of passing the laf through all the methods, can't we create and use a class variable?
Can be done but can't see any functional improvements. This seems ok to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, those are to reduce redundancy in code, not functional...... Otherwise the fix looks fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not redundancy: passing the laf
explicitly makes the data flow clearer, even though laf
isn't directly used.
I agree that making laf
a class field doesn't provide much benefit.
In a way, it could be removed completely, however, reporting the L&F at which the test case failed gives more details, you don't need to look at the test log to find the L&F.
/integrate |
Going to push as commit 4ef24e2.
Your commit was automatically rebased without conflicts. |
@kumarabhi006 Pushed as commit 4ef24e2. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
The test fails for JFileChooser selection mode set to
DIRECTORIES_ONLY
. ForDIRECTORIES_ONLY
mode, there may not be any directories in home directory and due to that test failed. Added the code to create temporary directories and files for the test.Tested the current change on the machine it failed for multiple times, no failure observed.
CI link attached in JBS.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16674/head:pull/16674
$ git checkout pull/16674
Update a local copy of the PR:
$ git checkout pull/16674
$ git pull https://git.openjdk.org/jdk.git pull/16674/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 16674
View PR using the GUI difftool:
$ git pr show -t 16674
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16674.diff
Webrev
Link to Webrev Comment