problem: nullpointer stacktrace if json is just "null"
This commit is contained in:
@@ -46,7 +46,8 @@ class CacheRequested(
|
|||||||
if (params.size != 1) {
|
if (params.size != 1) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val parsed = Global.objectMapper.readValue(json, TransactionReceiptJson::class.java)
|
// note: json could be a `null` value
|
||||||
|
val parsed = Global.objectMapper.readValue(json, TransactionReceiptJson::class.java) ?: return
|
||||||
val value = DefaultContainer<TransactionReceiptJson>(
|
val value = DefaultContainer<TransactionReceiptJson>(
|
||||||
TxId.from(parsed.transactionHash),
|
TxId.from(parsed.transactionHash),
|
||||||
BlockId.from(parsed.blockHash),
|
BlockId.from(parsed.blockHash),
|
||||||
|
|||||||
@@ -42,4 +42,17 @@ class CacheRequestedSpec extends Specification {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def "Ignore null"() {
|
||||||
|
setup:
|
||||||
|
def caches = Mock(Caches)
|
||||||
|
CacheRequested instance = new CacheRequested(caches)
|
||||||
|
def json = 'null'.bytes
|
||||||
|
|
||||||
|
when:
|
||||||
|
instance.cacheTxReceipt(["0x5929b36be4586c57bd87dfb7ea6be3b985c1f527fa3d69d221604b424aeb4197"], json)
|
||||||
|
|
||||||
|
then:
|
||||||
|
0 * caches.cacheReceipt(_, _)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user