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

FileConfig failIfMissing parameter is used wrongly #38

Closed
twinprime opened this issue Oct 11, 2017 · 2 comments
Closed

FileConfig failIfMissing parameter is used wrongly #38

twinprime opened this issue Oct 11, 2017 · 2 comments

Comments

@twinprime
Copy link

I think the intended behavior of the class is to throw an exception if the given file is not found by default (which is inline with the spirit of Typesafe config) but it is currently doing the reverse.

open class FileConfig(val file: File, val failIfMissing: Boolean = true) : ConfigLoader() {
    override fun load(): Config {
        val options = ConfigParseOptions.defaults().setAllowMissing(failIfMissing)
        return ConfigFactory.parseFileAnySyntax(file, options)
    }
}

I think it should be corrected as such but it will cause backward compatibility issues:

val options = ConfigParseOptions.defaults().setAllowMissing(!failIfMissing)

The other option is to rename the parameter to "allowMissing" in order to maintain backward compatibility.

Same issue for many other classes in the same file.

@apatrida
Copy link
Contributor

thanks, I think it is best to have it work by how the parameter is named, since most people probably coded to the name and not the actual functionality (if they tested it at all, they likely would have reported it as you did). I'll go into a new version with a feature bump and anyone watching this issue will see it go into the release.

@apatrida
Copy link
Contributor

Fixed in 2.4.0 as mentioned above, so the meaning of the flags now matches the naming, you need to update your code if you changed it for actual behaviour versus how the API was defined.

2.4.0 is being released now.

apatrida added a commit that referenced this issue Feb 24, 2018
clean build files
update copyright dates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants