Examples of errors detected by the V6009 diagnostic
V6009. Function receives an odd argument.
Apache NiFi
V6009 Function 'equals' receives an odd argument. The 'o.getClass().getGenericInterfaces()' argument was passed several times. EqualsWrapper.java 126
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null
|| getClass() != o.getClass()
|| !Arrays.equals(
o.getClass().getGenericInterfaces(), // <=
o.getClass().getGenericInterfaces() // <=
)
) {
return false;
}
....
}
Elasticsearch
V6009 Function 'assertSame' receives an odd argument. The 'right.array()' argument was passed several times. AbstractBytesReferenceTestCase.java 713
public void testReadSlices() throws IOException {
....
try (StreamInput input1 = bytesReference.streamInput();
StreamInput input2 = bytesReference.streamInput()) {
for (int i = 0; i < refs; i++) {
boolean sliceLeft = randomBoolean();
BytesReference left = sliceLeft ?
input1.readSlicedBytesReference()
: input1.readBytesReference();
if (sliceLeft && bytesReference.hasArray()) {
assertSame(left.array(), bytesReference.array()); // <=
}
boolean sliceRight = randomBoolean();
BytesReference right = sliceRight ?
input2.readSlicedBytesReference()
: input2.readBytesReference();
assertEquals(left, right);
if (sliceRight && bytesReference.hasArray()) {
assertSame(right.array(), right.array()); // <=
}
}
}
}
NetBeans 21
V6009 Buffer capacity is set to '47' using a char value. Most likely, the '/' symbol was supposed to be placed in the buffer. IgnoreUnignoreCommand.java(107)
private void changeIgnoreStatus (File f) throws IOException {
File parent = f;
boolean isDirectory = f.isDirectory() && (! Files.isSymbolicLink(f.toPath()));
StringBuilder sb = new StringBuilder('/');
if (isDirectory) {
sb.append('/');
}
boolean cont = true;
while (cont) {
sb.insert(0, parent.getName()).insert(0, '/');
parent = parent.getParentFile();
String path = sb.toString();
if (parent.equals(getRepository().getWorkTree())) {
if (addStatement(new File(parent, Constants.DOT_GIT_IGNORE),
path, isDirectory, false) &&
handleAdditionalIgnores(path, isDirectory)) {
addStatement(new File(parent, Constants.DOT_GIT_IGNORE),
path, isDirectory, true);
}
cont = false;
} else {
cont = addStatement(new File(parent, Constants.DOT_GIT_IGNORE),
path, isDirectory, false);
}
}
NGB
V6009 The 'substring' function could receive the '-1' value while non-negative value is expected. Inspect argument: 2. TabixReader.java(430)
private TIntv getIntv(final String s) {
....
int end = s.indexOf('\t', beg);
while (end >= 0 || end == -1) {
if (col == mSc) {
....
} else {
if ((mPreset & TYPE_FLAG) == 0) {
if (col == mEc) {
intv.end = Integer.parseInt(end != -1
? s.substring(beg, end)
: s.substring(beg));
}
} else if ((mPreset & TYPE_FLAG) == 1) {
if (col == 6) {
String cigar = s.substring(beg, end);
....
}
} else if ((mPreset & TYPE_FLAG) == 2) {
String alt;
alt = end >= 0 ? s.substring(beg, end)
: s.substring(beg);
....
}
}
if (end == -1) {
break;
}
beg = end + 1;
end = s.indexOf('\t', beg);
}
return intv;
}
NGB
V6009 The 'substring' function could receive the '-1' value while non-negative value is expected. Inspect argument: 2. VcfGa4ghReader.java(212)
private VariantSet variationMetadata(final String path) {
final int index = path.indexOf('-');
VariantSet variantSet;
final String variantSetId;
if (index >= 0) {
variantSetId = path.substring(0, index - 1);
} else {
variantSetId = path;
}
....
return variantSet;
}
ELKI
V6009 Function 'equals' receives an odd argument. An object 'other.similarityFunction' is used as an argument to its own method. AbstractSimilarityAdapter.java(91)
@Override
public boolean equals(Object obj) {
if(obj == null) {
return false;
}
if(!this.getClass().equals(obj.getClass())) {
return false;
}
AbstractSimilarityAdapter<?> other = (AbstractSimilarityAdapter<?>) obj;
return other.similarityFunction.equals(other.similarityFunction);
}
Huawei Cloud
V6009 The 'substring' function could receive the '-1' value while non-negative value is expected. Inspect argument: 2. RemoveVersionProjectIdFromURL.java(37)
@Override
public String apply(String url) {
String urlRmovePojectId = url.substring(0, url.lastIndexOf("/"));
return urlRmovePojectId.substring(0, urlRmovePojectId.lastIndexOf("/"));
}
Similar errors can be found in some other places:
- V6009 The 'substring' function could receive the '-1' value while non-negative value is expected. Inspect argument: 2. RemoveProjectIdFromURL.java(37)
- V6009 The 'substring' function could receive the '-1' value while non-negative value is expected. Inspect argument: 2. RemoveVersionProjectIdFromURL.java(38)
Apache Dubbo
V6009 The 'substring' function could receive the '-1' value while non-negative value is expected. Inspect argument: 2. AbstractEtcdClient.java(169)
protected void createParentIfAbsent(String fixedPath) {
int i = fixedPath.lastIndexOf('/');
if (i > 0) {
String parentPath = fixedPath.substring(0, i);
if (categories.stream().anyMatch(c -> fixedPath.endsWith(c))) {
if (!checkExists(parentPath)) {
this.doCreatePersistent(parentPath);
}
} else if (categories.stream().anyMatch(c -> parentPath.endsWith(c))) {
String grandfather = parentPath
.substring(0, parentPath.lastIndexOf('/')); // <=
if (!checkExists(grandfather)) {
this.doCreatePersistent(grandfather);
}
}
}
}
Apache Hive
V6009 Function 'compareTo' receives an odd argument. An object 'o2.getWorkerIdentity()' is used as an argument to its own method. LlapFixedRegistryImpl.java(244)
@Override
public List<LlapServiceInstance> getAllInstancesOrdered(....) {
....
Collections.sort(list, new Comparator<LlapServiceInstance>() {
@Override
public int compare(LlapServiceInstance o1, LlapServiceInstance o2) {
return o2.getWorkerIdentity().compareTo(o2.getWorkerIdentity()); // <=
}
});
....
}
CUBA Platform
V6009 The 'delete' function could receive the '-1' value while non-negative value is expected. Inspect argument: 1. AbstractCollectionDatasource.java(556)
protected DataLoadContextQuery createDataQuery(....) {
....
StringBuilder orderBy = new StringBuilder();
....
if (orderBy.length() > 0) {
orderBy.delete(orderBy.length() - 2, orderBy.length());
orderBy.insert(0, " order by ");
}
....
}
Elasticsearch
V6009 Function 'substring' receives an odd arguments. The 'queryStringIndex + 1' argument should not be greater than 'queryStringLength'. LoggingAuditTrail.java(660)
LogEntryBuilder withRestUriAndMethod(RestRequest request) {
final int queryStringIndex = request.uri().indexOf('?');
int queryStringLength = request.uri().indexOf('#');
if (queryStringLength < 0) {
queryStringLength = request.uri().length();
}
if (queryStringIndex < 0) {
logEntry.with(....);
} else {
logEntry.with(....);
}
if (queryStringIndex > -1) {
logEntry.with(....,
request.uri().substring(queryStringIndex + 1,// <=
queryStringLength)); // <=
}
....
}
Elasticsearch
V6009 Function 'equals' receives an odd argument. An object 'shardId.getIndexName()' is used as an argument to its own method. SnapshotShardFailure.java(208)
@Override
public boolean equals(Object o) {
....
return shardId.id() == that.shardId.id() &&
shardId.getIndexName().equals(shardId.getIndexName()) && // <=
Objects.equals(reason, that.reason) &&
Objects.equals(nodeId, that.nodeId) &&
status.getStatus() == that.status.getStatus();
}