Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-1289

JDBCCustomFinderQuery hides ObjectNotFoundException

    XMLWordPrintable

Details

    Description

      When a custom finder method returns an ObjectNotFoundException, the exception is logged as an error and re-wrapped inside a more generic FinderException.

      There are two problems here:
      1) The hiding of the ObjectNotFoundException
      2) The extra logging of an error level message, the application code might be expecting an ObjectNotFound exception (test for existance) and does not require logging...

      The following is a code snippet that shows a diff between the current code and a potential fix:

      /cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java - Line #134

      ***************

          • 134,143 ****
            }
            catch(InvocationTargetException e) { ! log.error("Error invoking custom finder " + finderMethod.getName(), ! e.getTargetException()); ! throw new FinderException("Errror invoking cutom finder " + ! finderMethod.getName() + ": " + e.getTargetException()); }

            }

      — 134,149 ----
      }
      catch(InvocationTargetException e)
      {
      ! Throwable t = e.getTargetException();
      ! if (t instanceof FinderException)

      { ! // Just quietly rethrow the original finder exception... ! throw (FinderException)t; ! }

      else

      { ! log.error("Error invoking custom finder " + finderMethod.getName( ), ! t); ! throw new FinderException("Errror invoking cutom finder " + ! finderMethod.getName() + ": " + t); ! }

      }
      }

      Attachments

        Activity

          People

            starksm64 Scott Stark (Inactive)
            ddeucher_jira David Deuchert (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: