Examples of errors detected by the V6008 diagnostic
V6008. Potential null dereference.
Elasticsearch
V6008 Null dereference of 'line'. GoogleCloudStorageFixture.java(451)
private static PathTrie<RequestHandler> defaultHandlers(....) {
....
handlers.insert("POST /batch/storage/v1", (request) -> {
....
// Reads the body
line = reader.readLine();
byte[] batchedBody = new byte[0];
if ((line != null) ||
(line.startsWith("--" + boundary) == false)) // <=
{
batchedBody = line.getBytes(StandardCharsets.UTF_8);
}
....
});
....
}
Elasticsearch
V6008 Potential null dereference of 'followIndexMetadata'. TransportResumeFollowAction.java(171), TransportResumeFollowAction.java(170), TransportResumeFollowAction.java(194)
void start(
ResumeFollowAction.Request request,
String clusterNameAlias,
IndexMetaData leaderIndexMetadata,
IndexMetaData followIndexMetadata,
....) throws IOException
{
MapperService mapperService = followIndexMetadata != null // <=
? ....
: null;
validate(request,
leaderIndexMetadata,
followIndexMetadata, // <=
leaderIndexHistoryUUIDs,
mapperService);
....
}
Apache Hive
V6008 Potential null dereference of 'dagLock'. QueryTracker.java(557), QueryTracker.java(553)
private void handleFragmentCompleteExternalQuery(QueryInfo queryInfo)
{
if (queryInfo.isExternalQuery())
{
ReadWriteLock dagLock = getDagLock(queryInfo.getQueryIdentifier());
if (dagLock == null) {
LOG.warn("Ignoring fragment completion for unknown query: {}",
queryInfo.getQueryIdentifier());
}
boolean locked = dagLock.writeLock().tryLock();
....
}
}
Apache Hive
V6008 Null dereference of 'buffer' in function 'unlockSingleBuffer'. MetadataCache.java(410), MetadataCache.java(465)
private boolean lockBuffer(LlapBufferOrBuffers buffers, ....)
{
LlapAllocatorBuffer buffer = buffers.getSingleLlapBuffer();
if (buffer != null) { // <=
return lockOneBuffer(buffer, doNotifyPolicy);
}
LlapAllocatorBuffer[] bufferArray = buffers.getMultipleLlapBuffers();
for (int i = 0; i < bufferArray.length; ++i) {
if (lockOneBuffer(bufferArray[i], doNotifyPolicy)) continue;
for (int j = 0; j < i; ++j) {
unlockSingleBuffer(buffer, true); // <=
}
....
}
....
}
....
private void unlockSingleBuffer(LlapAllocatorBuffer buffer, ....) {
boolean isLastDecref = (buffer.decRef() == 0); // <=
if (isLastDecref) {
....
}
}
Huawei Cloud
V6008 Potential null dereference of 'FileId.get(path)' in function '<init>'. TrackedFile.java(140), TrackedFile.java(115)
public TrackedFile(FileFlow<?> flow, Path path) throws IOException
{
this(flow, path, FileId.get(path), ....);
}
Similar errors can be found in some other places:
- V6008 Potential null dereference of 'buffer'. PublishingQueue.java(518)
Huawei Cloud
V6008 Potential null dereference of 'dataTmpFile'. CacheManager.java(91)
@Override
public void putToCache(PutRecordsRequest putRecordsRequest)
{
....
if (dataTmpFile == null || !dataTmpFile.exists())
{
try
{
dataTmpFile.createNewFile(); // <=
}
catch (IOException e)
{
LOGGER.error("Failed to create cache tmp file, return.", e);
return ;
}
}
....
}
Ghidra
V6008 Null dereference of 'selectedNode' in function 'setViewPanel'. OptionsPanel.java(266)
private void processSelection(OptionsTreeNode selectedNode) {
if (selectedNode == null) {
setViewPanel(defaultPanel, selectedNode); // <=
return;
}
....
}
private void setViewPanel(JComponent component, OptionsTreeNode selectedNode) {
....
setHelpLocation(component, selectedNode);
....
}
private void setHelpLocation(JComponent component, OptionsTreeNode node) {
Options options = node.getOptions();
....
}
XMage
V6008 Null dereference of 'savedSpecialRares'. DragonsMaze.java(230)
public final class DragonsMaze extends ExpansionSet {
....
private List<CardInfo> savedSpecialRares = new ArrayList<>();
....
@Override
public List<CardInfo> getSpecialRare() {
if (savedSpecialRares == null) { // <=
CardCriteria criteria = new CardCriteria();
criteria.setCodes("GTC").name("Breeding Pool");
savedSpecialRares.addAll(....); // <=
criteria = new CardCriteria();
criteria.setCodes("GTC").name("Godless Shrine");
savedSpecialRares.addAll(....);
....
}
return new ArrayList<>(savedSpecialRares);
}
}
Similar errors can be found in some other places:
- V6008 Null dereference of 'match'. TableController.java(973)
WildFly
V6008 Null dereference of 'tc'. ExternalPooledConnectionFactoryService.java(382)
private void createService(....) throws Exception {
....
for (TransportConfiguration tc : connectors) {
if (tc == null) {
throw MessagingLogger.ROOT_LOGGER.connectorNotDefined(tc.getName());
}
}
....
}
Rhino
V6008 Potential null dereference of 'generatorState' in function 'freezeGenerator'. Interpreter.java(1244), Interpreter.java(3188)
public final class Interpreter extends Icode implements Evaluator {
....
private static Object interpretLoop(Context cx,
CallFrame frame,
Object throwable) {
GeneratorState generatorState = null;
if (throwable != null) {
if (throwable instanceof GeneratorState) {
generatorState = (GeneratorState) throwable;
....
} else if (!(throwable instanceof ContinuationJump)) {
Kit.codeBug();
}
}
....
StateLoop:
for (; ; ) {
....
if (throwable != null) {
....
} else {
if (generatorState == null && frame.frozen) Kit.codeBug();
}
for (; ; ) {
....
int op = iCode[frame.pc++];
jumplessRun:
{
switch (op) {
....
case ....:
{
if (!frame.frozen) {
return freezeGenerator(....,
generatorState, // <=
....);
}
....
}
// many more cases
....
}
}
....
}
....
}
....
}
....
private static Object freezeGenerator(....,
GeneratorState generatorState,
....) {
if (generatorState.operation == NativeGenerator.GENERATOR_CLOSE){ // <=
// Error: no yields when generator is closing
throw ScriptRuntime.typeErrorById("msg.yield.closing");
}
....
}
}
NetBeans 21
V6008 Null dereference of 's'. SourceJavadocAttacherUtil.java(141)
public void run() {
for (SourceJavadocAttacherImplementation.Definer d : plugins) {
....
List<? extends URL> s = source ?
d.getSources(root, this) : d.getJavadoc(root, this);
if (s != null || s.isEmpty()) {
....
}
}
}
NetBeans 21
V6008 Null dereference of 'listeners'. MavenArtifactsImplementation.java(613)
public void propertyChange(PropertyChangeEvent evt) {
....
synchronized (this) {
artifacts = null;
if (listeners == null && listeners.isEmpty()) {
return;
}
....
}
}
NetBeans 21
V6008 Null dereference of 'tm'. SourcesModel.java(713)
private SourcesModel getModel () {
SourcesModel tm = model.get ();
if (tm == null) {
tm.sourcePath.removePropertyChangeListener (this);
tm.debugger.getSmartSteppingFilter ().
removePropertyChangeListener (this);
}
return tm;
}
NetBeans 21
V6008 Null dereference of 'this.suspendedSteppingThreads'. JPDAThreadImpl.java(2329)
void unsetStepSuspendedByBpIn(JPDAThreadImpl thread) {
JPDABreakpoint oldBp;
synchronized (stepBreakpointLock) {
....
if (this.suspendedSteppingThreads == null) {
this.suspendedSteppingThreads.remove(thread);
....
}
}
....
}
NetBeans 21
V6008 Null dereference of 'view'. CollapsedView.java(627)
public @Override Element getElement() {
if (view != null) {
return view.getElement();
} else {
return view.getDocument().getDefaultRootElement();
}
}
NetBeans 21
V6008 Null dereference of 'project'. ModulePathsProblemsProvider.java(93)
public ModulePathsProblemsProvider(@NonNull final Lookup baseLkp) {
this.project = baseLkp.lookup(J2SEProject.class);
if (this.project == null) {
throw new IllegalArgumentException(String.format(
"Unsupported project: %s of type: %s", //NOI18N
project,
project.getClass()
));
}
this.moduleInfoListeners = new HashSet<>();
this.listeners = new PropertyChangeSupport(this);
}
NetBeans 21
V6008 Null dereference of 'lex'. XMLSyntaxTokenManager.java(216)
public static void main(String args[]) throws Exception {
....
Bridge lex = null; //new XMLSyntaxTokenManager(input);
int i = 25; //token count
int id;
int toks = 0;
long time = System.currentTimeMillis();
while (i/*--*/>0) {
lex.next();
....
}
}
Keycloak
V6008 Potential null dereference of 'rs'. CertificateValidator.java 701 , CertificateValidator.java 708
private void checkRevocationUsingOCSP(X509Certificate[] certs)
throws GeneralSecurityException {
....
if (rs == null) {
if (_ocspFailOpen)
logger.warnf(....);
else
throw new GeneralSecurityException(....);
}
if (rs.getRevocationStatus() ==
OCSPProvider.RevocationStatus.UNKNOWN) {
if (_ocspFailOpen)
logger.warnf(....);
else
throw new GeneralSecurityException(....);
....
}
Apache Solr
V6008 Null dereference of 'meta'. SolrSnapshotsTool.java 262
public Map<String, List<String>> getIndexFilesPathForSnapshot(
String collectionName, String snapshotName, String pathPrefix)
throws SolrServerException, IOException {
....
if (meta != null) { // <=
throw new IllegalArgumentException(
"The snapshot named " + snapshotName +
" is not found for collection " + collectionName);
}
DocCollection collectionState = solrClient.getClusterState()
.getCollection(collectionName);
for (Slice s : collectionState.getSlices()) {
List<CoreSnapshotMetaData> replicaSnaps =
meta.getReplicaSnapshotsForShard(s.getName()); // <=
....
}
return result;
}
Apache Solr
V6008 Potential null dereference of 'value'. IndexSizeEstimator.java 735, IndexSizeEstimator.java 736
public void stringField(FieldInfo fieldInfo, String value) throws IOException {
// trim the value if needed
int len = value != null ?
UnicodeUtil.calcUTF16toUTF8Length(value, 0, value.length()) : 0;
if (value.length() > maxLength) { // <=
value = value.substring(0, maxLength);
}
countItem(fieldInfo.name, value, len);
}
Apache Solr
V6008 Potential null dereference of 'collection'. ClusterStatus.java 303, ClusterStatus.java 335
public static Map<String, Object> postProcessCollectionJSON(
Map<String, Object> collection) {
final Map<String, Map<String, Object>> shards = collection != null // <=
? (Map<String, Map<String, Object>>)
collection.getOrDefault("shards", Collections.emptyMap())
: Collections.emptyMap();
final List<Health> healthStates = new ArrayList<>(shards.size());
shards.forEach(
....
);
collection.put("health", Health.combine(healthStates).toString()); // <=
return collection;
}
Apache Kafka
V6008 Potential null dereference of 'oldMember' in function 'removeStaticMember'. ConsumerGroup.java 311, ConsumerGroup.java 323
@Override
public void removeMember(String memberId) {
ConsumerGroupMember oldMember = members.remove(memberId);
....
removeStaticMember(oldMember);
....
}
private void removeStaticMember(ConsumerGroupMember oldMember) {
if (oldMember.instanceId() != null) {
staticMembers.remove(oldMember.instanceId());
}
}