Clean up Sonar results 3 19/40319/1
authorInstrumental <jcgmisc@stl.gathman.org>
Fri, 30 Mar 2018 02:40:16 +0000 (21:40 -0500)
committerInstrumental <jcgmisc@stl.gathman.org>
Fri, 30 Mar 2018 02:40:24 +0000 (21:40 -0500)
Issue-ID: AAF-206
Change-Id: I4494990e8e0bd702b475bbbfb140eaadd566d2a0
Signed-off-by: Instrumental <jcgmisc@stl.gathman.org>
30 files changed:
auth/auth-batch/src/main/java/org/onap/aaf/auth/actions/Email.java
auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/Cred.java
auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/InputIterator.java
auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/CacheInfoDAO.java
auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/HistoryDAO.java
auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/Cmd.java
auth/auth-core/src/main/java/org/onap/aaf/auth/local/AbsData.java
auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationFactory.java
auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CachingFileAccess.java
auth/auth-deforg/src/main/java/org/onap/aaf/org/DefaultOrg.java
auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PendingRequestsShow.java
auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RolesShow.java
auth/auth-service/src/main/java/org/onap/aaf/auth/service/AuthzCassServiceImpl.java
auth/auth-service/src/main/java/org/onap/aaf/auth/service/api/API_History.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/cert/AAFListedCertIdentity.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/CmAgent.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/persist/Persist.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/persist/Persisting.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/register/Registrar.java
cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsAuthentication.java
cadi/client/src/main/java/org/onap/aaf/cadi/http/HRcli.java
cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java
cadi/core/src/main/java/org/onap/aaf/cadi/CmdLine.java
cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java
cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java
misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java
misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java
misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java
misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java

index 0687364..25e2ffc 100644 (file)
@@ -167,7 +167,7 @@ public class Email implements Action<Organization,Void, String>{
                        try {
                                Thread.sleep(wait);
                        } catch (InterruptedException e) {
-                               return exec(trans,org,sb);
+                                Thread.currentThread().interrupt();
                        }
                }
                return exec(trans,org,sb);
index 58af03b..1131aca 100644 (file)
@@ -264,7 +264,7 @@ public class Cred  {
                }
 
                public long authCount(int idx) {
-                       return basic_auth[idx]+basic_auth_256[idx];
+                       return (long)basic_auth[idx]+basic_auth_256[idx];
                }
                
                public long x509Count(int idx) {
index cb0bfa6..0afcac2 100644 (file)
@@ -25,6 +25,7 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 public class InputIterator implements Iterable<String> {
        private BufferedReader in;
@@ -57,6 +58,9 @@ public class InputIterator implements Iterable<String> {
 
                        @Override
                        public String next() {
+                               if(!hasNext()) {
+                                       throw new NoSuchElementException();
+                               }
                                return input;
                        }
 
index e47e935..66ab734 100644 (file)
@@ -321,6 +321,7 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
                                        }
                                } catch (InterruptedException e1) {
                                        go = false;
+                                       Thread.currentThread().interrupt();
                                }
                        } while(go);
                }
@@ -353,6 +354,7 @@ public class CacheInfoDAO extends CassDAOImpl<AuthzTrans,CacheInfoDAO.Data> impl
                                }
                        } catch (InterruptedException e) {
                                trans.error().log("Cache Notify Queue posting was interrupted" );
+                               Thread.currentThread().interrupt();
                        }
                }
 
