Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 207763

Summary: Exception when de-serializing nested Common Base Event XML fragments/documents.
Product: z_Archived Reporter: Paul Slauenwhite <paulslau>
Component: TPTPAssignee: Rohit Shetty <rohit.shetty>
Status: CLOSED FIXED QA Contact:
Severity: critical    
Priority: P1 CC: apnan, danap, grothens, jkubasta, paulslau, rohit.shetty
Version: unspecifiedKeywords: plan
Target Milestone: ---Flags: paulslau: review-
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
CBE XML Files.
none
Patch for bug 207763
none
Consolidated patch
none
Updated test cases
none
Updated tests - With CBE verification
none
4.2.1 patch for 207763 and 207806
none
Bugzilla_207763_Test.java none

Description Paul Slauenwhite CLA 2007-10-29 08:20:46 EDT
Exception when de-serializing nested Common Base Event XML fragments/documents.

When de-serializing nested Common Base Event XML fragments/documents from the any element, a NullPointerException is thrown:


	System.out.println("Reading the 1st CBE.");
			FileInputStream is1 = new FileInputStream(new File(OUTER_CBE));
			CommonBaseEvent[] cbes1 = EventFormatter.eventsFromCanonicalXMLDoc(is1);

			System.out.println("Reading the 2nd CBE.");
			FileInputStream is2 = new FileInputStream(new File(OUTER_CBE));
			CommonBaseEvent[] cbes2 = EventFormatter.eventsFromCanonicalXMLDoc(is2);

			CommonBaseEvent containing = cbes1[0];
			String nestedElement = 
				"<diag:diagnosticInformation xmlns:diag=\"http://www.ibm.com/xmlns/prod/websphere/monitoring/6.1.0/diagnosticInformation\">" + 
				EventFormatter.toCanonicalXMLDocString(cbes2).substring(38) +  // 38 characters removes the superfluous "<?xml version="1.0" encoding="UTF-8"?>"
				"\n</diag:diagnosticInformation>";
			
			System.out.println("#####NESTED_ELEMENT\n" + nestedElement + "\n\n");
			System.out.println("#####CONTAINING BEFORE NEST\n" + EventFormatter.toCanonicalXMLDocString(containing) + "\n\n");
			
			containing.addAny(nestedElement);
		
			String containingAsString = EventFormatter.toCanonicalXMLDocString(containing);
			System.out.println("#####CONTAINING AFTER NEST\n" + EventFormatter.toCanonicalXMLDocString(containing) + "\n\n");
			
			try {
				System.out.println("Reading the nested CBE using event formatter.");
				ByteArrayInputStream nestedStream = new ByteArrayInputStream(containingAsString.getBytes("UTF-8"));
				CommonBaseEvent[] nestedCBEs = EventFormatter.eventsFromCanonicalXMLDoc(nestedStream);
				
				System.out.println("#####CONTAINING CBE USING EVENT FORMATTER\n" + EventFormatter.toCanonicalXMLDocString(nestedCBEs) + "\n\n");
			} catch (Exception e) {
				System.err.println("ERROR USING EVENT FORMATTER!!!!!! " + e.toString());
				e.printStackTrace();
			}
Comment 1 Paul Slauenwhite CLA 2007-10-29 08:21:44 EDT
Sicne 4.5 i1 development is closed, will complete in 4.5 i2.
Comment 2 Paul Slauenwhite CLA 2007-11-06 08:24:44 EST
Reassign to Project Lead for triage.
Comment 3 Paul Slauenwhite CLA 2007-11-07 18:29:39 EST
Correcting target.
Comment 4 Alex Nan CLA 2007-11-18 15:24:52 EST
Can you please provide a sample CBE XML that I can use to reproduce this problem.
Comment 5 Paul Slauenwhite CLA 2007-11-19 07:05:54 EST
Created attachment 83228 [details]
CBE XML Files.

These files are used by the code snippet in the defect description.
Comment 6 Alex Nan CLA 2007-11-20 01:12:42 EST
Created attachment 83306 [details]
Patch for bug 207763

Attaching patch.
Comment 7 Alex Nan CLA 2007-11-20 01:15:14 EST
Paul, please review the attached patch.
Comment 8 Paul Slauenwhite CLA 2007-11-20 14:31:51 EST
This patch is fine except:

-org.eclipse.osgi.baseadaptor.bundlefile.NestedDirBundleFile cannot be used since the Common Base Event implementation currently supports a stand-alone use case and OSGi is not currently required. 

-We should resolve this in the non-EMF Java implementation as well.

-We need to handle the same scenario where the XML fragment is embedded in the OtherSituation element.

-We also need test cases for nested XML fragment in none,both,either/or of the any and OtherSituation elements.
Comment 9 Alex Nan CLA 2007-11-21 22:07:42 EST
Rohit please take a look at the fix, I don't have time to spend on this defect anymore. Some of the old CBE logging test cases are failing, which means the fix has affected existing function. It's the CommonBaseEvent any element which doesn't seem to be handled correctly, see test case testEventsFromCanonicalXMLDoc_String at step 2A, count ==11.
Thanks.
Comment 10 Rohit Shetty CLA 2007-11-25 02:57:16 EST
Created attachment 83712 [details]
Consolidated patch

Consolidated patch that fixes the problem described by Alex and has the fix for Bugzilla 207806.
Comment 11 Rohit Shetty CLA 2007-11-25 02:58:25 EST
Created attachment 83713 [details]
Updated test cases

Updated/Consolidated test cases which includes tests for 207806
Comment 12 Rohit Shetty CLA 2007-11-25 02:59:31 EST
Alex,
Can you please have a look at this consolidated patch.
Comment 13 Rohit Shetty CLA 2007-11-29 07:47:18 EST
Created attachment 84055 [details]
Updated tests - With CBE verification
Comment 14 Paul Slauenwhite CLA 2007-12-03 13:04:07 EST
(In reply to comment #8)
> This patch is fine except:
> 
> -org.eclipse.osgi.baseadaptor.bundlefile.NestedDirBundleFile cannot be used
> since the Common Base Event implementation currently supports a stand-alone use
> case and OSGi is not currently required. 
> 
> -We should resolve this in the non-EMF Java implementation as well.
> 
> -We need to handle the same scenario where the XML fragment is embedded in the
> OtherSituation element.
> 
> -We also need test cases for nested XML fragment in none,both,either/or of the
> any and OtherSituation elements.
> 

Alex/Rohit, can you confirm if these have been addressed?
Comment 15 Alex Nan CLA 2007-12-03 14:24:26 EST
Yes, they have been. We are still waiting from an answer from Websphere, I don't know yet if they need the fix in 4.4.1 or not. If I'm not getting an answer soon I will retarget the defect to 4.5.
Comment 16 jkubasta CLA 2007-12-05 12:29:06 EST
Alex, I have just spoken with the consuming product.  They would like a patch provided for 4.2.1.  So, would you please have a patch created for 4.2.x and 4.3.x and then request approval for this fix to be included in 4.4.1?  The 4.2.1 patch is urgently needed (ie in the next day or two).
Comment 17 Alex Nan CLA 2007-12-05 12:37:22 EST
We have a 4.4.1 patch which was tested. I need to port it to 4.2.1. Since the problem they have is on 4.2.1 I think a 4.2.1 patch would be sufficient. Not sure if I need to ask for 4.4.1 approval, I have asked last week and approval was denied.
Comment 18 Alex Nan CLA 2007-12-06 11:06:52 EST
Created attachment 84635 [details]
4.2.1 patch for 207763 and 207806

Attaching consolidated patch for 207763 and 207806 ported to 4.2.1.
Comment 19 jkubasta CLA 2007-12-09 10:10:20 EST
Please check patch for 4.5 into head and resolve this defect as fixed.  PMC approval not granted for 4.4.1
Comment 20 Alex Nan CLA 2007-12-10 10:49:43 EST
Joanna, I am retargettting the defect to 4.5 i5 and checking in the fix in i5. This fix is not neccessarily needed in the M4 driver. Do you agree?
Comment 21 jkubasta CLA 2007-12-10 11:25:47 EST
Agree. Target updated.
Comment 22 Alex Nan CLA 2008-01-09 16:17:30 EST
Fix checked in.
Comment 23 Paul Slauenwhite CLA 2008-02-12 09:10:55 EST
Did this fix make it into I5?  The enclosed test class using the attached CBE XML files is still throwing exceptions.
Comment 24 Paul Slauenwhite CLA 2008-02-12 09:11:21 EST
Created attachment 89498 [details]
Bugzilla_207763_Test.java
Comment 25 Alex Nan CLA 2008-02-12 09:38:31 EST
It looks like I forgot to check in the patch.
Comment 26 Alex Nan CLA 2008-02-12 17:36:29 EST
Patch checked in.
Comment 27 Gabi Rothestein CLA 2008-04-02 14:17:53 EDT
WPS/WAS are seeing the problem under TPTP 4.2.1
Comment 28 Paul Slauenwhite CLA 2008-06-10 09:55:53 EDT
Verified in TPTP-4.5.0-200806070100.  Closing.