From 7e966914050e66219689001ff4ab601a49eef0ac Mon Sep 17 00:00:00 2001 From: Instrumental Date: Fri, 7 Sep 2018 13:43:23 -0500 Subject: Mass whitespace changes (Style Warnings) Issue-ID: AAF-473 Change-Id: Ia1b3825a527bd56299949b5962bb9354dffbeef8 Signed-off-by: Instrumental --- .../onap/aaf/cadi/client/AbsAuthentication.java | 12 ++-- .../org/onap/aaf/cadi/client/AbsTransferSS.java | 2 +- .../main/java/org/onap/aaf/cadi/client/Rcli.java | 38 ++++++------- .../main/java/org/onap/aaf/cadi/client/Result.java | 2 +- .../onap/aaf/cadi/http/HAuthorizationHeader.java | 4 +- .../java/org/onap/aaf/cadi/http/HBasicAuthSS.java | 4 +- .../main/java/org/onap/aaf/cadi/http/HClient.java | 30 +++++----- .../main/java/org/onap/aaf/cadi/http/HMangr.java | 40 +++++++------- .../java/org/onap/aaf/cadi/http/HNoAuthSS.java | 2 +- .../main/java/org/onap/aaf/cadi/http/HRcli.java | 4 +- .../org/onap/aaf/cadi/http/HSecurityInfoInit.java | 4 +- .../java/org/onap/aaf/cadi/http/HTransferSS.java | 6 +- .../main/java/org/onap/aaf/cadi/http/HX509SS.java | 18 +++--- .../java/org/onap/aaf/cadi/locator/DNSLocator.java | 30 +++++----- .../org/onap/aaf/cadi/locator/HotPeerLocator.java | 64 +++++++++++----------- .../org/onap/aaf/cadi/locator/PropertyLocator.java | 54 +++++++++--------- .../aaf/cadi/locator/SingleEndpointLocator.java | 4 +- .../org/onap/aaf/cadi/routing/GreatCircle.java | 4 +- .../aaf/cadi/locator/test/JU_PropertyLocator.java | 2 +- 19 files changed, 162 insertions(+), 162 deletions(-) (limited to 'cadi/client') diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsAuthentication.java b/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsAuthentication.java index cce7b5f3..da85702d 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsAuthentication.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsAuthentication.java @@ -76,7 +76,7 @@ public abstract class AbsAuthentication implements SecuritySetter implements SecuritySetter0 && lastMiss>System.currentTimeMillis()) { + if (lastMiss>0 && lastMiss>System.currentTimeMillis()) { return true; } else { lastMiss=0L; @@ -102,17 +102,17 @@ public abstract class AbsAuthentication implements SecuritySetterMAX_TEMP_COUNT) { + if (lastMiss==0L && count>MAX_TEMP_COUNT) { lastMiss=System.currentTimeMillis()+WAIT_TIME; } - // if(count>MAX_SPAM_COUNT) { + // if (count>MAX_SPAM_COUNT) { // System.err.printf("Your service has %d consecutive bad service logins to AAF. \nIt will now exit\n", // count); // System.exit(401); // } - if(count%1000==0) { + if (count%1000==0) { System.err.printf("Your service has %d consecutive bad service logins to AAF. AAF Access will be disabled after %d\n", count,MAX_SPAM_COUNT); } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsTransferSS.java b/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsTransferSS.java index 0c38bd90..baac6daa 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsTransferSS.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsTransferSS.java @@ -56,7 +56,7 @@ public abstract class AbsTransferSS implements SecuritySetter { private void init(TaggedPrincipal principal, String app) { this.principal=principal; - if(principal==null) { + if (principal==null) { return; } else { value = principal.getName() + ':' + diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java index b414487b..6b486b8e 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java @@ -268,20 +268,20 @@ public abstract class Rcli { @Override public void transfer(OutputStream os) throws IOException, APIException { PrintStream ps; - if(os instanceof PrintStream) { + if (os instanceof PrintStream) { ps = (PrintStream)os; } else { ps = new PrintStream(os); } boolean first = true; - for(String fp : formParam) { - if(fp!=null) { - if(first) { + for (String fp : formParam) { + if (fp!=null) { + if (first) { first = false; } else { ps.print('&'); } - if(fp.endsWith("=")) { + if (fp.endsWith("=")) { first = true; } ps.print(fp); @@ -376,7 +376,7 @@ public abstract class Rcli { client.setMethod(GET); client.addHeader(ACCEPT, accept); - for(int i=1;i { EClient client = client(); client.setMethod(GET); client.addHeader(ACCEPT, accept); - for(int i=1;i { EClient client = client(); client.setMethod(GET); client.addHeader(ACCEPT, typeString(df.getTypeClass())); - for(int i=1;i { throw new CadiException("Invalid incoming URI",e); } String name; - for(Enumeration en = req.getHeaderNames();en.hasMoreElements();) { + for (Enumeration en = req.getHeaderNames();en.hasMoreElements();) { name = en.nextElement(); client.addHeader(name,req.getHeader(name)); } @@ -673,7 +673,7 @@ public abstract class Rcli { client.setPathInfo(pathParam); String meth = req.getMethod(); client.setMethod(meth); - if(!"GET".equals(meth)) { + if (!"GET".equals(meth)) { client.setPayload(new EClient.Transfer() { @Override public void transfer(OutputStream os) throws IOException, APIException { @@ -682,7 +682,7 @@ public abstract class Rcli { // reuse Buffers Pooled pbuff = buffPool.get(); try { - while((read=is.read(pbuff.content))>=0) { + while ((read=is.read(pbuff.content))>=0) { os.write(pbuff.content,0,read); } } finally { @@ -704,21 +704,21 @@ public abstract class Rcli { public ParsePath(final String origPath) { path = origPath; - if(origPath==null) { + if (origPath==null) { query=queryEnd=pound=-1; queryParams=null; } else { query = origPath.indexOf('?'); pound = origPath.indexOf('#'); queryEnd = pound>=0?pound:path.length(); - if(oneCallQueryParams==null) { - if(query>=0) { + if (oneCallQueryParams==null) { + if (query>=0) { queryParams = path.substring(query+1,queryEnd); } else { queryParams=null; } } else { - if(query>=0) { + if (query>=0) { queryParams = oneCallQueryParams + '&' + path.substring(query+1,queryEnd); } else { queryParams = oneCallQueryParams; @@ -729,12 +729,12 @@ public abstract class Rcli { } public String path() { - if(query>=0) { - if(pound>=0) { + if (query>=0) { + if (pound>=0) { return path.substring(pound+1); } return path.substring(0,query); - } else if(pound>=0) { + } else if (pound>=0) { return path.substring(0,pound); } else { return path; @@ -746,7 +746,7 @@ public abstract class Rcli { } public String frag() { - if(pound>=0) { + if (pound>=0) { return path.substring(pound+1); } else { return null; diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Result.java b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Result.java index e9de27e7..0e2a4b16 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Result.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Result.java @@ -51,7 +51,7 @@ public class Result { public String toString() { StringBuilder sb = new StringBuilder("Code: "); sb.append(code); - if(error!=null) { + if (error!=null) { sb.append(" = "); sb.append(error); } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HAuthorizationHeader.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HAuthorizationHeader.java index 3c38ff8d..c2f56458 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HAuthorizationHeader.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HAuthorizationHeader.java @@ -38,7 +38,7 @@ public class HAuthorizationHeader extends AbsAuthentication { @Override public void setSecurity(HttpURLConnection huc) throws CadiException { - if(isDenied()) { + if (isDenied()) { throw new CadiException(REPEAT_OFFENDER); } try { @@ -46,7 +46,7 @@ public class HAuthorizationHeader extends AbsAuthentication { } catch (IOException e) { throw new CadiException(e); } - if(securityInfo!=null && huc instanceof HttpsURLConnection) { + if (securityInfo!=null && huc instanceof HttpsURLConnection) { securityInfo.setSocketFactoryOn((HttpsURLConnection)huc); } } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HBasicAuthSS.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HBasicAuthSS.java index e4ab6d72..7e5cbd3b 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HBasicAuthSS.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HBasicAuthSS.java @@ -48,7 +48,7 @@ public class HBasicAuthSS extends HAuthorizationHeader implements BasicAuth { public HBasicAuthSS(SecurityInfoC si, String user, String pass, boolean asDefault) throws IOException { this(si, user,pass); - if(asDefault) { + if (asDefault) { si.set(this); } } @@ -59,7 +59,7 @@ public class HBasicAuthSS extends HAuthorizationHeader implements BasicAuth { public HBasicAuthSS(BasicPrincipal bp, SecurityInfoC si, boolean asDefault) throws IOException { this(si, bp.getName(),new String(bp.getCred())); - if(asDefault) { + if (asDefault) { si.set(this); } } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java index 1d3d9547..d8852834 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java @@ -111,13 +111,13 @@ public class HClient implements EClient { public void send() throws APIException { try { // Build URL from given URI plus current Settings - if(uri.getPath()==null) { + if (uri.getPath()==null) { throw new APIException("Invalid URL entered for HClient"); } StringBuilder pi=null; - if(pathinfo!=null) { // additional pathinfo + if (pathinfo!=null) { // additional pathinfo pi = new StringBuilder(uri.getPath()); - if(!pathinfo.startsWith("/")) { + if (!pathinfo.startsWith("/")) { pi.append('/'); } pi.append(pathinfo); @@ -133,7 +133,7 @@ public class HClient implements EClient { ); huc = getConnection(sendURI, pi); huc.setRequestMethod(meth); - if(ss!=null) { + if (ss!=null) { ss.setSecurity(huc); } if (headers != null) @@ -153,7 +153,7 @@ public class HClient implements EClient { throw new APIException(e); } finally { // ensure all these are reset after sends meth=pathinfo=null; - if(headers!=null) { + if (headers!=null) { headers.clear(); } pathinfo = query = fragment = ""; @@ -200,7 +200,7 @@ public class HClient implements EClient { huc.setReadTimeout(timeout); respCode = huc.getResponseCode(); ss.setLastResponse(respCode); - if(evalInfo(huc)) { + if (evalInfo(huc)) { return true; } else { extractError(); @@ -216,13 +216,13 @@ public class HClient implements EClient { private void extractError() { InputStream is = huc.getErrorStream(); try { - if(is==null) { + if (is==null) { is = huc.getInputStream(); } - if(is!=null) { + if (is!=null) { errContent = new StringBuilder(); int c; - while((c=is.read())>=0) { + while ((c=is.read())>=0) { errContent.append((char)c); } } @@ -274,7 +274,7 @@ public class HClient implements EClient { } public void close() { - if(huc!=null) { + if (huc!=null) { huc.disconnect(); } } @@ -382,12 +382,12 @@ public class HClient implements EClient { int read; InputStream is; OutputStream os = resp.getOutputStream(); - if(respCode==expected) { + if (respCode==expected) { is = huc.getInputStream(); // reuse Buffers Pooled pbuff = Rcli.buffPool.get(); try { - while((read=is.read(pbuff.content))>=0) { + while ((read=is.read(pbuff.content))>=0) { os.write(pbuff.content,0,read); } } finally { @@ -396,14 +396,14 @@ public class HClient implements EClient { return true; } else { is = huc.getErrorStream(); - if(is==null) { + if (is==null) { is = huc.getInputStream(); } - if(is!=null) { + if (is!=null) { errContent = new StringBuilder(); Pooled pbuff = Rcli.buffPool.get(); try { - while((read=is.read(pbuff.content))>=0) { + while ((read=is.read(pbuff.content))>=0) { os.write(pbuff.content,0,read); } } finally { diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java index da349efc..8e3138af 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java @@ -49,7 +49,7 @@ public class HMangr { public HMangr(Access access, Locator loc) throws LocatorException { readTimeout = 10000; connectionTimeout=3000; - if(loc == null) { + if (loc == null) { throw new LocatorException("Null Locator passed"); } this.loc = loc; @@ -79,20 +79,20 @@ public class HMangr { do { Item item; // if no previous state, get the best - if(retryable.item()==null) { + if (retryable.item()==null) { item = loc.best(); - if(item==null) { + if (item==null) { throw new LocatorException("No Services Found for " + loc); } retryable.item(item); retryable.lastClient = null; } - if(client==null) { + if (client==null) { item = retryable.item(); URI uri=loc.get(item); - if(uri==null) { + if (uri==null) { loc.invalidate(retryable.item()); - if(loc.hasItems()) { + if (loc.hasItems()) { retryable.item(loc.next(retryable.item())); continue; } else { @@ -116,22 +116,22 @@ public class HMangr { retryable.item(loc.next(item)); try { Throwable ec = e.getCause(); - if(ec instanceof java.net.ConnectException) { - if(client!=null && loc.hasItems()) { + if (ec instanceof java.net.ConnectException) { + if (client!=null && loc.hasItems()) { access.log(Level.WARN,"Connection refused, trying next available service"); retry = true; } else { throw new CadiException("Connection refused, no more services to try"); } - } else if(ec instanceof java.net.SocketException) { - if(client!=null && loc.hasItems()) { + } else if (ec instanceof java.net.SocketException) { + if (client!=null && loc.hasItems()) { access.log(Level.WARN,"Socket prematurely closed, trying next available service"); retry = true; } else { throw new CadiException("Socket prematurely closed, no more services to try"); } - } else if(ec instanceof SocketException) { - if("java.net.SocketException: Connection reset".equals(ec.getMessage())) { + } else if (ec instanceof SocketException) { + if ("java.net.SocketException: Connection reset".equals(ec.getMessage())) { access.log(Level.ERROR, ec.getMessage(), " can mean Certificate Expiration or TLS Protocol issues"); } retryable.item(null); @@ -148,7 +148,7 @@ public class HMangr { loc.invalidate(item); retryable.item(loc.next(item)); } - } while(retry); + } while (retry); } finally { retryable.lastClient = client; } @@ -172,9 +172,9 @@ public class HMangr { RET ret = null; // make sure we have all current references: loc.refresh(); - for(Item li=loc.first();li!=null;li=loc.next(li)) { + for (Item li=loc.first();li!=null;li=loc.next(li)) { URI uri=loc.get(li); - if(host!=null && !host.equals(uri.getHost())) { + if (host!=null && !host.equals(uri.getHost())) { break; } try { @@ -182,14 +182,14 @@ public class HMangr { access.log(Level.DEBUG,"Success calling",uri,"during call to all services"); } catch (APIException | CadiException e) { Throwable t = e.getCause(); - if(t!=null && t instanceof ConnectException) { + if (t!=null && t instanceof ConnectException) { loc.invalidate(li); access.log(Level.ERROR,"Connection to",uri,"refused during call to all services"); - } else if(t instanceof SSLHandshakeException) { + } else if (t instanceof SSLHandshakeException) { access.log(Level.ERROR,t.getMessage()); loc.invalidate(li); - } else if(t instanceof SocketException) { - if("java.net.SocketException: Connection reset".equals(t.getMessage())) { + } else if (t instanceof SocketException) { + if ("java.net.SocketException: Connection reset".equals(t.getMessage())) { access.log(Level.ERROR, t.getMessage(), " can mean Certificate Expiration or TLS Protocol issues"); } retryable.item(null); @@ -203,7 +203,7 @@ public class HMangr { } } - if(ret == null && notify) + if (ret == null && notify) throw new LocatorException("No available clients to call"); return ret; } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HNoAuthSS.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HNoAuthSS.java index 0f1c8b41..1fecce2b 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HNoAuthSS.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HNoAuthSS.java @@ -37,7 +37,7 @@ public class HNoAuthSS extends AbsAuthentication { @Override public void setSecurity(HttpURLConnection client) throws CadiException { - if(securityInfo!=null && client instanceof HttpsURLConnection) { + if (securityInfo!=null && client instanceof HttpsURLConnection) { securityInfo.setSocketFactoryOn((HttpsURLConnection)client); } } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HRcli.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HRcli.java index 674936d7..cbd7b33e 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HRcli.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HRcli.java @@ -81,9 +81,9 @@ public class HRcli extends Rcli { */ protected EClient client() throws CadiException { try { - if(uri==null) { + if (uri==null) { Item item = hman.loc.best(); - if(item==null) { + if (item==null) { throw new CadiException("No service available for " + hman.loc.toString()); } uri = hman.loc.get(item); diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HSecurityInfoInit.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HSecurityInfoInit.java index d792be49..3f3517f2 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HSecurityInfoInit.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HSecurityInfoInit.java @@ -41,9 +41,9 @@ public class HSecurityInfoInit implements SecurityInfoInit { @Override public SecuritySetter bestDefault(SecurityInfoC si) throws CadiException { try { - if(si.defaultAlias!=null) { + if (si.defaultAlias!=null) { si.set(new HX509SS(si)); - } else if(si.access.getProperty(Config.AAF_APPID, null)!=null && + } else if (si.access.getProperty(Config.AAF_APPID, null)!=null && si.access.getProperty(Config.AAF_APPPASS, null)!=null) { si.set(new HBasicAuthSS(si)); } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HTransferSS.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HTransferSS.java index c527ed02..f68c1f61 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HTransferSS.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HTransferSS.java @@ -44,14 +44,14 @@ public class HTransferSS extends AbsTransferSS { @Override public void setSecurity(HttpURLConnection huc) throws CadiException { - if(defSS==null) { + if (defSS==null) { throw new CadiException("Need App Credentials to send message"); } defSS.setSecurity(huc); - if(value!=null) { + if (value!=null) { huc.addRequestProperty(Config.CADI_USER_CHAIN, value); } - if(securityInfo!=null) { + if (securityInfo!=null) { securityInfo.setSocketFactoryOn((HttpsURLConnection)huc); } } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HX509SS.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HX509SS.java index cb8e6ce0..f441186e 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HX509SS.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HX509SS.java @@ -68,8 +68,8 @@ public class HX509SS implements SecuritySetter { public HX509SS(final String sendAlias, SecurityInfoC si, boolean asDefault) throws APIException, CadiException { securityInfo = si; - if((alias=sendAlias) == null) { - if(si.defaultAlias == null) { + if ((alias=sendAlias) == null) { + if (si.defaultAlias == null) { throw new APIException("JKS Alias is required to use X509SS Security. Use " + Config.CADI_ALIAS +" to set default alias"); } else { alias = si.defaultAlias; @@ -78,16 +78,16 @@ public class HX509SS implements SecuritySetter { priv=null; X509KeyManager[] xkms = si.getKeyManagers(); - if(xkms==null || xkms.length==0) { + if (xkms==null || xkms.length==0) { throw new APIException("There are no valid keys available in given Keystores. Wrong Keypass? Expired?"); } - for(int i=0;priv==null&&i0) { + if (chain!=null&&chain.length>0) { algo = chain[0].getSigAlgName(); pub = chain[0].getEncoded(); ByteArrayOutputStream baos = new ByteArrayOutputStream(pub.length*2); @@ -99,17 +99,17 @@ public class HX509SS implements SecuritySetter { } catch (CertificateEncodingException | IOException e) { throw new CadiException(e); } - if(algo==null) { + if (algo==null) { throw new APIException("X509 Security Setter not configured"); } } @Override public void setSecurity(HttpURLConnection huc) throws CadiException { - if(huc instanceof HttpsURLConnection) { + if (huc instanceof HttpsURLConnection) { securityInfo.setSocketFactoryOn((HttpsURLConnection)huc); } - if(alias==null) { // must be a one-way + if (alias==null) { // must be a one-way huc.setRequestProperty(AbsAuthentication.AUTHORIZATION, cert); // Test Signed content diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java index 1fc4b83e..8357129f 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java @@ -46,7 +46,7 @@ public class DNSLocator implements Locator { this.protocol = protocol; this.access = access; int dash = range.indexOf('-'); - if(dash<0) { + if (dash<0) { startPort = endPort = Integer.parseInt(range); } else { startPort = Integer.parseInt(range.substring(0,dash)); @@ -57,15 +57,15 @@ public class DNSLocator implements Locator { public DNSLocator(Access access, String aaf_locate) throws LocatorException { this.access = access; - if(aaf_locate==null) { + if (aaf_locate==null) { throw new LocatorException("Null passed into DNSLocator constructor"); } int start, port; - if(aaf_locate.startsWith("https:")) { + if (aaf_locate.startsWith("https:")) { protocol = "https:"; start = 9; // https:// port = 443; - } else if(aaf_locate.startsWith("http:")) { + } else if (aaf_locate.startsWith("http:")) { protocol = "http:"; start = 8; // http:// port = 80; @@ -83,8 +83,8 @@ public class DNSLocator implements Locator { @Override public boolean hasItems() { - for(Host h : hosts) { - if(h.status==Status.OK) { + for (Host h : hosts) { + if (h.status==Status.OK) { return true; } } @@ -100,7 +100,7 @@ public class DNSLocator implements Locator { @Override public Item best() throws LocatorException { // not a good "best" - for(int i=0;i { break; case UNTRIED: try { - if(hosts[i].ia.isReachable(CHECK_TIME)) { + if (hosts[i].ia.isReachable(CHECK_TIME)) { hosts[i].status = Status.OK; return new DLItem(i); } @@ -133,7 +133,7 @@ public class DNSLocator implements Locator { @Override public Item next(Item item) throws LocatorException { DLItem di = (DLItem)item; - if(++di.cnt { InetAddress[] ias = InetAddress.getAllByName(host); Host[] temp = new Host[ias.length * (1 + endPort - startPort)]; int cnt = -1; - for(int j=startPort; j<=endPort; ++j) { - for(int i=0;i { private void parsePorts(String aaf_locate, int defaultPort) throws LocatorException { int slash, start; int colon = aaf_locate.indexOf(':'); - if(colon > 0) { + if (colon > 0) { start = colon + 1; int left = aaf_locate.indexOf('[', start); - if(left > 0) { + if (left > 0) { int right = aaf_locate.indexOf(']', left + 1); if (right < 0) { throw new LocatorException("Missing closing bracket in DNSLocator constructor. (requested URL " + aaf_locate + ')'); @@ -176,7 +176,7 @@ public class DNSLocator implements Locator { if (dash == (right - 1) || dash == (left + 1)) { throw new LocatorException("Missing ports in brackets in DNSLocator constructor. (requested URL " + aaf_locate + ')'); } - if(dash < 0) { + if (dash < 0) { startPort = endPort = Integer.parseInt(aaf_locate.substring(left + 1, right)); } else { startPort = Integer.parseInt(aaf_locate.substring(left + 1, dash)); @@ -188,7 +188,7 @@ public class DNSLocator implements Locator { if (slash == start) { throw new LocatorException("Missing port before '/' in DNSLocator constructor. (requested URL " + aaf_locate + ')'); } - if(slash < 0) { + if (slash < 0) { startPort = endPort = Integer.parseInt(aaf_locate.substring(start)); } else { startPort = endPort = Integer.parseInt(aaf_locate.substring(start, slash)); diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/HotPeerLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/HotPeerLocator.java index 26b8817b..93cefc58 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/HotPeerLocator.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/HotPeerLocator.java @@ -74,15 +74,15 @@ public abstract class HotPeerLocator implements Locator { this.invalidateTime = invalidateTime; double distance = Double.MAX_VALUE; - for(int i=0;i implements Locator { distances[i]=d; // find preferred server - if(d implements Locator { @Override public Item best() throws LocatorException { - if(failures[preferred]==0L) { + if (failures[preferred]==0L) { return new HPItem(preferred); } else { long now = System.currentTimeMillis(); @@ -125,9 +125,9 @@ public abstract class HotPeerLocator implements Locator { int best = -1; boolean tickle = false; // try for best existing client - for(int i=0;i implements Locator { } } } - if(best<0 && tickle) { + if (best<0 && tickle) { tickle=false; - if(refresh()) { + if (refresh()) { // try again - for(int i=0;i implements Locator { * If a valid client is available, but there are some that can refresh, return the client immediately * but start a Thread to do the background Client setup. */ - if(tickle) { + if (tickle) { synchronized(clients) { - if(refreshThread==null) { + if (refreshThread==null) { refreshThread = new Thread(new Runnable(){ @Override public void run() { @@ -170,7 +170,7 @@ public abstract class HotPeerLocator implements Locator { } } - if(best<0) { + if (best<0) { throw new LocatorException("No Clients available"); } @@ -183,8 +183,8 @@ public abstract class HotPeerLocator implements Locator { public CLIENT get(Item item) throws LocatorException { HPItem hpi = (HPItem)item; CLIENT c = clients[hpi.idx]; - if(c==null) { - if(failures[hpi.idx]>System.currentTimeMillis()) { + if (c==null) { + if (failures[hpi.idx]>System.currentTimeMillis()) { throw new LocatorException("Client requested is invalid"); } else { synchronized(clients) { @@ -192,7 +192,7 @@ public abstract class HotPeerLocator implements Locator { failures[hpi.idx]=0L; } } - } else if(failures[hpi.idx]>0){ + } else if (failures[hpi.idx]>0){ throw new LocatorException("Client requested is invalid"); } return c; @@ -200,7 +200,7 @@ public abstract class HotPeerLocator implements Locator { public String info(Item item) { HPItem hpi = (HPItem)item; - if(hpi!=null && hpi.idx implements Locator { @Override public boolean hasItems() { - for(int i=0;i implements Locator { @Override public Item next(Item item) throws LocatorException { HPItem hpi = (HPItem)item; - if(++hpi.idx>=clients.length) { + if (++hpi.idx>=clients.length) { return null; } return hpi; @@ -244,11 +244,11 @@ public abstract class HotPeerLocator implements Locator { boolean force = !hasItems(); // If no Items at all, reset boolean rv = true; long now = System.currentTimeMillis(); - for(int i=0;i0L && (failures[i]0L && (failures[i] implements Locator { @Override public void destroy() { - for(int i=0;i implements Locator { } public boolean invalidate(CLIENT client) throws LocatorException { - for(int i=0;i { minRefresh = minRefreshMillis; backgroundRefresh = backgroundRefreshMillis; lastRefreshed=0L; - if(locList==null) { + if (locList==null) { throw new LocatorException("No Location List given for PropertyLocator"); } String[] locarray = Split.split(',',locList); @@ -69,10 +69,10 @@ public class PropertyLocator implements Locator { random = new SecureRandom(); - for(int i=0;i { int slash = locarray[i].indexOf('/',brac); int start = Integer.parseInt(locarray[i].substring(range+2, dash)); int end = Integer.parseInt(locarray[i].substring(dash+1, brac)); - for(int port=start;port<=end;++port) { + for (int port=start;port<=end;++port) { uriList.add(new URI(mach_colon+port + (slash>=0?locarray[i].substring(slash):""))); } } @@ -106,7 +106,7 @@ public class PropertyLocator implements Locator { @Override public URI get(Item item) throws LocatorException { synchronized(orig) { - if(item==null) { + if (item==null) { return null; } else { return resolved[((PLItem)item).idx]; @@ -126,31 +126,31 @@ public class PropertyLocator implements Locator { @Override public Item next(Item item) throws LocatorException { - if(item==null) { + if (item==null) { return null; } else { int spot; - if((spot=(((PLItem)item).order+1))>=end)return null; + if ((spot=(((PLItem)item).order+1))>=end)return null; return current[spot]; } } @Override public synchronized void invalidate(Item item) throws LocatorException { - if(--end<0) { + if (--end<0) { refresh(); return; } - if(item==null) { + if (item==null) { return; } PLItem pli = (PLItem)item; int i,order; - for(i=0;i { @Override public Item best() throws LocatorException { - if(current.length==0) { + if (current.length==0) { refresh(); } switch(current.length) { @@ -175,27 +175,27 @@ public class PropertyLocator implements Locator { @Override public synchronized boolean refresh() { - if(System.currentTimeMillis()>lastRefreshed) { + if (System.currentTimeMillis()>lastRefreshed) { // Build up list List resolve = new ArrayList<>(); String realname; - for(int i = 0; i < orig.length ; ++i) { + for (int i = 0; i < orig.length ; ++i) { try { InetAddress ia[] = InetAddress.getAllByName(orig[i].getHost()); URI o,n; - for(int j=0;j { } } catch (IOException e) { } finally { - if(!socket.isClosed()) { + if (!socket.isClosed()) { try { socket.close(); } catch (IOException e) { @@ -227,14 +227,14 @@ public class PropertyLocator implements Locator { } end=resolve.size(); PLItem[] newCurrent; - if(current==null || current.length!=end) { + if (current==null || current.length!=end) { newCurrent = new PLItem[end]; } else { newCurrent = current; } - for(int i=0; i< end; ++i) { - if(newCurrent[i]==null){ + for (int i=0; i< end; ++i) { + if (newCurrent[i]==null){ newCurrent[i]=new PLItem(i); } else { newCurrent[i].idx=newCurrent[i].order=i; @@ -271,18 +271,18 @@ public class PropertyLocator implements Locator { public String toString() { StringBuilder sb = new StringBuilder(); boolean first = true; - for(URI uri : orig) { + for (URI uri : orig) { boolean isResolved=false; - if(uri!=null) { - if(first) { + if (uri!=null) { + if (first) { first = false; } else { sb.append(", "); } sb.append(uri.toString()); sb.append(" ["); - for(URI u2 : resolved) { - if(uri.equals(u2)) { + for (URI u2 : resolved) { + if (uri.equals(u2)) { isResolved = true; break; } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java index 816dec82..3b79dba5 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java @@ -47,8 +47,8 @@ public class SingleEndpointLocator implements Locator { @Override public boolean hasItems() { - if(noRetryUntil!=null) { - if(new Date().after(noRetryUntil)) { + if (noRetryUntil!=null) { + if (new Date().after(noRetryUntil)) { noRetryUntil = null; } else { return false; diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/routing/GreatCircle.java b/cadi/client/src/main/java/org/onap/aaf/cadi/routing/GreatCircle.java index 3bce5245..27eb507f 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/routing/GreatCircle.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/routing/GreatCircle.java @@ -87,7 +87,7 @@ public class GreatCircle { switch(coords.length) { case 1: array = Split.split(',',coords[0]); - if(array.length!=4)return -1; + if (array.length!=4)return -1; return calc( Double.parseDouble(array[0]), Double.parseDouble(array[1]), @@ -97,7 +97,7 @@ public class GreatCircle { case 2: array = Split.split(',',coords[0]); String [] array2 = Split.split(',',coords[1]); - if(array.length!=2 || array2.length!=2)return -1; + if (array.length!=2 || array2.length!=2)return -1; return calc( Double.parseDouble(array[0]), Double.parseDouble(array[1]), diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_PropertyLocator.java b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_PropertyLocator.java index 7b61e398..0eae1198 100644 --- a/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_PropertyLocator.java +++ b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_PropertyLocator.java @@ -107,7 +107,7 @@ public class JU_PropertyLocator { private int countItems(PropertyLocator pl) throws LocatorException { int count = 0; - for(Item i = pl.first(); i != null; i = pl.next(i)) { + for (Item i = pl.first(); i != null; i = pl.next(i)) { ++count; } return count; -- cgit 1.2.3-korg