`java.lang.IndexOutOfBoundsException` indexing `com.fasterxml.jackson.module__jackson-module-kotlin__2.11.4`
olafurpg opened this issue · 1 comments
olafurpg commented
[info] Caused by: java.lang.IndexOutOfBoundsException: start -1, end -1, length 0
[info] at java.base/java.lang.AbstractStringBuilder.checkRange(AbstractStringBuilder.java:1802)
[info] at java.base/java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:680)
[info] at java.base/java.lang.StringBuilder.append(StringBuilder.java:218)
[info] at com.sourcegraph.semanticdb_kotlinc.SemanticdbTextDocumentBuilder.stripKDocAsterisks(SemanticdbTextDocumentBuilder.kt:160)
marcleblanc2 commented
Customer 8682 has reported this in support ticket 13497, and suggests a fix:
"Not sure where the best place the to send this is, but there’s a bug in the precise code indexer for Kotlin which is preventing me from indexing any of our code.
The bug seems to be here: sourcegraph/lsif-kotlin/-/blob/semanticdb-kotlinc/src/main/kotlin/com/sourcegraph/semanticdb_kotlinc/SemanticdbTextDocumentBuilder.kt?L136
Somebody needs to add a check for 0 length lines e.g.
private fun stripKDocAsterisks(kdoc: String): String {
if (kdoc.isEmpty()) return kdoc
val out = StringBuilder().append("\n\n").append("----").append("\n")
kdoc.lineSequence().forEach { line ->
if (line.length <= 0) { continue } // Suggested adding this check
var start = 0
while (start < line.length && line[start].isWhitespace()) {
start++
}
if (start < line.length && line[start] == '/') {
start++
}
while (start < line.length && line[start] == '*') {
start++
}
var end = line.length - 1
if (end > start && line[end] == '/') {
end--
}
while (end > start && line[end] == '*') {
end--
}
while (end > start && line[end].isWhitespace()) {
end--
}
start = minOf(start, line.length - 1)
if (end > start) {
end++
}
out.append("\n").append(line, start, end)
}
return out.toString()
}