You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Adam Heath <do...@brainfood.com> on 2010/02/05 02:00:37 UTC

Re: svn commit: r898721 - /ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java

erwan@apache.org wrote:
> Author: erwan
> Date: Wed Jan 13 11:26:13 2010
> New Revision: 898721
> 
> URL: http://svn.apache.org/viewvc?rev=898721&view=rev
> Log:
> fix test to avoid NPE
> 
> Modified:
>     ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java
> 
> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java?rev=898721&r1=898720&r2=898721&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java (original)
> +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java Wed Jan 13 11:26:13 2010
> @@ -144,7 +144,7 @@
>          Map generalProperties = UtilProperties.getProperties("general");
>          while (it.hasNext()) {
>              Map.Entry pairs = (Map.Entry) it.next();

This is bad generiics.  UtilProperties.getProperties() returns
Properties, which extends Hashtable<Object, Object>.  The cast below
could throw a CCE.

On that note, since generalProperties has Object for it's keys, you
don't have to cast at all.

> -            if (pairs.getValue().equals("DEFAULT")) {
> +            if ("DEFAULT".equals(pairs.getValue())) {
>                  if (UtilValidate.isNotEmpty(generalProperties.get(pairs.getKey()))) {
>                      userPrefMap.put((String) pairs.getKey(), generalProperties.get(pairs.getKey()));
>                  }
> 
>