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

8320692: Null icon returned for .exe without custom icon #17475

Closed
wants to merge 3 commits into from

Conversation

azuev-java
Copy link
Member

@azuev-java azuev-java commented Jan 18, 2024

Replaced asserts with NullPointerException calls because outside of testing that would be more informative - i do not think many people running their applications with assertions in system libraries enabled;
Added a code that will analyze the result of the getIcon and will fall back to the default icon for the file type retrieved from the ShellFolder;
Added a test case made by Aleksei Ivanov.


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-8320692: Null icon returned for .exe without custom icon (Bug - P4)

Reviewers

Contributors

  • Alexey Ivanov <aivanov@openjdk.org>

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 17475

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

Using diff file

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

Webrev

Link to Webrev Comment

Replaced asserts with NullPointerException calls because outside of
testing that would be more informative - i do not think
many people running their applications with assertions in system
libraries enabled;
Added a code that will analyze the result of the getIcon and
will fall back to the default icon for the file type retrieved from the
ShellFolder;
Added a test case made by Aleksei Ivanov.
@bridgekeeper
Copy link

bridgekeeper bot commented Jan 18, 2024

👋 Welcome back kizune! 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 Jan 18, 2024
@azuev-java
Copy link
Member Author

/label client

@openjdk
Copy link

openjdk bot commented Jan 18, 2024

@azuev-java 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 Jan 18, 2024
@openjdk
Copy link

openjdk bot commented Jan 18, 2024

@azuev-java The client label was already applied.

@mlbridge
Copy link

mlbridge bot commented Jan 18, 2024

Webrevs

Comment on lines 1204 to 1208
if (multiResolutionIcon.containsValue(null)) {
return null;
} else {
return new MultiResolutionIconImage(size, multiResolutionIcon);
}
Copy link
Member

Choose a reason for hiding this comment

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

Can we return null immediately if an icon that we're about to put into multiResolutionIcon is null?

That is change the line 1198(1195)

to

    if (newIcon == null) {
        return null;
    }
    multiResolutionIcon.put(s, newIcon);

I assume if newIcon == null then hIcon is also null, in which case we can move this condition to the line 1195(1192)

before calling makeIcon.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, i will move it to the line 1198 because i can not guarantee that we do not need to dispose hIcon if we can not make icon out of it so i would rather avoid potential resource leak.

Copy link
Member

Choose a reason for hiding this comment

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

We need to dispose of hIcon if it's non-null. I see that in this case hIcon is not null yet makeIcon fails to get the bitmap for whatever reason.

It would be good to understand why makeIcon fails even though hIcon is not null.

It is possible that makeIcon fails to extract an icon, so the added null-check ensures null is returned instead of returning a broken MRI.

Comment on lines 1414 to 1423
assert !resolutionVariants.containsValue(null)
: "There are null icons in the MRI variants map";
if (resolutionVariants.containsValue(null)) {
throw new NullPointerException("There are null icons in the MRI variants map");
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm unsure about this. The idea with assert was to provide a debugging aid without affecting regular runtime. We control all the paths that call this constructor and, therefore, we should ensure it's never called if resolutionVariants contains null.

It's exactly what you've done in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, i will revert that part.

@azuev-java
Copy link
Member Author

/contributor add @aivanov-jdk

@openjdk
Copy link

openjdk bot commented Jan 18, 2024

@azuev-java
Contributor Alexey Ivanov <aivanov@openjdk.org> successfully added.

Move null check inside the loop so we do not retrieve extra
icons if we encounter a null one
Comment on lines 1415 to 1421
: "There are null icons in the MRI variants map";
: "There are null icons in the MRI variants map";
Copy link
Member

Choose a reason for hiding this comment

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

Here's an extra space. The colon aligned with ! which starts the condition.

Could you please revert it too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure.

@openjdk
Copy link

openjdk bot commented Jan 19, 2024

@azuev-java 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:

8320692: Null icon returned for .exe without custom icon

Co-authored-by: Alexey Ivanov <aivanov@openjdk.org>
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 118 new commits pushed to the master branch:

  • 5acd37f: 8324207: Serial: Remove Space::set_saved_mark_word
  • f5e6d11: 8324210: Serial: Remove unused methods in Generation
  • bcb340d: 8324286: Fix backsliding on use of nullptr instead of NULL
  • 3696765: 8323964: runtime/Thread/ThreadCountLimit.java fails intermittently on AIX
  • 5a74c2a: 8323438: Enhance assertions for Windows sync API failures
  • 52523d3: 8324050: Issue store-store barrier after re-materializing objects during deoptimization
  • df370d7: 8314329: AgeTable: add is_clear() & allocation spec, and relax assert to allow use of 0-index slot
  • 0d8543d: 8324065: Daylight saving information for Africa/Casablanca are incorrect
  • c9cacfb: 8323657: Compilation of snippet results in VerifyError at runtime with --release 9 (and above)
  • bde650f: 8322282: Incorrect LoaderConstraintTable::add_entry after JDK-8298468
  • ... and 108 more: https://git.openjdk.org/jdk/compare/84cf4cb350331aac147fdf4c6d130cdf5448c987...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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 19, 2024

FileSystemView fsv = FileSystemView.getFileSystemView();
// No NullPointerException is expected
fsv.getSystemIcon(hello.toFile());
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should check that something useful is returned? at least non-null VS null value?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should check that something useful is returned? at least non-null VS null value?

Makes sense to ensure the returned value is not null.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure.

Test now checks for returned icon not to be null
@azuev-java
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Jan 24, 2024

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

  • 32eb529: 8324553: Shenandoah: Move periodic tasks closer to their collaborators
  • c702dca: 8323815: Source launcher should find classes with $ in names
  • c432dc0: 8322149: ConcurrentHashMap smarter presizing for copy constructor and putAll
  • fb822e4: 8324514: ClassLoaderData::print_on should print address of class loader
  • 00bb6bf: 8324220: jdk/jfr/event/io/TestSerializationMisdeclarationEvent.java had 22 failures
  • bccd823: 8324613: Serial: Rename GenerationPool to TenuredGenerationPool
  • 8c003d8: 8321512: runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java fails on 32-bit platforms
  • 67f29b1: 8324537: Remove superfluous _FILE_OFFSET_BITS=64
  • 1c1cb04: 8324512: Serial: Remove Generation::Name
  • b65e5eb: 8324543: Remove Space::object_iterate
  • ... and 128 more: https://git.openjdk.org/jdk/compare/84cf4cb350331aac147fdf4c6d130cdf5448c987...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 24, 2024
@openjdk openjdk bot closed this Jan 24, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 24, 2024
@openjdk
Copy link

openjdk bot commented Jan 24, 2024

@azuev-java Pushed as commit 6212264.

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

@azuev-java azuev-java deleted the JDK-8320692 branch March 14, 2024 12:21
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.

3 participants