Skip to content

STGroupFile constructor suppresses exceptions #204

@bobflannigon

Description

@bobflannigon

Passing in a null URL into this constructor does not fail:
STGroupFile(URL url, String encoding, delimiterStartChar, char delimiterStopChar)

This constructor: STGroupFile(String fileName, char delimiterStartChar, char delimiterStopChar) will throw a MalformedURLException if the file cannot be found.

Inconsistent behaviour aside, this constructor allows us to instantiate the STGroupFile with a null URL, meaning that we can call load(), mark the alreadyLoaded flag as true, load will fail and the STGroupFile Object is in a state from which we can never recover or easily find out what went wrong.

Required Fix:

  1. Fix the constructors so they throw the same exceptions (in particular MalformedURLException, preferably IllegalArgumentException for nulls).

Nice-to-have:

  1. Fix load so that if loading fails the alreadyLoaded flag is reset, and throw an exception from this method that isn't just a NullPointerException.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions