From f9799a61d559290c1ba6f6de557535348480caa0 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Tue, 19 Jun 2018 23:20:22 +0200 Subject: [PATCH] chg: ignore NoSuchFileException for Pwned Passwords MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If we can’t open the Pwned Passwords database because the file does not exist, there’s no need to print a detailed stack trace: the warning message should be enough to gently inform the system administrator that they can improve their security by installing the database. Any other errors (e. g. permission errors) are still reported. This is mainly motivated by the dozens of NoSuchFileException stack traces in CI builds, which this commit should silence. Change-Id: Id08afc1600a70acfc49b2c4335b533949413b09a --- src/club/wpia/gigi/Gigi.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/club/wpia/gigi/Gigi.java b/src/club/wpia/gigi/Gigi.java index 660c3d30..36e8c8cc 100644 --- a/src/club/wpia/gigi/Gigi.java +++ b/src/club/wpia/gigi/Gigi.java @@ -6,6 +6,7 @@ import java.io.UnsupportedEncodingException; import java.math.BigInteger; import java.nio.channels.FileChannel; import java.nio.file.FileSystems; +import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.security.KeyStore; import java.security.MessageDigest; @@ -319,7 +320,9 @@ public final class Gigi extends HttpServlet { throw new RuntimeException("Error while opening password hash database, refusing startup", e); } else { System.err.println("Error while opening password hash database, passwords will be checked only by strength"); - e.printStackTrace(); + if (!(e instanceof NoSuchFileException)) { + e.printStackTrace(); + } return new PasswordStrengthChecker(); } } -- 2.39.2