[417555] NPE merging web app models Signed-off-by: Nitin Dahyabhai <thatnitind@gmail.com>
diff --git a/plugins/org.eclipse.jst.j2ee/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.j2ee/META-INF/MANIFEST.MF index ecb9caf..f7b17f7 100644 --- a/plugins/org.eclipse.jst.j2ee/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.jst.j2ee/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name.0 Bundle-SymbolicName: org.eclipse.jst.j2ee; singleton:=true -Bundle-Version: 1.2.301.qualifier +Bundle-Version: 1.2.400.qualifier Bundle-Activator: org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin Bundle-Vendor: %Bundle-Vendor.0 Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/JavaEEArchiveUtilities.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/JavaEEArchiveUtilities.java index ece5464..03dbdbb 100644 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/JavaEEArchiveUtilities.java +++ b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/JavaEEArchiveUtilities.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2015 IBM Corporation and others. + * Copyright (c) 2005, 2020 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -920,19 +920,21 @@ InputStream ioStream = null; try { ioStream = archiveResource.getInputStream(); - IClassFileReader classFileReader = ToolFactory.createDefaultClassFileReader(ioStream, IClassFileReader.CLASSFILE_ATTRIBUTES); - //classFileReader will be null if this is an invalid java .class file - if(classFileReader != null){ - IClassFileAttribute[] attributes = classFileReader.getAttributes(); - for (IClassFileAttribute attribute : attributes) { - char[] attributeName = attribute.getAttributeName(); - if (Arrays.equals(attributeName, RUNTIME_VISIBLE)) { - IRuntimeVisibleAnnotationsAttribute annotationsAttribute = (IRuntimeVisibleAnnotationsAttribute) attribute; - IAnnotation[] annotations = annotationsAttribute.getAnnotations(); - for (IAnnotation annotation : annotations) { - char[] typedName = annotation.getTypeName(); - if (Arrays.equals(typedName, STATELESS) || Arrays.equals(typedName, STATEFUL) || Arrays.equals(typedName, MESSAGEDRIVEN) || Arrays.equals(typedName, SINGLETON)) { - return true; + if (ioStream != null) { + IClassFileReader classFileReader = ToolFactory.createDefaultClassFileReader(ioStream, IClassFileReader.CLASSFILE_ATTRIBUTES); + //classFileReader will be null if this is an invalid java .class file + if(classFileReader != null) { + IClassFileAttribute[] attributes = classFileReader.getAttributes(); + for (IClassFileAttribute attribute : attributes) { + char[] attributeName = attribute.getAttributeName(); + if (Arrays.equals(attributeName, RUNTIME_VISIBLE)) { + IRuntimeVisibleAnnotationsAttribute annotationsAttribute = (IRuntimeVisibleAnnotationsAttribute) attribute; + IAnnotation[] annotations = annotationsAttribute.getAnnotations(); + for (IAnnotation annotation : annotations) { + char[] typedName = annotation.getTypeName(); + if (Arrays.equals(typedName, STATELESS) || Arrays.equals(typedName, STATEFUL) || Arrays.equals(typedName, MESSAGEDRIVEN) || Arrays.equals(typedName, SINGLETON)) { + return true; + } } } }
diff --git a/plugins/org.eclipse.jst.j2ee/pom.xml b/plugins/org.eclipse.jst.j2ee/pom.xml index 02890bb..25a29f3 100644 --- a/plugins/org.eclipse.jst.j2ee/pom.xml +++ b/plugins/org.eclipse.jst.j2ee/pom.xml
@@ -21,6 +21,6 @@ <groupId>org.eclipse.webtools.javaee</groupId> <artifactId>org.eclipse.jst.j2ee</artifactId> - <version>1.2.301-SNAPSHOT</version> + <version>1.2.400-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
diff --git a/plugins/org.eclipse.jst.jee.web/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.jee.web/META-INF/MANIFEST.MF index 1984631..d88fd7c 100644 --- a/plugins/org.eclipse.jst.jee.web/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.jst.jee.web/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name.0 Bundle-SymbolicName: org.eclipse.jst.jee.web;singleton:=true -Bundle-Version: 1.0.701.qualifier +Bundle-Version: 1.0.702.qualifier Bundle-Activator: org.eclipse.jst.jee.web.Activator Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", org.eclipse.wst.common.project.facet.core;bundle-version="[1.3.0,2.0.0)",
diff --git a/plugins/org.eclipse.jst.jee.web/pom.xml b/plugins/org.eclipse.jst.jee.web/pom.xml index a286826..f875afd 100644 --- a/plugins/org.eclipse.jst.jee.web/pom.xml +++ b/plugins/org.eclipse.jst.jee.web/pom.xml
@@ -21,6 +21,6 @@ <groupId>org.eclipse.webtools.javaee</groupId> <artifactId>org.eclipse.jst.jee.web</artifactId> - <version>1.0.701-SNAPSHOT</version> + <version>1.0.702-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
diff --git a/plugins/org.eclipse.jst.jee.web/web/org/eclipse/jst/jee/model/internal/mergers/WebAppMerger.java b/plugins/org.eclipse.jst.jee.web/web/org/eclipse/jst/jee/model/internal/mergers/WebAppMerger.java index 0c4974b..59327ee 100644 --- a/plugins/org.eclipse.jst.jee.web/web/org/eclipse/jst/jee/model/internal/mergers/WebAppMerger.java +++ b/plugins/org.eclipse.jst.jee.web/web/org/eclipse/jst/jee/model/internal/mergers/WebAppMerger.java
@@ -1,5 +1,5 @@ /*********************************************************************** - * Copyright (c) 2008, 2010 by SAP AG, Walldorf. + * Copyright (c) 2008, 2020 by SAP AG, Walldorf, and Others * 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 @@ -28,6 +28,7 @@ import org.eclipse.jst.javaee.web.Servlet; import org.eclipse.jst.javaee.web.ServletMapping; import org.eclipse.jst.javaee.web.WebApp; +import org.eclipse.jst.jee.web.Activator; /** * WebApp merger merges the WebApp artifact. @@ -87,6 +88,7 @@ mergeSecurityRoles(warnings); mergeSecurityConstraints(warnings); } catch (Exception e) { + Activator.log(e); throw new ModelException(e); } return warnings; @@ -263,13 +265,34 @@ } protected boolean artifactIsValid(Object javaEEObject) { - if (javaEEObject instanceof Servlet){ - return ( (Servlet)javaEEObject).getServletName() != null; - } else if (javaEEObject instanceof Listener){ - return ((Listener)javaEEObject).getListenerClass() != null; - } else if (javaEEObject instanceof Filter){ - return ((Filter)javaEEObject).getFilterName() != null; - } + if (javaEEObject instanceof Servlet) { + return ((Servlet) javaEEObject).getServletName() != null; + } + else if (javaEEObject instanceof Listener) { + return ((Listener) javaEEObject).getListenerClass() != null; + } + else if (javaEEObject instanceof Filter) { + return ((Filter) javaEEObject).getFilterName() != null; + + } + else if (javaEEObject instanceof Description) { + return ((Description) javaEEObject).getValue() != null; + } + else if (javaEEObject instanceof WelcomeFile) { + return ((WelcomeFile) javaEEObject).getWelcomeFile() != null; + } + else if (javaEEObject instanceof ServletMapping) { + return ((ServletMapping) javaEEObject).getServletName() != null; + } + else if (javaEEObject instanceof FilterMapping) { + return ((FilterMapping) javaEEObject).getFilterName() != null; + } + else if (javaEEObject instanceof UrlPatternType) { + return ((UrlPatternType) javaEEObject).getValue() != null; + } + else if (javaEEObject instanceof ParamValue) { + return ((ParamValue) javaEEObject).getParamName() != null; + } return true; } @@ -283,7 +306,6 @@ continue; } if (javaEEObject instanceof Servlet){ - if(((Servlet) targetArtifact).getServletName().equals(((Servlet)javaEEObject).getServletName())){ return (JavaEEObject) targetArtifact; }