Uploaded image for project: 'Railo'
  1. Railo
  2. RAILO-2516

Improve error handling of railo.commons.io.cache.Cache.getCacheEntry(String)

    Details

    • Type: Enhancement
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Rejected
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:

      Description

      This is in regards to writing a custom cache extension that implements the interface: railo.commons.io.cache.Cache

      The method getCacheEntry(String key) is to throw an exception of type IOException "when entry does not exist or is stale". That's fine, and easy to implement but the problem is that for every cache miss, I get an error dumped into my logs. In addition to the overhead of file I/O for every miss, I don't want all those entries in my logs for what is basically an expected and recoverable error. Now, that being said, if my cache provider does run into some other non-recoverable error that prevents it from being able to access the underlying cache engine and needs to throw that error, I would like it to be in the logs.

      Therefore, I would like to submit the idea that the getCacheEntry methods throw two types of exceptions, a new one called KeyNotFound and the standard IOException.

      This will allow Railo to differentiate between a recoverable exception that doesn't need to be logged (KeyNotFound) and something bad that should be logged, and hopefully rethrown (IOException).

      This is a similar approach I am already taking in my cache provider so I can tell the difference between an exception that simply indicates the key was not found and an exception that means something really bad happened.

      try{		    
      	// Try to get the item.
      	...
      	//If not found
      	throw(new KeyNotFoundException("Key [" + key + "] was not found"));
      }catch(KeyNotFoundException e){
      	// nothing to see here, just move along
      	throw(new IOException("Error retrieving key [" + key + "] from Couchbase cache.",e));
      }catch(Throwable e){
      	// This is not good-- please log whatever happened
      	log.error(e);
      	throw(new IOException("Error retrieving key [" + key + "] from Couchbase cache.",e));
      }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                micstriit Michael Offner
                Reporter:
                bdw429s Brad Wood
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: