Skip to content

Commit 8edea57

Browse files
Copilotcarstenartur
andcommitted
Fix empty catch blocks - add explanatory comments
Co-authored-by: carstenartur <3164220+carstenartur@users.noreply.github.com>
1 parent bd94934 commit 8edea57

4 files changed

Lines changed: 39 additions & 12 deletions

File tree

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/heapwalking/JavaWatchExpressionFilter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ public boolean canCreateWatchExpression(IVariable variable) {
4646
if (variable.getValue() instanceof JDIPlaceholderValue){
4747
return false;
4848
}
49-
} catch (DebugException e) {}
49+
} catch (DebugException e) {
50+
// ignore - unable to get variable value
51+
}
5052
return true;
5153
}
5254

org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/JavaLaunchableTester.java

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,12 @@ private boolean hasMain(IJavaElement element) {
181181
}
182182
}
183183
}
184-
catch (JavaModelException e) {}
185-
catch (CoreException ce){}
184+
catch (JavaModelException e) {
185+
// ignore - element may not be accessible
186+
}
187+
catch (CoreException ce){
188+
// ignore - element may not be accessible
189+
}
186190
return false;
187191
}
188192

@@ -278,7 +282,9 @@ private boolean hasMethod(IJavaElement element, Object[] args) {
278282
}
279283
}
280284
}
281-
catch (JavaModelException e) {}
285+
catch (JavaModelException e) {
286+
// ignore - method may not exist
287+
}
282288
return false;
283289
}
284290

@@ -322,8 +328,12 @@ private boolean hasTypeWithAnnotation(IJavaElement element, String annotationTyp
322328
}
323329
}
324330
}
325-
catch (JavaModelException e) {}
326-
catch (InvalidInputException e) {}
331+
catch (JavaModelException e) {
332+
// ignore - type may not have annotation
333+
}
334+
catch (InvalidInputException e) {
335+
// ignore - scanner may fail on invalid input
336+
}
327337
return false;
328338
}
329339

@@ -400,7 +410,9 @@ private boolean hasMethodWithAnnotation(IJavaElement element, Object[] args) {
400410
}
401411
}
402412
} catch (JavaModelException e) {
413+
// ignore - method may not have annotation
403414
} catch (InvalidInputException e) {
415+
// ignore - scanner may fail on invalid input
404416
}
405417
return false;
406418
}
@@ -456,7 +468,10 @@ private boolean hasProjectNature(IJavaElement element, String ntype) {
456468
}
457469
return false;
458470
}
459-
catch (CoreException e) {return false;}
471+
catch (CoreException e) {
472+
// ignore - element may not have the specified nature
473+
return false;
474+
}
460475
}
461476

462477
/**
@@ -477,7 +492,9 @@ private boolean hasSuperclass(IJavaElement element, String qname) {
477492
}
478493
}
479494
}
480-
catch(JavaModelException e) {}
495+
catch(JavaModelException e) {
496+
// ignore - type may not have superclass hierarchy
497+
}
481498
return false;
482499
}
483500

@@ -534,7 +551,9 @@ private boolean hasItemsOnBuildPath(IJavaProject project, Set<IJavaProject> sear
534551
return true;
535552
}
536553
}
537-
} catch (JavaModelException e) {}
554+
} catch (JavaModelException e) {
555+
// ignore - classpath may not be accessible
556+
}
538557
return false;
539558
}
540559

@@ -556,7 +575,9 @@ private boolean implementsInterface(IJavaElement element, String qname) {
556575
}
557576
}
558577
}
559-
catch(JavaModelException e) {}
578+
catch(JavaModelException e) {
579+
// ignore - type may not have interface hierarchy
580+
}
560581
return false;
561582
}
562583

org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingPlugin.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ public void vmChanged(org.eclipse.jdt.launching.PropertyChangeEvent event) {
272272
}
273273
}
274274
}
275-
} catch (CoreException e) {}
275+
} catch (CoreException e) {
276+
// ignore - unable to update launch configuration
277+
}
276278
}
277279
}
278280
}

org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/SocketListenConnectorProcess.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ public void done(IJobChangeEvent event) {
133133
} else {
134134
try{
135135
terminate();
136-
} catch (DebugException e){}
136+
} catch (DebugException e){
137+
// ignore - unable to terminate connection
138+
}
137139
}
138140
}
139141
});

0 commit comments

Comments
 (0)