Skip to content

Commit

Permalink
Fix Issues Reported by Sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
garyrussell committed Apr 27, 2021
1 parent 2cded99 commit f52a671
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
import org.springframework.util.ErrorHandler;
import org.springframework.util.backoff.BackOff;

import com.rabbitmq.client.Channel;

/**
* A Factory bean to create a listener container.
*
Expand Down Expand Up @@ -276,7 +274,7 @@ public void setPrefetchCount(int prefetchCount) {
* Apply prefetch to the entire channel.
* @param globalQos true for a channel-wide prefetch.
* @since 2.2.17
* @see Channel#basicQos(int, boolean)
* @see com.rabbitmq.client.Channel#basicQos(int, boolean)
*/
public void setGlobalQos(boolean globalQos) {
this.globalQos = globalQos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ protected ApplicationEventPublisher getApplicationEventPublisher() {

@Override
public void onApplicationEvent(ContextClosedEvent event) {
if (getApplicationContext() == event.getApplicationContext()) {
if (getApplicationContext().equals(event.getApplicationContext())) {
this.contextStopped = true;
}
if (this.publisherConnectionFactory != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 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.
Expand Down Expand Up @@ -1098,7 +1098,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
}
if (methodName.equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0]);
return (proxy == args[0]); // NOSONAR
}
else if (methodName.equals("hashCode")) {
// Use hashCode of Channel proxy.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
Expand Down Expand Up @@ -161,7 +161,7 @@ public void commitAll() throws AmqpException {
public void closeAll() {
for (Channel channel : this.channels) {
try {
if (channel != ConsumerChannelRegistry.getConsumerChannel()) {
if (channel != ConsumerChannelRegistry.getConsumerChannel()) { // NOSONAR
channel.close();
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ public MessageConverter getMessageConverter() {
}

public void setConfirmCallback(ConfirmCallback confirmCallback) {
Assert.state(this.confirmCallback == null || this.confirmCallback == confirmCallback,
Assert.state(this.confirmCallback == null || this.confirmCallback.equals(confirmCallback),
"Only one ConfirmCallback is supported by each RabbitTemplate");
this.confirmCallback = confirmCallback;
}
Expand All @@ -466,7 +466,7 @@ public void setConfirmCallback(ConfirmCallback confirmCallback) {
*/
@Deprecated
public void setReturnCallback(ReturnCallback returnCallback) {
Assert.state(this.returnsCallback == null || this.returnsCallback.delegate() == returnCallback,
Assert.state(this.returnsCallback == null || this.returnsCallback.delegate().equals(returnCallback),
"Only one ReturnCallback is supported by each RabbitTemplate");
this.returnsCallback = new ReturnsCallback() {

Expand All @@ -485,7 +485,7 @@ public ReturnCallback delegate() {
}

public void setReturnsCallback(ReturnsCallback returnCallback) {
Assert.state(this.returnsCallback == null || this.returnsCallback == returnCallback,
Assert.state(this.returnsCallback == null || this.returnsCallback.equals(returnCallback),
"Only one ReturnCallback is supported by each RabbitTemplate");
this.returnsCallback = returnCallback;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 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.
Expand Down Expand Up @@ -268,7 +268,7 @@ public void onMessage(Message message, Channel channel) throws Exception { // NO
// Check whether the delegate is a MessageListener impl itself.
// In that case, the adapter will simply act as a pass-through.
Object delegateListener = getDelegate();
if (delegateListener != this) {
if (!delegateListener.equals(this)) {
if (delegateListener instanceof ChannelAwareMessageListener) {
((ChannelAwareMessageListener) delegateListener).onMessage(message, channel);
return;
Expand Down

0 comments on commit f52a671

Please sign in to comment.