Bug 526497 - Config methods should throw checked Exceptions instead of IllegalArgumentExceptions
Summary: Config methods should throw checked Exceptions instead of IllegalArgumentExce...
Status: NEW
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X
: P3 enhancement (vote)
Target Milestone: 5.0   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 526503
  Show dependency tree
 
Reported: 2017-10-26 06:59 EDT by Matthias Sohn CLA
Modified: 2020-03-03 18:03 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Sohn CLA 2017-10-26 06:59:11 EDT
Config methods should throw checked Exceptions instead of IllegalArgumentExceptions in case of invalid values: a user can easily introduce invalid values into .git/config. This does not represent an internal or API usage error. The current API, which is using IllegalArgumentException, makes it very hard to detect and handle such cases.

see https://dev.eclipse.org/mhonarc/lists/jgit-dev/msg03445.html
Comment 1 Marc Strapetz CLA 2018-05-17 13:31:24 EDT
I've uploaded a draft patch 119970 now to Gerrit, requesting for comments.
Comment 2 Marc Strapetz CLA 2020-03-03 18:03:27 EST
I'd like to bring this up again. Maybe we can address this problem as part of a larger concept, as discussed in:

https://www.eclipse.org/lists/jgit-dev/msg03582.html

(1) In a first step, we could introduce JGitException (extends Exception) and have ConfigInvalidException deriving from it.

(2) In a second step we could introduce ConfigIllegalValueException (extends JGitException), as a substitute for the problematic IAEs. At the same time we would generalize "throws ConfigInvalidException" to "throws JGitException" where both kinds of Exceptions would occur.

Checked JGitException should be used at least throughout the entire org.eclipse.jgit.internal package. At boundaries to other packages, we can convert into RuntimeExceptions to stay backwards compatible as far as possible. For example, for org.eclipse.jgit.transport, as suggested at:

https://www.eclipse.org/lists/jgit-dev/msg03588.html