-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8284672: Collapse identical catch branches in java.desktop #8154
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
Conversation
|
👋 Welcome back aturbanov! A progress list of the required criteria for merging this PR into |
|
@turbanoff 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
|
src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java
Show resolved
Hide resolved
src/java.desktop/share/classes/com/sun/media/sound/DLSSoundbankReader.java
Show resolved
Hide resolved
| } catch (RIFFInvalidFormatException e) { | ||
| return null; | ||
| } catch(IOException ioe) { | ||
| } catch (IOException e) { |
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.
same here
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. I think it makes sense to amend behavior here and not catch IOException. Callers should be ready for it.
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 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.
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.
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.
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 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 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 1011 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 |
|
/reviewers 2 |
|
@prrace |
|
@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! |
| if (themeName != null) { | ||
| try { | ||
| INSTANCE = new Metacity(themeName); | ||
| } catch (FileNotFoundException ex) { |
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 possible that the FileNotFoundException was ignored intentionally? After this change, it will be traced.
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 didn't change how FileNotFoundException is handled. It's still ignored.
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 reason I thought it was merged to the IOException.
| } catch (RIFFInvalidFormatException e) { | ||
| return null; | ||
| } catch(IOException ioe) { | ||
| } catch (IOException e) { |
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 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) { |
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.
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.
src/java.desktop/share/classes/javax/swing/text/InternationalFormatter.java
Outdated
Show resolved
Hide resolved
src/java.desktop/share/classes/javax/swing/text/InternationalFormatter.java
Outdated
Show resolved
Hide resolved
move '}' to new line
| if (themeName != null) { | ||
| try { | ||
| INSTANCE = new Metacity(themeName); | ||
| } catch (FileNotFoundException ex) { |
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 reason I thought it was merged to the IOException.
| } catch (RIFFInvalidFormatException e) { | ||
| return null; | ||
| } catch(IOException ioe) { | ||
| } catch (IOException e) { |
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 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.
|
Thank you for review! |
|
Going to push as commit 695d865.
Your commit was automatically rebased without conflicts. |
|
@turbanoff Pushed as commit 695d865. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
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
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/8154/head:pull/8154$ git checkout pull/8154Update a local copy of the PR:
$ git checkout pull/8154$ git pull https://git.openjdk.org/jdk pull/8154/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 8154View PR using the GUI difftool:
$ git pr show -t 8154Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/8154.diff