From d86dd644e1543743cfcbc83b230bd4f2cb2e5d4e Mon Sep 17 00:00:00 2001 From: Instrumental Date: Thu, 29 Mar 2018 19:02:24 -0500 Subject: Clean up Sonar results 1 Issue-ID: AAF-206 Change-Id: If1fced5b528490a52691508fb1e30962dbe28856 Signed-off-by: Instrumental --- .../src/main/java/org/onap/aaf/auth/local/AbsData.java | 6 +----- .../src/main/java/org/onap/aaf/auth/local/TextIndex.java | 8 ++++++-- .../main/java/org/onap/aaf/auth/validation/Validator.java | 13 ++++++++++--- 3 files changed, 17 insertions(+), 10 deletions(-) (limited to 'auth/auth-core/src/main') diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/AbsData.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/AbsData.java index 40e0b22c..d9f7ac96 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/AbsData.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/AbsData.java @@ -71,7 +71,7 @@ public abstract class AbsData implements Iterable { public void open(AuthzTrans trans, long timeout) throws IOException { TimeTaken tt = trans.start("Open Data File", Env.SUB); - boolean opened = false, first = true; + boolean first = true; try { if(!dataf.exists()) { throw new FileNotFoundException("Data File Missing:" + dataf.getCanonicalPath()); @@ -102,14 +102,10 @@ public abstract class AbsData implements Iterable { throw e; } ti.open(); - opened = true; } finally { tt.done(); } - if(!opened) { - throw new IOException("DataFile pair for " + name + " was not able to be opened in " + timeout + "ms"); - } } private synchronized void ensureIdxGood(AuthzTrans trans) throws IOException { diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/TextIndex.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/TextIndex.java index 5169cf88..cbb3603e 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/TextIndex.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/TextIndex.java @@ -132,8 +132,12 @@ public class TextIndex { TimeTaken tt2 = trans.start("Open Files", Env.SUB); try { raf = new RandomAccessFile(file,"rw"); - raf.setLength(0L); - fos = raf.getChannel(); + try { + raf.setLength(0L); + fos = raf.getChannel(); + } finally { + raf.close(); + } } finally { tt2.done(); } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java index 16c0d3ba..7078cf0f 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java @@ -146,8 +146,12 @@ public class Validator { } public final Validator permType(String type, String ns) { - if(nob(type,NAME_CHARS)) { - msg("Perm Type [" + (ns==null?"":ns+(type.length()==0?"":'.'))+type + "] is invalid."); + if(type==null) { + msg("Perm Type is null"); + } else if(ns==null) { + msg("Perm NS is null"); + } else if(nob(type,NAME_CHARS)) { + msg("Perm Type [" + (ns+(type.length()==0?"":'.'))+type + "] is invalid."); } return this; } @@ -175,7 +179,10 @@ public class Validator { } public final Validator ns(String ns) { - if(nob(ns,NAME_CHARS)){ + if(ns==null) { + msg("NS is null"); + return this; + } else if(nob(ns,NAME_CHARS)) { msg("NS [" + ns + "] is invalid."); } for(String s : nsKeywords) { -- cgit 1.2.3-korg