From b2af320231c7298d9cfaa48ec74574252675eab6 Mon Sep 17 00:00:00 2001 From: Una Thompson Date: Tue, 23 Jun 2020 12:41:42 -0700 Subject: [PATCH] Remove no-longer-needed BlobAccess hack, print SQL exceptions, 4s 202 --- .../jortage/poolmgr/MastodonHackHandler.java | 2 +- src/main/java/com/jortage/poolmgr/Queries.java | 17 +++++++++++++++++ .../java/com/jortage/poolmgr/RedirHandler.java | 5 ----- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/jortage/poolmgr/MastodonHackHandler.java b/src/main/java/com/jortage/poolmgr/MastodonHackHandler.java index e0a65bb..517d449 100644 --- a/src/main/java/com/jortage/poolmgr/MastodonHackHandler.java +++ b/src/main/java/com/jortage/poolmgr/MastodonHackHandler.java @@ -42,7 +42,7 @@ public class MastodonHackHandler extends HandlerWrapper { response.sendError(202); } catch (IOException e) { } - }, 500, TimeUnit.MILLISECONDS); + }, 4000, TimeUnit.MILLISECONDS); } super.handle(target, baseRequest, request, response); if (shortCircuit != null) shortCircuit.cancel(false); diff --git a/src/main/java/com/jortage/poolmgr/Queries.java b/src/main/java/com/jortage/poolmgr/Queries.java index 6f8f431..d9d2a91 100644 --- a/src/main/java/com/jortage/poolmgr/Queries.java +++ b/src/main/java/com/jortage/poolmgr/Queries.java @@ -37,6 +37,11 @@ public class Queries { return sfn; } + private static void onSQLException(SQLException e) { + e.printStackTrace(); + System.err.println("Got SQL exception!"); + } + public static HashCode getMap(DataSource dataSource, String identity, String name) { name = toSFN(name); try (Connection c = dataSource.getConnection()) { @@ -52,6 +57,7 @@ public class Queries { } } } catch (SQLException e) { + onSQLException(e); throw new RuntimeException(e); } } @@ -67,6 +73,7 @@ public class Queries { ps.executeUpdate(); } } catch (SQLException e) { + onSQLException(e); throw new RuntimeException(e); } } @@ -80,6 +87,7 @@ public class Queries { return ps.executeUpdate() > 0; } } catch (SQLException e) { + onSQLException(e); throw new RuntimeException(e); } } @@ -97,6 +105,7 @@ public class Queries { } } } catch (SQLException e) { + onSQLException(e); throw new RuntimeException(e); } } @@ -110,6 +119,7 @@ public class Queries { } } } catch (SQLException e) { + onSQLException(e); throw new RuntimeException(e); } } @@ -122,6 +132,7 @@ public class Queries { ps.executeUpdate(); } } catch (SQLException e) { + onSQLException(e); throw new RuntimeException(e); } } @@ -144,6 +155,7 @@ public class Queries { ps.executeUpdate(); } } catch (SQLException e) { + onSQLException(e); throw new RuntimeException(e); } } @@ -155,6 +167,7 @@ public class Queries { ps.executeUpdate(); } } catch (SQLException e) { + onSQLException(e); throw new RuntimeException(e); } } @@ -170,6 +183,7 @@ public class Queries { ps.executeUpdate(); } } catch (SQLException e) { + onSQLException(e); throw new RuntimeException(e); } } @@ -189,6 +203,7 @@ public class Queries { } } } catch (SQLException e) { + onSQLException(e); throw new RuntimeException(e); } } @@ -206,6 +221,7 @@ public class Queries { } } } catch (SQLException e) { + onSQLException(e); throw new RuntimeException(e); } } @@ -217,6 +233,7 @@ public class Queries { ps.executeUpdate(); } } catch (SQLException e) { + onSQLException(e); throw new RuntimeException(e); } } diff --git a/src/main/java/com/jortage/poolmgr/RedirHandler.java b/src/main/java/com/jortage/poolmgr/RedirHandler.java index d49e444..516e99e 100644 --- a/src/main/java/com/jortage/poolmgr/RedirHandler.java +++ b/src/main/java/com/jortage/poolmgr/RedirHandler.java @@ -9,7 +9,6 @@ import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.handler.AbstractHandler; import org.jclouds.blobstore.BlobStore; import org.jclouds.blobstore.domain.Blob; -import org.jclouds.blobstore.domain.BlobAccess; import com.google.common.base.Splitter; import com.google.common.io.ByteStreams; @@ -69,10 +68,6 @@ public final class RedirHandler extends AbstractHandler { response.setHeader("Jortage-Waited", "true"); } String hash = Queries.getMap(Poolmgr.dataSource, identity, name).toString(); - BlobAccess ba = Poolmgr.backingBlobStore.getBlobAccess(Poolmgr.bucket, Poolmgr.hashToPath(hash)); - if (ba != BlobAccess.PUBLIC_READ) { - Poolmgr.backingBlobStore.setBlobAccess(Poolmgr.bucket, Poolmgr.hashToPath(hash), BlobAccess.PUBLIC_READ); - } response.setHeader("Cache-Control", "public"); response.setHeader("Location", Poolmgr.publicHost+"/"+Poolmgr.hashToPath(hash)); response.setStatus(301);