diff options
author | Nitin Dahyabhai | 2020-07-01 13:29:34 +0000 |
---|---|---|
committer | Nitin Dahyabhai | 2020-07-01 13:29:34 +0000 |
commit | 69dd85642bdeb6b89b51c5b21caf3039669a5a4f (patch) | |
tree | 5a7ea50702f3d935ab14e4a12a86c55ed6af90d6 /plugins | |
parent | bfb7ef4f2e3f60d30ea56253ce502ef9fb180832 (diff) | |
download | webtools.javaee-69dd85642bdeb6b89b51c5b21caf3039669a5a4f.tar.gz webtools.javaee-69dd85642bdeb6b89b51c5b21caf3039669a5a4f.tar.xz webtools.javaee-69dd85642bdeb6b89b51c5b21caf3039669a5a4f.zip |
[417555] NPE merging web app models
Signed-off-by: Nitin Dahyabhai <thatnitind@gmail.com>
Diffstat (limited to 'plugins')
6 files changed, 51 insertions, 27 deletions
diff --git a/plugins/org.eclipse.jst.j2ee/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.j2ee/META-INF/MANIFEST.MF index ecb9cafad..f7b17f7c7 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 @@ Manifest-Version: 1.0 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 ece546415..03dbdbb93 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 @@ public class JavaEEArchiveUtilities extends ArchiveFactoryImpl { 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 02890bb42..25a29f3bb 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 198463111..d88fd7cf1 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 @@ Manifest-Version: 1.0 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 a286826aa..f875afd60 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 0c4974b05..59327ee94 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.FilterMapping; 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 @@ public class WebAppMerger extends ModelElementMerger { mergeSecurityRoles(warnings); mergeSecurityConstraints(warnings); } catch (Exception e) { + Activator.log(e); throw new ModelException(e); } return warnings; @@ -263,13 +265,34 @@ public class WebAppMerger extends ModelElementMerger { } 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 @@ public class WebAppMerger extends ModelElementMerger { continue; } if (javaEEObject instanceof Servlet){ - if(((Servlet) targetArtifact).getServletName().equals(((Servlet)javaEEObject).getServletName())){ return (JavaEEObject) targetArtifact; } |