Jump to content
  • Incorrect override of getCause in JRException


    tcloonan
    Assigned User teodord
    CategoryBug report
    PriorityLow
    ReproducibilityAlways
    ResolutionFixed
    SeverityTrivial
    StatusClosed

    Original issue moved from:

    https://sourceforge.net/tracker/index.php?func=detail&aid=1462594&group_id=36382&atid=416703

     

    Consult the original issue for any attachments.

     

    [ 1462594 ] Incorrect override of getCause in JRException

     

    Submitted By: Gunnar Grim - gugrim

    Date Submitted: 2006-04-01 01:11

    Last Updated By: ionutned - Comment added

    Date Last Updated: 2006-04-17 02:02

    Number of Comments: 1

    Number of Attachments: 0

     

    Assigned To: Nobody/Anonymous

    Priority: 5

     

    Summary:

    Incorrect override of getCause in JRException

     

    I believe the implementation of getCause in JRException is incorrect:

     

    public Throwable getCause()

    {

    return this.nestedThrowable;

    }

     

    If a JRException is caught and then has its cause set using initCause, subsequent calls to getCause will still return null. The following implementation should solve this problem:

     

    public Throwable getCause()

    {

    if (this.nestedThrowable != null)

    return this.nestedThrowable;

    else

    return super.getCause();

    }

     

    An alternative would of course be to just drop the nestedThrowable and use the JDK support for nested throwables.

     

    Comments

     

    Date: 2006-04-17 02:02

    Sender: ionutned

    Logged In: YES

    user_id=1247959

     

    We cannot use JDK support for nested throwables, because methods like getCause() and initCause() were introduced in JDK1.4 and JasperReports is 1.3 compatible.

     

     

    No Files Currently Attached



    User Feedback

    Recommended Comments

     

    Hi,

     

    After doring some more reseach on this, it indeed looks like there is no solution for making the JR exception be fully compatible with the JDK1.4 exceptions, as far as the getCause() method is concerned.

    There is no way of calling JDK1.4 implementation of this method, if available.

    The only fix that we made to the exceptions was to detect the version of the JDK and adapt the way the content of the stack trace is printed, to avoid duplication of information there.

     

    We consider this closed, as the motives for this bug report tell us about a rather unusual way of dealing with exceptions and we are not going to support them because of the above mentioned reasons.

     

    Thank you,

    Teodor

     

    Link to comment
    Share on other sites


×
×
  • Create New...