Skip to content

Commit c289c8d

Browse files
authored
Merge pull request #162 from benedekh/fix/NFE-in-ClientIdProcessor
NumberFormatException in ClientIdProcessor
2 parents 1005d52 + 0577a3e commit c289c8d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

model-server/src/main/kotlin/org/modelix/model/server/store/ClientIdProcessor.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ class ClientIdProcessor : EntryProcessor<String?, String?, Long> {
2222
@Throws(EntryProcessorException::class)
2323
override fun process(mutableEntry: MutableEntry<String?, String?>, vararg objects: Any): Long {
2424
val idStr = mutableEntry.value
25-
var id = idStr?.toLong() ?: 0
26-
id++
25+
val id = try {
26+
idStr?.toLong() ?: 0L
27+
} catch (e : NumberFormatException) {
28+
0L
29+
} + 1L
2730
mutableEntry.value = id.toString()
2831
return id
2932
}

0 commit comments

Comments
 (0)