Fix Checkstyle warnings about empty catch blocks

Most of them are empty because the exceptions are ignored.  In these
cases add an "Ignored" comment to prevent the warning.

In the other couple of cases the problem might be worth investigation
by an admin, so add a warning log.

Change-Id: I415fa042f5205cb0745ef7286fba5f5910f1dedd
This commit is contained in:
David Pursehouse
2015-08-25 18:04:25 +09:00
parent 717b98fe46
commit f73fccea80
20 changed files with 26 additions and 1 deletions

View File

@@ -81,6 +81,7 @@ public class UserAgent {
try {
return Integer.parseInt(p);
} catch (NumberFormatException nan) {
// Ignored
}
}
return -1;

View File

@@ -89,6 +89,7 @@ public class NpIntTextBox extends NpTextBox {
try {
intValue = Integer.parseInt(getText());
} catch (NumberFormatException e) {
// Ignored
}
}
return intValue;

View File

@@ -52,6 +52,7 @@ public class Gsql extends SiteProgram {
try {
System.in.close();
} catch (IOException e) {
// Ignored
}
manager.stop();
}

View File

@@ -170,6 +170,7 @@ public class Init extends BaseInit {
try {
proc.getOutputStream().close();
} catch (IOException e) {
// Ignored
}
IoUtil.copyWithThread(proc.getInputStream(), System.err);

View File

@@ -75,6 +75,7 @@ public class Browser {
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
// Ignored
}
continue;
}

View File

@@ -154,6 +154,7 @@ public class CreateAccount implements RestModifyView<TopLevelResource, Input> {
try {
db.accountExternalIds().delete(Collections.singleton(extUser));
} catch (OrmException cleanupError) {
// Ignored
}
throw new UnprocessableEntityException(
"email '" + input.email + "' already exists");

View File

@@ -263,6 +263,7 @@ import javax.security.auth.login.LoginException;
recursivelyExpandGroups(groupDNs, schema, ctx, nextDN);
}
} catch (PartialResultException e) {
// Ignored
}
}
}
@@ -298,6 +299,7 @@ import javax.security.auth.login.LoginException;
dns.add((String) groups.next());
}
} catch (PartialResultException e) {
// Ignored
}
}
} catch (NamingException e) {

View File

@@ -75,6 +75,7 @@ class LdapQuery {
r.add(new Result(res.next()));
}
} catch (PartialResultException e) {
// Ignored
}
return r;
} finally {

View File

@@ -187,6 +187,7 @@ public class GetSummary implements RestReadView<ConfigResource> {
try {
jvmSummary.host = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
// Ignored
}
jvmSummary.currentWorkingDirectory =

View File

@@ -367,6 +367,7 @@ public class EventFactory {
patchSetAttribute.files.add(p);
}
} catch (PatchListNotAvailableException e) {
log.warn("Cannot get patch list", e);
}
}

View File

@@ -109,11 +109,11 @@ public abstract class ChangeEmail extends NotificationEmail {
for (Account.Id who : changeData.reviewers().values()) {
names.add(getNameEmailFor(who));
}
for (String name : names) {
appendText("Gerrit-Reviewer: " + name + "\n");
}
} catch (OrmException e) {
log.warn("Cannot get change reviewers", e);
}
formatFooter();
}

View File

@@ -278,6 +278,7 @@ public class SmtpEmailSender implements EmailSender {
try {
client.disconnect();
} catch (IOException e2) {
//Ignored
}
}
throw new EmailException(e.getMessage(), e);
@@ -286,6 +287,7 @@ public class SmtpEmailSender implements EmailSender {
try {
client.disconnect();
} catch (IOException e2) {
// Ignored
}
}
throw e;

View File

@@ -45,6 +45,7 @@ class PluginCleanerTask implements Runnable {
Thread.sleep(50);
}
} catch (InterruptedException e) {
// Ignored
}
int left = loader.processPendingCleanups();

View File

@@ -37,6 +37,7 @@ class PluginScannerThread extends Thread {
return;
}
} catch (InterruptedException e) {
// Ignored
}
loader.rescan();
}
@@ -47,6 +48,7 @@ class PluginScannerThread extends Thread {
try {
join();
} catch (InterruptedException e) {
// Ignored
}
}
}

View File

@@ -65,6 +65,7 @@ class IsVisibleToPredicate extends OperatorPredicate<ChangeData> {
return true;
}
} catch (NoSuchChangeException e) {
// Ignored
}
return false;
}

View File

@@ -356,6 +356,7 @@ public abstract class BaseCommand implements Command {
err.write((f.getMessage() + "\n").getBytes(ENC));
err.flush();
} catch (IOException e2) {
// Ignored
} catch (Throwable e2) {
log.warn("Cannot send failure message to client", e2);
}
@@ -366,6 +367,7 @@ public abstract class BaseCommand implements Command {
err.write("fatal: internal server error\n".getBytes(ENC));
err.flush();
} catch (IOException e2) {
// Ignored
} catch (Throwable e2) {
log.warn("Cannot send internal server error message to client", e2);
}
@@ -450,10 +452,12 @@ public abstract class BaseCommand implements Command {
try {
out.flush();
} catch (Throwable e2) {
// Ignored
}
try {
err.flush();
} catch (Throwable e2) {
// Ignored
}
rc = handleError(e);
} finally {

View File

@@ -187,6 +187,7 @@ class NoShell implements Factory<Command> {
try {
return new URL(url).getHost();
} catch (MalformedURLException e) {
// Ignored
}
}
return SystemReader.getInstance().getHostname();

View File

@@ -107,6 +107,7 @@ final class PluginInstallCommand extends SshCommand {
try {
data.close();
} catch (IOException err) {
// Ignored
}
}
}

View File

@@ -361,6 +361,7 @@ public class ReviewCommand extends SshCommand {
try {
err.write(msg.getBytes(ENC));
} catch (IOException e) {
// Ignored
}
}

View File

@@ -270,6 +270,7 @@ public class SetReviewersCommand extends SshCommand {
try {
err.write((type + ": " + msg + "\n").getBytes(ENC));
} catch (IOException e) {
// Ignored
}
}