Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C60D9200BAA for ; Thu, 27 Oct 2016 12:38:13 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C4BB1160AF6; Thu, 27 Oct 2016 10:38:13 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 14117160AE4 for ; Thu, 27 Oct 2016 12:38:12 +0200 (CEST) Received: (qmail 46615 invoked by uid 500); 27 Oct 2016 10:38:12 -0000 Mailing-List: contact dev-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list dev@camel.apache.org Received: (qmail 46603 invoked by uid 99); 27 Oct 2016 10:38:11 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Oct 2016 10:38:11 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 4EBF6180682 for ; Thu, 27 Oct 2016 10:38:11 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.679 X-Spam-Level: * X-Spam-Status: No, score=1.679 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id OQ9ow1VxP9S8 for ; Thu, 27 Oct 2016 10:38:07 +0000 (UTC) Received: from mail-lf0-f46.google.com (mail-lf0-f46.google.com [209.85.215.46]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id C313D5FCA2 for ; Thu, 27 Oct 2016 10:38:01 +0000 (UTC) Received: by mail-lf0-f46.google.com with SMTP id f134so22312417lfg.2 for ; Thu, 27 Oct 2016 03:38:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=r38SrSd3QpBdjGRQDn5h4aY55gyRPA+J4xWx2KA9Y4Q=; b=ZFUaZyo7tQX8z9m0TIZ+wl5+YS4EJk5xlxHtWVHqpWGYR/3az+Kb/9l4ySulkPy65H P7evJ8wfAp9poZA9SaPM9xvMvThIR9XIi5h4e6dXc9OW4KweDNCe+jmU4+iDHqpU1wM+ hIxt3qZSbvlkAZoITxXmNoti8Dl9CjlWref6io+iK2wd+AFKf2NgRYBMGnqRTtyYGNbe lhYe+nnFNjQ4sr8qHQeAAHottAnJP6p6KYY4tjMR4d344xWhuBJkuXkqM5JA2gayjHCf yj8KcktiiqXB8dQ4cbMdYON+9CDMW1RYokqGLlx/2h8xROE7RnnxeivrIhCVyCpbfXtw yGIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=r38SrSd3QpBdjGRQDn5h4aY55gyRPA+J4xWx2KA9Y4Q=; b=icmKNIVktYDtjL18vxdCWCwcxp+SJAk2jNggNxiQXdHRLZnot9M014nCIL4I/SOvSj OX4Yre2ezRuEocLjtHHv38zT6Mg0dWuOtBdX73+UolgFUIWeAYfLDy02yPe6SaGdCj10 J4TXLF1rnDdAoxP/I4XlIg6BPrsSJ7ZI+IuZBsmUW6K5knoh+WKT4HIFWLMlthEyeNog ATdGJgOdUi3CGYmSoVekVfDGyNjeM0Od9sSHS4a9IuE519WRm4pFP7k69FghLluvmJ1u DoHAth51/PqRekCOwAeK+OOj4t4aDcp1VKz06EviAZtSc1ztZe0HTXAVy49ahViws33h PtZw== X-Gm-Message-State: ABUngvdTYEVHyZNy0OiHewnassOn2CuJHh08EsV+wE84WDJbGAWoxNhbP3SG+xRKSV66vA== X-Received: by 10.25.32.67 with SMTP id g64mr4850493lfg.180.1477564680217; Thu, 27 Oct 2016 03:38:00 -0700 (PDT) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com. [209.85.215.51]) by smtp.gmail.com with ESMTPSA id s78sm1158863lfs.33.2016.10.27.03.37.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Oct 2016 03:37:59 -0700 (PDT) Received: by mail-lf0-f51.google.com with SMTP id x79so27174813lff.0 for ; Thu, 27 Oct 2016 03:37:59 -0700 (PDT) X-Received: by 10.25.170.83 with SMTP id t80mr5712953lfe.25.1477564679150; Thu, 27 Oct 2016 03:37:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.114.79.40 with HTTP; Thu, 27 Oct 2016 03:37:58 -0700 (PDT) In-Reply-To: <03FFAD4B-CFDF-4317-96F7-1CA482A9B966@stefanutti.fr> References: <03FFAD4B-CFDF-4317-96F7-1CA482A9B966@stefanutti.fr> From: Nicola Ferraro Date: Thu, 27 Oct 2016 12:37:58 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Camel 3.0 ideas: Remove throws Exception from API signatures and use unchecked exceptions To: dev@camel.apache.org Content-Type: multipart/alternative; boundary=001a113db07ad573cb053fd6558b archived-at: Thu, 27 Oct 2016 10:38:14 -0000 --001a113db07ad573cb053fd6558b Content-Type: text/plain; charset=UTF-8 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 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 --001a113db07ad573cb053fd6558b--