You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by se...@apache.org on 2004/08/27 02:59:29 UTC

cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/modules/actions LogoutUser.java

seade       2004/08/26 17:59:29

  Modified:    src/java/org/apache/turbine/modules/actions Tag:
                        TURBINE_2_3_BRANCH LogoutUser.java
  Log:
  Commons Configuration no longer returns a default value but throws an exception if a property is missing and no default value is given.
  How many of these are we yet to find?
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.11.2.3  +2 -2      jakarta-turbine-2/src/java/org/apache/turbine/modules/actions/LogoutUser.java
  
  Index: LogoutUser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/actions/LogoutUser.java,v
  retrieving revision 1.11.2.2
  retrieving revision 1.11.2.3
  diff -u -r1.11.2.2 -r1.11.2.3
  --- LogoutUser.java	20 May 2004 03:03:53 -0000	1.11.2.2
  +++ LogoutUser.java	27 Aug 2004 00:59:29 -0000	1.11.2.3
  @@ -75,7 +75,7 @@
   
           Configuration conf = Turbine.getConfiguration();
   
  -        data.setMessage(conf.getString(TurbineConstants.LOGOUT_MESSAGE));
  +        data.setMessage(conf.getString(TurbineConstants.LOGOUT_MESSAGE, ""));
   
           // This will cause the acl to be removed from the session in
           // the Turbine servlet code.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/modules/actions LogoutUser.java

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
"Eric Pugh" <ep...@upstate.com> writes:

>Getting a nice exception immediatly tells me that I misconfigured
>something..  Maybe  teh ConfigurationFactory was wrong, or something else..
>And I know where to go to fix it.  getting a NPE doesn't help so much...

I understand this. However, from an users point of view, using a
pre-1.0 release for a number of years (!)  and then suddently getting
an exception from a code part that has never thrown an exception
before (but is reported to return null if the property does not
exist), will annoy users, that simply exchange a
commons-configuration-<some random snapshot> jar for the
commons-configuration-1.0.jar. Getting these exceptions from released
jars like the turbine-2.3 or torque-3.1 will not help, either. :-)

Hibernate e.g. took the pragmatic approach. You have one method that
might return null ( Session.get(Class, Serializable) ) and another
that throws an exception if the requested object does not exist
(Session.find(Class, Serializable).

	Regards
		Henning
-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

"Fighting for one's political stand is an honorable action, but re-
 fusing to acknowledge that there might be weaknesses in one's
 position - in order to identify them so that they can be remedied -
 is a large enough problem with the Open Source movement that it
 deserves to be on this list of the top five problems."
                       -- Michelle Levesque, "Fundamental Issues with
                                    Open Source Software Development"

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


RE: cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/modules/actions LogoutUser.java

Posted by Eric Pugh <ep...@upstate.com>.
In so far as changing c-c to have getVector() etc, I'm pretty happy with it.
Or, at least, I understand the logic and don't want to totally piss off the
users!  My problem with not throwing an exception for missing values is that
it really can bury all sorts of problems.

The whole reason for being able to return a default value:
getString("my.value","default string"); is to provide the defaults.  Doing
this: getString("my.value") and returning null is just wrong..  my app will
crash with an obscure NullPointerException somewhere just because I forgot
to specify my.value.   c-c assumes that the values are there, otherwise if
the value may/maynot be there, then user the default, or do hasKey(); to
check...

Getting a nice exception immediatly tells me that I misconfigured
something..  Maybe  teh ConfigurationFactory was wrong, or something else..
And I know where to go to fix it.  getting a NPE doesn't help so much...

While we could go with the "throw Exception,return Null" switch, it just
feels to me like it is muddying things up...  It would be better to have
explicit defaults instead, or, accept that a ConfigurationException is a
good thing when a key is missing and you aren't doing hasKey();

ERic

> -----Original Message-----
> From: Henning P. Schmiedehausen [mailto:hps@intermeta.de]
> Sent: Tuesday, September 07, 2004 12:16 PM
> To: turbine-dev@jakarta.apache.org
> Subject: Re: cvs commit:
> jakarta-turbine-2/src/java/org/apache/turbine/modules/actions
> LogoutUser.java
>
>
> seade@apache.org writes:
>
> >seade       2004/08/26 17:59:29
>
> >  Modified:    src/java/org/apache/turbine/modules/actions Tag:
> >                        TURBINE_2_3_BRANCH LogoutUser.java
> >  Log:
> >  Commons Configuration no longer returns a default value but
> throws an exception if a property is missing and no default value
> is given.
> >  How many of these are we yet to find?
>
> Emmanuel and I basically agree, that we revert the behaviour of C-c
> back. We only need to convince Eric. ;-) However, it is still a good
> thing to spot all these.
>
> An explicit search might be nice before the 2.3.1 release. I put it on
> my todo-list.
>
> Another nit: I try to remove the usage of "magic" values in the
> code. So changing this to
>
> data.setMessage(conf.getString(TurbineConstants.LOGOUT_MESSAGE,
> TurbineConstants.LOGOUT_MESSAGE_DEFAULT));
>
> and a
>
> /** The default Logout Message */
> public static final String LOGOUT_MESSAGE_DEFAULT = "";
>
> in TurbineConstants
>
> would help with this.
>
> 	Regards
> 		Henning
>
> --
> Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
> hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/
>
> RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
>    Linux, Java, perl, Solaris -- Consulting, Training, Development
>
> "Fighting for one's political stand is an honorable action, but re-
>  fusing to acknowledge that there might be weaknesses in one's
>  position - in order to identify them so that they can be remedied -
>  is a large enough problem with the Open Source movement that it
>  deserves to be on this list of the top five problems."
>                        -- Michelle Levesque, "Fundamental Issues with
>                                     Open Source Software Development"
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/modules/actions LogoutUser.java

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
seade@apache.org writes:

>seade       2004/08/26 17:59:29

>  Modified:    src/java/org/apache/turbine/modules/actions Tag:
>                        TURBINE_2_3_BRANCH LogoutUser.java
>  Log:
>  Commons Configuration no longer returns a default value but throws an exception if a property is missing and no default value is given.
>  How many of these are we yet to find?

Emmanuel and I basically agree, that we revert the behaviour of C-c
back. We only need to convince Eric. ;-) However, it is still a good
thing to spot all these.

An explicit search might be nice before the 2.3.1 release. I put it on
my todo-list.

Another nit: I try to remove the usage of "magic" values in the
code. So changing this to

data.setMessage(conf.getString(TurbineConstants.LOGOUT_MESSAGE, TurbineConstants.LOGOUT_MESSAGE_DEFAULT));

and a 

/** The default Logout Message */
public static final String LOGOUT_MESSAGE_DEFAULT = "";

in TurbineConstants

would help with this.

	Regards
		Henning

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

"Fighting for one's political stand is an honorable action, but re-
 fusing to acknowledge that there might be weaknesses in one's
 position - in order to identify them so that they can be remedied -
 is a large enough problem with the Open Source movement that it
 deserves to be on this list of the top five problems."
                       -- Michelle Levesque, "Fundamental Issues with
                                    Open Source Software Development"

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org