This is an automated email from the ASF dual-hosted git repository. orudyy pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/qpid-broker-j.git
The following commit(s) were added to refs/heads/master by this push: new 98261ad QPID-8366: [Broker-J] Handle ConnectionScopeRuntimeException on execution of HouseKeepingTaks 98261ad is described below commit 98261ad92020c11784a3be2ab890cbabddec5fbc Author: Alex Rudyy <oru...@apache.org> AuthorDate: Tue Oct 1 21:51:33 2019 +0100 QPID-8366: [Broker-J] Handle ConnectionScopeRuntimeException on execution of HouseKeepingTaks --- .../store/berkeleydb/AbstractBDBMessageStore.java | 27 +++++++++--- .../qpid/server/virtualhost/HouseKeepingTask.java | 14 +++++- .../server/virtualhost/HouseKeepingTaskTest.java | 51 ++++++++++++++++++++++ .../protocol/v0_8/AMQPConnection_0_8Impl.java | 2 +- 4 files changed, 85 insertions(+), 9 deletions(-) diff --git a/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java b/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java index b48cd54..05733ad 100644 --- a/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java +++ b/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java @@ -382,7 +382,10 @@ public abstract class AbstractBDBMessageStore implements MessageStore } catch (RuntimeException e) { - getLogger().error("Unexpected BDB exception", e); + if (getLogger().isDebugEnabled()) + { + getLogger().debug("Unexpected BDB exception", e); + } try { @@ -630,7 +633,10 @@ public abstract class AbstractBDBMessageStore implements MessageStore } catch (RuntimeException e) { - getLogger().error("Failed to enqueue: {}", e.getMessage(), e); + if (getLogger().isDebugEnabled()) + { + getLogger().debug("Failed to enqueue: {}", e.getMessage(), e); + } throw getEnvironmentFacade().handleDatabaseException("Error writing enqueued message with id " + messageId + " for queue " @@ -679,8 +685,10 @@ public abstract class AbstractBDBMessageStore implements MessageStore } catch (RuntimeException e) { - - getLogger().error("Failed to dequeue message " + messageId + " in transaction " + tx, e); + if (getLogger().isDebugEnabled()) + { + getLogger().debug("Failed to dequeue message {} in transaction {}", messageId, tx, e); + } throw getEnvironmentFacade().handleDatabaseException("Error accessing database while dequeuing message: " + e.getMessage(), e); @@ -718,7 +726,10 @@ public abstract class AbstractBDBMessageStore implements MessageStore } catch (RuntimeException e) { - getLogger().error("Failed to write xid: " + e.getMessage(), e); + if (getLogger().isDebugEnabled()) + { + getLogger().debug("Failed to write xid: {}", e.getMessage(), e); + } throw getEnvironmentFacade().handleDatabaseException("Error writing xid to database", e); } } @@ -749,8 +760,10 @@ public abstract class AbstractBDBMessageStore implements MessageStore } catch (RuntimeException e) { - - getLogger().error("Failed to remove xid in transaction " + txn, e); + if (getLogger().isDebugEnabled()) + { + getLogger().error("Failed to remove xid in transaction {}", e); + } throw getEnvironmentFacade().handleDatabaseException("Error accessing database while removing xid: " + e.getMessage(), e); diff --git a/broker-core/src/main/java/org/apache/qpid/server/virtualhost/HouseKeepingTask.java b/broker-core/src/main/java/org/apache/qpid/server/virtualhost/HouseKeepingTask.java index 28ea3c7..f55404b 100644 --- a/broker-core/src/main/java/org/apache/qpid/server/virtualhost/HouseKeepingTask.java +++ b/broker-core/src/main/java/org/apache/qpid/server/virtualhost/HouseKeepingTask.java @@ -25,10 +25,15 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.concurrent.ScheduledFuture; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.apache.qpid.server.model.VirtualHost; +import org.apache.qpid.server.util.ConnectionScopedRuntimeException; public abstract class HouseKeepingTask implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(HouseKeepingTask.class); private final String _name; private final AccessControlContext _accessControlContext; private ScheduledFuture<?> _future; @@ -53,7 +58,14 @@ public abstract class HouseKeepingTask implements Runnable @Override public Object run() { - execute(); + try + { + execute(); + } + catch (ConnectionScopedRuntimeException e) + { + LOGGER.warn("Execution of housekeeping task failed", e); + } return null; } }, _accessControlContext); diff --git a/broker-core/src/test/java/org/apache/qpid/server/virtualhost/HouseKeepingTaskTest.java b/broker-core/src/test/java/org/apache/qpid/server/virtualhost/HouseKeepingTaskTest.java new file mode 100644 index 0000000..ea61910 --- /dev/null +++ b/broker-core/src/test/java/org/apache/qpid/server/virtualhost/HouseKeepingTaskTest.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.qpid.server.virtualhost; + +import static org.mockito.Mockito.mock; + +import java.security.AccessControlContext; +import java.security.AccessController; + +import org.junit.Test; + +import org.apache.qpid.server.model.VirtualHost; +import org.apache.qpid.server.util.ConnectionScopedRuntimeException; +import org.apache.qpid.test.utils.UnitTestBase; + +public class HouseKeepingTaskTest extends UnitTestBase +{ + @Test + public void runExecuteThrowsConnectionScopeRuntimeException() + { + final VirtualHost virualHost = mock(VirtualHost.class); + final AccessControlContext context = AccessController.getContext(); + final HouseKeepingTask task = new HouseKeepingTask(getTestName(), virualHost, context) + { + @Override + public void execute() + { + throw new ConnectionScopedRuntimeException("Test"); + } + }; + + task.run(); + } +} diff --git a/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQPConnection_0_8Impl.java b/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQPConnection_0_8Impl.java index a4e5e68..d16eaa0 100644 --- a/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQPConnection_0_8Impl.java +++ b/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQPConnection_0_8Impl.java @@ -274,7 +274,7 @@ public class AMQPConnection_0_8Impl { exception = exceptionForThisChannel; } - LOGGER.error("Error informing channel that receiving is complete. Channel: " + channel, + LOGGER.info("Error informing channel that receiving is complete. Channel: " + channel, exceptionForThisChannel); } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org