Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

[Bug]: NullPointerException: Null value passed for browser parameter to BrowseListener.serviceFound() #215

Open
2 tasks
phatblat opened this issue May 25, 2022 · 0 comments
Assignees
Labels

Comments

@phatblat
Copy link

What happened?

Ran across a crash running the Ditto Android test suite. Somehow it appears that a null value is being passed to the serviceFound() method of our anonymous BrowseListener implementation from the RxDNSSD library.

// dnssd: DNSSD?
browseService = dnssd!!.browse("_http-alt._tcp", object : BrowseListener {
    override fun serviceFound(
        browser: DNSSDService, flags: Int, ifIndex: Int,
        serviceName: String, regType: String, domain: String
    ) {
        searchingPrefix?.let { prefix ->
            DittoLog.d(TAG, "mDNS saw service $serviceName")
            // Ignore any _http-alt._tcp peers who are not Ditto. Their announce string comes after the prefix.
            if (!serviceName.startsWith(prefix)) {
                return
            }
            // Ignore ourselves
            if (serviceName == makeServiceNameForPrefix(prefix, announce)) {
                return
            }
            val params = ResolveParameters()
            params.flags = flags
            params.ifIndex = ifIndex
            params.serviceName = serviceName
            params.regType = regType
            params.domain = domain
            val announce = serviceName.substring(prefix.length)
            serviceInfo[announce] = params
            peerAppeared(announce)
        }
    }

    override fun serviceLost(
        browser: DNSSDService, flags: Int, ifIndex: Int,
        serviceName: String, regType: String, domain: String
    ) {
        searchingPrefix?.let { prefix ->
            DittoLog.i(TAG, "mDNS lost service $serviceName")
            if (serviceName.startsWith(prefix)) {
                val announce = serviceName.substring(prefix.length)
                peerDisappeared(announce)
            }
        }
    }

    override fun operationFailed(service: DNSSDService, errorCode: Int) {
        DittoLog.e(TAG, "mDNS browse error: $errorCode")
        browseFailed()
    }
})

Version

0.9.15

What API do you use?

Bindable (recommended)

What device / emulator do you use?

SM-G960U1

What Android API version is on your device?

29

Relevant log output

live.ditto.dittotests.DittoTests > dittoTransportDiagnostics[SM-G960U1 - 10] FAILED
java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter browser
at live.ditto.transports.MdnsPlatform$doStartSearching$1.serviceFound(Unknown Source:2)
Tests on SM-G960U1 - 10 failed: Instrumentation run failed due to 'Process crashed.'

Could you reproduce this issue in samples?

  • Yes, I can reproduce this issue in sample app of this repo?
  • Yes, I can reproduce this issue in Bonjour Browser?
@phatblat phatblat added the bug label May 25, 2022
@phatblat phatblat changed the title [Bug]: NullPointerException: Null value passed for browser parameter to BrowseListener.serviceFound() method [Bug]: NullPointerException: Null value passed for browser parameter to BrowseListener.serviceFound() May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants