title: recursively call a method but log only second time?
body: <p>I have a below method which does URL decoding on the value passed along with using charset.</p>
  
  <pre><code>  public String decodeValue(String value, Charset charset) {
      if (!Strings.isNullOrEmpty(value)) {
        try {
          value = URLDecoder.decode(value, charset.name());
        } catch (UnsupportedEncodingException ex) {
          // log error
          return null;
        }
      }
      return value;
    }
  </code></pre>
  
  <p>Now if <code>URLDecoder.decode</code> line throws <code>UnsupportedEncodingException</code> first time then I want to run same <code>value</code> against below three lines:</p>
  
  <pre><code>value = value.replaceAll("%(?![0-9a-fA-F]{2})", "%25");
  value = value.replaceAll("\\+", "%2B");
  value = URLDecoder.decode(value, charset.name());
  </code></pre>
  
  <p>And if then again <code>URLDecoder.decode</code> line throws exception second time, then I will log the error but only second time and return null value otherwise return the value which is decoded.</p>
  
  <p>What is the best and elegant way to do this?</p>