Re: svn commit: r1033928 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r1033928 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java

Adam Heath-2
On 11/11/2010 07:08 AM, [hidden email] wrote:
> Author: ashish
> Date: Thu Nov 11 13:08:38 2010
> New Revision: 1033928
>
> URL: http://svn.apache.org/viewvc?rev=1033928&view=rev
> Log:
> Fixing NPE. Thanks Pranay!

In what situations would this NPE occur?

>
> Modified:
>      ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java
>
> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java?rev=1033928&r1=1033927&r2=1033928&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java (original)
> +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java Thu Nov 11 13:08:38 2010
> @@ -32,6 +32,7 @@ import org.ofbiz.base.util.GeneralExcept
>   import org.ofbiz.base.util.UtilDateTime;
>   import org.ofbiz.base.util.UtilMisc;
>   import org.ofbiz.base.util.UtilProperties;
> +import org.ofbiz.base.util.UtilValidate;
>   import org.ofbiz.common.KeywordSearchUtil;
>   import org.ofbiz.content.data.DataResourceWorker;
>   import org.ofbiz.entity.Delegator;
> @@ -182,10 +183,11 @@ public class KeywordIndex {
>                   }
>               }
>           }
> -
> -        for (String str: strings) {
> -            // call process keywords method here
> -            KeywordSearchUtil.processKeywordsForIndex(str, keywords, separators, stopWordBagAnd, stopWordBagOr, removeStems, stemSet);
> +        if (UtilValidate.isNotEmpty(strings)) {
> +            for (String str: strings) {
> +                // call process keywords method here
> +                KeywordSearchUtil.processKeywordsForIndex(str, keywords, separators, stopWordBagAnd, stopWordBagOr, removeStems, stemSet);
> +            }
>           }
>
>           List<GenericValue>  toBeStored = FastList.newInstance();
>
>

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r1033928 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java

Scott Gray-2
On 1/12/2010, at 11:27 AM, Adam Heath wrote:

> On 11/11/2010 07:08 AM, [hidden email] wrote:
>> Author: ashish
>> Date: Thu Nov 11 13:08:38 2010
>> New Revision: 1033928
>>
>> URL: http://svn.apache.org/viewvc?rev=1033928&view=rev
>> Log:
>> Fixing NPE. Thanks Pranay!
>
> In what situations would this NPE occur?
Ooh ooh, I think I know the answer to this one! Is it when strings is null?

>>
>> Modified:
>>     ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java
>>
>> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java?rev=1033928&r1=1033927&r2=1033928&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java (original)
>> +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java Thu Nov 11 13:08:38 2010
>> @@ -32,6 +32,7 @@ import org.ofbiz.base.util.GeneralExcept
>>  import org.ofbiz.base.util.UtilDateTime;
>>  import org.ofbiz.base.util.UtilMisc;
>>  import org.ofbiz.base.util.UtilProperties;
>> +import org.ofbiz.base.util.UtilValidate;
>>  import org.ofbiz.common.KeywordSearchUtil;
>>  import org.ofbiz.content.data.DataResourceWorker;
>>  import org.ofbiz.entity.Delegator;
>> @@ -182,10 +183,11 @@ public class KeywordIndex {
>>                  }
>>              }
>>          }
>> -
>> -        for (String str: strings) {
>> -            // call process keywords method here
>> -            KeywordSearchUtil.processKeywordsForIndex(str, keywords, separators, stopWordBagAnd, stopWordBagOr, removeStems, stemSet);
>> +        if (UtilValidate.isNotEmpty(strings)) {
>> +            for (String str: strings) {
>> +                // call process keywords method here
>> +                KeywordSearchUtil.processKeywordsForIndex(str, keywords, separators, stopWordBagAnd, stopWordBagOr, removeStems, stemSet);
>> +            }
>>          }
>>
>>          List<GenericValue>  toBeStored = FastList.newInstance();
>>
>>
>


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r1033928 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java

Adam Heath-2
On 11/30/2010 05:11 PM, Scott Gray wrote:

> On 1/12/2010, at 11:27 AM, Adam Heath wrote:
>
>> On 11/11/2010 07:08 AM, [hidden email] wrote:
>>> Author: ashish
>>> Date: Thu Nov 11 13:08:38 2010
>>> New Revision: 1033928
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1033928&view=rev
>>> Log:
>>> Fixing NPE. Thanks Pranay!
>>
>> In what situations would this NPE occur?
>
> Ooh ooh, I think I know the answer to this one! Is it when strings is null?

But in what circumstance would strings be null?  Note the lack of
context before the patch.

>
>>>
>>> Modified:
>>>      ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java
>>>
>>> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java?rev=1033928&r1=1033927&r2=1033928&view=diff
>>> ==============================================================================
>>> --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java (original)
>>> +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java Thu Nov 11 13:08:38 2010
>>> @@ -32,6 +32,7 @@ import org.ofbiz.base.util.GeneralExcept
>>>   import org.ofbiz.base.util.UtilDateTime;
>>>   import org.ofbiz.base.util.UtilMisc;
>>>   import org.ofbiz.base.util.UtilProperties;
>>> +import org.ofbiz.base.util.UtilValidate;
>>>   import org.ofbiz.common.KeywordSearchUtil;
>>>   import org.ofbiz.content.data.DataResourceWorker;
>>>   import org.ofbiz.entity.Delegator;
>>> @@ -182,10 +183,11 @@ public class KeywordIndex {
>>>                   }
>>>               }
>>>           }
>>> -
>>> -        for (String str: strings) {
>>> -            // call process keywords method here
>>> -            KeywordSearchUtil.processKeywordsForIndex(str, keywords, separators, stopWordBagAnd, stopWordBagOr, removeStems, stemSet);
>>> +        if (UtilValidate.isNotEmpty(strings)) {
>>> +            for (String str: strings) {
>>> +                // call process keywords method here
>>> +                KeywordSearchUtil.processKeywordsForIndex(str, keywords, separators, stopWordBagAnd, stopWordBagOr, removeStems, stemSet);
>>> +            }
>>>           }
>>>
>>>           List<GenericValue>   toBeStored = FastList.newInstance();
>>>
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r1033928 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java

Scott Gray-2
On 1/12/2010, at 12:13 PM, Adam Heath wrote:

> On 11/30/2010 05:11 PM, Scott Gray wrote:
>> On 1/12/2010, at 11:27 AM, Adam Heath wrote:
>>
>>> On 11/11/2010 07:08 AM, [hidden email] wrote:
>>>> Author: ashish
>>>> Date: Thu Nov 11 13:08:38 2010
>>>> New Revision: 1033928
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=1033928&view=rev
>>>> Log:
>>>> Fixing NPE. Thanks Pranay!
>>>
>>> In what situations would this NPE occur?
>>
>> Ooh ooh, I think I know the answer to this one! Is it when strings is null?
>
> But in what circumstance would strings be null?  Note the lack of context before the patch.
Good point, now that I actually go and look at a longer diff this fix shouldn't be necessary at all.  strings is initialized with a FastList instance and isn't nulled anywhere that I can see.

>>
>>>>
>>>> Modified:
>>>>     ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java
>>>>
>>>> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java
>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java?rev=1033928&r1=1033927&r2=1033928&view=diff
>>>> ==============================================================================
>>>> --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java (original)
>>>> +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java Thu Nov 11 13:08:38 2010
>>>> @@ -32,6 +32,7 @@ import org.ofbiz.base.util.GeneralExcept
>>>>  import org.ofbiz.base.util.UtilDateTime;
>>>>  import org.ofbiz.base.util.UtilMisc;
>>>>  import org.ofbiz.base.util.UtilProperties;
>>>> +import org.ofbiz.base.util.UtilValidate;
>>>>  import org.ofbiz.common.KeywordSearchUtil;
>>>>  import org.ofbiz.content.data.DataResourceWorker;
>>>>  import org.ofbiz.entity.Delegator;
>>>> @@ -182,10 +183,11 @@ public class KeywordIndex {
>>>>                  }
>>>>              }
>>>>          }
>>>> -
>>>> -        for (String str: strings) {
>>>> -            // call process keywords method here
>>>> -            KeywordSearchUtil.processKeywordsForIndex(str, keywords, separators, stopWordBagAnd, stopWordBagOr, removeStems, stemSet);
>>>> +        if (UtilValidate.isNotEmpty(strings)) {
>>>> +            for (String str: strings) {
>>>> +                // call process keywords method here
>>>> +                KeywordSearchUtil.processKeywordsForIndex(str, keywords, separators, stopWordBagAnd, stopWordBagOr, removeStems, stemSet);
>>>> +            }
>>>>          }
>>>>
>>>>          List<GenericValue>   toBeStored = FastList.newInstance();
>>>>
>>>>
>>>
>>
>


smime.p7s (3K) Download Attachment