This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 87107 - addition of recursive import creates stack overflow
Summary: addition of recursive import creates stack overflow
Status: VERIFIED FIXED
Alias: None
Product: soa
Classification: Unclassified
Component: BPEL (show other bugs)
Version: 5.x
Hardware: All All
: P1 blocker (vote)
Assignee: Vitaly Bychkov
URL:
Keywords: REGRESSION
Depends on:
Blocks:
 
Reported: 2006-10-13 14:56 UTC by Michael Frisino
Modified: 2006-10-17 15:54 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Frisino 2006-10-13 14:56:45 UTC
Steps to reproduce:

Add a recursive import statement to any WSDL file.
For example add this to SynchronousSample.wsdl.

   <import location="SynchronousSample.wsdl"
namespace="http://localhost/SynchronousSample/SynchronousSample"/>
 

Now do anything that would cause the BPEL diagram ide to attempt to add import
for that WSDL file. 

For instance Add Correlation Set.

It will generate a stack overflow. 
See attachment in bug 87102.


This is not a duplicate of 87102 because 87102 is a separate problem. However,
both bugs were discovered at same time based on same scenario.
Comment 1 Michael Frisino 2006-10-13 15:12:21 UTC
Here is fix for the stack overflow problem.

--- ImportRegistrationHelper.java	22 Sep 2006 13:17:46 -0000	1.1.2.15
+++ ImportRegistrationHelper.java	13 Oct 2006 14:09:20 -0000	1.1.2.15.2.1
@@ -56,7 +56,11 @@
                 if (imps != null){
                     for (org.netbeans.modules.xml.wsdl.model.Import i: imps){
                         try {
+                            // check if the imported model is itself #87107
+                            Model tmpImpModel = i.getImportedWSDLModel();
+                            if (tmpImpModel != null &&
!(tmpImpModel.equals(i.getModel()))) {
                             addImport(i.getImportedWSDLModel());
+                            }
                         } catch (CatalogModelException ex) {
                             //Just ignore this type of exception
                         }




--------------------------------
Comment 2 Michael Frisino 2006-10-13 15:13:33 UTC
fix has been checked in by Vitaly to release55_dev
Comment 3 Michael Frisino 2006-10-13 15:29:49 UTC
I think the first fix does not go far enough to prevent recursive adds. 

If there is any cyclical import in any of the set of files, this fix will not
cover that case.

I propose adding a check to see if the target import file is already present in
the BPEL process imports list. If it is already present we should not add it
again, and we should not continue processing it recursively.
Comment 4 Michael Frisino 2006-10-13 17:19:24 UTC
here is vitaly's latest fix.

File [changed]: ResolverUtility.java
Url:
http://enterprise.netbeans.org/source/browse/enterprise/bpel/editors/src/org/netbeans/modules/bpel/properties/ResolverUtility.java?r1=1.1.2.26.2.1&r2=1.1.2.26.2.2
Delta lines:  +16 -2
--------------------
--- ResolverUtility.java	9 Oct 2006 19:22:02 -0000	1.1.2.26.2.1
+++ ResolverUtility.java	13 Oct 2006 16:17:08 -0000	1.1.2.26.2.2
@@ -302,6 +302,20 @@
      * Check if the specified model is imported to the current BPEL.
      */
     public static boolean isModelImported(Model model, Lookup lookup) {
+        BpelModel bpelModel = (BpelModel)lookup.lookup(BpelModel.class);
+        return isModelImported(model, bpelModel);
+    }
+    
+    /**
+     * Check if the specified model is imported to the current BPEL.
+     */
+    public static boolean isModelImported(Model model, BpelModel bpelModel) 
+        throws IllegalStateException 
+    {
+        if (model == null|| bpelModel == null) {
+            throw new IllegalStateException();
+        }
+        
         FileObject targetModelFo = (FileObject)model.getModelSource().
                 getLookup().lookup(FileObject.class);
         if (targetModelFo == null) {
@@ -310,9 +324,9 @@
                 return true;
             }
         } else {
-            FileObject bpelFolderFo = getBpelProcessFolder(lookup);
+            FileObject bpelFolderFo = getBpelProcessFolder(bpelModel);
             if (bpelFolderFo != null) {
-                BpelModel bpelModel = (BpelModel)lookup.lookup(BpelModel.class);
+
                 Import[] importArr = bpelModel.getProcess().getImports();
                 for (Import importObj : importArr) {
                     String location = importObj.getLocation();

File [changed]: ImportRegistrationHelper.java
Url:
http://enterprise.netbeans.org/source/browse/enterprise/bpel/editors/src/org/netbeans/modules/bpel/properties/ImportRegistrationHelper.java?r1=1.1.2.15.2.1&r2=1.1.2.15.2.2
Delta lines:  +11 -2
--------------------
--- ImportRegistrationHelper.java	13 Oct 2006 14:09:20 -0000	1.1.2.15.2.1
+++ ImportRegistrationHelper.java	13 Oct 2006 16:17:08 -0000	1.1.2.15.2.2
@@ -32,6 +32,7 @@
 import org.openide.ErrorManager;
 
 import org.openide.filesystems.FileObject;
+import org.openide.util.Lookup;
 
 /**
  *
@@ -58,8 +59,16 @@
                         try {
                             // check if the imported model is itself #87107
                             Model tmpImpModel = i.getImportedWSDLModel();
-                            if (tmpImpModel != null &&
!(tmpImpModel.equals(i.getModel()))) {
-                                addImport(i.getImportedWSDLModel());
+                            boolean isRequireImport = false;
+                            try {
+                                isRequireImport =
!ResolverUtility.isModelImported(tmpImpModel, model);
+                            } catch (IllegalStateException ex) {
+                                isRequireImport = false;
+                            }
+                            if (tmpImpModel != null &&
!(tmpImpModel.equals(i.getModel())) 
+                                && isRequireImport) 
+                            {
+                                addImport(tmpImpModel);
                             }
                         } catch (CatalogModelException ex) {
                             //Just ignore this type of exception
Comment 5 Vladimir Yaroslavskiy 2006-10-16 08:28:53 UTC
Fix looks well.
Comment 6 Alexey Yarmolenko 2006-10-16 11:24:44 UTC
Agreed with proposed fix.
Comment 7 Vitaly Bychkov 2006-10-16 11:48:40 UTC
Fixed
Comment 8 Vitaly Bychkov 2006-10-16 11:56:33 UTC
integrated into release55
Comment 9 Andrey Yamkovoy 2006-10-17 15:54:51 UTC
Looks like fixed ...