Skip to content

Commit

Permalink
Fix Sonar Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
garyrussell committed Nov 4, 2020
1 parent 58820af commit b94fdc5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public synchronized void destroy() {

private static final class ConnectionWrapper extends SimpleConnection {

private static final Log logger = LogFactory.getLog(ConnectionWrapper.class);
private static final Log LOGGER = LogFactory.getLog(ConnectionWrapper.class);

private final ObjectPool<Channel> channels;

Expand Down Expand Up @@ -164,7 +164,8 @@ private Channel createProxy(Channel channel, boolean transacted) {
String method = invocation.getMethod().getName();
switch (method) {
case "close":
return handleClose(channel, transacted, proxy);
handleClose(channel, transacted, proxy);
return null;
case "getTargetChannel":
return channel;
case "isTransactional":
Expand All @@ -189,8 +190,8 @@ private Channel createProxy(Channel channel, boolean transacted) {
return proxy.get();
}

private Object handleClose(Channel channel, boolean transacted, AtomicReference<Channel> proxy)
throws Exception {
private void handleClose(Channel channel, boolean transacted, AtomicReference<Channel> proxy)
throws Exception { // NOSONAR returnObject() throws it

if (!RabbitUtils.isPhysicalCloseRequired()) {
if (transacted) {
Expand All @@ -199,12 +200,10 @@ private Object handleClose(Channel channel, boolean transacted, AtomicReference<
else {
ConnectionWrapper.this.channels.returnObject(proxy.get());
}
return null;
}
else {
physicalClose(channel);
}
return null;
}

@Override
Expand All @@ -224,7 +223,7 @@ private void physicalClose(Channel channel) {
channel.close();
}
catch (IOException | TimeoutException e) {
logger.debug("Error on close", e);
LOGGER.debug("Error on close", e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import org.aopalliance.aop.Advice;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import org.springframework.amqp.AmqpException;
import org.springframework.amqp.rabbit.support.RabbitExceptionTranslator;
Expand Down Expand Up @@ -160,7 +159,8 @@ private Channel createProxy(Channel channel, boolean transactional) {
String method = invocation.getMethod().getName();
switch (method) {
case "close":
return handleClose(channel, transactional, invocation);
handleClose(channel, transactional);
return null;
case "getTargetChannel":
return channel;
case "isTransactional":
Expand All @@ -184,11 +184,10 @@ private Channel createProxy(Channel channel, boolean transactional) {
return (Channel) pf.getProxy();
}

private Object handleClose(Channel channel, boolean transactional, MethodInvocation invocation)
throws Throwable {
private void handleClose(Channel channel, boolean transactional) {

if (ConnectionWrapper.this.channels.get() == null) {
return invocation.proceed();
physicalClose(channel);
}
else {
if (RabbitUtils.isPhysicalCloseRequired()) {
Expand All @@ -201,7 +200,6 @@ private Object handleClose(Channel channel, boolean transactional, MethodInvocat
}
RabbitUtils.clearPhysicalCloseRequired();
}
return null;
}
}

Expand Down

0 comments on commit b94fdc5

Please sign in to comment.