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

8284672: Collapse identical catch branches in java.desktop #8154

Closed

Conversation

turbanoff
Copy link
Member

@turbanoff turbanoff commented Apr 8, 2022

Let's take advantage of Java 7 language feature - "Catching Multiple Exception Types".
It simplifies code. Reduces duplication.
Found by IntelliJ IDEA inspection Identical 'catch' branches in 'try' statement


Progress

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

Issue

  • JDK-8284672: Collapse identical catch branches in java.desktop

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 8154

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 8, 2022

👋 Welcome back aturbanov! 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
Copy link

openjdk bot commented Apr 8, 2022

@turbanoff 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 Apr 8, 2022
@turbanoff turbanoff changed the title [PATCH] Collapse identical catch branches in java.desktop 8284672: Collapse identical catch branches in java.desktop Apr 11, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 11, 2022
@mlbridge
Copy link

mlbridge bot commented Apr 11, 2022

Webrevs

} catch (RIFFInvalidFormatException e) {
return null;
} catch(IOException ioe) {
} catch (IOException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. I think it makes sense to amend behavior here and not catch IOException. Callers should be ready for it.

Copy link
Member

Choose a reason for hiding this comment

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

This getSoundbank method is called when we iterate over providers and check which can be used, unfortunately, that code is not ready for the IOException and we return "null" -> the next provider will be checked. This is a kind of compatibility quirk.

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't IOException mean the next provider is to be checked?

That is the IOException could be handled in the iterator, its code may need to be updated for that. Then the implementations of getSoundbank(URL) could propagate the IOException too and eliminate duplicate code.

InvalidMidiDataException isn't caught there, so the iterator code should handle it.

Copy link
Member

Choose a reason for hiding this comment

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

It is implemented in a way that if the bundled provider will fail we will try some next provider, but if the user add custom provider then getSoundbank(URL) will throw IOException signalling that something went wrong.

I think InvalidMidiDataException should not be caught since that exception means the sound bank provider started to read the file, recognized that the file is supported, but then found the broken midi data.

@openjdk
Copy link

openjdk bot commented Apr 27, 2022

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

8284672: Collapse identical catch branches in java.desktop

Reviewed-by: prr, aivanov, serb

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

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 Apr 27, 2022
@prrace
Copy link
Contributor

prrace commented Apr 27, 2022

/reviewers 2

@openjdk
Copy link

openjdk bot commented Apr 27, 2022

@prrace
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with 1 of role reviewers, 1 of role authors).

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Apr 27, 2022
@bridgekeeper
Copy link

bridgekeeper bot commented May 25, 2022

@turbanoff This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@@ -118,11 +118,7 @@ class Metacity implements SynthConstants {
try {
INSTANCE = new Metacity(themeName);
} catch (FileNotFoundException ex) {
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 possible that the FileNotFoundException was ignored intentionally? After this change, it will be traced.

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't change how FileNotFoundException is handled. It's still ignored.

Copy link
Member

Choose a reason for hiding this comment

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

For some reason I thought it was merged to the IOException.

} catch (RIFFInvalidFormatException e) {
return null;
} catch(IOException ioe) {
} catch (IOException e) {
Copy link
Member

Choose a reason for hiding this comment

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

This getSoundbank method is called when we iterate over providers and check which can be used, unfortunately, that code is not ready for the IOException and we return "null" -> the next provider will be checked. This is a kind of compatibility quirk.

} catch (RIFFInvalidFormatException e) {
return null;
} catch(IOException ioe) {
} catch (IOException e) {
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't IOException mean the next provider is to be checked?

That is the IOException could be handled in the iterator, its code may need to be updated for that. Then the implementations of getSoundbank(URL) could propagate the IOException too and eliminate duplicate code.

InvalidMidiDataException isn't caught there, so the iterator code should handle it.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 17, 2022
@@ -118,11 +118,7 @@ class Metacity implements SynthConstants {
try {
INSTANCE = new Metacity(themeName);
} catch (FileNotFoundException ex) {
Copy link
Member

Choose a reason for hiding this comment

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

For some reason I thought it was merged to the IOException.

} catch (RIFFInvalidFormatException e) {
return null;
} catch(IOException ioe) {
} catch (IOException e) {
Copy link
Member

Choose a reason for hiding this comment

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

It is implemented in a way that if the bundled provider will fail we will try some next provider, but if the user add custom provider then getSoundbank(URL) will throw IOException signalling that something went wrong.

I think InvalidMidiDataException should not be caught since that exception means the sound bank provider started to read the file, recognized that the file is supported, but then found the broken midi data.

@turbanoff
Copy link
Member Author

Thank you for review!
/integrate

@openjdk
Copy link

openjdk bot commented Jun 20, 2022

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

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jun 20, 2022

@turbanoff Pushed as commit 695d865.

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

@turbanoff turbanoff deleted the identical_catch_java.desktop branch October 27, 2022 18:40
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
4 participants