summaryrefslogtreecommitdiffstats
path: root/auth/auth-batch/src/main
diff options
context:
space:
mode:
authorOleksandr Moliavko <o.moliavko@samsung.com>2019-10-18 14:13:51 +0300
committerOleksandr Moliavko <o.moliavko@samsung.com>2019-10-18 14:13:51 +0300
commit3a9d138300642c3d09c8dc4bdc3f7413abfd584a (patch)
tree33b9666c2c0db3a6e2ed44a9b3443be0ec79eb24 /auth/auth-batch/src/main
parentbc5f9dec37da59182034c1166a6a9d4150f40847 (diff)
Tidied up load() method to remove several static
analyzer warnings Issue-ID: AAF-837 Signed-off-by: Oleksandr Moliavko <o.moliavko@samsung.com> Change-Id: I3f0f997839b5ad4ac516961be73b53d56fc1452f
Diffstat (limited to 'auth/auth-batch/src/main')
-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();
}
}
}