alexstyl / contactstore

A modern, strongly-typed contacts API for Android.
https://alexstyl.github.io/contactstore
Apache License 2.0
440 stars 15 forks source link

Crash -> Error java.lang.NumberFormatException #16

Closed rbenza closed 2 years ago

rbenza commented 2 years ago

It seems you lib produces a crash when a user has an invalid phone number. See stack trace below. I made a PR for it to fix the issue: https://github.com/alexstyl/contactstore/pull/17

Caused by java.lang.NumberFormatException: For input string: ""
       at java.lang.Integer.parseInt(Integer.java:627)
       at java.lang.Integer.parseInt(Integer.java:650)
       at a.a.invoke(a.java:10)
       at com.alexstyl.contactstore.utils.CursorKt.iterate(CursorKt.java:10)
       at com.alexstyl.contactstore.ContactQueries.access$fetchAdditionalColumns(ContactQueries.java:10)
       at com.alexstyl.contactstore.ContactQueries$queryContacts$$inlined$map$1$2.emit(ContactQueries.java:10)
       at com.alexstyl.contactstore.ContactQueries$queryAllContacts$$inlined$map$1$2.emit(ContactQueries.java:62)
       at com.alexstyl.contactstore.utils.ContentResolverKt$runQueryFlow$$inlined$map$1$2.emit(ContentResolverKt.java:72)
       at kotlinx.coroutines.flow.internal.SafeCollectorKt$emitFun$1.invoke(SafeCollectorKt.java:1)
       at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.java:9)
       at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.java)
       at com.alexstyl.contactstore.utils.FlowExtensionsKt$a.invokeSuspend(FlowExtensionsKt.java:32)
       at com.alexstyl.contactstore.utils.FlowExtensionsKt$a.invoke(FlowExtensionsKt.java:2)
       at kotlinx.coroutines.flow.FlowKt__EmittersKt$onStart$$inlined$unsafeFlow$1.collect(FlowKt__EmittersKt.java:90)
       at com.alexstyl.contactstore.utils.ContentResolverKt$runQueryFlow$$inlined$map$1.collect(ContentResolverKt.java:21)
       at com.alexstyl.contactstore.ContactQueries$queryAllContacts$$inlined$map$1.collect(ContactQueries.java:5)
       at com.alexstyl.contactstore.ContactQueries$lookupFromMail$$inlined$map$1.collect$bridge(ContactQueries.java:5)
       at com.alexstyl.contactstore.ContactQueries$queryContacts$$inlined$map$1.collect(ContactQueries.java:11)
       at kotlinx.coroutines.flow.FlowKt__ReduceKt.firstOrNull(FlowKt__ReduceKt.java:1)
       at kotlinx.coroutines.flow.FlowKt.firstOrNull(FlowKt.java:1)
alexstyl commented 2 years ago

Thanks for raising this @rbenza . I have left a comment in your PR

alexstyl commented 2 years ago

Just merged this to main. It will be available in 0.7.0

Closing this as resolved