Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.6k stars 594 forks source link

Proposal: make UnirestException a RuntimeException #181

Closed ryber closed 5 years ago

ryber commented 7 years ago

Hello, A few months ago I started using UniRest and I have mostly enjoyed it. The one criticism is that UnirestException is checked. I would like to propose that it be changed to a RuntimeException for the following reasons:

  1. Checked exceptions do not work well (or at all) with Java 8 streams and poorly with lambdas in general without writing your own checkable function library. This makes using Unirest in a stream or lambda painful
  2. UnirestException is generic in of itself and provides no clue about what you want the developer to do in case it happens without unpacking the exception to look at the "real reason". As such it's no better than a RuntimeException and is far more annoying.
  3. Checked Exceptions have mostly been abandoned as a failure by pretty much every post-java language in existence. https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=checked%20exceptions%20are%20evil
luanzhu commented 7 years ago

+1 Totally agree, runtime exceptions instead of checked exceptions will make UniRest even more enjoyable to use!

mmaryo commented 7 years ago

+1

mmaryo commented 7 years ago

a pull request https://github.com/Mashape/unirest-java/pull/184

mmaryo commented 7 years ago

No developement since 11 month !

jacek99 commented 6 years ago

+1 having checked exceptions is so 1995 in Java. Please change to RuntimeException

T3rm1 commented 6 years ago

I agree with you. There is no reason to have a generic checked exception. Looks like this project is dead though. Are there any other lightweight libraries for rest?

ryber commented 6 years ago

OpenFeign is quite nice and very very testable (It was originally created by Netflix):

https://github.com/OpenFeign/feign

It's the only thing I use for full production systems now. I do still like Unirest for hacking around and playing with APIs though because I can manipulate things much faster than with Feign (not that it's THAT hard to change an interface signature.

ryber commented 6 years ago

I've been trying to get someone at Mashape to let me maintain this thing because it still has value and more importantly has some pressing security issues due to the old version of HttpClient it uses. I can't get anyone to answer me though.

ryber commented 5 years ago

Hello, this should be resolved or addressed in Unirest 2. Please see the upgrade guide for important changes.