YamlFileResource requires an existing File

Open
#234 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
java
Domain
tooling

Research direction

Read Utils.createFileIfNotExists and its use in SettingsManagerBuilder, then inspect YamlFileResource#createReader and YamlFileReader#loadFile. Refactor the utility as described and use it when creating the reader so a missing configuration file no longer causes NoSuchFileException.

Written by the indexing model from the issue text.

Description

YamlFileResource#createReader calls YamlFileReader#loadFile which uses Files.newInputStream(path: Path) which will throw a NoSuchFileException if the File at that path does not exist.

SettingsManagerBuilder uses the Utils method Utils.createFileIfNotExists(path: Path) to avoid this scenario:
https://github.com/AuthMe/ConfigMe/blob/5f8aa2a4007348efaefbc9a41b740ffb6788bf25/src/main/java/ch/jalu/configme/SettingsManagerBuilder.java#L58

Refactoring this method to return the path, and using it inline here:
https://github.com/AuthMe/ConfigMe/blob/5f8aa2a4007348efaefbc9a41b740ffb6788bf25/src/main/java/ch/jalu/configme/resource/YamlFileResource.java#L53

Would probably be the best route for ensuring proper functionality of YamlFileResource as a whole.

Dominant language
Java
Stars
44
Forks
21
Avg merge
2d 2h
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AuthMe/ConfigMe

All issues in AuthMe/ConfigMe

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.