Skip to content
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

6616245: NullPointerException when using JFileChooser with a custom FileView #10485

Closed
wants to merge 9 commits into from

Conversation

TejeshR13
Copy link
Contributor

@TejeshR13 TejeshR13 commented Sep 29, 2022

When a custom FileView is used and folder traversal is restricted to a particular directory NPE occurs when user tries to traverse/select other folders except traversable folder. This is caused because when user selects folder other than traversable, the traversal is rejected and hence no file is selected as currentDirectory of JFileChooser. When user tries to access the restricted folder second time, previous selected file check is failing because of NPE since getFileChooser().getCurrentDirectory(); is null. To fix the issue, NPE check is added.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-6616245: NullPointerException when using JFileChooser with a custom FileView

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10485/head:pull/10485
$ git checkout pull/10485

Update a local copy of the PR:
$ git checkout pull/10485
$ git pull https://git.openjdk.org/jdk pull/10485/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10485

View PR using the GUI difftool:
$ git pr show -t 10485

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10485.diff

fix

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@bridgekeeper
Copy link

bridgekeeper bot commented Sep 29, 2022

👋 Welcome back tr! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 29, 2022
@openjdk
Copy link

openjdk bot commented Sep 29, 2022

@TejeshR13 The following label will be automatically applied to this pull request:

  • client

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.

@openjdk openjdk bot added the client client-libs-dev@openjdk.org label Sep 29, 2022
@mlbridge
Copy link

mlbridge bot commented Sep 29, 2022

@kumarabhi006
Copy link
Contributor

The instruction are not quite clear. Can you please modify it as we discussed over call?

@TejeshR13
Copy link
Contributor Author

The instruction are not quite clear. Can you please modify it as we discussed over call?

Updated.

@TejeshR13
Copy link
Contributor Author

TejeshR13 commented Oct 3, 2022

@kumarabhi006 Can you please review this PR.

@TejeshR13
Copy link
Contributor Author

@azuev-java Can you please review this PR.

Copy link
Member

@aivanov-jdk aivanov-jdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You say that the current directory in JFileChooser gets set to null because of forbidden navigation to a folder which is not traversable. You avoid the NPE by a null-check.

However, you should prevent the current directory to be set to null. If navigation is not allowed, the current directory should remain unchanged instead of being reset to null.

