Bug 247159 - Change Analyzer throws a NPE on valid parameter value types representing substiution values.
Summary: Change Analyzer throws a NPE on valid parameter value types representing subs...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Cosmos (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Jeff Hamm CLA
QA Contact:
URL:
Whiteboard:
Keywords: core
Depends on:
Blocks:
 
Reported: 2008-09-12 09:45 EDT by Jeff Hamm CLA
Modified: 2012-01-03 13:47 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Hamm CLA 2008-09-12 09:45:48 EDT
The is a issue with the change analyzer in that is does not handle param values correctly when those parameter values are defined as substitutional params. For example, for the the COSMOS SDD, a parameter option value was defined as $(APACHE)/$(PATH). This according to the SDD specification is a correct parameter value but does it causes the following NPE in the Change Analyzer.

I’m getting the following exception when trying to run the change analyzer with cosmos_sdd.xml and cosmos_pd.xml Jason pointed to below.

Exception in thread "main" java.lang.NullPointerException
      at org.eclipse.cosmos.me.internal.deployment.sdd.runtime.ca.util.GeneralUtility.getParamValues(GeneralUtility.java:92)
      at org.eclipse.cosmos.me.internal.deployment.sdd.runtime.ca.util.GeneralUtility.processVariablesValue(GeneralUtility.java:69)
      at org.eclipse.cosmos.me.internal.deployment.sdd.runtime.core.ca.sdd.VariablesImpl.processVariables(VariablesImpl.java:77)
      at org.eclipse.cosmos.me.internal.deployment.sdd.runtime.core.ca.logicalresourcecombination.LogicalResourceCombinationFactoryImpl.processVariables(LogicalResourceCombinationFactoryImpl.java:148)
      at org.eclipse.cosmos.me.internal.deployment.sdd.runtime.core.ca.logicalresourcecombination.InstallUnitCombinationProducerImpl.createLogicalResourceCombinationList(InstallUnitCombinationProducerImpl.java:170)
      at org.eclipse.cosmos.me.internal.deployment.sdd.runtime.core.ca.changeanalyzer.ChangeAnalyzerControllerImpl.processAction(ChangeAnalyzerControllerImpl.java:82)
      at org.eclipse.cosmos.me.internal.deployment.sdd.runtime.core.ca.changeanalyzer.businessdelegate.ChangeAnalyzerDelegate.invokeController(ChangeAnalyzerDelegate.java:65)
      at org.eclipse.cosmos.me.internal.deployment.sdd.runtime.core.ca.changeanalyzer.ChangeAnalyzerImpl.execute(ChangeAnalyzerImpl.java:49)
      at org.eclipse.cosmos.me.internal.deployment.sdd.runtime.core.ca.changeanalyzer.ChangeAnalyzerImpl.main(ChangeAnalyzerImpl.java:63)

It appears to be getting a null when doing a lookup of “AXIS2_LOCATION” in “variableMap”, which from the debugger appears to contain the following at the time of the lookup:

{axis2Location=$(AXIS2_LOCATION)/$(PATH), birtLocation=$(BIRT_LOCATION), dojoLocation=$(DOJO_LOCATION), installLocation=$(INSTALL_LOCATION), tomcatLocation=$(TOMCAT_LOCATION)}

-Brad

From: Jason Losh [mailto:Jason.Losh@sas.com] 
Sent: Wednesday, September 10, 2008 1:29 PM
To: Merri Jensen; Beck, Bradley C; Jeff Hamm
Subject: RE: Cosmos ME: ChangeAnalyzer_Tuscany.zip...

Hi,

Jeff and I have been using the COSMOS example SDD as well.  Both the deployment descriptor and package descriptor are attached to this ER.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=231811

Let me know if you have any other questions.

Thanks,
-Jason

From: Merri Jensen 
Sent: Wednesday, September 10, 2008 12:32 PM
To: Beck, Bradley C; Jason Losh
Subject: RE: Cosmos ME: ChangeAnalyzer_Tuscany.zip...

Brad-

Take a look at the Word doc inside the zip.  I’ve included below the package descriptor for the shopping cart example given in the Doc.  For the deployment descriptor in the doc you will need to add “id” attributes to the ResourceConstraints defined under the DerivedVariable Element with “id=SelectedDatabase”.  I’m using the cd04 versions of the SDD schemas.  If you don’t have copies of the SDD schema files, I’ll put them out for you as well, just let me know.  You’ll need to change the xsi:schemaLocation attribute in both files to point to your copies of the SDD schema files.  The SDD TC is working on getting the web versions fixed so that they will work, but the fixes have not been put in place yet.

<?xml version="1.0" encoding="UTF-8"?>
<sdd-pd:PackageDescriptor 
    xmlns:sdd-pd="http://docs.oasis-open.org/sdd/ns/packageDescriptor" 
    xmlns:sdd-common="http://docs.oasis-open.org/sdd/ns/common" 
    xmlns:ds="http://www.w3.org/2000/09/xmldsig#" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://docs.oasis-open.org/sdd/ns/packageDescriptor C:\Development\OASIS\cl1_schema\cd04\cd04-sdd-packageDescriptor-1.0.xsd http://docs.oasis-open.org/sdd/ns/common C:\Development\OASIS\cl1_schema\cd04\cd04-sdd-common-1.0.xsd"
    descriptorID="30001111111111111111111111111111" 
    lastModified="2006-10-07T09:30:00.0Z" 
    schemaVersion="1.0">
    <sdd-pd:PackageIdentity softwareID="5786-345" packageType="baseInstall">
        <sdd-common:Description>A Shopping Cart Application</sdd-common:Description>
        <sdd-common:Name>Shopping Cart</sdd-common:Name>
        <sdd-common:Version>6.0.2.3</sdd-common:Version>
        <sdd-common:Manufacturer>
            <sdd-common:Name>IBM Corporation</sdd-common:Name>
            <sdd-common:Location>
                <sdd-common:Address>1133 Westchester Avenue White Plains, New York 10604</sdd-common:Address>
                <sdd-common:Country>U.S.A.</sdd-common:Country>
            </sdd-common:Location>
        </sdd-common:Manufacturer>
    </sdd-pd:PackageIdentity>
    <sdd-pd:Contents>
        <sdd-pd:Content pathname="shoppingcart_dd.xml" id="DD" purpose="deploymentDescriptor"/>
        <sdd-pd:Content pathname="files/shoppingcart.war" id="InstallProgramsInstallArtifact" purpose="content"/>
    </sdd-pd:Contents>
</sdd-pd:PackageDescriptor>

-Merri


From: Beck, Bradley C [mailto:Bradley.Beck@ca.com] 
Sent: Wednesday, September 10, 2008 12:00 PM
To: Jason Losh
Cc: Merri Jensen
Subject: RE: Cosmos ME: ChangeAnalyzer_Tuscany.zip...

Jason,

Thanks, I downloaded the zip with no problem. Do you have some package and deployment descriptor that you know work as an example?

Thanks
-Brad
________________________________________
From: Jason Losh [mailto:Jason.Losh@sas.com] 
Sent: Wednesday, September 10, 2008 10:39 AM
To: Beck, Bradley C; Merri Jensen
Subject: RE: Cosmos ME: ChangeAnalyzer_Tuscany.zip...

Hi Brad,

You should be able to get the change analyzer from ftp://ftp.sas.com/outgoing/changeAnalyzer/ChangeAnalyzer_Tuscany.zip.

If prompted for credentials, you can use anonymous ftp by specifying a username of anonymous and a password which is your email address.

It takes about 30 minutes for this to mirror out to the site so you should be able to see it around noon.

Let Merri or I know if you run into issues.

Thanks,
-Jason

From: Beck, Bradley C [mailto:Bradley.Beck@ca.com] 
Sent: Monday, September 08, 2008 4:39 PM
To: Jason Losh
Subject: Cosmos ME: ChangeAnalyzer_Tuscany.zip...

Jason,

Can you send me the ChangeAnalyzer_Tuscany.zip that is referenced in the wiki page?

Thanks,

Bradley Beck
CA 
Sr Software Architect 
Tel: +1-952-838-1002
Bradley.Beck@ca.com
Comment 1 Jeff Hamm CLA 2008-09-16 11:32:23 EDT
Fix to GeneralUtility.java under org.eclipse.cosmos.me.internal.deployment.sdd.runtime.ca.util to getParamValues() method to allow for checking of variable map expressions.


--Original Code --

		for (int i = 1; i < result.length; i++) {
			String expr = result[i].substring(0, result[i].indexOf(")"))
			.toString();
			//    System.out.println("expr - "+expr);
			String val = variableMap.get(expr).toString();
			//    System.out.println("Val  - "+val);
			if (val.indexOf("$") != -1)
				getParamValues(Key, val, variableMap);
			if (val.indexOf("\\") != -1)
				val = val.replaceAll("\\\\", "\\#");
			value = value.replaceAll("\\$\\(" + expr + "\\)", val);
			value = value.replaceAll("\\#", "\\\\");
			variableMap.put(Key, value);
		}


--- New Code --


			String expr = result[i].substring(0, result[i].indexOf(")")).toString();

			
			Object o = variableMap.get(expr);
			String val = null;
			if(o != null) {
				val = o.toString();
				//System.out.println("Val - "+ val);
				if (val.indexOf("$") != -1) {
					getParamValues(Key, val, variableMap);
				}
				if (val.indexOf("\\") != -1) {
					val = val.replaceAll("\\\\", "\\#");
				}
				value = value.replaceAll("\\$\\(" + expr + "\\)", val);
				value = value.replaceAll("\\#", "\\\\");
				variableMap.put(Key, value);
			}