From 921e349939ebc8f75054d959b3ca0905ea8d6cbf Mon Sep 17 00:00:00 2001 From: Andy Jackson Date: Fri, 28 May 2021 12:47:59 +0100 Subject: [PATCH] Update AMPQ client library to address security warning. --- contrib/pom.xml | 2 +- .../archive/crawler/frontier/AMQPUrlReceiver.java | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/contrib/pom.xml b/contrib/pom.xml index b270574e..13c6d3fb 100644 --- a/contrib/pom.xml +++ b/contrib/pom.xml @@ -55,7 +55,7 @@ com.rabbitmq amqp-client - 3.2.1 + 4.8.0 com.itextpdf diff --git a/contrib/src/main/java/org/archive/crawler/frontier/AMQPUrlReceiver.java b/contrib/src/main/java/org/archive/crawler/frontier/AMQPUrlReceiver.java index 1d2cf5b6..78b50b88 100644 --- a/contrib/src/main/java/org/archive/crawler/frontier/AMQPUrlReceiver.java +++ b/contrib/src/main/java/org/archive/crawler/frontier/AMQPUrlReceiver.java @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.concurrent.TimeoutException; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.logging.Level; @@ -180,7 +181,7 @@ public class AMQPUrlReceiver // start up again try { startConsumer(); - } catch (IOException e) { + } catch (IOException | TimeoutException e) { logger.log(Level.SEVERE, "problem starting AMQP consumer (will try again after 10 seconds)", e); } } @@ -193,7 +194,7 @@ public class AMQPUrlReceiver consumerTag = null; logger.info("Cancelled URLConsumer."); } - } catch (IOException e) { + } catch (IOException | TimeoutException e) { logger.log(Level.SEVERE, "problem cancelling AMQP consumer (will try again after 10 seconds)", e); } } @@ -209,7 +210,7 @@ public class AMQPUrlReceiver } } - public void startConsumer() throws IOException { + public void startConsumer() throws IOException, TimeoutException { Consumer consumer = new UrlConsumer(channel()); channel().exchangeDeclare(getExchange(), "direct", true); channel().queueDeclare(getQueueName(), durable, @@ -235,7 +236,7 @@ public class AMQPUrlReceiver // try to synchronously start the consumer right now, so // that the queue is bound before crawling starts starterRestarter.startConsumer(); - } catch (IOException e) { + } catch (IOException | TimeoutException e) { logger.log(Level.SEVERE, "problem starting AMQP consumer (will try again soon)", e); } starterRestarter.start(); @@ -278,7 +279,7 @@ public class AMQPUrlReceiver transient protected Connection connection = null; transient protected Channel channel = null; - protected Connection connection() throws IOException { + protected Connection connection() throws IOException, TimeoutException { lock.lock(); try { if (connection != null && !connection.isOpen()) { @@ -302,7 +303,7 @@ public class AMQPUrlReceiver } } - protected Channel channel() throws IOException { + protected Channel channel() throws IOException, TimeoutException { lock.lock(); try { if (channel != null && !channel.isOpen()) {