camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luca Burgazzoli <lburgazz...@gmail.com>
Subject Re: Camel 3.0 ideas: Remove throws Exception from API signatures and use unchecked exceptions
Date Thu, 27 Oct 2016 10:53:05 GMT
This may be an interesting read:
https://vanilla-java.github.io/2016/06/21/Reviewing-Exception-Handling.html

---
Luca Burgazzoli


On Thu, Oct 27, 2016 at 12:47 PM, Nicola Ferraro <ni.ferraro@gmail.com> wrote:
> Of course, if this targets 3.0 and so we don't have to care much about
> backward compatibility, removing checked exception from the API is
> something worth doing.
>
> On Thu, Oct 27, 2016 at 12:37 PM, Nicola Ferraro <ni.ferraro@gmail.com>
> wrote:
>
>> My 2 cents.
>>
>> A fake "throws Exception" put in place "for future usage" can be removed
>> IMO. But turning an exception into a RuntimeException may affect a route
>> behaviour if the Camel API you're talking about is available for the end
>> users in DSL (eg. error handling policies).
>>
>> So, we should analyze it case by case.
>>
>> On the other hand, I see that some functional transformations (eg.
>> https://github.com/apache/camel/blob/master/camel-core/
>> src/main/java/org/apache/camel/builder/ExpressionClause.java#L155-L161)
>> can also accept a checked function or supplier.
>>
>> I mean, we can solve the problem almost like the Javaslang guys did
>> (greatly !) for the Java collections: https://github.
>> com/javaslang/javaslang/blob/master/javaslang/src/main/
>> java/javaslang/control/Try.java#L728-L743.
>>
>>
>>
>> On Wed, Oct 26, 2016 at 6:47 PM, Antonin Stefanutti <antonin@stefanutti.fr
>> > wrote:
>>
>>> Hi,
>>>
>>> Would you think that makes sense to remove the 'throws Exception' from a
>>> number of Camel API signatures as well as using unchecked exceptions
>>> instead?
>>>
>>> While this may be a matter of opinion still debated, there are a couple
>>> resources that gives some guidelines on the topic and that may help
>>> answering that question:
>>>
>>> - "How to Design a Good API and Why it Matters" presentation and
>>> "Effective Java" from Joshua Bloch
>>> - https://docs.oracle.com/javase/tutorial/essential/exceptions
>>> /runtime.html
>>>
>>> I raise the question as I've encountered yet another case where checked
>>> exceptions fail to deliver on their promises, that is with functional
>>> interfaces (stream, lambda, ...) introduced in Java 8. There is a lot of
>>> resources out there describing the problem in details:
>>>
>>> - http://stackoverflow.com/questions/27644361/how-can-i-throw-
>>> checked-exceptions-from-inside-java-8-streams.
>>> - http://literatejava.com/exceptions/checked-exceptions-javas-
>>> biggest-mistake/
>>>
>>> Hence the question. WDYT?
>>>
>>> Antonin
>>
>>
>>

Mime
View raw message