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/11/30 23:27:33 UTC
Re: svn commit: r1033928 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java
On 11/11/2010 07:08 AM, ashish@apache.org 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();
>
>
Re: svn commit: r1033928 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java
Posted by Scott Gray <sc...@hotwaxmedia.com>.
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, ashish@apache.org 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();
>>>>
>>>>
>>>
>>
>
Re: svn commit: r1033928 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java
Posted by Adam Heath <do...@brainfood.com>.
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, ashish@apache.org 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();
>>>
>>>
>>
>
Re: svn commit: r1033928 - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java
Posted by Scott Gray <sc...@hotwaxmedia.com>.
On 1/12/2010, at 11:27 AM, Adam Heath wrote:
> On 11/11/2010 07:08 AM, ashish@apache.org 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();
>>
>>
>