Uploaded image for project: 'Commons BeanUtils'
  1. Commons BeanUtils
  2. BEANUTILS-241

BeanComparator throws wrong exception and hides cause

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.6
    • 1.8.0
    • None
    • None

    Description

      BeanComparator does this:

      catch ( Exception e )

      { throw new ClassCastException( e.toString() ); }

      In my case, it was a getter throwing an exception, so it wasnt a ClassCastException, but BeanComparator threw as such. I couldnt see what the real exception was since the exception was not propagated as cause. I recommend:

      catch(Exception e) {
      if (e instanceof RuntimeException)

      { throw (RuntimeException)e; }

      //if this isnt available in the java version you are targetting, the above line will improve things...
      throw new RuntimeException(e);
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            mchyzer Chris Hyzer
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: