Repository: tomee Updated Branches: refs/heads/master f519c3c40 -> df8d80edc
Use foreach instead of manual interaction by index. Available in Java 5 and newer. Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/59c77e56 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/59c77e56 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/59c77e56 Branch: refs/heads/master Commit: 59c77e567b584ecd212db3f4e0622eace4439666 Parents: 761c283 Author: Otavio Santana <otaviopolianasant...@gmail.com> Authored: Thu Dec 20 08:14:00 2018 -0200 Committer: Otavio Santana <otaviopolianasant...@gmail.com> Committed: Thu Dec 20 08:14:00 2018 -0200 ---------------------------------------------------------------------- .../java/org/apache/openejb/MethodSpec.java | 4 +- .../main/java/org/apache/openejb/OpenEJB.java | 12 +++--- .../org/apache/openejb/config/AppValidator.java | 40 ++++++++++---------- .../config/OpenEJBDeploymentManager.java | 3 +- .../apache/openejb/config/SunConversion.java | 4 +- .../openejb/config/rules/CheckMethods.java | 40 ++++++++++---------- .../openejb/core/NoSuchObjectException.java | 8 ++-- .../apache/openejb/core/cmp/cmp2/CmrSet.java | 3 +- .../openejb/core/cmp/cmp2/SetValuedCmr.java | 4 +- .../core/entity/EntityEjbHomeHandler.java | 4 +- .../security/jaas/PropertiesLoginModule.java | 4 +- .../jaas/UsernamePasswordCallbackHandler.java | 3 +- .../TransactionRolledbackException.java | 8 ++-- .../math/stat/descriptive/moment/Variance.java | 4 +- .../java/org/apache/openejb/util/Base64.java | 16 ++++---- .../openejb/util/IntrospectionSupport.java | 23 +++++------ .../org/apache/openejb/util/URISupport.java | 14 +++---- .../org/apache/openejb/DependencyVisitor.java | 4 +- 18 files changed, 96 insertions(+), 102 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/MethodSpec.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/MethodSpec.java b/container/openejb-core/src/main/java/org/apache/openejb/MethodSpec.java index 1a40702..295c7fe 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/MethodSpec.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/MethodSpec.java @@ -76,8 +76,8 @@ public class MethodSpec implements Comparable, Serializable { int result = 17; result = 37 * result + methodIntf.hashCode(); result = 37 * result + methodName.hashCode(); - for (int i = 0; i < parameterTypes.length; i++) { - result = 37 * result + parameterTypes[i].hashCode(); + for (String parameterType : parameterTypes) { + result = 37 * result + parameterType.hashCode(); } return result; } http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/OpenEJB.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/OpenEJB.java b/container/openejb-core/src/main/java/org/apache/openejb/OpenEJB.java index ccc1d7f..6bd5d88 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/OpenEJB.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/OpenEJB.java @@ -172,9 +172,9 @@ public final class OpenEJB { if (containerSystem.containers().length > 0) { final Container[] c = containerSystem.containers(); logger.debug("startup.debugContainersType"); - for (int i = 0; i < c.length; i++) { + for (Container container : c) { String entry = " "; - switch (c[i].getContainerType()) { + switch (container.getContainerType()) { case BMP_ENTITY: entry += "BMP ENTITY "; break; @@ -191,7 +191,7 @@ public final class OpenEJB { entry += "MESSAGE "; break; } - entry += c[i].getContainerID(); + entry += container.getContainerID(); logger.debug("startup.debugEntry", entry); } } @@ -200,9 +200,9 @@ public final class OpenEJB { if (containerSystem.deployments().length > 0) { logger.debug("startup.debugDeploymentsType"); final BeanContext[] d = containerSystem.deployments(); - for (int i = 0; i < d.length; i++) { + for (BeanContext beanContext : d) { String entry = " "; - switch (d[i].getComponentType()) { + switch (beanContext.getComponentType()) { case BMP_ENTITY: entry += "BMP_ENTITY "; break; @@ -225,7 +225,7 @@ public final class OpenEJB { entry += "MESSAGE "; break; } - entry += d[i].getDeploymentID(); + entry += beanContext.getDeploymentID(); logger.debug("startup.debugEntry", entry); } } http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/config/AppValidator.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AppValidator.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AppValidator.java index 9bb664f..f462e99 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/config/AppValidator.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AppValidator.java @@ -98,8 +98,8 @@ public class AppValidator { Thread.currentThread().setContextClassLoader(appModule.getClassLoader()); // be sure to not mix classloaders try { final ValidationRule[] rules = getValidationRules(); - for (int i = 0; i < rules.length; i++) { - rules[i].validate(appModule); + for (ValidationRule rule : rules) { + rule.validate(appModule); } } catch (final DefinitionException de) { throw de; @@ -164,22 +164,22 @@ public class AppValidator { } protected void printValidationExceptions(final ValidationException[] exceptions) { - for (int i = 0; i < exceptions.length; i++) { + for (ValidationException exception : exceptions) { System.out.print(" "); - System.out.print(exceptions[i].getPrefix()); + System.out.print(exception.getPrefix()); System.out.print(" ... "); - if (!(exceptions[i] instanceof ValidationError)) { - System.out.print(exceptions[i].getComponentName()); + if (!(exception instanceof ValidationError)) { + System.out.print(exception.getComponentName()); System.out.print(": "); } if (level > 2) { - System.out.println(exceptions[i].getMessage(1)); + System.out.println(exception.getMessage(1)); System.out.println(); System.out.print('\t'); - System.out.println(exceptions[i].getMessage(level)); + System.out.println(exception.getMessage(level)); System.out.println(); } else { - System.out.println(exceptions[i].getMessage(level)); + System.out.println(exception.getMessage(level)); } } if (printCount && exceptions.length > 0) { @@ -211,23 +211,23 @@ public class AppValidator { } protected void printValidationExceptionsXML(final ValidationException[] exceptions) { - for (int i = 0; i < exceptions.length; i++) { + for (ValidationException exception : exceptions) { System.out.print(" <"); - System.out.print(exceptions[i].getPrefix()); + System.out.print(exception.getPrefix()); System.out.println(">"); - if (!(exceptions[i] instanceof ValidationError)) { + if (!(exception instanceof ValidationError)) { System.out.print(" <ejb-name>"); - System.out.print(exceptions[i].getComponentName()); + System.out.print(exception.getComponentName()); System.out.println("</ejb-name>"); } System.out.print(" <summary>"); - System.out.print(exceptions[i].getMessage(1)); + System.out.print(exception.getMessage(1)); System.out.println("</summary>"); System.out.println(" <description><![CDATA["); - System.out.println(exceptions[i].getMessage(3)); + System.out.println(exception.getMessage(3)); System.out.println("]]></description>"); System.out.print(" </"); - System.out.print(exceptions[i].getPrefix()); + System.out.print(exception.getPrefix()); System.out.println(">"); } } @@ -235,13 +235,13 @@ public class AppValidator { public void displayResults(final ValidationResults[] sets) { if (printXml) { System.out.println("<results>"); - for (int i = 0; i < sets.length; i++) { - printResultsXML(sets[i]); + for (ValidationResults set : sets) { + printResultsXML(set); } System.out.println("</results>"); } else { - for (int i = 0; i < sets.length; i++) { - printResults(sets[i]); + for (ValidationResults set : sets) { + printResults(set); } for (int i = 0; i < sets.length; i++) { if (sets[i].hasErrors() || sets[i].hasFailures()) { http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/config/OpenEJBDeploymentManager.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/OpenEJBDeploymentManager.java b/container/openejb-core/src/main/java/org/apache/openejb/config/OpenEJBDeploymentManager.java index 47d2075..87671a6 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/config/OpenEJBDeploymentManager.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/config/OpenEJBDeploymentManager.java @@ -95,8 +95,7 @@ public class OpenEJBDeploymentManager implements DeploymentManager { // target.* - known targets available on the server // target.*.description - known targets available on the server final SortedMap<String, Target> targets = new TreeMap<>(); - for (final Iterator<Map.Entry<Object, Object>> iterator = properties.entrySet().iterator(); iterator.hasNext(); ) { - final Map.Entry entry = iterator.next(); + for (final Map.Entry entry : properties.entrySet()) { final String key = (String) entry.getKey(); final String targetName = (String) entry.getValue(); if (key.startsWith("target.") && !key.endsWith(".description")) { http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/config/SunConversion.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/SunConversion.java b/container/openejb-core/src/main/java/org/apache/openejb/config/SunConversion.java index 2511d2b..1589b4c 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/config/SunConversion.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/config/SunConversion.java @@ -1171,9 +1171,9 @@ public class SunConversion implements DynamicDeployer { boolean inWitespace = false; StringBuilder currentSymbol = new StringBuilder(); - for (int i = 0; i < bits.size(); i++) { + for (Object bit1 : bits) { final TokenType tokenType; - final String bit = (String) bits.get(i); + final String bit = (String) bit1; switch (bit.charAt(0)) { case ' ': case '\t': http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckMethods.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckMethods.java b/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckMethods.java index eb541ea..b89ca7e 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckMethods.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckMethods.java @@ -94,13 +94,13 @@ public class CheckMethods extends ValidationBase { final Method[] interfaceMethods = intrface.getMethods(); - for (int i = 0; i < interfaceMethods.length; i++) { - if (interfaceMethods[i].getDeclaringClass() == EJBLocalObject.class) { + for (Method interfaceMethod : interfaceMethods) { + if (interfaceMethod.getDeclaringClass() == EJBLocalObject.class) { continue; } - final String name = interfaceMethods[i].getName(); + final String name = interfaceMethod.getName(); try { - final Class[] params = interfaceMethods[i].getParameterTypes(); + final Class[] params = interfaceMethod.getParameterTypes(); beanClass.getMethod(name, params); } catch (final NoSuchMethodException nsme) { final List<Method> differentArgs = new ArrayList<>(); @@ -115,13 +115,13 @@ public class CheckMethods extends ValidationBase { } if (differentArgs.size() > 0) { - fail(b, "no.busines.method.args", interfaceMethods[i].getName(), interfaceMethods[i].toString(), "local", intrface.getName(), beanClass.getName(), differentArgs.size()); + fail(b, "no.busines.method.args", interfaceMethod.getName(), interfaceMethod.toString(), "local", intrface.getName(), beanClass.getName(), differentArgs.size()); } if (differentCase.size() > 0) { - fail(b, "no.busines.method.case", interfaceMethods[i].getName(), interfaceMethods[i].toString(), "local", intrface.getName(), beanClass.getName(), differentCase.size()); + fail(b, "no.busines.method.case", interfaceMethod.getName(), interfaceMethod.toString(), "local", intrface.getName(), beanClass.getName(), differentCase.size()); } if (differentArgs.size() == 0 && differentCase.size() == 0) { - fail(b, "no.busines.method", interfaceMethods[i].getName(), interfaceMethods[i].toString(), "local", intrface.getName(), beanClass.getName()); + fail(b, "no.busines.method", interfaceMethod.getName(), interfaceMethod.toString(), "local", intrface.getName(), beanClass.getName()); } } } @@ -145,13 +145,13 @@ public class CheckMethods extends ValidationBase { final Method[] interfaceMethods = intrface.getMethods(); - for (int i = 0; i < interfaceMethods.length; i++) { - if (interfaceMethods[i].getDeclaringClass() == EJBObject.class) { + for (Method interfaceMethod : interfaceMethods) { + if (interfaceMethod.getDeclaringClass() == EJBObject.class) { continue; } - final String name = interfaceMethods[i].getName(); + final String name = interfaceMethod.getName(); try { - final Class[] params = interfaceMethods[i].getParameterTypes(); + final Class[] params = interfaceMethod.getParameterTypes(); beanClass.getMethod(name, params); } catch (final NoSuchMethodException nsme) { final List<Method> differentArgs = new ArrayList<>(); @@ -166,13 +166,13 @@ public class CheckMethods extends ValidationBase { } if (differentArgs.size() > 0) { - fail(b, "no.busines.method.args", interfaceMethods[i].getName(), interfaceMethods[i].toString(), "remote", intrface.getName(), beanClass.getName(), differentArgs.size()); + fail(b, "no.busines.method.args", interfaceMethod.getName(), interfaceMethod.toString(), "remote", intrface.getName(), beanClass.getName(), differentArgs.size()); } if (differentCase.size() > 0) { - fail(b, "no.busines.method.case", interfaceMethods[i].getName(), interfaceMethods[i].toString(), "remote", intrface.getName(), beanClass.getName(), differentCase.size()); + fail(b, "no.busines.method.case", interfaceMethod.getName(), interfaceMethod.toString(), "remote", intrface.getName(), beanClass.getName(), differentCase.size()); } if (differentArgs.size() == 0 && differentCase.size() == 0) { - fail(b, "no.busines.method", interfaceMethods[i].getName(), interfaceMethods[i].toString(), "remote", intrface.getName(), beanClass.getName()); + fail(b, "no.busines.method", interfaceMethod.getName(), interfaceMethod.toString(), "remote", intrface.getName(), beanClass.getName()); } } } @@ -229,12 +229,12 @@ public class CheckMethods extends ValidationBase { final Method[] homeMethods = home.getMethods(); - for (int i = 0; i < homeMethods.length; i++) { - if (!homeMethods[i].getName().startsWith("create")) { + for (Method homeMethod : homeMethods) { + if (!homeMethod.getName().startsWith("create")) { continue; } - final Method create = homeMethods[i]; + final Method create = homeMethod; final StringBuilder ejbCreateName = new StringBuilder(create.getName()); ejbCreateName.replace(0, 1, "ejbC"); @@ -279,11 +279,11 @@ public class CheckMethods extends ValidationBase { final Method[] homeMethods = home.getMethods(); final Method[] beanMethods = bean.getMethods(); - for (int i = 0; i < homeMethods.length; i++) { - if (!homeMethods[i].getName().startsWith("create")) { + for (Method homeMethod : homeMethods) { + if (!homeMethod.getName().startsWith("create")) { continue; } - final Method create = homeMethods[i]; + final Method create = homeMethod; final StringBuilder ejbPostCreateName = new StringBuilder(create.getName()); ejbPostCreateName.replace(0, 1, "ejbPostC"); try { http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/core/NoSuchObjectException.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/NoSuchObjectException.java b/container/openejb-core/src/main/java/org/apache/openejb/core/NoSuchObjectException.java index a962fd4..7ff96a7 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/core/NoSuchObjectException.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/core/NoSuchObjectException.java @@ -101,8 +101,8 @@ public class NoSuchObjectException extends java.rmi.NoSuchObjectException { // Don't use getStackTrace() as it calls clone() // Get stackTrace, in case stackTrace is reassigned final StackTraceElement[] stack = getStackTrace(); - for (int i = 0; i < stack.length; i++) { - err.println("\tat " + stack[i]); + for (StackTraceElement stackTraceElement : stack) { + err.println("\tat " + stackTraceElement); } StackTraceElement[] parentStack = stack; @@ -134,8 +134,8 @@ public class NoSuchObjectException extends java.rmi.NoSuchObjectException { // Don't use getStackTrace() as it calls clone() // Get stackTrace, in case stackTrace is reassigned final StackTraceElement[] stack = getStackTrace(); - for (int i = 0; i < stack.length; i++) { - err.println("\tat " + stack[i]); + for (StackTraceElement stackTraceElement : stack) { + err.println("\tat " + stackTraceElement); } StackTraceElement[] parentStack = stack; http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/CmrSet.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/CmrSet.java b/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/CmrSet.java index 20a3249..87dca1a 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/CmrSet.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/CmrSet.java @@ -90,8 +90,7 @@ public class CmrSet<Bean extends EntityBean, Proxy extends EJBLocalObject> exten public boolean addAll(final Collection c) { final Set<Bean> entityBeans = getEntityBeans(c, relatedLocal); boolean changed = false; - for (final Iterator<Bean> iterator = entityBeans.iterator(); iterator.hasNext(); ) { - final Bean bean = iterator.next(); + for (final Bean bean : entityBeans) { changed = add(bean) || changed; } return changed; http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/SetValuedCmr.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/SetValuedCmr.java b/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/SetValuedCmr.java index b317a47..cbd2abd 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/SetValuedCmr.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/core/cmp/cmp2/SetValuedCmr.java @@ -108,8 +108,8 @@ public class SetValuedCmr<Bean extends EntityBean, Proxy extends EJBLocalObject> } relatedBeans.clear(); - for (final Iterator iterator = new ArrayList(newProxies).iterator(); iterator.hasNext(); ) { - final Proxy newProxy = (Proxy) iterator.next(); + for (Object o : new ArrayList(newProxies)) { + final Proxy newProxy = (Proxy) o; final Bean newBean = Cmp2Util.<Bean>getEntityBean(newProxy); if (newProxy != null) { http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityEjbHomeHandler.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityEjbHomeHandler.java b/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityEjbHomeHandler.java index 62daa13..3b93ac2 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityEjbHomeHandler.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityEjbHomeHandler.java @@ -71,8 +71,8 @@ public class EntityEjbHomeHandler extends EjbHomeProxyHandler { if (retValue instanceof Collection) { final Object[] proxyInfos = ((Collection) retValue).toArray(); final Vector proxies = new Vector(); - for (int i = 0; i < proxyInfos.length; i++) { - final ProxyInfo proxyInfo = (ProxyInfo) proxyInfos[i]; + for (Object proxyInfo1 : proxyInfos) { + final ProxyInfo proxyInfo = (ProxyInfo) proxyInfo1; proxies.addElement(createProxy(proxyInfo.getPrimaryKey(), getMainInterface())); } return proxies; http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/core/security/jaas/PropertiesLoginModule.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/security/jaas/PropertiesLoginModule.java b/container/openejb-core/src/main/java/org/apache/openejb/core/security/jaas/PropertiesLoginModule.java index a906d11..ce6e1ae 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/core/security/jaas/PropertiesLoginModule.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/core/security/jaas/PropertiesLoginModule.java @@ -133,8 +133,8 @@ public class PropertiesLoginModule implements LoginModule { for (final Enumeration enumeration = groups.keys(); enumeration.hasMoreElements(); ) { final String name = (String) enumeration.nextElement(); final String[] userList = String.valueOf(groups.getProperty(name)).split(","); - for (int i = 0; i < userList.length; i++) { - if (user.equals(userList[i])) { + for (String s : userList) { + if (user.equals(s)) { principals.add(new GroupPrincipal(name)); break; } http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/core/security/jaas/UsernamePasswordCallbackHandler.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/security/jaas/UsernamePasswordCallbackHandler.java b/container/openejb-core/src/main/java/org/apache/openejb/core/security/jaas/UsernamePasswordCallbackHandler.java index 9c8358e..992195e 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/core/security/jaas/UsernamePasswordCallbackHandler.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/core/security/jaas/UsernamePasswordCallbackHandler.java @@ -38,8 +38,7 @@ public class UsernamePasswordCallbackHandler implements CallbackHandler { } public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException { - for (int i = 0; i < callbacks.length; i++) { - final Callback callback = callbacks[i]; + for (final Callback callback : callbacks) { if (callback instanceof PasswordCallback) { final PasswordCallback passwordCallback = (PasswordCallback) callback; if (password == null) { http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/core/transaction/TransactionRolledbackException.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/transaction/TransactionRolledbackException.java b/container/openejb-core/src/main/java/org/apache/openejb/core/transaction/TransactionRolledbackException.java index bd29af5..46991cb 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/core/transaction/TransactionRolledbackException.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/core/transaction/TransactionRolledbackException.java @@ -112,8 +112,8 @@ public class TransactionRolledbackException extends javax.transaction.Transactio // Don't use getStackTrace() as it calls clone() // Get stackTrace, in case stackTrace is reassigned final StackTraceElement[] stack = getStackTrace(); - for (int i = 0; i < stack.length; i++) { - err.println("\tat " + stack[i]); + for (StackTraceElement stackTraceElement : stack) { + err.println("\tat " + stackTraceElement); } StackTraceElement[] parentStack = stack; @@ -146,8 +146,8 @@ public class TransactionRolledbackException extends javax.transaction.Transactio // Don't use getStackTrace() as it calls clone() // Get stackTrace, in case stackTrace is reassigned final StackTraceElement[] stack = getStackTrace(); - for (int i = 0; i < stack.length; i++) { - err.println("\tat " + stack[i]); + for (StackTraceElement stackTraceElement : stack) { + err.println("\tat " + stackTraceElement); } StackTraceElement[] parentStack = stack; http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/moment/Variance.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/moment/Variance.java b/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/moment/Variance.java index e4a34a7..3d21e9f 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/moment/Variance.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/moment/Variance.java @@ -510,8 +510,8 @@ public class Variance extends AbstractStorelessUnivariateStatistic implements Se } double sumWts = 0; - for (int i = 0; i < weights.length; i++) { - sumWts += weights[i]; + for (double weight : weights) { + sumWts += weight; } if (isBiasCorrected) { http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/util/Base64.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/Base64.java b/container/openejb-core/src/main/java/org/apache/openejb/util/Base64.java index abce7c8..b8f25d7 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/util/Base64.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/util/Base64.java @@ -179,8 +179,8 @@ public class Base64 { // return false; return true; } - for (int i = 0; i < length; i++) { - if (!isBase64(arrayOctect[i])) { + for (byte b : arrayOctect) { + if (!isBase64(b)) { return false; } } @@ -462,15 +462,15 @@ public class Base64 { final byte[] groomedData = new byte[data.length]; int bytesCopied = 0; - for (int i = 0; i < data.length; i++) { - switch (data[i]) { + for (byte datum : data) { + switch (datum) { case (byte) ' ': case (byte) '\n': case (byte) '\r': case (byte) '\t': break; default: - groomedData[bytesCopied++] = data[i]; + groomedData[bytesCopied++] = datum; } } @@ -494,9 +494,9 @@ public class Base64 { final byte[] groomedData = new byte[data.length]; int bytesCopied = 0; - for (int i = 0; i < data.length; i++) { - if (isBase64(data[i])) { - groomedData[bytesCopied++] = data[i]; + for (byte datum : data) { + if (isBase64(datum)) { + groomedData[bytesCopied++] = datum; } } http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/util/IntrospectionSupport.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/IntrospectionSupport.java b/container/openejb-core/src/main/java/org/apache/openejb/util/IntrospectionSupport.java index 6815e41..b126a51 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/util/IntrospectionSupport.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/util/IntrospectionSupport.java @@ -52,13 +52,12 @@ public class IntrospectionSupport { final Class clazz = target.getClass(); final Method[] methods = clazz.getMethods(); - for (int i = 0; i < methods.length; i++) { - final Method method = methods[i]; + for (final Method method : methods) { String name = method.getName(); final Class type = method.getReturnType(); final Class[] params = method.getParameterTypes(); if (name.startsWith("get") && params.length == 0 && type != null - && isSettableType(type)) { + && isSettableType(type)) { try { @@ -73,7 +72,7 @@ public class IntrospectionSupport { } name = name.substring(3, 4).toLowerCase() - + name.substring(4); + + name.substring(4); props.put(optionPrefix + name, strValue); rc = true; @@ -206,11 +205,10 @@ public class IntrospectionSupport { // Build the method name. name = "set" + name.substring(0, 1).toUpperCase() + name.substring(1); final Method[] methods = clazz.getMethods(); - for (int i = 0; i < methods.length; i++) { - final Method method = methods[i]; + for (final Method method : methods) { final Class[] params = method.getParameterTypes(); if (method.getName().equals(name) && params.length == 1 - && isSettableType(params[0])) { + && isSettableType(params[0])) { return method; } } @@ -241,8 +239,8 @@ public class IntrospectionSupport { buffer.append(" {"); final Set entrySet = map.entrySet(); boolean first = true; - for (final Iterator iter = entrySet.iterator(); iter.hasNext(); ) { - final Map.Entry entry = (Map.Entry) iter.next(); + for (Object o : entrySet) { + final Entry entry = (Entry) o; if (first) { first = false; } else { @@ -277,11 +275,10 @@ public class IntrospectionSupport { } final Field[] fields = startClass.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) { - final Field field = fields[i]; + for (final Field field : fields) { if (Modifier.isStatic(field.getModifiers()) - || Modifier.isTransient(field.getModifiers()) - || Modifier.isPrivate(field.getModifiers())) { + || Modifier.isTransient(field.getModifiers()) + || Modifier.isPrivate(field.getModifiers())) { continue; } http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/main/java/org/apache/openejb/util/URISupport.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/URISupport.java b/container/openejb-core/src/main/java/org/apache/openejb/util/URISupport.java index 829327b..b23cddf 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/util/URISupport.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/util/URISupport.java @@ -171,14 +171,14 @@ public class URISupport { final Map<String, String> rc = new LinkedHashMap<>(); if (uri != null) { final String[] parameters = uri.split("&"); - for (int i = 0; i < parameters.length; i++) { - final int p = parameters[i].indexOf('='); + for (String parameter : parameters) { + final int p = parameter.indexOf('='); if (p >= 0) { - final String name = URLDecoder.decode(parameters[i].substring(0, p), "UTF-8"); - final String value = URLDecoder.decode(parameters[i].substring(p + 1), "UTF-8"); + final String name = URLDecoder.decode(parameter.substring(0, p), "UTF-8"); + final String value = URLDecoder.decode(parameter.substring(p + 1), "UTF-8"); rc.put(name, value); } else { - rc.put(parameters[i], null); + rc.put(parameter, null); } } } @@ -313,14 +313,14 @@ public class URISupport { if (options.size() > 0) { final StringBuilder rc = new StringBuilder(); boolean first = true; - for (final Iterator iter = options.keySet().iterator(); iter.hasNext(); ) { + for (Object o : options.keySet()) { if (first) { first = false; } else { rc.append("&"); } - final String key = (String) iter.next(); + final String key = (String) o; final String value = (String) options.get(key); rc.append(URLEncoder.encode(key, "UTF-8")); rc.append("="); http://git-wip-us.apache.org/repos/asf/tomee/blob/59c77e56/container/openejb-core/src/test/java/org/apache/openejb/DependencyVisitor.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/DependencyVisitor.java b/container/openejb-core/src/test/java/org/apache/openejb/DependencyVisitor.java index d6abf86..d1eadb7 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/DependencyVisitor.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/DependencyVisitor.java @@ -369,8 +369,8 @@ public class DependencyVisitor extends EmptyVisitor { private void addMethodDesc(final String desc) { addType(Type.getReturnType(desc)); final Type[] types = Type.getArgumentTypes(desc); - for (int i = 0; i < types.length; i++) { - addType(types[i]); + for (Type type : types) { + addType(type); } }