if (!getFileChooser().getCurrentDirectory().equals(f)) {
File curDir = getFileChooser().getCurrentDirectory();

if (curDir != null && !curDir.equals(f)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If f is always not null, you can you use !f.equals(curDir).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevention of not setting to null means I have to modify JFileChooser class itself, so just handling here. And yeahfcan't be null, can do that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it bad to modify JFileChooser class itself?

I think setting the current directory to null while it displays a directory kind of breaks the invariant.

JFileChooser navigated to a directory and the current directory is set to it. You tried navigating to another directory, FileSystem didn't allow the navigation, so JFileChooser continues to display the files in the directory that is showed before. Thus, the current directory hasn't changed. From this point of view, the current directory should remain unchanged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Here the above logic checks if the current selected directory is traversable and if not it goes up to parent directory till top level and when every check fails then null is set to currentDirectory. Should we think of modifying this logic to not to set to null, rather remain in previously valid folder......?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the logic there tries to prevent the current directory from becoming null. Yet it traverses up the tree:

File prev = null;
while (!isTraversable(dir) && prev != dir) {
prev = dir;
dir = getFileSystemView().getParentDirectory(dir);
}

Probably, if dir becomes null in the end, it should resort to its default behaviour: getFileSystemView().getDefaultDirectory(). Or not change at all?

Then, you can handle the situation here: if getFileChooser().getCurrentDirectory() returns null, restore the previous current directory.

And what about other L&F? If the same code runs in Windows L&F, Nimbus L&F, any other?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other L&F the same problem exist, but NPE is does not occurs because previous state check is not done, directly the clicked file is been set.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the logic there tries to prevent the current directory from becoming null. Yet it traverses up the tree:

File prev = null;
while (!isTraversable(dir) && prev != dir) {
prev = dir;
dir = getFileSystemView().getParentDirectory(dir);
}

Probably, if dir becomes null in the end, it should resort to its default behaviour: getFileSystemView().getDefaultDirectory(). Or not change at all?

This behaviour is specified.

* If the file passed in as <code>currentDirectory</code> is not a
* directory, the parent of the file will be used as the currentDirectory.
* If the parent is not traversable, then it will walk up the parent tree
* until it finds a traversable directory, or hits the root of the
* file system.

Yet it doesn't take into account a custom implementation of FileSystem which does not allow navigating up. It may be a problem in FileSystem implementation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other L&F the same problem exist, but NPE is does not occurs because previous state check is not done, directly the clicked file is been set.

Maybe it's the way to go for Metal too? I mean call setCurrentDirectory unconditionally.

What do other L&Fs do?

Copy link
Contributor Author

@TejeshR13 TejeshR13 Oct 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other L&F, null gets assigned to currentDirectory and NPE doesn't occur since that previous directory check is not done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

… NPE doesn't occur since that previous directory check is not done.

Then I suggest going this way and just drop the checks from Metal L&F.

The test should set Metal L&F explicitly. Or better yet, it should be run in all L&Fs to ensure NPE isn't thrown.


As for preserving the current value of currentDirectory if the passed in folder cannot be navigated to. I think it should be done yet it's a separate issue from this one. Shall I submit a new bug? Does anyone have an opinion on this?

Comment on lines 110 to 114
if ((filePath != null) && (filePath.isDirectory())) {
return filePath.getAbsolutePath().startsWith(basePath);
} else {
return false;
}
Copy link
Member

@aivanov-jdk aivanov-jdk Oct 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be simplified to:

Suggested change
if ((filePath != null) && (filePath.isDirectory())) {
return filePath.getAbsolutePath().startsWith(basePath);
} else {
return false;
}
return ((filePath != null) && (filePath.isDirectory())
&& filePath.getAbsolutePath().startsWith(basePath));

I'm not insisting though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be done, no issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

jfc = new JFileChooser();
String path = "";
if (Platform.isWindows()) {
path = "C:" + File.separator + "temp";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's rare but possible that Windows is installed not on C: drive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since temp will be better option without creating any new directory for the test, I didn't change it (it was reused from JBS report). Any other alternative......?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not request the path to the system temporary directory?

Temporary directory on Windows is not located in C:\temp. Likely this folder does not exist. You should use TMP or TEMP environment variable. Alternatively, you can use createTempFile from from java.io.File or java.nio.Files to create a file in the temp directory, its parent is the path to the temp directory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User's home could be a better option. It's guaranteed to exist, user.home system property points to it. And it's a more real-life scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I can just make user.home directory as the only traversable.......?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

* @test
* @bug 6616245
* @key headful
* @requires (os.family == "windows" | os.family == "linux")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason to exclude macOS? Is it only because the default L&F isn't Metal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, was not able to reproduce in macOS.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can set Metal L&F explicitly on macOS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I checked it now and the issue is reproducible in macOS also, have to update the test to include macOS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had thought that default L&F in macOS will be metal, didn't realize have to set it explicitly. My mistake, thank you @aivanov-jdk and @mrserb for pointing it out.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@TejeshR13
Copy link
Contributor Author

@aivanov-jdk I have updated as per the review comments. Please let me know if its fine. I have put up the mach5 test link in JBS for reference.

@kumarabhi006
Copy link
Contributor

@TejeshR13 Verified latest fix on ubuntu and fix is working fine.


//Initialize the components
final String INSTRUCTIONS = """
Instructions to Test:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JFileChooser extends JComponent, probably we can create a frame with embedded JFileChooser and programmatically change the value of that "Look-In ComboBox"-> and catch an exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Means in Test INSTRUCTIONS a link to Look-In can be attached......?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or suggesting to make the test automatic......?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrserb is suggesting making the test automatic. JFileChooser is embedded in a frame in the test. It should be possible… I'm fine with manual test though… for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, since the test has to select non traversable folders in both windows and linux I had thought that making it as manual would be better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably it will be good to automate it, and cover the macOS? I do not see a reason why we cannot set Metal L&F and verify the fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to reproduce the issue in macOS, so didn't include it in test...... And the fix is for metal L&F and should we explicitly set the L&F? Anyhow default L&F is metal right....?

Copy link
Member

@aivanov-jdk aivanov-jdk Oct 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably it will be good to automate it

I've submitted JDK-8295298: Automate javax/swing/JFileChooser/FileViewNPETest.java

… and cover the macOS? I do not see a reason why we cannot set Metal L&F and verify the fix.

Agreed.

I wasn't able to reproduce the issue in macOS, so didn't include it in test...... And the fix is for metal L&F and should we explicitly set the L&F? Anyhow default L&F is metal right....?

The default Look and Feel is Metal except for macOS where the default one is Aqua which is the system L&F. The default L&F can be changed using a property file or setting the system property.

You can always change the L&F in the code.

Copy link
Contributor Author

@TejeshR13 TejeshR13 Oct 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok will check in macOS again then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I had not set Metal L&F while checking in macOS, the is reproducible in macOS also, and the test case has to be updated for macOS.

Comment on lines 80 to 81
jfc = new JFileChooser();
String path = System.getProperty("user.home");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test does not work for me on Windows. It starts with user.home as the current folder as expected; when select C:\, it goes to Desktop which is the root of the Shell namespace.

I guess, you have to change it to System.getProperty("user.home") + File.separator + "Documents" as you and I discussed. It'll make Desktop unreachable.

On Linux, the test works correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

}

class CustomFileView extends FileView {
private String basePath;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private String basePath;
private final String basePath;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Comment on lines 104 to 105
return ((filePath != null) && (filePath.isDirectory())) &&
filePath.getAbsolutePath().startsWith(basePath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return ((filePath != null) && (filePath.isDirectory())) &&
filePath.getAbsolutePath().startsWith(basePath);
return ((filePath != null) && (filePath.isDirectory()))
&& filePath.getAbsolutePath().startsWith(basePath);

I prefer wrapping before the operator, it makes it clear that it's a continuation line. Java Coding Style suggests wrapping this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.


//Initialize the components
final String INSTRUCTIONS = """
Instructions to Test:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yet you control which folders are non-traversable. Anyway… A test is better than no test; an automatic test is better than a manual one.

import javax.swing.WindowConstants;

import javax.swing.filechooser.FileView;
import jdk.test.lib.Platform;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not used any more, please remove.

Leave one blank line after the last import and the following comment with the jtreg tags.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

* @test
* @bug 6616245
* @key headful
* @requires (os.family == "windows" | os.family == "linux")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can set Metal L&F explicitly on macOS.

Comment on lines 41 to 42
* @library /java/awt/regtesthelpers /test/lib
* @build PassFailJFrame jdk.test.lib.Platform
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @library /java/awt/regtesthelpers /test/lib
* @build PassFailJFrame jdk.test.lib.Platform
* @library /java/awt/regtesthelpers
* @build PassFailJFrame

Platform class from /test/lib is not used any more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In mac the issue was not reproducible.....

JFrame frame;
JFileChooser jfc;

//Initialize the components
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the comment is redundant. Being placed before the instruction text, it's confusing. The method name initialize is self-explanatory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Comment on lines 67 to 77
Instructions to Test:
1. The traversable folder set is to "user/home" Directory,
other than these folder all other
folders are considered as non-traversable.
2. When file chooser appears on screen, select any
non-traversable folder from "Look-In" ComboBox by mouse
click/key press. (The folder will not be opened since its
non-traversable). Select the same folder again.
3. If NPE occurs on second selection then test FAILS, else test
is PASS.
""";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose the following text:

                Instructions to Test:
                1. The traversable folder is set to the Documents folder,
                 if it exists, in the user's home folder, otherwise
                 it's the user's home. Other folders are non-traversable.
                2. When the file chooser appears on the screen, select any
                 non-traversable folder from "Look-In" combo box,
                 for example the user's folder or a folder above it.
                 (The folder will not be opened since it's non-traversable).
                3. Select the Documents folder again.
                4. If NullPointerException occurs in the step 3, click Fail,
                 otherwise click Pass.

It consistently uses “folder”, no mention of “directory”. It explains that the user's home could be the root of the traversable tree. The instructions use imperative to select either Fail or Pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4th point has been modified, since user can only select Pass, otherwise the test itself fails.

frame = new JFrame("JFileChooser File View NPE test");
passFailJFrame = new PassFailJFrame("Test Instructions", INSTRUCTIONS, 5L, 13, 40);
jfc = new JFileChooser();
String path = System.getProperty("user.home") + File.separator + "Documents";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String path = System.getProperty("user.home") + File.separator + "Documents";
String userHome = System.getProperty("user.home");
String docs = userHome + File.separator + "Documents";
String path = (new File(docs).exists()) ? docs : userHome;

This will make the test more robust, it can continue to run even if Documents folder does not exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

String path = System.getProperty("user.home") + File.separator + "Documents";

jfc.setCurrentDirectory(new File(path));
jfc.setFileView(new CustomFileView(path));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
jfc.setFileView(new CustomFileView(path));
jfc.setFileView(new CustomFileView(path));
jfc.setControlButtonsAreShown(false);

Hide Open and Cancel buttons in the file chooser.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Copy link
Member

@aivanov-jdk aivanov-jdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now.

Comment on lines 81 to 82
String path = System.getProperty("user.home") + File.separator + "Documents";
String userHome = System.getProperty("user.home");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer a blank line here to logically separate dealing with paths from creating the components. But it's a nit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@openjdk
Copy link

openjdk bot commented Oct 10, 2022

@TejeshR13 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:

6616245: NullPointerException when using JFileChooser with a custom FileView

Reviewed-by: aivanov

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 138 new commits pushed to the master branch:

  • fba763f: 8291519: jdk/jfr/api/event/TestShouldCommit.java failed with Unexpected value of shouldCommit()
  • 6053bf0: 8293782: Shenandoah: some tests failed on lock rank check
  • 4435d56: 8282395: URL.openConnection can throw IOOBE
  • fe70487: 8294958: java/net/httpclient/ConnectTimeout tests are slow
  • 97f1321: 8294356: IGV: scheduled graphs contain duplicated elements
  • 5e05e42: 8294901: remove pre-VS2017 checks in Windows related coding
  • e775acf: 8293986: Incorrect double-checked locking in com.sun.beans.introspect.ClassInfo
  • 9d116ec: 8294262: AArch64: compiler/vectorapi/TestReverseByteTransforms.java test failed on SVE machine
  • 4b17d28: 8294261: AArch64: Use pReg instead of pRegGov when possible
  • 891156a: 8295003: Do not mention applets in the "java.awt.color" package
  • ... and 128 more: https://git.openjdk.org/jdk/compare/ce85cac947158b4e1f554c55f726c923a49b1a41...master

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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@aivanov-jdk) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 10, 2022
Comment on lines 76 to 77
4. If NullPointerException does not occurs in the step 3,
click Pass, otherwise the Test Fails.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
4. If NullPointerException does not occurs in the step 3,
click Pass, otherwise the Test Fails.
4. If NullPointerException does not occur in the step 3,
click Pass, otherwise the test fails automatically.

I guess this is better and has no grammar mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

/*
* @test
* @bug 6616245
* @key headful
Copy link
Contributor

@kumarabhi006 kumarabhi006 Oct 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it required to have a key tag for manual test case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it required to have a key tag for manual test case?

A manual test is declared by its @run tag:

 * @run main/manual FileViewNPETest

If -a (automatic tests) is passed to jtreg, this test isn't selected for running.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the tag.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I admit I misunderstood the question. I thought @kumarabhi006 had asked for adding another keyword to @key to specify a manual test.

I didn't think about removing @key headful. At the same time, a manual test implies being headful to the UI with instructions.

click Pass, otherwise the Test Fails.
""";
frame = new JFrame("JFileChooser File View NPE test");
passFailJFrame = new PassFailJFrame("Test Instructions", INSTRUCTIONS, 5L, 13, 40);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few lines are going beyond 80 columns, can you please update them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few lines are going beyond 80 columns, can you please update them?

I agree, line 80 could be wrapped, it's 92 columns long. At the same, I wouldn't have insisted because it contains the parameters to PassFailJFrame which aren't so important to understanding the logic of the test.

Line 92 with the position is better left untouched, it's not too long (five chars outside of 80-column limit) and it's cleaner unwrapped. You may statically-import PassFailJFrame.Position in which case the line would become shorter:

        PassFailJFrame.positionTestWindow(frame, Position.HORIZONTAL);

I am for keeping line 61 as it is now even though it doesn't fit the limit by 5 characters. It's still readable. In fact, this throws clause could be avoided altogether by restructuring the code. The constructor of PassFailJFrame is designed to be called on the main thread, yet Tejesh prefers it this way. I don't think it's worth moving the code around at this point when it's approved already.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@kumarabhi006
Copy link
Contributor

Verified the latest fix and is working fine.

@@ -36,7 +36,6 @@
/*
* @test
* @bug 6616245
* @key headful
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove headful?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added again, though some manual tests have this tag and some don't better to keep it as an indication that represents as headful test......

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Oct 11, 2022
@TejeshR13
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added ready Pull request is ready to be integrated sponsor Pull request is ready to be sponsored labels Oct 11, 2022
@openjdk
Copy link

openjdk bot commented Oct 11, 2022

@TejeshR13
Your change (at version 5854ef2) is now ready to be sponsored by a Committer.

@aivanov-jdk
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Oct 11, 2022

Going to push as commit 33d0618.
Since your change was applied there have been 138 commits pushed to the master branch:

  • fba763f: 8291519: jdk/jfr/api/event/TestShouldCommit.java failed with Unexpected value of shouldCommit()
  • 6053bf0: 8293782: Shenandoah: some tests failed on lock rank check
  • 4435d56: 8282395: URL.openConnection can throw IOOBE
  • fe70487: 8294958: java/net/httpclient/ConnectTimeout tests are slow
  • 97f1321: 8294356: IGV: scheduled graphs contain duplicated elements
  • 5e05e42: 8294901: remove pre-VS2017 checks in Windows related coding
  • e775acf: 8293986: Incorrect double-checked locking in com.sun.beans.introspect.ClassInfo
  • 9d116ec: 8294262: AArch64: compiler/vectorapi/TestReverseByteTransforms.java test failed on SVE machine
  • 4b17d28: 8294261: AArch64: Use pReg instead of pRegGov when possible
  • 891156a: 8295003: Do not mention applets in the "java.awt.color" package
  • ... and 128 more: https://git.openjdk.org/jdk/compare/ce85cac947158b4e1f554c55f726c923a49b1a41...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Oct 11, 2022
@openjdk openjdk bot closed this Oct 11, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Oct 11, 2022
@openjdk
Copy link

openjdk bot commented Oct 11, 2022

@aivanov-jdk @TejeshR13 Pushed as commit 33d0618.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

None yet

4 participants