You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Justin Bertram (Jira)" <ji...@apache.org> on 2020/10/05 15:54:00 UTC
[jira] [Commented] (ARTEMIS-2931) Potential null pointer access at
several places
[ https://issues.apache.org/jira/browse/ARTEMIS-2931?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17208150#comment-17208150 ]
Justin Bertram commented on ARTEMIS-2931:
-----------------------------------------
I think the static analysis is incorrect because of line 391:
{code:java}
this.channel = channel;
{code}
So {{this.channel}} and {{channel}} are _the same_. The variable {{this.channel}} is checked on line 408 and protects access to {{channel}}:
{code:java}
if (this.channel != null && outgoingInterceptors != null) {
{code}
I'll admit the code isn't particularly clear or straight-forward, but I think it is correct.
> Potential null pointer access at several places
> ------------------------------------------------
>
> Key: ARTEMIS-2931
> URL: https://issues.apache.org/jira/browse/ARTEMIS-2931
> Project: ActiveMQ Artemis
> Issue Type: Bug
> Components: Broker
> Reporter: Petr Kuzel
> Priority: Major
>
> Open the artemis-server project in Eclipse. Static analysis reports numerous Potential null pointer access. Looking at an example, the static analyzer is correct.
> ReplicationEndpoint:
> {code:java}
> public void setChannel(final Channel channel) {
> this.channel = channel;
> if (channel == null) {
> supportResponseBatching = false;
> } else {
> try {
> final CoreRemotingConnection connection = channel.getConnection();
> if (connection != null) {
> this.supportResponseBatching = connection.getTransportConnection() instanceof NettyConnection;
> } else {
> this.supportResponseBatching = false;
> }
> } catch (Throwable t) {
> logger.warn("Error while checking the channel connection", t);
> this.supportResponseBatching = false;
> }
> } if (this.channel != null && outgoingInterceptors != null) {
> if (channel.getConnection() instanceof RemotingConnectionImpl) { // NPE risk
> {code}
> line 392 the channel can be null.
> line 409 for unknown reason assumes the channel is never null.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)