Fix null-pointer vulnerability and restore Android compatibility #1495
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The loop checking the list of input extensions passed as a constructor parameter was blindly calling getClass() on any element in the list. This is not null safe and broke compatibility with some Android versions.
Change the code to a null-safe instanceof check, which also restores Android compatibility.
Fixes Issue #1353.
Description
Simple one-liner fix to make the code more robust and restore Android compatibility.
Related Issue
This fixes the crash on some Android versions:
java.lang.IncompatibleClassChangeError: The method 'java.lang.Class java.lang.Object.getClass()' was expected to be of type interface but instead was found to be of type virtual (declaration of 'org.java_websocket.drafts.Draft_6455')
as reported in #1353
Motivation and Context
It restores Android compatibility and makes the code more robust.
How Has This Been Tested?
Tested on Android 8.0 and verified to cure the crash shown above.
Types of changes
Checklist: