hiero-ledger / hiero-ledger/hiero-consensus-node

SpotBugs NP_NULL_ON_SOME_PATH : Possible null pointer dereference

Open
#14,860 0 comments 0 reactions 1 assignee Claimed by @alex-kuzmin-hg View on GitHub
Platform
Dominant language
Java
Stars
406
Forks
226
Avg merge
3d 4h
Merged PRs (30d)
210

Description

### Description

There are 18 places in hedera-services where we try to deref known null instance.
Example:

```
Possible null pointer dereference of DefaultPcesWriter.currentMutableFile in com.swirlds.platform.event.preconsensus.DefaultPcesWriter.processFlushRequests()
--
  | Bug type NP_NULL_ON_SOME_PATH (click for details)In class com.swirlds.platform.event.preconsensus.DefaultPcesWriterIn method com.swirlds.platform.event.preconsensus.DefaultPcesWriter.processFlushRequests()Value contained in com.swirlds.platform.event.preconsensus.DefaultPcesWriter.currentMutableFileDereferenced at DefaultPcesWriter.java:[line 209]Null value at DefaultPcesWriter.java:[line 204]Known null at DefaultPcesWriter.java:[line 205]

Possible null pointer dereference of DefaultPcesWriter.currentMutableFile in com.swirlds.platform.event.preconsensus.DefaultPcesWriter.processFlushRequests()
[Bug type NP_NULL_ON_SOME_PATH (click for details)](https://github.com/hashgraph/hedera-services/issues/new?assignees=&labels=bug&projects=&template=bug.yml#NP_NULL_ON_SOME_PATH)
In class com.swirlds.platform.event.preconsensus.DefaultPcesWriter
In method com.swirlds.platform.event.preconsensus.DefaultPcesWriter.processFlushRequests()
Value contained in com.swirlds.platform.event.preconsensus.DefaultPcesWriter.currentMutableFile
Dereferenced at DefaultPcesWriter.java:[line 209]
Null value at DefaultPcesWriter.java:[line 204]
Known null at DefaultPcesWriter.java:[line 205]
```

Evidence:

```
if (currentMutableFile == null) {
logger.error(EXCEPTION.getMarker(), "Flush required, but no file is open. This should never happen");
}

try {
currentMutableFile.flush();
} catch (final IOException e) {
throw new UncheckedIOException(e);
}
```

### Steps to reproduce

Review SpotBugs reports NP_NULL_ON_SOME_PATH

### Additional context

_No response_

### Hedera network

other

### Version

0.53

### Operating system

Other

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.