You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Babak Vahdat <ba...@swissonline.ch> on 2013/11/22 13:12:14 UTC
About the commit for CAMEL-6689
http://git-wip-us.apache.org/repos/asf/camel/diff/405c74a2
Hi,
Probably instead of duplicating the SAME logic (having an exception
handling) 4 times again and again inside this class we could write a tiny
'private static' utility for this, something like:
private static String decode(String uri) {
try {
// try to decode as the uri may contain %20 for spaces etc
return URLDecoder.decode(uri, "UTF-8");
} catch (Exception e) {
LOG.debug("Could not decode the URI [" + uri + "]. This exception
will be ignored.", e);
return uri;
}
}
And then reuse the SAME logic as easy as:
uri = decode(uri);
Also if we intend to swallow an exception, maybe we should at least log
this @ debug level so the user has an idea about why decoding went wrong
(e.g. when UTF-32 encoding is in use).
Babak
Re: About the commit for CAMEL-6689 http://git-wip-us.apache.org/repos/asf/camel/diff/405c74a2
Posted by Claus Ibsen <cl...@gmail.com>.
Good idea
On Fri, Nov 22, 2013 at 1:12 PM, Babak Vahdat
<ba...@swissonline.ch> wrote:
> Hi,
>
> Probably instead of duplicating the SAME logic (having an exception
> handling) 4 times again and again inside this class we could write a tiny
> 'private static' utility for this, something like:
>
> private static String decode(String uri) {
> try {
> // try to decode as the uri may contain %20 for spaces etc
> return URLDecoder.decode(uri, "UTF-8");
> } catch (Exception e) {
> LOG.debug("Could not decode the URI [" + uri + "]. This exception
> will be ignored.", e);
> return uri;
> }
> }
>
> And then reuse the SAME logic as easy as:
>
> uri = decode(uri);
>
> Also if we intend to swallow an exception, maybe we should at least log
> this @ debug level so the user has an idea about why decoding went wrong
> (e.g. when UTF-32 encoding is in use).
>
> Babak
>
>
>
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen