Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the impossible downcast of toArray(). #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix the impossible downcast of toArray(). #125

wants to merge 1 commit into from

Commits on Oct 10, 2017

  1. Fix the impossible downcast of toArray().

    This code is casting the result of this.items.toArray() on a list to the String type.
    This will usually fail by throwing a ClassCastException. The toArray() of almost all collections return an Object[]. They can't really do anything else, since the Collection object has no reference to the declared generic type of the collection.
    
    The correct and efficient way to get a string  array from a list is to use list.toArray(new String[list.size()]);.
    http://findbugs.sourceforge.net/bugDescriptions.html#BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY
    Kui-Liu committed Oct 10, 2017
    Configuration menu
    Copy the full SHA
    0c69b64 View commit details
    Browse the repository at this point in the history