Scarab commit: svn commit: r10725 - trunk/src/java/org/tigris/scarab/om

Hussayn Dabbous <[email protected]>
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: dabbous
Date: 2009-05-21 04:10:52-0700
New Revision: 10725

Modified:
   trunk/src/java/org/tigris/scarab/om/AttributeGroup.java
   trunk/src/java/org/tigris/scarab/om/AttributeValue.java

Log:
(Maybe related to SCB2620) I found a potential NPE source. It may be related to NPE's during remove of AttributeGroups...

Modified: trunk/src/java/org/tigris/scarab/om/AttributeGroup.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/om/AttributeGroup.java?view=diff&pathrev=10725&r1=10724&r2=10725
==============================================================================
--- trunk/src/java/org/tigris/scarab/om/AttributeGroup.java	(original)
+++ trunk/src/java/org/tigris/scarab/om/AttributeGroup.java	2009-05-21 04:10:52-0700
@@ -279,7 +279,7 @@
                      attribute.getAttributeId());
            
             List resultList = RAttributeAttributeGroupPeer.doSelect(crit);
-            if(resultList != null)
+            if(resultList != null && resultList.size() > 0)
             {
                 result = (RAttributeAttributeGroup)resultList.get(0);
                 ScarabCache.put(result, this, GET_R_ATTRIBUTE_ATTRGROUP, 
@@ -592,16 +592,19 @@
                                                             AttributePeer.NON_USER);    
                     final RModuleAttribute rma = module
                         .getRModuleAttribute(attribute, issueType);
-                    rma.delete();
+                    if(rma != null)rma.delete();
                     WorkflowFactory.getInstance().deleteWorkflowsForAttribute
                                                   (attribute, module, issueType);
-                    rmas.remove(rma);
+                    if(rma != null)rmas.remove(rma);
 
                     // Remove attribute - module mapping from template type
                     final RModuleAttribute rma2 = module
                                    .getRModuleAttribute(attribute, template);
-                    rma2.delete();
-                    rmas.remove(rma2);
+                    if(rma2 != null)
+                    {
+                        rma2.delete();
+                        rmas.remove(rma2);
+                    }
                 }
             }
 

Modified: trunk/src/java/org/tigris/scarab/om/AttributeValue.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/om/AttributeValue.java?view=diff&pathrev=10725&r1=10724&r2=10725
==============================================================================
--- trunk/src/java/org/tigris/scarab/om/AttributeValue.java	(original)
+++ trunk/src/java/org/tigris/scarab/om/AttributeValue.java	2009-05-21 04:10:52-0700
@@ -660,26 +660,34 @@
         return rma;
     }
     
-	public String getDisplayValue()
-	    throws TorqueException
-	{
-		String displayValue = null;
-		
-		if(getAttribute().isOptionAttribute())
-	    {
-			displayValue = getIssue().getModule().getRModuleOption( getAttributeOption(), getIssue().getIssueType()).getDisplayValue();
-			//displayValue = getRModuleAttribute().getDisplayValue();
-	    }
-		else if(getAttribute().isUserAttribute())
-		{
-			displayValue = getScarabUser().getUserName();
-		}
-	    else
-	    {
-	    	displayValue = getValue();
-	    }
-		return displayValue;
-	}
+    public String getDisplayValue()
+    throws TorqueException
+    {
+        String displayValue = null;
+
+        if(getAttribute().isOptionAttribute())
+        {
+            try
+            {
+                displayValue = getIssue().getModule().getRModuleOption( getAttributeOption(), getIssue().getIssueType()).getDisplayValue();
+                //displayValue = getRModuleAttribute().getDisplayValue();
+            }
+            catch (NullPointerException npe)
+            {
+                // Something wrong in the database ?
+                displayValue="";
+            }
+        }
+        else if(getAttribute().isUserAttribute())
+        {
+            displayValue = getScarabUser().getUserName();
+        }
+        else
+        {
+            displayValue = getValue();
+        }
+        return displayValue;
+    }
 
 
     public AttributeOption getAttributeOption()
@@ -874,4 +882,4 @@
         setUserId(attVal1.getUserId());
         setValue(attVal1.getValue());
     }
-}
\ No newline at end of file
+}

------------------------------------------------------
http://scarab.tigris.org/ds/viewMessage.do?dsForumId=3577&dsMessageId=2348108
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.