summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Gathman <jonathan.gathman@att.com>2019-11-06 13:31:07 +0000
committerGerrit Code Review <gerrit@onap.org>2019-11-06 13:31:07 +0000
commit82865bf0ee1e3258751542b6af682fcd851fbc71 (patch)
tree66eec06423dfe4c70f9c7ac6d7b0c40558bf1006
parent6dd9704640eb8cc8d6b4ccd266e40a3f6f589e75 (diff)
parent3a9d138300642c3d09c8dc4bdc3f7413abfd584a (diff)
Merge "Tidied up load() method to remove several static analyzer warnings"
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyBody.java67
1 files changed, 35 insertions, 32 deletions
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyBody.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyBody.java
index 04814e01..b002dd8b 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyBody.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/NotifyBody.java
@@ -80,7 +80,6 @@ public abstract class NotifyBody {
if(row.size()>3) {
escalation = Integer.parseInt(row.get(3));
}
- return;
} else if(type.equals(row.get(0))) {
String user = user(row);
if(user!=null) {
@@ -180,42 +179,46 @@ public abstract class NotifyBody {
String path = pkg.getName().replace('.', '/');
URL url = cl.getResource(path);
List<String> classNames = new ArrayList<>();
- String urlString = url.toString();
- if(urlString.startsWith("jar:file:")) {
- int exclam = urlString.lastIndexOf('!');
- JarFile jf = new JarFile(urlString.substring(9,exclam));
- try {
- Enumeration<JarEntry> jfe = jf.entries();
- while(jfe.hasMoreElements()) {
- String name = jfe.nextElement().getName();
- if(name.startsWith(path) && name.endsWith(".class")) {
- classNames.add(name.substring(0,name.length()-6).replace('/', '.'));
+ String urlString;
+ if (url != null) {
+ urlString = url.toString();
+ if (urlString.startsWith("jar:file:")) {
+ int exclam = urlString.lastIndexOf('!');
+ JarFile jf = new JarFile(urlString.substring(9, exclam));
+ try {
+ Enumeration<JarEntry> jfe = jf.entries();
+ while (jfe.hasMoreElements()) {
+ String name = jfe.nextElement().getName();
+ if (name.startsWith(path) && name.endsWith(".class")) {
+ classNames.add(name.substring(0, name.length() - 6).replace('/', '.'));
+ }
}
+ } finally {
+ jf.close();
}
- } finally {
- jf.close();
- }
- } else {
- File dir = new File(url.getFile());
- for( String f : dir.list()) {
- if(f.endsWith(".class")) {
- classNames.add(pkg.getName() + '.' + f.substring(0,f.length() - 6));
+ } else {
+ File dir = new File(url.getFile());
+ String[] dirs = dir.list();
+ if (dirs != null) {
+ for (String f : dirs) {
+ if (f.endsWith(".class")) {
+ classNames.add(pkg.getName() + '.' + f.substring(0, f.length() - 6));
+ }
+ }
}
}
- }
- for(String cls : classNames) {
- try {
- Class<?> c = cl.loadClass(cls);
- if((c!=null)&&(!Modifier.isAbstract(c.getModifiers()))) {
- Constructor<?> cst = c.getConstructor(Access.class);
- NotifyBody nb = (NotifyBody)cst.newInstance(access);
- if(nb!=null) {
- bodyMap.put("info|" + nb.name, nb);
- bodyMap.put(nb.type+'|' + nb.name, nb);
- }
+ for (String cls : classNames) {
+ try {
+ Class<?> c = cl.loadClass(cls);
+ if ((c != null) && (!Modifier.isAbstract(c.getModifiers()))) {
+ Constructor<?> cst = c.getConstructor(Access.class);
+ NotifyBody nb = (NotifyBody) cst.newInstance(access);
+ bodyMap.put("info|" + nb.name, nb);
+ bodyMap.put(nb.type + '|' + nb.name, nb);
+ }
+ } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ e.printStackTrace();
}
- } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- e.printStackTrace();
}
}
}