diff options
author | Instrumental <jcgmisc@stl.gathman.org> | 2018-03-29 19:02:24 -0500 |
---|---|---|
committer | Instrumental <jcgmisc@stl.gathman.org> | 2018-03-29 19:02:44 -0500 |
commit | d86dd644e1543743cfcbc83b230bd4f2cb2e5d4e (patch) | |
tree | 698e12f7c0142441cd494cd68da03437e510d0b0 /auth/auth-cass | |
parent | 17ca744723bd652f15d59d6c8555824f6e49018d (diff) |
Clean up Sonar results 1
Issue-ID: AAF-206
Change-Id: If1fced5b528490a52691508fb1e30962dbe28856
Signed-off-by: Instrumental <jcgmisc@stl.gathman.org>
Diffstat (limited to 'auth/auth-cass')
5 files changed, 22 insertions, 18 deletions
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/AbsCassDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/AbsCassDAO.java index 9794b2e5..89fb12fe 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/AbsCassDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/AbsCassDAO.java @@ -357,6 +357,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> { private static final String NEW_CASSANDRA_SESSION_CREATED = "New Cassandra Session Created"; private static final String NEW_CASSANDRA_CLUSTER_OBJECT_CREATED = "New Cassandra Cluster Object Created"; private static final String NEW_CASSANDRA_SESSION = "New Cassandra Session"; + private static final Object LOCK = new Object(); private static class ResetRequest { //package on purpose @@ -398,7 +399,7 @@ public abstract class AbsCassDAO<TRANS extends TransStore,DATA> { Cluster tempCluster = null; Session tempSession = null; try { - synchronized(NEW_CASSANDRA_SESSION_CREATED) { + synchronized(LOCK) { boolean reset = false; for(ResetRequest r : resetDeque) { if(r.session == session) { diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassDAOImpl.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassDAOImpl.java index bd6d0863..f7cdec5e 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassDAOImpl.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassDAOImpl.java @@ -185,7 +185,7 @@ public class CassDAOImpl<TRANS extends TransStore,DATA> extends AbsCassDAO<TRANS */ public Result<DATA> create(TRANS trans, DATA data) { if(createPS==null) { - Result.err(Result.ERR_NotImplemented,"Create is disabled for %s",getClass().getSimpleName()); + return Result.err(Result.ERR_NotImplemented,"Create is disabled for %s",getClass().getSimpleName()); } if(async) /*ResultSetFuture */ { Result<ResultSetFuture> rs = createPS.execAsync(trans, C_TEXT, data); @@ -207,21 +207,21 @@ public class CassDAOImpl<TRANS extends TransStore,DATA> extends AbsCassDAO<TRANS */ public Result<List<DATA>> read(TRANS trans, DATA data) { if(readPS==null) { - Result.err(Result.ERR_NotImplemented,"Read is disabled for %s",getClass().getSimpleName()); + return Result.err(Result.ERR_NotImplemented,"Read is disabled for %s",getClass().getSimpleName()); } return readPS.read(trans, R_TEXT, data); } public Result<List<DATA>> read(TRANS trans, Object ... key) { if(readPS==null) { - Result.err(Result.ERR_NotImplemented,"Read is disabled for %s",getClass().getSimpleName()); + return Result.err(Result.ERR_NotImplemented,"Read is disabled for %s",getClass().getSimpleName()); } return readPS.read(trans, R_TEXT, key); } public Result<DATA> readPrimKey(TRANS trans, Object ... key) { if(readPS==null) { - Result.err(Result.ERR_NotImplemented,"Read is disabled for %s",getClass().getSimpleName()); + return Result.err(Result.ERR_NotImplemented,"Read is disabled for %s",getClass().getSimpleName()); } Result<List<DATA>> rld = readPS.read(trans, R_TEXT, key); if(rld.isOK()) { @@ -241,7 +241,7 @@ public class CassDAOImpl<TRANS extends TransStore,DATA> extends AbsCassDAO<TRANS public Result<Void> update(TRANS trans, DATA data, boolean async) { if(updatePS==null) { - Result.err(Result.ERR_NotImplemented,"Update is disabled for %s",getClass().getSimpleName()); + return Result.err(Result.ERR_NotImplemented,"Update is disabled for %s",getClass().getSimpleName()); } if(async)/* ResultSet rs =*/ { Result<ResultSetFuture> rs = updatePS.execAsync(trans, U_TEXT, data); @@ -262,7 +262,7 @@ public class CassDAOImpl<TRANS extends TransStore,DATA> extends AbsCassDAO<TRANS // This method Sig for Cached... public Result<Void> delete(TRANS trans, DATA data, boolean reread) { if(deletePS==null) { - Result.err(Result.ERR_NotImplemented,"Delete is disabled for %s",getClass().getSimpleName()); + return Result.err(Result.ERR_NotImplemented,"Delete is disabled for %s",getClass().getSimpleName()); } // Since Deleting will be stored off, for possible re-constitution, need the whole thing if(reread) { diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CertDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CertDAO.java index a47b8c9e..28e27497 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CertDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CertDAO.java @@ -163,12 +163,12 @@ public class CertDAO extends CassDAOImpl<AuthzTrans,CertDAO.Data> { data.x509 = readString(is,buff); data.ca = readString(is,buff); int i = is.readInt(); - if(i<0) { - data.serial=null; - } else { + data.serial=null; + if(i>=0) { byte[] bytes = new byte[i]; // a bit dangerous, but lessened because of all the previous sized data reads - is.read(bytes); - data.serial = new BigInteger(bytes); + if(is.read(bytes)>0) { + data.serial = new BigInteger(bytes); + } } } } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CredDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CredDAO.java index 46dc12bf..7a85ae1a 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CredDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CredDAO.java @@ -182,9 +182,8 @@ public class CredDAO extends CassDAOImpl<AuthzTrans,CredDAO.Data> { data.notes = readString(is,buff); int i = is.readInt(); - if(i<0) { - data.cred=null; - } else { + data.cred=null; + if(i>=0) { byte[] bytes = new byte[i]; // a bit dangerous, but lessened because of all the previous sized data reads is.read(bytes); data.cred = ByteBuffer.wrap(bytes); diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java index 6b0bb17b..3634af97 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java @@ -367,10 +367,14 @@ public class Question { if (r.isOKhasData()) { return Result.ok(r.value.get(0)); } else { - int dot = child == null ? -1 : child.lastIndexOf('.'); + int dot; + if(child==null) { + return Result.err(Status.ERR_NsNotFound, "No Namespace"); + } else { + dot = child.lastIndexOf('.'); + } if (dot < 0) { - return Result.err(Status.ERR_NsNotFound, - "No Namespace for [%s]", child); + return Result.err(Status.ERR_NsNotFound, "No Namespace for [%s]", child); } else { return deriveNs(trans, child.substring(0, dot)); } |