]> WPIA git - gigi.git/commitdiff
chg: Avoid dirtying the environment with Thread Interruption exceptions if nobody...
authorBenny Baumann <BenBE1987@gmx.net>
Sun, 31 Jul 2016 12:17:14 +0000 (14:17 +0200)
committerBenny Baumann <BenBE1987@gmx.net>
Sun, 31 Jul 2016 15:03:14 +0000 (17:03 +0200)
Change-Id: I8fd3ced25e058c24752776702425888576397c92

src/org/cacert/gigi/api/CreateCertificate.java
src/org/cacert/gigi/api/RevokeCertificate.java
src/org/cacert/gigi/dbObjects/Job.java
src/org/cacert/gigi/pages/account/certs/CertificateIssueForm.java
src/org/cacert/gigi/pages/account/certs/CertificateModificationForm.java
util-testing/org/cacert/gigi/pages/Manager.java

index 0d5a27e05c76da1673f5da7d193347c0a177c14e..1c589379a31a20909d17cb84afd73e88da6b4f2e 100644 (file)
@@ -79,8 +79,6 @@ public class CreateCertificate extends APIPoint {
             resp.setStatus(500);
             PrintWriter wr = resp.getWriter();
             e.formatPlain(wr);
             resp.setStatus(500);
             PrintWriter wr = resp.getWriter();
             e.formatPlain(wr);
-        } catch (InterruptedException e) {
-            resp.sendError(500, "Interrupted");
         }
     }
 }
         }
     }
 }
index 404d73ce82afbcb1da3ecb7e7babeb5c9eb57109..2f15511afe69af95179e9678b6a6f231b15918b9 100644 (file)
@@ -21,31 +21,32 @@ public class RevokeCertificate extends APIPoint {
             resp.sendError(500, "Error, POST required.");
             return;
         }
             resp.sendError(500, "Error, POST required.");
             return;
         }
+
         if (req.getQueryString() != null) {
             resp.sendError(500, "Error, no query String allowed.");
             return;
         }
         if (req.getQueryString() != null) {
             resp.sendError(500, "Error, no query String allowed.");
             return;
         }
+
         String tserial = req.getParameter("serial");
         if (tserial == null) {
             resp.sendError(500, "Error, no Serial found");
             return;
         }
         String tserial = req.getParameter("serial");
         if (tserial == null) {
             resp.sendError(500, "Error, no Serial found");
             return;
         }
-        try {
-            Certificate c = Certificate.getBySerial(tserial);
-            if (c == null || c.getOwner() != u) {
-                resp.sendError(403, "Access Denied");
-                return;
-            }
-            Job job = c.revoke();
-            job.waitFor(60000);
-            if (c.getStatus() != CertificateStatus.REVOKED) {
-                resp.sendError(510, "Error, issuing timed out");
-                return;
-            }
-            resp.getWriter().println("OK");
+
+        Certificate c = Certificate.getBySerial(tserial);
+        if (c == null || c.getOwner() != u) {
+            resp.sendError(403, "Access Denied");
+            return;
+        }
+
+        Job job = c.revoke();
+        job.waitFor(60000);
+        if (c.getStatus() != CertificateStatus.REVOKED) {
+            resp.sendError(510, "Error, issuing timed out");
             return;
             return;
-        } catch (InterruptedException e) {
-            e.printStackTrace();
         }
         }
+
+        resp.getWriter().println("OK");
+
     }
 }
     }
 }
index bb357a8d07b742fddda040031abf4a8ca0dd8d83..a48e44ac667cf5d9ec78d0083568e970c6d7d637 100644 (file)
@@ -51,7 +51,7 @@ public class Job implements IdCachable {
         }
     }
 
         }
     }
 
-    public synchronized boolean waitFor(int max) throws InterruptedException {
+    public synchronized boolean waitFor(int max) {
         long start = System.currentTimeMillis();
         try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT 1 FROM `jobs` WHERE id=? AND state='open'")) {
             ps.setInt(1, id);
         long start = System.currentTimeMillis();
         try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT 1 FROM `jobs` WHERE id=? AND state='open'")) {
             ps.setInt(1, id);
@@ -61,7 +61,12 @@ public class Job implements IdCachable {
                 if (max != 0 && System.currentTimeMillis() - start > max) {
                     return false;
                 }
                 if (max != 0 && System.currentTimeMillis() - start > max) {
                     return false;
                 }
-                Thread.sleep((long) (2000 + Math.random() * 2000));
+                try {
+                    this.wait((long) (2000 + Math.random() * 2000));
+                } catch (InterruptedException ie) {
+                    // Ignore the interruption
+                    ie.printStackTrace();
+                }
                 rs = ps.executeQuery();
             }
         }
                 rs = ps.executeQuery();
             }
         }
index c32fc716f050f3972edd59df68a882d446d140f0..eecb31fe786a5e7373ee7445462af5e5446661c2 100644 (file)
@@ -104,8 +104,6 @@ public class CertificateIssueForm extends Form {
             } catch (GeneralSecurityException e) {
                 e.printStackTrace();
                 throw new GigiApiException("Certificate Request format is invalid.");
             } catch (GeneralSecurityException e) {
                 e.printStackTrace();
                 throw new GigiApiException("Certificate Request format is invalid.");
-            } catch (InterruptedException e) {
-                e.printStackTrace();
             }
         } catch (GigiApiException e) {
             e.format(out, Page.getLanguage(req));
             }
         } catch (GigiApiException e) {
             e.format(out, Page.getLanguage(req));
index 6553a77323fc805e6af8c8ac92e5eb31be01f3cd..a58f3a6c961e4e5ac7067a17c5c6f855a14f5ed3 100644 (file)
@@ -48,15 +48,11 @@ public class CertificateModificationForm extends Form {
         }
         long start = System.currentTimeMillis();
         for (Job job : revokes) {
         }
         long start = System.currentTimeMillis();
         for (Job job : revokes) {
-            try {
-                int toWait = (int) (60000 + start - System.currentTimeMillis());
-                if (toWait > 0) {
-                    job.waitFor(toWait);
-                } else {
-                    break; // canceled... waited too log
-                }
-            } catch (InterruptedException e) {
-                e.printStackTrace();
+            int toWait = (int) (60000 + start - System.currentTimeMillis());
+            if (toWait > 0) {
+                job.waitFor(toWait);
+            } else {
+                break; // canceled... waited too log
             }
         }
 
             }
         }
 
index 21b7e43218d907342d22480b52cd6332809fd7a8..f6de409b0c64eb65cb4c4fb2863701a29f4babd4 100644 (file)
@@ -352,9 +352,6 @@ public class Manager extends Page {
                 resp.getWriter().println("error");
             } catch (GigiApiException e) {
                 e.format(resp.getWriter(), Language.getInstance(Locale.ENGLISH));
                 resp.getWriter().println("error");
             } catch (GigiApiException e) {
                 e.format(resp.getWriter(), Language.getInstance(Locale.ENGLISH));
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-                resp.getWriter().println("interrupted");
             }
 
         } else if (req.getParameter("addExDom") != null) {
             }
 
         } else if (req.getParameter("addExDom") != null) {