[
https://issues.apache.org/jira/browse/ARTEMIS-2931?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17283482#comment-17283482
]
ASF subversion and git services commented on ARTEMIS-2931:
----------------------------------------------------------
Commit a75dce9577cc4a2fa4ff10fcc7f4e0ab4ee8242e in activemq-artemis's branch
refs/heads/master from Petr Kužel
[ https://gitbox.apache.org/repos/asf?p=activemq-artemis.git;h=a75dce9 ]
ARTEMIS-2931: Resolving potential NPEs detected by eclipse
WARNING: the eclipse static analyser is pretty limited and it cannot cope with
cases like: correlated variables, exception paths, .... 70% of eclipse warnings
on artemis codebase is a false alarm.
Anyway some variable correlations can be eliminated and code becomes more
readable for humans too.
For "never-throws", the assumption is made explicit. If you disagree with the
reverse-engineered assumption then it is likely an indication of a true
potential NPE.
Last but not least, copy&paste is a common source of bugs. I suspect eclipse
indirectly detected one such case.
Hope it helps
> 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
> Time Spent: 2.5h
> Remaining Estimate: 0h
>
> 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)