Good idea

On Fri, Nov 22, 2013 at 1:12 PM, Babak Vahdat
<babak.vah...@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: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to