You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Michael Jouravlev (JIRA)" <ji...@apache.org> on 2007/02/17 03:47:16 UTC
[jira] Commented: (STR-2499) Throw exception when forward not found
[ https://issues.apache.org/struts/browse/STR-2499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_40161 ]
Michael Jouravlev commented on STR-2499:
----------------------------------------
I am with Frank on this one, but I suppose that starting throwing an exception after seven years of not doing so will break the backward compatibility. So, I am inclined to close this with "Won't Fix".
> Throw exception when forward not found
> --------------------------------------
>
> Key: STR-2499
> URL: https://issues.apache.org/struts/browse/STR-2499
> Project: Struts 1
> Issue Type: Improvement
> Components: Core
> Affects Versions: Future
> Environment: Operating System: All
> Platform: All
> Reporter: Frank W. Zammetti
> Priority: Minor
>
> Currently, when mapping.findForward() is called in an Action, and the named
> forward is not found (because of a typo, or perhaps because it is dynamically
> determined incorrectly), Struts returns null, which resuls in a blank page,
> and no indication to the developer about what went wrong.
> Someone, I forget who (sorry!) recently added some code to log a message in
> such a case, but that was after 1.2.7 was cut. That would be a step in the
> right direction, but I believe still not optimal.
> My feeling, echoed by some on the mailing lists, is that an exception should
> be thrown. The thinking is that such a situation really shouldn't happen in a
> production application, it should generally be a development-time problem, and
> as such should be easier to track down. Also, it is pretty much a showstopper
> kind of problem, i.e., not something an app would expect to recover from. As
> such, an exeption is probably more appropriate than just a log message.
> I propose the following change be made... in the ActionMapping class, alter
> the findForward() method as follows:
> /**
> * <p>Find and return the <code>ForwardConfig</code> instance defining
> * how forwarding to the specified logical name should be handled. This is
> * performed by checking local and then global configurations for the
> * specified forwarding configuration. If no forwarding configuration
> * can be found, return <code>null</code>.</p>
> *
> * @param name Logical name of the forwarding instance to be returned
> * @throws IllegalStateException If the forward is not found
> */
> public ActionForward findForward(String name) throws IllegalStateException {
> ForwardConfig config = findForwardConfig(name);
> if (config == null) {
> config = getModuleConfig().findForwardConfig(name);
> }
> if (null == config) {
> throw new IllegalStateException("Forward not found: " + name);
> }
> return ((ActionForward) config);
> }
> Arguably there is a more appropriate exception type than
> IllegalStateException, and I have no problem if someone has a better
> suggestion. This is clearly a trivial change, but one I believe will make
> life easier on developers
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.