You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Paul Benedict (JIRA)" <ji...@apache.org> on 2007/12/06 06:55:34 UTC

[jira] Created: (STR-3119) Standardize exceptions rethrows to contain root cause (JDK 5)

Standardize exceptions rethrows to contain root cause (JDK 5)
-------------------------------------------------------------

                 Key: STR-3119
                 URL: https://issues.apache.org/struts/browse/STR-3119
             Project: Struts 1
          Issue Type: Improvement
          Components: Core, Extras, Scripting, Taglibs, Tiles 1 Plugin
    Affects Versions: 1.1.1, 1.2.9, 1.3.8
         Environment: Operating System: All
Platform: All
            Reporter: Lukas Bradley
            Assignee: Paul Benedict
            Priority: Minor
             Fix For: 1.4.0


It would be exceptionally helpful if the Struts project were to standardize
throughout development that all caught exceptions that are to be re-thrown
should contain the root cause unless a clearly stated, specific reason exists to
not do so.

For example, in org.apache.struts.taglib.tiles.InsertTag on any Exception within
doEngTag(), the following occurs:

catch (ServletException e) {
  Throwable cause = e;
  if (e.getRootCause() != null) {
     cause = e.getRootCause();
  }
  String msg = "ServletException in '" + page + "': " + cause.getMessage();
  log.error(msg, e);
  throw new JspException(msg);
}

It would be rather simple to do the following for the last line:

  throw new JspException(msg, e);

While the root exception message is logged, this information is not available to
an upper-level application layer.  For example, if a custom SecurityException is
thrown on a JSP or Tag, important information may be lost in the propogation of
this exception.

I have looked within the 1.2.6 beta codebase (as of today, 25 April 2005) and
the approach remains the same.

Note: I did not choose the "Tiles Framework" for this report's Component
purposefully.  In my opinion, it should be a standard coding procedure across
Struts, and possibly other Jakarta projects.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (STR-3119) Standardize exceptions rethrows to contain root cause (JDK 5)

Posted by "Paul Benedict (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/STR-3119?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Benedict updated STR-3119:
-------------------------------

          Description: STR-2437 added the root cause to exceptions as much as possible in JDK 1.4, but IllegalStateException and IllegalArgumentException do not participate in this practice until JDK 5.  (was: It would be exceptionally helpful if the Struts project were to standardize
throughout development that all caught exceptions that are to be re-thrown
should contain the root cause unless a clearly stated, specific reason exists to
not do so.

For example, in org.apache.struts.taglib.tiles.InsertTag on any Exception within
doEngTag(), the following occurs:

catch (ServletException e) {
  Throwable cause = e;
  if (e.getRootCause() != null) {
     cause = e.getRootCause();
  }
  String msg = "ServletException in '" + page + "': " + cause.getMessage();
  log.error(msg, e);
  throw new JspException(msg);
}

It would be rather simple to do the following for the last line:

  throw new JspException(msg, e);

While the root exception message is logged, this information is not available to
an upper-level application layer.  For example, if a custom SecurityException is
thrown on a JSP or Tag, important information may be lost in the propogation of
this exception.

I have looked within the 1.2.6 beta codebase (as of today, 25 April 2005) and
the approach remains the same.

Note: I did not choose the "Tiles Framework" for this report's Component
purposefully.  In my opinion, it should be a standard coding procedure across
Struts, and possibly other Jakarta projects.)
    Affects Version/s:     (was: 1.1.1)
                           (was: 1.2.9)
                           (was: 1.3.8)
                       1.4.0
             Reporter: Paul Benedict  (was: Lukas Bradley)
        Fix Version/s:     (was: 1.4.0)
                       Future

> Standardize exceptions rethrows to contain root cause (JDK 5)
> -------------------------------------------------------------
>
>                 Key: STR-3119
>                 URL: https://issues.apache.org/struts/browse/STR-3119
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core, Extras, Scripting, Taglibs, Tiles 1 Plugin
>    Affects Versions: 1.4.0
>         Environment: Operating System: All
> Platform: All
>            Reporter: Paul Benedict
>            Assignee: Paul Benedict
>            Priority: Minor
>             Fix For: Future
>
>
> STR-2437 added the root cause to exceptions as much as possible in JDK 1.4, but IllegalStateException and IllegalArgumentException do not participate in this practice until JDK 5.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (STR-3119) Standardize exceptions rethrows to contain root cause (JDK 5)

Posted by "Paul Benedict (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/STR-3119?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Benedict updated STR-3119:
-------------------------------

    Fix Version/s:     (was: Future)
                   1.4.0

Thanks Niall! That's the info I needed for JDK 1.4

> Standardize exceptions rethrows to contain root cause (JDK 5)
> -------------------------------------------------------------
>
>                 Key: STR-3119
>                 URL: https://issues.apache.org/struts/browse/STR-3119
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core, Extras, Scripting, Taglibs, Tiles 1 Plugin
>    Affects Versions: 1.4.0
>         Environment: Operating System: All
> Platform: All
>            Reporter: Paul Benedict
>            Priority: Minor
>             Fix For: 1.4.0
>
>
> STR-2437 added the root cause to exceptions as much as possible in JDK 1.4, but IllegalStateException and IllegalArgumentException do not participate in this practice until JDK 5.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (STR-3119) Standardize exceptions rethrows to contain root cause (JDK 5)

Posted by "Paul Benedict (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/STR-3119?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Benedict updated STR-3119:
-------------------------------

    Assignee:     (was: Paul Benedict)

> Standardize exceptions rethrows to contain root cause (JDK 5)
> -------------------------------------------------------------
>
>                 Key: STR-3119
>                 URL: https://issues.apache.org/struts/browse/STR-3119
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core, Extras, Scripting, Taglibs, Tiles 1 Plugin
>    Affects Versions: 1.4.0
>         Environment: Operating System: All
> Platform: All
>            Reporter: Paul Benedict
>            Priority: Minor
>             Fix For: Future
>
>
> STR-2437 added the root cause to exceptions as much as possible in JDK 1.4, but IllegalStateException and IllegalArgumentException do not participate in this practice until JDK 5.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (STR-3119) Standardize exception rethrows to contain root cause (initCause)

Posted by "Paul Benedict (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/STR-3119?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Benedict updated STR-3119:
-------------------------------

    Summary: Standardize exception rethrows to contain root cause (initCause)  (was: Standardize exception rethrows to contain root cause)

> Standardize exception rethrows to contain root cause (initCause)
> ----------------------------------------------------------------
>
>                 Key: STR-3119
>                 URL: https://issues.apache.org/struts/browse/STR-3119
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core, Extras, Scripting, Taglibs, Tiles 1 Plugin
>    Affects Versions: 1.4.0
>         Environment: Operating System: All
> Platform: All
>            Reporter: Paul Benedict
>            Assignee: Paul Benedict
>            Priority: Minor
>             Fix For: 1.4.0
>
>
> STR-2437 added the root cause to exceptions as much as possible in JDK 1.4, but IllegalStateException and IllegalArgumentException do not participate in this practice until JDK 5.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (STR-3119) Standardize exception rethrows to contain root cause

Posted by "Paul Benedict (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/STR-3119?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Benedict updated STR-3119:
-------------------------------

    Assignee: Paul Benedict
     Summary: Standardize exception rethrows to contain root cause  (was: Standardize exceptions rethrows to contain root cause (JDK 5))

> Standardize exception rethrows to contain root cause
> ----------------------------------------------------
>
>                 Key: STR-3119
>                 URL: https://issues.apache.org/struts/browse/STR-3119
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core, Extras, Scripting, Taglibs, Tiles 1 Plugin
>    Affects Versions: 1.4.0
>         Environment: Operating System: All
> Platform: All
>            Reporter: Paul Benedict
>            Assignee: Paul Benedict
>            Priority: Minor
>             Fix For: 1.4.0
>
>
> STR-2437 added the root cause to exceptions as much as possible in JDK 1.4, but IllegalStateException and IllegalArgumentException do not participate in this practice until JDK 5.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (STR-3119) Standardize exceptions rethrows to contain root cause (JDK 5)

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/STR-3119?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42785 ] 

Niall Pemberton commented on STR-3119:
--------------------------------------

Although some exceptions lack constructors which take a throwable the initCause(Throwable) method was added in JDK 1.4 - its slightly more verbose, but this can be done using JDK 1.4:

        IllegalStateException ex = new IllegalStateException("..");
        ex.initCause(cause);
        throw ex;


> Standardize exceptions rethrows to contain root cause (JDK 5)
> -------------------------------------------------------------
>
>                 Key: STR-3119
>                 URL: https://issues.apache.org/struts/browse/STR-3119
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core, Extras, Scripting, Taglibs, Tiles 1 Plugin
>    Affects Versions: 1.4.0
>         Environment: Operating System: All
> Platform: All
>            Reporter: Paul Benedict
>            Assignee: Paul Benedict
>            Priority: Minor
>             Fix For: Future
>
>
> STR-2437 added the root cause to exceptions as much as possible in JDK 1.4, but IllegalStateException and IllegalArgumentException do not participate in this practice until JDK 5.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (STR-3119) Standardize exception rethrows to contain root cause

Posted by "Paul Benedict (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/STR-3119?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Benedict resolved STR-3119.
--------------------------------

    Resolution: Fixed

Added initial cause to rethrown exceptions that do not accept the root cause in the constructor.

> Standardize exception rethrows to contain root cause
> ----------------------------------------------------
>
>                 Key: STR-3119
>                 URL: https://issues.apache.org/struts/browse/STR-3119
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core, Extras, Scripting, Taglibs, Tiles 1 Plugin
>    Affects Versions: 1.4.0
>         Environment: Operating System: All
> Platform: All
>            Reporter: Paul Benedict
>            Assignee: Paul Benedict
>            Priority: Minor
>             Fix For: 1.4.0
>
>
> STR-2437 added the root cause to exceptions as much as possible in JDK 1.4, but IllegalStateException and IllegalArgumentException do not participate in this practice until JDK 5.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.