Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,8 @@ public static void storeLaunchElements(ILaunchConfigurationWorkingCopy configura
public static void removeLaunchElements(ILaunchConfigurationWorkingCopy configuration) {
try {
for (String attr : configuration.getAttributes().keySet()) {
try {
if (attr.startsWith(MULTI_LAUNCH_CONSTANTS_PREFIX)) {
configuration.removeAttribute(attr);
}
} catch (Exception e) {
DebugPlugin.log(e);
if (attr.startsWith(MULTI_LAUNCH_CONSTANTS_PREFIX)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What kind of exception might happen? Do you really want the whole loop to terminate if there is an exception?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since neither startsWith() nor removeAttribute() declares any exceptions, I initially thought the inner try/catch could be removed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It all looks a little overly cautious given that nothing declares any thrown exceptions. It looks like it's always been there so there's no real accounting for why either of those try blocks are there, neither the inner nor the outer. Maybe it happened during some initial implementation and was then never cleaned up. I'm not sure what to say about that. 😞

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I checked other references of removeAttribute(), and they don't have a similar try/catch. Since neither API declares any exceptions, the inner try/catch may just be leftover from an older implementation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do other places have the outer try block? It all looks a bit bogus...

Copy link
Copy Markdown
Contributor Author

@SougandhS SougandhS Jun 8, 2026

Choose a reason for hiding this comment

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

Only place I found a try block is in org.eclipse.jdt.debug.ui.launchConfigurations.JavaDependenciesTab.performApply(ILaunchConfigurationWorkingCopy) but that is only for catching CoreException (which is for org.eclipse.debug.core.ILaunchConfiguration.getAttribute(String, boolean) )
image

everywhere else is try-catch free..

configuration.removeAttribute(attr);
}
}
} catch (CoreException e) {
Expand Down
Loading