Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Bug: AxePropCalculator assumes that className is non-null #127

Open
DaveTryon opened this issue Dec 14, 2020 · 0 comments · May be fixed by #128
Open

Bug: AxePropCalculator assumes that className is non-null #127

DaveTryon opened this issue Dec 14, 2020 · 0 comments · May be fixed by #128

Comments

@DaveTryon
Copy link

Accessibility Insights for Android is using Axe-Android 0.2.0, and we're seeing a failure from inside axe-android. Specifically, some app pages (like FlipGrid's camera mode) contain nodes where accessibilityNodeInfo.getClassName() returns null. Talkback seems to have no difficulty with these apps, but axe-android throws the following (line numbers reference the 0.2.0 tag):

java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference at
com.deque.axe.android.AxePropCalculator.getCalculatedProps(AxePropCalculator.java:56) at
com.deque.axe.android.AxeView.calculateProps(AxeView.java:429) at
com.deque.axe.android.AxeView.(AxeView.java:194) at
com.deque.axe.android.AxeView.(AxeView.java:208) at
com.deque.axe.android.AxeView$Builder.build(AxeView.java:156) at

The code in AxePropCalculator.getCalculatedProps() switches on className, which triggers a call to String.hashCode(), which throws if className happens to be null.

So the question: Is it valid for an AccessibilityNodeInfo object to return a null value for getClassName()? As far as I can tell, the Android developer docs don't specify whether or not this field can legitimately be null. If it can be null, then the switch statement probably needs to first check for a non-null value. If it can't be null, then perhaps that's a rule in and of itself.

Happy to provide a PR for this (including appropriate unit tests) if it's determined that null is a valid return value from getClassName().

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant