Skip to content

Commit b94fdc5

Browse files
committed
Fix Sonar Issues
1 parent 58820af commit b94fdc5

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/PooledChannelConnectionFactory.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public synchronized void destroy() {
124124

125125
private static final class ConnectionWrapper extends SimpleConnection {
126126

127-
private static final Log logger = LogFactory.getLog(ConnectionWrapper.class);
127+
private static final Log LOGGER = LogFactory.getLog(ConnectionWrapper.class);
128128

129129
private final ObjectPool<Channel> channels;
130130

@@ -164,7 +164,8 @@ private Channel createProxy(Channel channel, boolean transacted) {
164164
String method = invocation.getMethod().getName();
165165
switch (method) {
166166
case "close":
167-
return handleClose(channel, transacted, proxy);
167+
handleClose(channel, transacted, proxy);
168+
return null;
168169
case "getTargetChannel":
169170
return channel;
170171
case "isTransactional":
@@ -189,8 +190,8 @@ private Channel createProxy(Channel channel, boolean transacted) {
189190
return proxy.get();
190191
}
191192

192-
private Object handleClose(Channel channel, boolean transacted, AtomicReference<Channel> proxy)
193-
throws Exception {
193+
private void handleClose(Channel channel, boolean transacted, AtomicReference<Channel> proxy)
194+
throws Exception { // NOSONAR returnObject() throws it
194195

195196
if (!RabbitUtils.isPhysicalCloseRequired()) {
196197
if (transacted) {
@@ -199,12 +200,10 @@ private Object handleClose(Channel channel, boolean transacted, AtomicReference<
199200
else {
200201
ConnectionWrapper.this.channels.returnObject(proxy.get());
201202
}
202-
return null;
203203
}
204204
else {
205205
physicalClose(channel);
206206
}
207-
return null;
208207
}
209208

210209
@Override
@@ -224,7 +223,7 @@ private void physicalClose(Channel channel) {
224223
channel.close();
225224
}
226225
catch (IOException | TimeoutException e) {
227-
logger.debug("Error on close", e);
226+
LOGGER.debug("Error on close", e);
228227
}
229228
}
230229
}

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/ThreadChannelConnectionFactory.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import org.aopalliance.aop.Advice;
2424
import org.aopalliance.intercept.MethodInterceptor;
25-
import org.aopalliance.intercept.MethodInvocation;
2625

2726
import org.springframework.amqp.AmqpException;
2827
import org.springframework.amqp.rabbit.support.RabbitExceptionTranslator;
@@ -160,7 +159,8 @@ private Channel createProxy(Channel channel, boolean transactional) {
160159
String method = invocation.getMethod().getName();
161160
switch (method) {
162161
case "close":
163-
return handleClose(channel, transactional, invocation);
162+
handleClose(channel, transactional);
163+
return null;
164164
case "getTargetChannel":
165165
return channel;
166166
case "isTransactional":
@@ -184,11 +184,10 @@ private Channel createProxy(Channel channel, boolean transactional) {
184184
return (Channel) pf.getProxy();
185185
}
186186

187-
private Object handleClose(Channel channel, boolean transactional, MethodInvocation invocation)
188-
throws Throwable {
187+
private void handleClose(Channel channel, boolean transactional) {
189188

190189
if (ConnectionWrapper.this.channels.get() == null) {
191-
return invocation.proceed();
190+
physicalClose(channel);
192191
}
193192
else {
194193
if (RabbitUtils.isPhysicalCloseRequired()) {
@@ -201,7 +200,6 @@ private Object handleClose(Channel channel, boolean transactional, MethodInvocat
201200
}
202201
RabbitUtils.clearPhysicalCloseRequired();
203202
}
204-
return null;
205203
}
206204
}
207205

0 commit comments

Comments
 (0)