From 81f993f0d8f4e714055964f9feab2998c9a25ff0 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 7 Aug 2014 15:52:17 +0300 Subject: [PATCH] INT-3486 SimplePool suppress InterruptedException JIRA: https://jira.spring.io/browse/INT-3486 Previously the undesired StackTrace has been logged in case of Thread interruption, e.g. component `stop()` Suppress `InterruptedException` in the `SimplePool#getItem()`. Since we do the `Thread.currentThread().interrupt();` on the `catch (InterruptedException e) {` it does not make sense to rethrow it as a `MessagingException`, because the thread is interrupted anyway. --- .../org/springframework/integration/util/SimplePool.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/SimplePool.java b/spring-integration-core/src/main/java/org/springframework/integration/util/SimplePool.java index 8c32ff8022..de4d565ae7 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/SimplePool.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/SimplePool.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.util; import java.util.Collections; @@ -34,6 +35,7 @@ import org.springframework.util.Assert; * Implementation of {@link Pool} supporting dynamic resizing and a variable * timeout when attempting to obtain an item from the pool. Pool grows on * demand up to the limit. + * * @author Gary Russell * @since 2.2 * @@ -158,14 +160,13 @@ public class SimplePool implements Pool { permitted = this.permits.tryAcquire(this.waitTimeout, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { + logger.error("Interrupted awaiting a pooled resource."); Thread.currentThread().interrupt(); - throw new MessagingException("Interrupted awaiting a pooled resource", e); } if (!permitted) { throw new IllegalStateException("Timed out while waiting to aquire a pool entry."); } - T item = doGetItem(); - return item; + return doGetItem(); } catch (Exception e) { if (permitted) {