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

Bug 325430

Summary: XmlExtendedMetadata: infinite recursion for package using ##targetNamespace
Product: [Modeling] MDT.BPMN2 Reporter: Henning Heitkoetter <hheitkoetter>
Component: CoreAssignee: Project Inbox <mdt-bpmn2-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Henning Heitkoetter CLA 2010-09-16 06:04:09 EDT
XmlExtendedMetadata.getNamespace is called for every EPackage that needs to appear in the namespace declarations of the serialized file. Our special version ensures that the namespace without "-XMI" is used (see comments 8-11 of bug 316591).

It does so by iterating over the structural features and using their namespace. However, if an EPackage uses metadata on references that has namespace=##targetNamespace, XmlExtendedMetadata is called again by BasicExtendedMetadata.basicGetNamespace, leading to an infinite recursion. This appears for example with the XMLTypePackage. (Packages other than the BPMN packages can for example be used because of ItemDefinition.structureRef.)

As the goal of our overriding implementation is removing the "-XMI" for the 4 EPackages defined in our plugin, we could test for these and simply remove the -XMI part instead of inspecting the features.

Like this, with some safeguards in order to only handle only "our" packages:
  String result = super.getNamespace(ePackage);
  if (result.endsWith("-XMI"))
    result = result.substring(0, result.length() - 4);
  return result;
  
What do you think? Am I overlooking something?
Comment 1 Henning Heitkoetter CLA 2010-09-24 04:11:36 EDT
Fixed in 185aac9fc8a676ce7fedb187df02bdd56da1f889.