index 8e4ada1..0cfc1dc 100644 (file)
@@ -56,9 +56,6 @@ import com.datastax.driver.core.Row;
 public class HistoryDAO extends CassDAOImpl<AuthzTrans, HistoryDAO.Data> {
        private static final String TABLE = "history";
 
-       public static final SimpleDateFormat monthFormat = new SimpleDateFormat("yyyyMM");
-//     private static final SimpleDateFormat dayTimeFormat = new SimpleDateFormat("ddHHmmss");
-
        private String[] helpers;
 
        private HistLoader defLoader;
@@ -177,7 +174,8 @@ public class HistoryDAO extends CassDAOImpl<AuthzTrans, HistoryDAO.Data> {
        public static Data newInitedData() {
                Data data = new Data();
                Date now = new Date();
-               data.yr_mon = Integer.parseInt(monthFormat.format(now));
+               // Sonar claims that SimpleDateFormat is not thread safe, so we can't be static
+               data.yr_mon = Integer.parseInt(new SimpleDateFormat("yyyyMM").format(now));
                // data.day_time = Integer.parseInt(dayTimeFormat.format(now));
                return data;            
        }
index 9ee321e..896cbb3 100644 (file)
@@ -56,7 +56,8 @@ import aaf.v2_0.Request;
 
 
 public abstract class Cmd {
-       private static final DateFormat dateFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
+       // Sonar claims DateFormat is not thread safe.  Leave as Instance Variable.
+       private final DateFormat dateFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
        protected static final String BLANK = "";
        protected static final String COMMA = ","; // for use in splits
 
index d9f7ac9..17edae4 100644 (file)
@@ -26,6 +26,7 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.RandomAccessFile;
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 import org.onap.aaf.auth.env.AuthzTrans;
 import org.onap.aaf.auth.local.DataFile.Token;
@@ -87,7 +88,7 @@ public abstract class AbsData implements Iterable<String> {
                                        try {
                                                Thread.sleep(200);
                                        } catch (InterruptedException e) {
-                                               break;
+                                               Thread.currentThread().interrupt();
                                        }
                                        begin = System.currentTimeMillis();
                                }
@@ -188,6 +189,9 @@ public abstract class AbsData implements Iterable<String> {
 
                @Override
                public String next() {
+                       if(!hasNext()) {
+                               throw new NoSuchElementException();
+                       }
                        reuse.reset();
                        int rec = tii.next();
                        reuse.pos(rec);
index 36efb5d..d12345a 100644 (file)
@@ -79,10 +79,16 @@ public class OrganizationFactory {
                        if(orgClass == null) {
                                env.warn().log("There is no Organization." + orgNS + " property");
                        } else {
-                               for(Organization o : orgs.values()) {
-                                       if(orgClass.equals(o.getClass().getName())) {
-                                               org = o;
+                               try {
+                                       Class<?> orgCls = Class.forName(orgClass);
+                                       for(Organization o : orgs.values()) {
+                                               if(o.getClass().isAssignableFrom(orgCls)) {
+                                                       org = o;
+                                               }
                                        }
+                               } catch (ClassNotFoundException e1) {
+                                       env.error().log(e1, orgClass + " is not on the Classpath.");
+                                       throw new OrganizationException(e1);
                                }
                                if(org==null) {
                                        try {
index 7bb276a..07b67bb 100644 (file)
@@ -486,7 +486,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void
                }
                
                public String toString() {
-                       return data.toString();
+                       return Arrays.toString(data);
                }
                
                public void write(Writer writer) throws IOException {
index e084892..9fc983e 100644 (file)
@@ -608,7 +608,7 @@ public class DefaultOrg implements Organization {
                                                        Identity mechid = getIdentity(trans, vars[0]);
                                                        if(mechid!=null) {
                                                                Identity sponsor = mechid.responsibleTo();
-                                                               if(sponsor!=null && requestor.equals(sponsor.fullID())) {
+                                                               if(sponsor!=null && requestor.fullID().equals(sponsor.fullID())) {
                                                                        return null;
                                                                } else {
                                                                        return trans.user() + " is not the Sponsor of MechID " + vars[0];
index e55d803..a42d6b0 100644 (file)
@@ -23,7 +23,6 @@ package org.onap.aaf.auth.gui.pages;
 
 import java.io.IOException;
 import java.net.ConnectException;
-import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -60,7 +59,6 @@ public class PendingRequestsShow extends Page {
        public static final String HREF = "/gui/myrequests";
        public static final String NAME = "MyRequests";
        static final String WEBPHONE = "http://webphone.att.com/cgi-bin/webphones.pl?id=";
-       private static DateFormat createdDF = new SimpleDateFormat("yyyy-MM-dd");
        
        public PendingRequestsShow(final AAF_GUI gui, final Page ... breadcrumbs) throws APIException, IOException {
                super(gui.env, NAME,HREF, NO_FIELDS,
@@ -153,7 +151,8 @@ public class PendingRequestsShow extends Page {
                                                                                        tsCell = AbsCell.Null;
                                                                                } else {
                                                                                        UUID id = UUID.fromString(a.getId());
-                                                                                       tsCell = new RefCell(createdDF.format((id.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH)/10000),
+                                                                                       // Sonar says SimpleDate should not be static
+                                                                                       tsCell = new RefCell(new SimpleDateFormat("yyyy-MM-dd").format((id.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH)/10000),
                                                                                                        RequestDetail.HREF + "?ticket=" + ticket,false);
                                                                                        prevTicket = ticket;
                                                                                }
index 071666d..e3f91ba 100644 (file)
@@ -58,11 +58,6 @@ import aaf.v2_0.UserRoles;
 public class RolesShow extends Page {
        public static final String HREF = "/gui/myroles";
        private static final String DATE_TIME_FORMAT = "yyyy-MM-dd";
-       private static SimpleDateFormat expiresDF;
-       
-       static {
-               expiresDF = new SimpleDateFormat(DATE_TIME_FORMAT);
-       }
        
        public RolesShow(final AAF_GUI gui, final Page ... breadcrumbs) throws APIException, IOException {
                super(gui.env, "MyRoles",HREF, NO_FIELDS,
@@ -101,7 +96,7 @@ public class RolesShow extends Page {
                                                                        if(u.getExpires().compare(Chrono.timeStamp()) < 0) {
                                                                                AbsCell[] sa = new AbsCell[] {
                                                                                                new TextCell(u.getRole() + "*", "class=expired"),
-                                                                                               new TextCell(expiresDF.format(u.getExpires().toGregorianCalendar().getTime()),"class=expired"),
+                                                                                               new TextCell(new SimpleDateFormat(DATE_TIME_FORMAT).format(u.getExpires().toGregorianCalendar().getTime()),"class=expired"),
                                                                                                new RefCell("Extend",
                                                                                                                UserRoleExtend.HREF + "?user="+trans.user()+"&role="+u.getRole(),
                                                                                                                false,
@@ -118,7 +113,7 @@ public class RolesShow extends Page {
                                                                                                new RefCell(u.getRole(),
                                                                                                                RoleDetail.HREF+"?role="+u.getRole(),
                                                                                                                false),
-                                                                                               new TextCell(expiresDF.format(u.getExpires().toGregorianCalendar().getTime())),
+                                                                                               new TextCell(new SimpleDateFormat(DATE_TIME_FORMAT).format(u.getExpires().toGregorianCalendar().getTime())),
                                                                                                AbsCell.Null,
                                                                                                new RefCell("Remove",
                                                                                                                UserRoleRemove.HREF + "?user="+trans.user()+"&role="+u.getRole(),
index 5c8526a..b567637 100644 (file)
@@ -2258,7 +2258,7 @@ public class AuthzCassServiceImpl <NSS,PERMS,PERMKEY,ROLES,USERS,USERROLES,DELGS
 
        }
 
-       private final long DAY_IN_MILLIS = 24*3600*1000;
+       private final long DAY_IN_MILLIS = 24*3600*1000L;
        
        @ApiDoc( 
                        method = POST,  
index 9800ca4..8c55e7d 100644 (file)
@@ -180,9 +180,10 @@ public class API_History {
        }
        
        // Get Common "yyyymm" parameter, or none
-       private static final SimpleDateFormat FMT = new SimpleDateFormat("yyyyMM");
        
        private static int[] getYears(HttpServletRequest req) throws NumberFormatException {
+               // Sonar says threading issues.
+               SimpleDateFormat FMT = new SimpleDateFormat("yyyyMM");
                String yyyymm = req.getParameter("yyyymm");
                ArrayList<Integer> ai= new ArrayList<Integer>();
                if(yyyymm==null) {
index de8ae7d..e336042 100644 (file)
@@ -56,7 +56,7 @@ import aaf.v2_0.Users.User;
 
 public class AAFListedCertIdentity implements CertIdentity {
        //TODO should 8 hours be configurable? 
-       private static final long EIGHT_HOURS = 1000*60*60*8; 
+       private static final long EIGHT_HOURS = 1000*60*60*8L
                        
        private static Map<ByteArrayHolder,String> certs = null;
        
index 19beef6..ab0f595 100644 (file)
@@ -28,6 +28,7 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.NoSuchElementException;
 
 import org.onap.aaf.cadi.Access;
 import org.onap.aaf.cadi.Access.Level;
@@ -291,7 +292,8 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
                        case 1:
                                return new AAFLItem(iter,first);
                        default:
-                               int i = Math.abs(sr.nextInt())%lep.size();
+                               int rand = sr.nextInt(); // Sonar chokes without.
+                               int i = Math.abs(rand)%lep.size();
                                if(i<0) {
                                        return null;
                                } else {
@@ -340,6 +342,9 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
 
                @Override
                public EP next() {
+                       if(!hasNext() ) {
+                               throw new NoSuchElementException();
+                       }
                        return (EP)epa[idx++];
                }
 
@@ -434,10 +439,10 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
                public int compareTo(EP o) {
                        if(distance<o.distance) {
                                return -1;
-                       } else if(distance==o.distance) {
-                               return 0;
-                       } else {
+                       } else if(distance>o.distance) {
                                return 1;
+                       } else {
+                               return 0;
                        }
                }
                
index 14efd32..f900a1f 100644 (file)
@@ -337,7 +337,7 @@ public class CmAgent {
                String mechID = mechID(cmds);
                String machine = machine(cmds);
                String[] newmachs = machines(cmds);
-               if(newmachs==null || newmachs == null) {
+               if(machine==null || newmachs == null) {
                        trans.error().log("No machines listed to copy to");
                } else {
                        TimeTaken tt = trans.start("Copy Artifact", Env.REMOTE);
index d9ea017..9754b1e 100644 (file)
@@ -48,8 +48,8 @@ import org.onap.aaf.misc.rosetta.env.RosettaDF;
 import org.onap.aaf.misc.rosetta.env.RosettaEnv;
 
 public abstract class Persist<T,CT extends Persistable<T>> extends PersistFile {
-       private static final long ONE_DAY = 86400000;
-       private static final long CLEAN_CHECK = 2*60*1000; // check every 2 mins
+       private static final long ONE_DAY = 86400000L;
+       private static final long CLEAN_CHECK = 2*60*1000L; // check every 2 mins
        private static Timer clean;
 
        // store all the directories to review
index f75527d..7131b60 100644 (file)
@@ -33,7 +33,7 @@ public class Persisting<T> implements Persistable<T> {
        private static final byte[] EMPTY = new byte[0];
        private final byte[] hash; // need to be able to validate disk entry
 
-       private static final long SYNC_TIME = 1000*60*1; // Checking File change max 1 min
+       private static final long SYNC_TIME = 1000*60*1L; // Checking File change max 1 min
        private FileTime lastTouched;
        private int count;
        private long expires;
index f2f4def..954c855 100644 (file)
@@ -32,7 +32,7 @@ import org.onap.aaf.misc.env.impl.BasicEnv;
 
 public class Registrar<ENV extends BasicEnv> {
        private static final String REGISTRAR = "Registrar";
-       private static final long INTERVAL = 15*60*1000; // 15 mins
+       private static final long INTERVAL = 15*60*1000L; // 15 mins
        private static final long START = 3000; // Start in 3 seconds
        private static final Object LOCK = new Object();
        private Deque<Registrant<ENV>> registrants;
index 7a32473..80e6dc4 100644 (file)
@@ -51,7 +51,7 @@ public abstract class AbsAuthentication<CLIENT> implements SecuritySetter<CLIENT
        protected static final String REPEAT_OFFENDER = "This call is aborted because of repeated usage of invalid Passwords";
        private static final int MAX_TEMP_COUNT = 10;
        private static final int MAX_SPAM_COUNT = 10000;
-       private static final long WAIT_TIME = 1000*60*4;
+       private static final long WAIT_TIME = 1000*60*4L;
        private final byte[] headValue;
        private String user;
        protected final SecurityInfoC<CLIENT> securityInfo;
index f289b0e..908b895 100644 (file)
@@ -58,7 +58,7 @@ public class HRcli extends Rcli<HttpURLConnection> {
        }
 
        public HRcli(HMangr hman, URI uri, Item locItem, SecuritySetter<HttpURLConnection> secSet) {
-               locItem=item;
+               item=locItem;
                this.uri = uri;
                this.hman = hman;
                ss=secSet;
index 5820bf2..9761937 100644 (file)
@@ -49,7 +49,7 @@ public class PropertyLocator implements Locator<URI> {
        private long backgroundRefresh;
 
        public PropertyLocator(String locList) throws LocatorException {
-               this(locList,10000L, 1000*60*20); // defaults, do not refresh more than once in 10 seconds, Refresh Locator every 20 mins.
+               this(locList,10000L, 1000*60*20L); // defaults, do not refresh more than once in 10 seconds, Refresh Locator every 20 mins.
        }
        /**
         * comma delimited root url list
@@ -168,7 +168,8 @@ public class PropertyLocator implements Locator<URI> {
                        case 1:
                                return current[0];
                        default:
-                               return current[Math.abs(random.nextInt())%current.length];
+                               int rand = random.nextInt(); // sonar driven syntax
+                               return current[Math.abs(rand)%current.length];
                }
        }
 
index 90f1440..99bdb49 100644 (file)
@@ -28,8 +28,6 @@ import java.io.FileOutputStream;
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
 import java.security.NoSuchAlgorithmException;
 
 import org.onap.aaf.cadi.util.Chmod;
@@ -160,7 +158,6 @@ public class CmdLine {
                                                                        if((idx = line.indexOf(' '))>=0 
                                                                                        && (idx = line.indexOf(' ',++idx))>0
                                                                                        && (idx = line.indexOf('=',++idx))>0
-                                                                                       && (idx = line.indexOf('=',++idx))>0
                                                                                        ) {
                                                                                System.out.println(line.substring(0, idx-5));
                                                                                int start = idx+2;
index 07e9b59..bd1ad72 100644 (file)
@@ -38,7 +38,8 @@ import org.onap.aaf.cadi.config.SecurityInfo;
 import java.util.Properties;
 
 public class PropAccess implements Access {
-       private static final SimpleDateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+       // Sonar says cannot be static... it's ok.  not too many PropAccesses created.
+       private final SimpleDateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
 
        public static Level DEFAULT = Level.AUDIT;
        
index a66b688..0c01154 100644 (file)
@@ -380,7 +380,13 @@ public class Config {
                        /////////////////////////////////////////////////////
                        if(!hasOAuthDirectTAF) {
                                String oauth_token_url = logProp(access,Config.AAF_OAUTH2_TOKEN_URL,null);
-                               if(additionalTafLurs!=null && additionalTafLurs.length>0 && additionalTafLurs[0].getClass().getName().equals("org.osaaf.authz.oauth.OAuthDirectTAF")) {
+                               Class<?> oadtClss;
+                               try {
+                                       oadtClss = Class.forName("org.osaaf.authz.oauth.OAuthDirectTAF");
+                               } catch (ClassNotFoundException e1) {
+                                       oadtClss = null;
+                               }
+                               if(additionalTafLurs!=null && additionalTafLurs.length>0 && (oadtClss!=null && additionalTafLurs[0].getClass().isAssignableFrom(oadtClss))) {
                                        htlist.add((HttpTaf)additionalTafLurs[0]);
                                        String array[] = new String[additionalTafLurs.length-1];
                                        if(array.length>0) {
@@ -428,9 +434,17 @@ public class Config {
                                if(additional instanceof HttpTaf) {
                                        htlist.add((HttpTaf)additional);
                                        access.printf(Level.INIT,"%s Authentication is enabled",additional.getClass().getSimpleName());
-                               } else if(hasOAuthDirectTAF && additional.getClass().getSimpleName().equals("DirectAAFUserPass")) {
-                                       htlist.add(new BasicHttpTaf(access, (CredVal)additional , basic_realm, userExp, basic_warn));
-                                       access.printf(Level.INIT,"Direct BasicAuth Authentication is enabled",additional.getClass().getSimpleName());
+                               } else if(hasOAuthDirectTAF) {
+                                       Class<?> daupCls;
+                                       try {
+                                               daupCls = Class.forName("org.onap.aaf.auth.direct.DirectAAFUserPass");
+                                       } catch (ClassNotFoundException e) {
+                                               daupCls = null;
+                                       }
+                                       if(daupCls != null && additional.getClass().isAssignableFrom(daupCls)) {
+                                               htlist.add(new BasicHttpTaf(access, (CredVal)additional , basic_realm, userExp, basic_warn));
+                                               access.printf(Level.INIT,"Direct BasicAuth Authentication is enabled",additional.getClass().getSimpleName());
+                                       }
                                }
                        }
                }
index a8830b4..f8c6611 100644 (file)
@@ -71,7 +71,7 @@ public class LogFileNamer {
        public void configure(String props) {
                String fname;
                if(new File(fname="etc/"+props).exists()) {
-                       org.apache.log4j.PropertyConfigurator.configureAndWatch(fname,60*1000);
+                       org.apache.log4j.PropertyConfigurator.configureAndWatch(fname,60*1000L);
                } else {
                        URL rsrc = ClassLoader.getSystemResource(props);
                        if(rsrc==null) System.err.println("Neither File: " + fname + " or resource on Classpath " + props + " exist" );
index d482b24..595bc63 100644 (file)
@@ -22,6 +22,7 @@
 package org.onap.aaf.misc.rosetta;
 
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 import org.onap.aaf.misc.env.Env;
 import org.onap.aaf.misc.env.TimeTaken;
@@ -58,6 +59,9 @@ public abstract class Marshal<T> implements Parse<T, Marshal.State> {
 
                @Override
                public Void next() {
+                       if(!hasNext()) {
+                               throw new NoSuchElementException();
+                       }
                        return null;
                }
 
index 5249a17..2776546 100644 (file)
@@ -22,6 +22,7 @@
 package org.onap.aaf.misc.rosetta.marshal;
 
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 import org.onap.aaf.misc.rosetta.Ladder;
 import org.onap.aaf.misc.rosetta.Marshal;
@@ -67,6 +68,9 @@ public class DocMarshal<T> extends Marshal<T> {
 
                @Override
                public Void next() {
+                       if(!hasNext()) {
+                               throw new NoSuchElementException();
+                       }
                        return null;
                }
 
index eaa7a74..4857293 100644 (file)
@@ -22,6 +22,7 @@
 package org.onap.aaf.misc.rosetta.marshal;
 
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 import org.onap.aaf.misc.rosetta.Ladder;
 import org.onap.aaf.misc.rosetta.Marshal;
@@ -111,6 +112,9 @@ public abstract class ObjMarshal<T> extends Marshal<T> {
 
                @Override
                public Marshal<T> next() {
+                       if(!hasNext()) {
+                               throw new NoSuchElementException();
+                       }
                        return pml[++idx];
                }