Bug 334395
Sporadic NPE on synchronizing WS model under heavy load
diff --git a/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/sync/SeiSynchronizer.java b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/sync/SeiSynchronizer.java
index 98efa72..8d360b9 100755
--- a/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/sync/SeiSynchronizer.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/sync/SeiSynchronizer.java
@@ -1,81 +1,85 @@
-/*******************************************************************************
- * Copyright (c) 2009 by SAP AG, Walldorf.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.ws.jaxws.dom.runtime.persistence.sync;
-
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.DomPackage;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.IServiceEndpointInterface;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebService;
-import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebServiceProject;
-import org.eclipse.jst.ws.jaxws.dom.runtime.persistence.IAnnotationSerializer;
-import org.eclipse.jst.ws.jaxws.dom.runtime.persistence.IModelElementSynchronizer;
-import org.eclipse.jst.ws.jaxws.utils.annotations.IAnnotation;
-import org.eclipse.jst.ws.jaxws.utils.annotations.IAnnotationInspector;
-
-/**
- * Synchronizer for explicit {@link IServiceEndpointInterface} instance. Updates the DOM instance to the current
- * SEI implementation class by reading relevant annotations and
- *
- * @author
- */
-public class SeiSynchronizer extends ElementSynchronizerImpl
-{
- private final SeiMerger seiMerger;
-
- SeiSynchronizer(IModelElementSynchronizer parent)
- {
- super(parent);
- seiMerger = new SeiMerger(this, new SeiMethodSynchronizer(this));
- }
-
- /* IServiceEndpointInterface */
- void synchronizeInterface(IWebServiceProject wsProject, IAnnotation<IType> wsAnnotation, IAnnotationInspector inspector) throws JavaModelException
- {
- final IServiceEndpointInterface sei = obtainInstance(wsProject, wsAnnotation.getAppliedElement().getFullyQualifiedName());
- seiMerger.merge(sei, wsAnnotation, inspector);
- resolveWsRefsToThisSei(sei);
- resource().getSerializerFactory().adapt(sei, IAnnotationSerializer.class);
- }
-
- private IServiceEndpointInterface obtainInstance(IWebServiceProject wsProject, String implName)
- {
- IServiceEndpointInterface sei = null;
- for (IServiceEndpointInterface existing : wsProject.getServiceEndpointInterfaces())
- {
- if (existing.getImplementation().equals(implName)) {
- sei = existing;
- }
- }
-
- if (sei==null)
- {
- sei = domFactory().createIServiceEndpointInterface();
- util().setFeatureValue(sei, DomPackage.IJAVA_WEB_SERVICE_ELEMENT__IMPLEMENTATION, implName);
- wsProject.getServiceEndpointInterfaces().add(sei);
- }
-
- util().setFeatureValue(sei, DomPackage.ISERVICE_ENDPOINT_INTERFACE__IMPLICIT, false);
-
- return sei;
- }
-
- private void resolveWsRefsToThisSei(IServiceEndpointInterface sei)
- {
- for (IWebService ws : serviceData().getImplementingWs(sei.getImplementation()))
- {
- if (ws.getServiceEndpoint() != sei)
- {
- util().setFeatureValue(ws, DomPackage.IWEB_SERVICE__SERVICE_ENDPOINT, sei);
- }
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009 by SAP AG, Walldorf.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.dom.runtime.persistence.sync;
+
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.DomPackage;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IServiceEndpointInterface;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebService;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebServiceProject;
+import org.eclipse.jst.ws.jaxws.dom.runtime.persistence.IAnnotationSerializer;
+import org.eclipse.jst.ws.jaxws.dom.runtime.persistence.IModelElementSynchronizer;
+import org.eclipse.jst.ws.jaxws.utils.annotations.IAnnotation;
+import org.eclipse.jst.ws.jaxws.utils.annotations.IAnnotationInspector;
+
+/**
+ * Synchronizer for explicit {@link IServiceEndpointInterface} instance. Updates the DOM instance to the current
+ * SEI implementation class by reading relevant annotations and
+ *
+ * @author
+ */
+public class SeiSynchronizer extends ElementSynchronizerImpl
+{
+ private final SeiMerger seiMerger;
+
+ public SeiSynchronizer(IModelElementSynchronizer parent)
+ {
+ super(parent);
+ seiMerger = new SeiMerger(this, new SeiMethodSynchronizer(this));
+ }
+
+ /* IServiceEndpointInterface */
+ public void synchronizeInterface(IWebServiceProject wsProject, IAnnotation<IType> wsAnnotation, IAnnotationInspector inspector) throws JavaModelException
+ {
+ if(wsAnnotation.getAppliedElement().getFullyQualifiedName()==null) {
+ return;
+ }
+
+ final IServiceEndpointInterface sei = obtainInstance(wsProject, wsAnnotation.getAppliedElement().getFullyQualifiedName());
+ seiMerger.merge(sei, wsAnnotation, inspector);
+ resolveWsRefsToThisSei(sei);
+ resource().getSerializerFactory().adapt(sei, IAnnotationSerializer.class);
+ }
+
+ private IServiceEndpointInterface obtainInstance(IWebServiceProject wsProject, String implName)
+ {
+ IServiceEndpointInterface sei = null;
+ for (IServiceEndpointInterface existing : wsProject.getServiceEndpointInterfaces())
+ {
+ if (existing.getImplementation().equals(implName)) {
+ sei = existing;
+ }
+ }
+
+ if (sei==null)
+ {
+ sei = domFactory().createIServiceEndpointInterface();
+ util().setFeatureValue(sei, DomPackage.IJAVA_WEB_SERVICE_ELEMENT__IMPLEMENTATION, implName);
+ wsProject.getServiceEndpointInterfaces().add(sei);
+ }
+
+ util().setFeatureValue(sei, DomPackage.ISERVICE_ENDPOINT_INTERFACE__IMPLICIT, false);
+
+ return sei;
+ }
+
+ private void resolveWsRefsToThisSei(IServiceEndpointInterface sei)
+ {
+ for (IWebService ws : serviceData().getImplementingWs(sei.getImplementation()))
+ {
+ if (ws.getServiceEndpoint() != sei)
+ {
+ util().setFeatureValue(ws, DomPackage.IWEB_SERVICE__SERVICE_ENDPOINT, sei);
+ }
+ }
+ }
+}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/sync/WsSynchronizer.java b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/sync/WsSynchronizer.java
index 424fe84..fb2b7d3 100755
--- a/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/sync/WsSynchronizer.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.dom.runtime/src/org/eclipse/jst/ws/jaxws/dom/runtime/persistence/sync/WsSynchronizer.java
@@ -58,6 +58,10 @@
public IWebService synchronizeWebService(IWebServiceProject wsProject, IAnnotation<IType> wsAnnotation, IAnnotationInspector inspector) throws JavaModelException
{
+ if(wsAnnotation.getAppliedElement().getFullyQualifiedName()==null) {
+ return null;
+ }
+
final IWebService ws = obtainInstance(wsProject, wsAnnotation.getAppliedElement().getFullyQualifiedName());
mergeWebService(ws, wsProject, wsAnnotation, inspector);
diff --git a/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/AllTestsSuite.java b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/AllTestsSuite.java
index 0b1cb1d..c5c18f6 100755
--- a/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/AllTestsSuite.java
+++ b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/AllTestsSuite.java
@@ -49,8 +49,10 @@
import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.sync.ModelSynchronizationTests;
import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.sync.OnEventModelSyncronizerTest;
import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.sync.SeiMethodSyncronizationTest;
+import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.sync.SeiSynchronizerTest;
import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.sync.SeiSyncronizationTest;
import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.sync.WsSynchronizationTest;
+import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.sync.WsSynchronizerTest;
import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.util.Dom2ResourceMapperTest;
import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.util.DomUtilTest;
import org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.validation.EndpointIsSessionBeanRuleTest;
@@ -91,6 +93,8 @@
suite.addTestSuite(SeiSyncronizationTest.class);
suite.addTestSuite(WsSynchronizationTest.class);
suite.addTestSuite(JaxWsDefaultsCalculatorTest.class);
+ suite.addTestSuite(SeiSynchronizerTest.class);
+ suite.addTestSuite(WsSynchronizerTest.class);
// state adapters tests
suite.addTestSuite(MethodPropertyStateAdapterTest.class);
suite.addTestSuite(PropertyStateAdapterFactoryTest.class);
diff --git a/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/persistence/sync/SeiSynchronizerTest.java b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/persistence/sync/SeiSynchronizerTest.java
new file mode 100644
index 0000000..d739149
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/persistence/sync/SeiSynchronizerTest.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2011 by SAP AG, Walldorf.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.sync;
+
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.DomFactory;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IServiceEndpointInterface;
+import org.eclipse.jst.ws.jaxws.dom.runtime.api.IWebServiceProject;
+import org.eclipse.jst.ws.jaxws.dom.runtime.internal.impl.DomFactoryImpl;
+import org.eclipse.jst.ws.jaxws.dom.runtime.persistence.sync.SeiSynchronizer;
+import org.eclipse.jst.ws.jaxws.testutils.jmock.Mock;
+import org.eclipse.jst.ws.jaxws.testutils.jmock.MockObjectTestCase;
+import org.eclipse.jst.ws.jaxws.utils.annotations.IAnnotation;
+
+public class SeiSynchronizerTest extends MockObjectTestCase {
+ public void testSEISynchronizeForImplementationNameValueNull() throws Exception {
+ SeiSynchronizer seiSynchronizer = new SeiSynchronizer(null) {
+ @Override
+ public DomFactory domFactory() {
+ DomFactoryImpl.init();
+ return new DomFactoryImpl();
+ }
+ };
+ final Mock<IWebServiceProject> webServiceProjectMock = mock(IWebServiceProject.class);
+ final EList<IServiceEndpointInterface> testSEIList = new BasicEList<IServiceEndpointInterface>();
+ webServiceProjectMock.stubs().method("getServiceEndpointInterfaces").withNoArguments().will(returnValue(testSEIList));
+ Mock<IAnnotation<IType>> annotationMock = mock(IAnnotation.class);
+ Mock<IType> typeMock = mock(IType.class);
+ typeMock.stubs().method("getFullyQualifiedName").withNoArguments().will(returnValue(null));
+ annotationMock.stubs().method("getAppliedElement").withNoArguments().will(returnValue(typeMock.proxy()));
+ seiSynchronizer.synchronizeInterface(webServiceProjectMock.proxy(), annotationMock.proxy(), null);
+ assertEquals("No SEI expected to be created when implementation name is null !", 0, testSEIList.size());
+ }
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/persistence/sync/WsSynchronizerTest.java b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/persistence/sync/WsSynchronizerTest.java
new file mode 100644
index 0000000..ddf61b6
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.dom.runtime.tests/src/org/eclipse/jst/ws/jaxws/dom/runtime/tests/dom/persistence/sync/WsSynchronizerTest.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2011 by SAP AG, Walldorf.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.persistence.sync;
+
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jst.ws.jaxws.dom.runtime.persistence.sync.WsSynchronizer;
+import org.eclipse.jst.ws.jaxws.testutils.jmock.Mock;
+import org.eclipse.jst.ws.jaxws.testutils.jmock.MockObjectTestCase;
+import org.eclipse.jst.ws.jaxws.utils.annotations.IAnnotation;
+
+public class WsSynchronizerTest extends MockObjectTestCase {
+ public void testWSSynchronizeForImplementationNameWithValueNull() throws Exception {
+ WsSynchronizer wsSynchronizerToTest = new WsSynchronizer(null);
+ Mock<IAnnotation<IType>> annotationMock = mock(IAnnotation.class);
+ Mock<IType> typeMock = mock(IType.class);
+ typeMock.stubs().method("getFullyQualifiedName").withNoArguments().will(returnValue(null));
+ annotationMock.stubs().method("getAppliedElement").withNoArguments().will(returnValue(typeMock.proxy()));
+ assertNull("WS instance gets created when the implementation name is null !", wsSynchronizerToTest.synchronizeWebService(null, annotationMock.proxy(), null));
+ }
+}