struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject [6/9] struts git commit: Minor code improvements's in the xwork-core module
Date Mon, 15 Jun 2015 17:38:07 GMT
http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/inject/util/ReferenceMap.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/inject/util/ReferenceMap.java b/xwork-core/src/main/java/com/opensymphony/xwork2/inject/util/ReferenceMap.java
index 2542a8c..4d8eebb 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/inject/util/ReferenceMap.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/inject/util/ReferenceMap.java
@@ -1,12 +1,12 @@
 /**
  * Copyright (C) 2006 Google Inc.
- *
+ * <p/>
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
+ * <p/>
  * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p/>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,8 +16,6 @@
 
 package com.opensymphony.xwork2.inject.util;
 
-import static com.opensymphony.xwork2.inject.util.ReferenceType.STRONG;
-
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
@@ -27,6 +25,8 @@ import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
+import static com.opensymphony.xwork2.inject.util.ReferenceType.STRONG;
+
 /**
  * Concurrent hash map that wraps keys and/or values in soft or weak
  * references. Does not support null keys or values. Uses identity equality
@@ -54,563 +54,552 @@ import java.util.concurrent.ConcurrentMap;
 @SuppressWarnings("unchecked")
 public class ReferenceMap<K, V> implements Map<K, V>, Serializable {
 
-  private static final long serialVersionUID = 0;
-
-  transient ConcurrentMap<Object, Object> delegate;
-
-  final ReferenceType keyReferenceType;
-  final ReferenceType valueReferenceType;
-
-  /**
-   * Concurrent hash map that wraps keys and/or values based on specified
-   * reference types.
-   *
-   * @param keyReferenceType key reference type
-   * @param valueReferenceType value reference type
-   */
-  public ReferenceMap(ReferenceType keyReferenceType,
-      ReferenceType valueReferenceType) {
-    ensureNotNull(keyReferenceType, valueReferenceType);
-
-    if (keyReferenceType == ReferenceType.PHANTOM
-        || valueReferenceType == ReferenceType.PHANTOM) {
-      throw new IllegalArgumentException("Phantom references not supported.");
-    }
-
-    this.delegate = new ConcurrentHashMap<Object, Object>();
-    this.keyReferenceType = keyReferenceType;
-    this.valueReferenceType = valueReferenceType;
-  }
-
-  V internalGet(K key) {
-    Object valueReference = delegate.get(makeKeyReferenceAware(key));
-    return valueReference == null
-        ? null
-        : (V) dereferenceValue(valueReference);
-  }
-
-  public V get(final Object key) {
-    ensureNotNull(key);
-    return internalGet((K) key);
-  }
-
-  V execute(Strategy strategy, K key, V value) {
-    ensureNotNull(key, value);
-    Object keyReference = referenceKey(key);
-    Object valueReference = strategy.execute(
-      this,
-      keyReference,
-      referenceValue(keyReference, value)
-    );
-    return valueReference == null ? null
-        : (V) dereferenceValue(valueReference);
-  }
-
-  public V put(K key, V value) {
-    return execute(putStrategy(), key, value);
-  }
-
-  public V remove(Object key) {
-    ensureNotNull(key);
-    Object referenceAwareKey = makeKeyReferenceAware(key);
-    Object valueReference = delegate.remove(referenceAwareKey);
-    return valueReference == null ? null
-        : (V) dereferenceValue(valueReference);
-  }
-
-  public int size() {
-    return delegate.size();
-  }
-
-  public boolean isEmpty() {
-    return delegate.isEmpty();
-  }
-
-  public boolean containsKey(Object key) {
-    ensureNotNull(key);
-    Object referenceAwareKey = makeKeyReferenceAware(key);
-    return delegate.containsKey(referenceAwareKey);
-  }
-
-  public boolean containsValue(Object value) {
-    ensureNotNull(value);
-    for (Object valueReference : delegate.values()) {
-      if (value.equals(dereferenceValue(valueReference))) {
-        return true;
-      }
-    }
-    return false;
-  }
-
-  public void putAll(Map<? extends K, ? extends V> t) {
-    for (Map.Entry<? extends K, ? extends V> entry : t.entrySet()) {
-      put(entry.getKey(), entry.getValue());
-    }
-  }
-
-  public void clear() {
-    delegate.clear();
-  }
-
-  /**
-   * Returns an unmodifiable set view of the keys in this map. As this method
-   * creates a defensive copy, the performance is O(n).
-   */
-  public Set<K> keySet() {
-    return Collections.unmodifiableSet(
-        dereferenceKeySet(delegate.keySet()));
-  }
-
-  /**
-   * Returns an unmodifiable set view of the values in this map. As this
-   * method creates a defensive copy, the performance is O(n).
-   */
-  public Collection<V> values() {
-    return Collections.unmodifiableCollection(
-        dereferenceValues(delegate.values()));
-  }
-
-  public V putIfAbsent(K key, V value) {
-    // TODO (crazybob) if the value has been gc'ed but the entry hasn't been
-    // cleaned up yet, this put will fail.
-    return execute(putIfAbsentStrategy(), key, value);
-  }
-
-  public boolean remove(Object key, Object value) {
-    ensureNotNull(key, value);
-    Object referenceAwareKey = makeKeyReferenceAware(key);
-    Object referenceAwareValue = makeValueReferenceAware(value);
-    return delegate.remove(referenceAwareKey, referenceAwareValue);
-  }
-
-  public boolean replace(K key, V oldValue, V newValue) {
-    ensureNotNull(key, oldValue, newValue);
-    Object keyReference = referenceKey(key);
-
-    Object referenceAwareOldValue = makeValueReferenceAware(oldValue);
-    return delegate.replace(
-      keyReference,
-      referenceAwareOldValue,
-      referenceValue(keyReference, newValue)
-    );
-  }
-
-  public V replace(K key, V value) {
-    // TODO (crazybob) if the value has been gc'ed but the entry hasn't been
-    // cleaned up yet, this will succeed when it probably shouldn't.
-    return execute(replaceStrategy(), key, value);
-  }
-
-  /**
-   * Returns an unmodifiable set view of the entries in this map. As this
-   * method creates a defensive copy, the performance is O(n).
-   */
-  public Set<Map.Entry<K, V>> entrySet() {
-    Set<Map.Entry<K, V>> entrySet = new HashSet<Map.Entry<K, V>>();
-    for (Map.Entry<Object, Object> entry : delegate.entrySet()) {
-      Map.Entry<K, V> dereferenced = dereferenceEntry(entry);
-      if (dereferenced != null) {
-        entrySet.add(dereferenced);
-      }
-    }
-    return Collections.unmodifiableSet(entrySet);
-  }
-
-  /**
-   * Dereferences an entry. Returns null if the key or value has been gc'ed.
-   */
-  Entry dereferenceEntry(Map.Entry<Object, Object> entry) {
-    K key = dereferenceKey(entry.getKey()); 
-    V value = dereferenceValue(entry.getValue());
-    return (key == null || value == null)
-        ? null
-        : new Entry(key, value);
-  }
-
-  /**
-   * Creates a reference for a key.
-   */
-  Object referenceKey(K key) {
-    switch (keyReferenceType) {
-      case STRONG: return key;
-      case SOFT: return new SoftKeyReference(key);
-      case WEAK: return new WeakKeyReference(key);
-      default: throw new AssertionError();
-    }
-  }
-
-  /**
-   * Converts a reference to a key.
-   */
-  K dereferenceKey(Object o) {
-    return (K) dereference(keyReferenceType, o);
-  }
-
-  /**
-   * Converts a reference to a value.
-   */
-  V dereferenceValue(Object o) {
-    return (V) dereference(valueReferenceType, o);
-  }
-
-  /**
-   * Returns the refererent for reference given its reference type.
-   */
-  Object dereference(ReferenceType referenceType, Object reference) {
-    return referenceType == STRONG ? reference : ((Reference) reference).get();
-  }
-
-  /**
-   * Creates a reference for a value.
-   */
-  Object referenceValue(Object keyReference, Object value) {
-    switch (valueReferenceType) {
-      case STRONG: return value;
-      case SOFT: return new SoftValueReference(keyReference, value);
-      case WEAK: return new WeakValueReference(keyReference, value);
-      default: throw new AssertionError();
-    }
-  }
-
-  /**
-   * Dereferences a set of key references.
-   */
-  Set<K> dereferenceKeySet(Set keyReferences) {
-    return keyReferenceType == STRONG
-        ? keyReferences
-        : dereferenceCollection(keyReferenceType, keyReferences, new HashSet());
-  }
-
-  /**
-   * Dereferences a collection of value references.
-   */
-  Collection<V> dereferenceValues(Collection valueReferences) {
-    return valueReferenceType == STRONG
-        ? valueReferences
-        : dereferenceCollection(valueReferenceType, valueReferences,
-            new ArrayList(valueReferences.size()));
-  }
-
-  /**
-   * Wraps key so it can be compared to a referenced key for equality.
-   */
-  Object makeKeyReferenceAware(Object o) {
-    return keyReferenceType == STRONG ? o : new KeyReferenceAwareWrapper(o);
-  }
-
-  /**
-   * Wraps value so it can be compared to a referenced value for equality.
-   */
-  Object makeValueReferenceAware(Object o) {
-    return valueReferenceType == STRONG ? o : new ReferenceAwareWrapper(o);
-  }
-
-  /**
-   * Dereferences elements in {@code in} using
-   * {@code referenceType} and puts them in {@code out}. Returns
-   * {@code out}.
-   */
-  <T extends Collection<Object>> T dereferenceCollection(
-      ReferenceType referenceType, T in, T out) {
-    for (Object reference : in) {
-      out.add(dereference(referenceType, reference));
-    }
-    return out;
-  }
-
-  /**
-   * Marker interface to differentiate external and internal references.
-   */
-  interface InternalReference {}
-
-  static int keyHashCode(Object key) {
-    return System.identityHashCode(key);
-  }
-
-  /**
-   * Tests weak and soft references for identity equality. Compares references
-   * to other references and wrappers. If o is a reference, this returns true
-   * if r == o or if r and o reference the same non null object. If o is a
-   * wrapper, this returns true if r's referent is identical to the wrapped
-   * object.
-   */
-  static boolean referenceEquals(Reference r, Object o) {
-    // compare reference to reference.
-    if (o instanceof InternalReference) {
-      // are they the same reference? used in cleanup.
-      if (o == r) {
-        return true;
-      }
+    private static final long serialVersionUID = 0;
 
-      // do they reference identical values? used in conditional puts.
-      Object referent = ((Reference) o).get();
-      return referent != null && referent == r.get();
-    }
+    transient ConcurrentMap<Object, Object> delegate;
 
-    // is the wrapped object identical to the referent? used in lookups.
-    return ((ReferenceAwareWrapper) o).unwrap() == r.get();
-  }
+    final ReferenceType keyReferenceType;
+    final ReferenceType valueReferenceType;
 
-  /**
-   * Big hack. Used to compare keys and values to referenced keys and values
-   * without creating more references.
-   */
-  static class ReferenceAwareWrapper {
+    /**
+     * Concurrent hash map that wraps keys and/or values based on specified
+     * reference types.
+     *
+     * @param keyReferenceType   key reference type
+     * @param valueReferenceType value reference type
+     */
+    public ReferenceMap(ReferenceType keyReferenceType,
+                        ReferenceType valueReferenceType) {
+        ensureNotNull(keyReferenceType, valueReferenceType);
 
-    Object wrapped;
+        if (keyReferenceType == ReferenceType.PHANTOM || valueReferenceType == ReferenceType.PHANTOM) {
+            throw new IllegalArgumentException("Phantom references not supported.");
+        }
 
-    ReferenceAwareWrapper(Object wrapped) {
-      this.wrapped = wrapped;
+        this.delegate = new ConcurrentHashMap<>();
+        this.keyReferenceType = keyReferenceType;
+        this.valueReferenceType = valueReferenceType;
     }
 
-    Object unwrap() {
-      return wrapped;
+    V internalGet(K key) {
+        Object valueReference = delegate.get(makeKeyReferenceAware(key));
+        return valueReference == null ? null : (V) dereferenceValue(valueReference);
     }
 
-    @Override
-    public int hashCode() {
-      return wrapped.hashCode();
+    public V get(final Object key) {
+        ensureNotNull(key);
+        return internalGet((K) key);
     }
 
-    @Override
-    public boolean equals(Object obj) {
-      // defer to reference's equals() logic.
-      return obj.equals(this);
+    V execute(Strategy strategy, K key, V value) {
+        ensureNotNull(key, value);
+        Object keyReference = referenceKey(key);
+        Object valueReference = strategy.execute(this, keyReference, referenceValue(keyReference, value));
+        return valueReference == null ? null : (V) dereferenceValue(valueReference);
     }
-  }
 
-  /**
-   * Used for keys. Overrides hash code to use identity hash code.
-   */
-  static class KeyReferenceAwareWrapper extends ReferenceAwareWrapper {
+    public V put(K key, V value) {
+        return execute(putStrategy(), key, value);
+    }
 
-    public KeyReferenceAwareWrapper(Object wrapped) {
-      super(wrapped);
+    public V remove(Object key) {
+        ensureNotNull(key);
+        Object referenceAwareKey = makeKeyReferenceAware(key);
+        Object valueReference = delegate.remove(referenceAwareKey);
+        return valueReference == null ? null : (V) dereferenceValue(valueReference);
     }
 
-    @Override
-    public int hashCode() {
-      return System.identityHashCode(wrapped);
+    public int size() {
+        return delegate.size();
     }
-  }
 
-  class SoftKeyReference extends FinalizableSoftReference<Object>
-      implements InternalReference {
+    public boolean isEmpty() {
+        return delegate.isEmpty();
+    }
 
-    int hashCode;
+    public boolean containsKey(Object key) {
+        ensureNotNull(key);
+        Object referenceAwareKey = makeKeyReferenceAware(key);
+        return delegate.containsKey(referenceAwareKey);
+    }
 
-    public SoftKeyReference(Object key) {
-      super(key);
-      this.hashCode = keyHashCode(key);
+    public boolean containsValue(Object value) {
+        ensureNotNull(value);
+        for (Object valueReference : delegate.values()) {
+            if (value.equals(dereferenceValue(valueReference))) {
+                return true;
+            }
+        }
+        return false;
     }
 
-    public void finalizeReferent() {
-      delegate.remove(this);
+    public void putAll(Map<? extends K, ? extends V> t) {
+        for (Map.Entry<? extends K, ? extends V> entry : t.entrySet()) {
+            put(entry.getKey(), entry.getValue());
+        }
     }
 
-    @Override public int hashCode() {
-      return this.hashCode;
+    public void clear() {
+        delegate.clear();
     }
 
-    @Override public boolean equals(Object o) {
-      return referenceEquals(this, o);
+    /**
+     * Returns an unmodifiable set view of the keys in this map. As this method
+     * creates a defensive copy, the performance is O(n).
+     */
+    public Set<K> keySet() {
+        return Collections.unmodifiableSet(dereferenceKeySet(delegate.keySet()));
     }
-  }
 
-  class WeakKeyReference extends FinalizableWeakReference<Object>
-      implements InternalReference {
+    /**
+     * Returns an unmodifiable set view of the values in this map. As this
+     * method creates a defensive copy, the performance is O(n).
+     */
+    public Collection<V> values() {
+        return Collections.unmodifiableCollection(dereferenceValues(delegate.values()));
+    }
+
+    public V putIfAbsent(K key, V value) {
+        // TODO (crazybob) if the value has been gc'ed but the entry hasn't been
+        // cleaned up yet, this put will fail.
+        return execute(putIfAbsentStrategy(), key, value);
+    }
 
-    int hashCode;
+    public boolean remove(Object key, Object value) {
+        ensureNotNull(key, value);
+        Object referenceAwareKey = makeKeyReferenceAware(key);
+        Object referenceAwareValue = makeValueReferenceAware(value);
+        return delegate.remove(referenceAwareKey, referenceAwareValue);
+    }
 
-    public WeakKeyReference(Object key) {
-      super(key);
-      this.hashCode = keyHashCode(key);
-    }
+    public boolean replace(K key, V oldValue, V newValue) {
+        ensureNotNull(key, oldValue, newValue);
+        Object keyReference = referenceKey(key);
+
+        Object referenceAwareOldValue = makeValueReferenceAware(oldValue);
+        return delegate.replace(keyReference, referenceAwareOldValue, referenceValue(keyReference, newValue));
+    }
+
+    public V replace(K key, V value) {
+        // TODO (crazybob) if the value has been gc'ed but the entry hasn't been
+        // cleaned up yet, this will succeed when it probably shouldn't.
+        return execute(replaceStrategy(), key, value);
+    }
+
+    /**
+     * Returns an unmodifiable set view of the entries in this map. As this
+     * method creates a defensive copy, the performance is O(n).
+     */
+    public Set<Map.Entry<K, V>> entrySet() {
+        Set<Map.Entry<K, V>> entrySet = new HashSet<>();
+        for (Map.Entry<Object, Object> entry : delegate.entrySet()) {
+            Map.Entry<K, V> dereferenced = dereferenceEntry(entry);
+            if (dereferenced != null) {
+                entrySet.add(dereferenced);
+            }
+        }
+        return Collections.unmodifiableSet(entrySet);
+    }
+
+    /**
+     * Dereferences an entry. Returns null if the key or value has been gc'ed.
+     */
+    Entry dereferenceEntry(Map.Entry<Object, Object> entry) {
+        K key = dereferenceKey(entry.getKey());
+        V value = dereferenceValue(entry.getValue());
+        return (key == null || value == null) ? null : new Entry(key, value);
+    }
+
+    /**
+     * Creates a reference for a key.
+     */
+    Object referenceKey(K key) {
+        switch (keyReferenceType) {
+            case STRONG:
+                return key;
+            case SOFT:
+                return new SoftKeyReference(key);
+            case WEAK:
+                return new WeakKeyReference(key);
+            default:
+                throw new AssertionError();
+        }
+    }
+
+    /**
+     * Converts a reference to a key.
+     */
+    K dereferenceKey(Object o) {
+        return (K) dereference(keyReferenceType, o);
+    }
+
+    /**
+     * Converts a reference to a value.
+     */
+    V dereferenceValue(Object o) {
+        return (V) dereference(valueReferenceType, o);
+    }
+
+    /**
+     * Returns the refererent for reference given its reference type.
+     */
+    Object dereference(ReferenceType referenceType, Object reference) {
+        return referenceType == STRONG ? reference : ((Reference) reference).get();
+    }
+
+    /**
+     * Creates a reference for a value.
+     */
+    Object referenceValue(Object keyReference, Object value) {
+        switch (valueReferenceType) {
+            case STRONG:
+                return value;
+            case SOFT:
+                return new SoftValueReference(keyReference, value);
+            case WEAK:
+                return new WeakValueReference(keyReference, value);
+            default:
+                throw new AssertionError();
+        }
+    }
+
+    /**
+     * Dereferences a set of key references.
+     */
+    Set<K> dereferenceKeySet(Set keyReferences) {
+        return keyReferenceType == STRONG
+                ? keyReferences
+                : dereferenceCollection(keyReferenceType, keyReferences, new HashSet());
+    }
+
+    /**
+     * Dereferences a collection of value references.
+     */
+    Collection<V> dereferenceValues(Collection valueReferences) {
+        return valueReferenceType == STRONG
+                ? valueReferences
+                : dereferenceCollection(valueReferenceType, valueReferences,
+                new ArrayList(valueReferences.size()));
+    }
+
+    /**
+     * Wraps key so it can be compared to a referenced key for equality.
+     */
+    Object makeKeyReferenceAware(Object o) {
+        return keyReferenceType == STRONG ? o : new KeyReferenceAwareWrapper(o);
+    }
+
+    /**
+     * Wraps value so it can be compared to a referenced value for equality.
+     */
+    Object makeValueReferenceAware(Object o) {
+        return valueReferenceType == STRONG ? o : new ReferenceAwareWrapper(o);
+    }
+
+    /**
+     * Dereferences elements in {@code in} using
+     * {@code referenceType} and puts them in {@code out}. Returns
+     * {@code out}.
+     */
+    <T extends Collection<Object>> T dereferenceCollection(ReferenceType referenceType, T in, T out) {
+        for (Object reference : in) {
+            out.add(dereference(referenceType, reference));
+        }
+        return out;
+    }
+
+    /**
+     * Marker interface to differentiate external and internal references.
+     */
+    interface InternalReference {
+    }
+
+    static int keyHashCode(Object key) {
+        return System.identityHashCode(key);
+    }
+
+    /**
+     * Tests weak and soft references for identity equality. Compares references
+     * to other references and wrappers. If o is a reference, this returns true
+     * if r == o or if r and o reference the same non null object. If o is a
+     * wrapper, this returns true if r's referent is identical to the wrapped
+     * object.
+     */
+    static boolean referenceEquals(Reference r, Object o) {
+        // compare reference to reference.
+        if (o instanceof InternalReference) {
+            // are they the same reference? used in cleanup.
+            if (o == r) {
+                return true;
+            }
+
+            // do they reference identical values? used in conditional puts.
+            Object referent = ((Reference) o).get();
+            return referent != null && referent == r.get();
+        }
+
+        // is the wrapped object identical to the referent? used in lookups.
+        return ((ReferenceAwareWrapper) o).unwrap() == r.get();
+    }
+
+    /**
+     * Big hack. Used to compare keys and values to referenced keys and values
+     * without creating more references.
+     */
+    static class ReferenceAwareWrapper {
+
+        Object wrapped;
+
+        ReferenceAwareWrapper(Object wrapped) {
+            this.wrapped = wrapped;
+        }
 
-    public void finalizeReferent() {
-      delegate.remove(this);
+        Object unwrap() {
+            return wrapped;
+        }
+
+        @Override
+        public int hashCode() {
+            return wrapped.hashCode();
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            // defer to reference's equals() logic.
+            return obj.equals(this);
+        }
     }
 
-    @Override public int hashCode() {
-      return this.hashCode;
+    /**
+     * Used for keys. Overrides hash code to use identity hash code.
+     */
+    static class KeyReferenceAwareWrapper extends ReferenceAwareWrapper {
+
+        public KeyReferenceAwareWrapper(Object wrapped) {
+            super(wrapped);
+        }
+
+        @Override
+        public int hashCode() {
+            return System.identityHashCode(wrapped);
+        }
     }
 
-    @Override public boolean equals(Object o) {
-      return referenceEquals(this, o);
+    class SoftKeyReference extends FinalizableSoftReference<Object> implements InternalReference {
+
+        int hashCode;
+
+        public SoftKeyReference(Object key) {
+            super(key);
+            this.hashCode = keyHashCode(key);
+        }
+
+        public void finalizeReferent() {
+            delegate.remove(this);
+        }
+
+        @Override
+        public int hashCode() {
+            return this.hashCode;
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            return referenceEquals(this, o);
+        }
     }
-  }
 
-  class SoftValueReference extends FinalizableSoftReference<Object>
-      implements InternalReference {
+    class WeakKeyReference extends FinalizableWeakReference<Object> implements InternalReference {
+
+        int hashCode;
+
+        public WeakKeyReference(Object key) {
+            super(key);
+            this.hashCode = keyHashCode(key);
+        }
 
-    Object keyReference;
+        public void finalizeReferent() {
+            delegate.remove(this);
+        }
 
-    public SoftValueReference(Object keyReference, Object value) {
-      super(value);
-      this.keyReference = keyReference;
+        @Override
+        public int hashCode() {
+            return this.hashCode;
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            return referenceEquals(this, o);
+        }
     }
 
-    public void finalizeReferent() {
-      delegate.remove(keyReference, this);
+    class SoftValueReference extends FinalizableSoftReference<Object> implements InternalReference {
+
+        Object keyReference;
+
+        public SoftValueReference(Object keyReference, Object value) {
+            super(value);
+            this.keyReference = keyReference;
+        }
+
+        public void finalizeReferent() {
+            delegate.remove(keyReference, this);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            return referenceEquals(this, obj);
+        }
     }
 
-    @Override public boolean equals(Object obj) {
-      return referenceEquals(this, obj);
+    class WeakValueReference extends FinalizableWeakReference<Object> implements InternalReference {
+
+        Object keyReference;
+
+        public WeakValueReference(Object keyReference, Object value) {
+            super(value);
+            this.keyReference = keyReference;
+        }
+
+        public void finalizeReferent() {
+            delegate.remove(keyReference, this);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            return referenceEquals(this, obj);
+        }
     }
-  }
 
-  class WeakValueReference extends FinalizableWeakReference<Object>
-      implements InternalReference {
+    protected interface Strategy {
+        public Object execute(ReferenceMap map, Object keyReference, Object valueReference);
+    }
 
-    Object keyReference;
+    protected Strategy putStrategy() {
+        return PutStrategy.PUT;
+    }
 
-    public WeakValueReference(Object keyReference, Object value) {
-      super(value);
-      this.keyReference = keyReference;
+    protected Strategy putIfAbsentStrategy() {
+        return PutStrategy.PUT_IF_ABSENT;
     }
 
-    public void finalizeReferent() {
-      delegate.remove(keyReference, this);
+    protected Strategy replaceStrategy() {
+        return PutStrategy.REPLACE;
     }
 
-    @Override public boolean equals(Object obj) {
-      return referenceEquals(this, obj);
+    private enum PutStrategy implements Strategy {
+        PUT {
+            public Object execute(ReferenceMap map, Object keyReference, Object valueReference) {
+                return map.delegate.put(keyReference, valueReference);
+            }
+        },
+
+        REPLACE {
+            public Object execute(ReferenceMap map, Object keyReference, Object valueReference) {
+                return map.delegate.replace(keyReference, valueReference);
+            }
+        },
+
+        PUT_IF_ABSENT {
+            public Object execute(ReferenceMap map, Object keyReference, Object valueReference) {
+                return map.delegate.putIfAbsent(keyReference, valueReference);
+            }
+        };
     }
-  }
 
-  protected interface Strategy {
-    public Object execute(ReferenceMap map, Object keyReference,
-        Object valueReference);
-  }
+    private static PutStrategy defaultPutStrategy;
 
-  protected Strategy putStrategy() {
-    return PutStrategy.PUT;
-  }
+    protected PutStrategy getPutStrategy() {
+        return defaultPutStrategy;
+    }
 
-  protected Strategy putIfAbsentStrategy() {
-    return PutStrategy.PUT_IF_ABSENT;
-  }
 
-  protected Strategy replaceStrategy() {
-    return PutStrategy.REPLACE;
-  }
+    class Entry implements Map.Entry<K, V> {
 
-  private enum PutStrategy implements Strategy {
-    PUT {
-      public Object execute(ReferenceMap map, Object keyReference,
-          Object valueReference) {
-        return map.delegate.put(keyReference, valueReference);
-      }
-    },
+        K key;
+        V value;
 
-    REPLACE {
-      public Object execute(ReferenceMap map, Object keyReference,
-          Object valueReference) {
-        return map.delegate.replace(keyReference, valueReference);
-      }
-    },
+        public Entry(K key, V value) {
+            this.key = key;
+            this.value = value;
+        }
 
-    PUT_IF_ABSENT {
-      public Object execute(ReferenceMap map, Object keyReference,
-          Object valueReference) {
-        return map.delegate.putIfAbsent(keyReference, valueReference);
-      }
-    };
-  };
+        public K getKey() {
+            return this.key;
+        }
 
-  private static PutStrategy defaultPutStrategy;
+        public V getValue() {
+            return this.value;
+        }
 
-  protected PutStrategy getPutStrategy() {
-    return defaultPutStrategy;
-  }
+        public V setValue(V value) {
+            return put(key, value);
+        }
 
+        @Override
+        public int hashCode() {
+            return key.hashCode() * 31 + value.hashCode();
+        }
 
-  class Entry implements Map.Entry<K, V> {
+        @Override
+        public boolean equals(Object o) {
+            if (!(o instanceof ReferenceMap.Entry)) {
+                return false;
+            }
 
-    K key;
-    V value;
+            Entry entry = (Entry) o;
+            return key.equals(entry.key) && value.equals(entry.value);
+        }
 
-    public Entry(K key, V value) {
-      this.key = key;
-      this.value = value;
+        @Override
+        public String toString() {
+            return key + "=" + value;
+        }
     }
 
-    public K getKey() {
-      return this.key;
+    static void ensureNotNull(Object o) {
+        if (o == null) {
+            throw new NullPointerException();
+        }
     }
 
-    public V getValue() {
-      return this.value;
+    static void ensureNotNull(Object... array) {
+        for (int i = 0; i < array.length; i++) {
+            if (array[i] == null) {
+                throw new NullPointerException("Argument #" + i + " is null.");
+            }
+        }
     }
 
-    public V setValue(V value) {
-      return put(key, value);
-    }
+    private void writeObject(ObjectOutputStream out) throws IOException {
+        out.defaultWriteObject();
+        out.writeInt(size());
+        for (Map.Entry<Object, Object> entry : delegate.entrySet()) {
+            Object key = dereferenceKey(entry.getKey());
+            Object value = dereferenceValue(entry.getValue());
 
-    @Override
-    public int hashCode() {
-      return key.hashCode() * 31 + value.hashCode();
+            // don't persist gc'ed entries.
+            if (key != null && value != null) {
+                out.writeObject(key);
+                out.writeObject(value);
+            }
+        }
+        out.writeObject(null);
     }
 
-    @Override
-    public boolean equals(Object o) {
-      if (!(o instanceof ReferenceMap.Entry)) {
-        return false;
-      }
-
-      Entry entry = (Entry) o;
-      return key.equals(entry.key) && value.equals(entry.value);
-    }
-
-    @Override
-    public String toString() {
-      return key + "=" + value;
-    }
-  }
-
-  static void ensureNotNull(Object o) {
-    if (o == null) {
-      throw new NullPointerException();
-    }
-  }
-
-  static void ensureNotNull(Object... array) {
-    for (int i = 0; i < array.length; i++) {
-      if (array[i] == null) {
-        throw new NullPointerException("Argument #" + i + " is null.");
-      }
-    }
-  }
-
-  private void writeObject(ObjectOutputStream out) throws IOException  {
-    out.defaultWriteObject();
-    out.writeInt(size());
-    for (Map.Entry<Object, Object> entry : delegate.entrySet()) {
-      Object key = dereferenceKey(entry.getKey());
-      Object value = dereferenceValue(entry.getValue());
-
-      // don't persist gc'ed entries.
-      if (key != null && value != null) {
-        out.writeObject(key);
-        out.writeObject(value);
-      }
-    }
-    out.writeObject(null);
-  }
-
-  private void readObject(ObjectInputStream in) throws IOException,
-      ClassNotFoundException {
-    in.defaultReadObject();
-    int size = in.readInt();
-    this.delegate = new ConcurrentHashMap<Object, Object>(size);
-    while (true) {
-      K key = (K) in.readObject();
-      if (key == null) {
-        break;
-      }
-      V value = (V) in.readObject();
-      put(key, value);
-    }
-  }
+    private void readObject(ObjectInputStream in) throws IOException,
+            ClassNotFoundException {
+        in.defaultReadObject();
+        int size = in.readInt();
+        this.delegate = new ConcurrentHashMap<Object, Object>(size);
+        while (true) {
+            K key = (K) in.readObject();
+            if (key == null) {
+                break;
+            }
+            V value = (V) in.readObject();
+            put(key, value);
+        }
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/AliasInterceptor.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/AliasInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/AliasInterceptor.java
index f05a75c..7bd9499 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/AliasInterceptor.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/AliasInterceptor.java
@@ -20,15 +20,15 @@ import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.ValidationAware;
 import com.opensymphony.xwork2.XWorkConstants;
-import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
-import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ClearableValueStack;
-import com.opensymphony.xwork2.util.ValueStackFactory;
 import com.opensymphony.xwork2.util.LocalizedTextUtil;
+import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.util.ValueStackFactory;
 import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.util.Map;
 
@@ -184,9 +184,7 @@ public class AliasInterceptor extends AbstractInterceptor {
                 if (clearableStack && (stack.getContext() != null) && (newStack.getContext() != null))
                     stack.getContext().put(ActionContext.CONVERSION_ERRORS, newStack.getContext().get(ActionContext.CONVERSION_ERRORS));
             } else {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("invalid alias expression:" + aliasesKey);
-                }
+                LOG.debug("invalid alias expression: {}", aliasesKey);
             }
         }
         

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ConversionErrorInterceptor.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ConversionErrorInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ConversionErrorInterceptor.java
index 8022790..47d020a 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ConversionErrorInterceptor.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ConversionErrorInterceptor.java
@@ -115,7 +115,7 @@ public class ConversionErrorInterceptor extends AbstractInterceptor {
                 }
 
                 if (fakie == null) {
-                    fakie = new HashMap<Object, Object>();
+                    fakie = new HashMap<>();
                 }
 
                 fakie.put(propertyName, getOverrideExpr(invocation, value));

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor.java
index a2ac59c..13cea0e 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor.java
@@ -19,8 +19,9 @@ import com.opensymphony.xwork2.Action;
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.ValidationAware;
 import com.opensymphony.xwork2.interceptor.annotations.InputConfig;
-import org.apache.logging.log4j.Logger;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.lang.reflect.Method;
 
@@ -185,7 +186,7 @@ public class DefaultWorkflowInterceptor extends MethodFilterInterceptor {
         String resultName = currentResultName;
         InputConfig annotation = action.getClass().getMethod(method, EMPTY_CLASS_ARRAY).getAnnotation(InputConfig.class);
         if (annotation != null) {
-            if (!annotation.methodName().equals("")) {
+            if (StringUtils.isNotEmpty(annotation.methodName())) {
                 Method m = action.getClass().getMethod(annotation.methodName());
                 resultName = (String) m.invoke(action);
             } else {

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java
index 99aadef..afdd534 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/I18nInterceptor.java
@@ -18,8 +18,8 @@ package com.opensymphony.xwork2.interceptor;
 
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.util.LocalizedTextUtil;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.util.Locale;
 import java.util.Map;
@@ -103,9 +103,7 @@ public class I18nInterceptor extends AbstractInterceptor {
     protected enum Storage { SESSION, NONE }
 
     public I18nInterceptor() {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("new I18nInterceptor()");
-        }
+        LOG.debug("new I18nInterceptor()");
     }
 
     public void setParameterName(String parameterName) {
@@ -123,8 +121,7 @@ public class I18nInterceptor extends AbstractInterceptor {
     @Override
     public String intercept(ActionInvocation invocation) throws Exception {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Intercept '{}/{}' {",
-                invocation.getProxy().getNamespace(), invocation.getProxy().getActionName());
+            LOG.debug("Intercept '{}/{}' {", invocation.getProxy().getNamespace(), invocation.getProxy().getActionName());
         }
 
         LocaleFinder localeFinder = new LocaleFinder(invocation);

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/LoggingInterceptor.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/LoggingInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/LoggingInterceptor.java
index 2ec655e..c82532f 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/LoggingInterceptor.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/LoggingInterceptor.java
@@ -16,8 +16,8 @@
 package com.opensymphony.xwork2.interceptor;
 
 import com.opensymphony.xwork2.ActionInvocation;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 
 /**
@@ -79,9 +79,7 @@ public class LoggingInterceptor extends AbstractInterceptor {
             }
 
             message.append(invocation.getProxy().getActionName());
-            if (LOG.isInfoEnabled()) {
         	LOG.info(message.toString());
-            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptor.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptor.java
index 0cdedb0..a46cf34 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptor.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptor.java
@@ -18,8 +18,8 @@ package com.opensymphony.xwork2.interceptor;
 
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.util.TextParseUtil;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.util.Collections;
 import java.util.Set;
@@ -104,10 +104,8 @@ public abstract class MethodFilterInterceptor extends AbstractInterceptor {
         String method = invocation.getProxy().getMethod();
         // ValidationInterceptor
         boolean applyMethod = MethodFilterInterceptorUtil.applyMethod(excludeMethods, includeMethods, method);
-        if (log.isDebugEnabled()) {
-        	if (!applyMethod) {
-        		log.debug("Skipping Interceptor... Method [" + method + "] found in exclude list.");
-        	}
+        if (!applyMethod) {
+            log.debug("Skipping Interceptor... Method [{}] found in exclude list.", method);
         }
         return applyMethod;
     }

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptorUtil.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptorUtil.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptorUtil.java
index ce0dbef..987d782 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptorUtil.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptorUtil.java
@@ -86,7 +86,7 @@ public class MethodFilterInterceptorUtil {
         for (String pattern : includeMethods) {
             if (pattern.contains("*")) {
                 int[] compiledPattern = wildcard.compilePattern(pattern);
-                HashMap<String,String> matchedPatterns = new HashMap<String, String>();
+                HashMap<String, String> matchedPatterns = new HashMap<>();
                 boolean matches = wildcard.match(matchedPatterns, methodCopy, compiledPattern);
                 if (matches) {
                     return true; // run it, includeMethods takes precedence
@@ -106,7 +106,7 @@ public class MethodFilterInterceptorUtil {
         for ( String pattern : excludeMethods) {
             if (pattern.contains("*")) {
                 int[] compiledPattern = wildcard.compilePattern(pattern);
-                HashMap<String,String> matchedPatterns = new HashMap<String, String>();
+                HashMap<String, String> matchedPatterns = new HashMap<>();
                 boolean matches = wildcard.match(matchedPatterns, methodCopy, compiledPattern);
                 if (matches) {
                     // if found, and wasn't included earlier, don't run it

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterFilterInterceptor.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterFilterInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterFilterInterceptor.java
index 1e4b036..46767d5 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterFilterInterceptor.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterFilterInterceptor.java
@@ -17,8 +17,9 @@ package com.opensymphony.xwork2.interceptor;
 
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.util.TextParseUtil;
-import org.apache.logging.log4j.Logger;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.util.Collection;
 import java.util.HashSet;
@@ -106,7 +107,7 @@ public class ParameterFilterInterceptor extends AbstractInterceptor {
     public String intercept(ActionInvocation invocation) throws Exception {
 
         Map<String, Object> parameters = invocation.getInvocationContext().getParameters();
-        HashSet<String> paramsToRemove = new HashSet<String>();
+        HashSet<String> paramsToRemove = new HashSet<>();
 
         Map<String, Boolean> includesExcludesMap = getIncludesExcludesMap();
 
@@ -116,7 +117,7 @@ public class ParameterFilterInterceptor extends AbstractInterceptor {
             for (String currRule : includesExcludesMap.keySet()) {
                 if (param.startsWith(currRule)
                         && (param.length() == currRule.length()
-                        || isPropSeperator(param.charAt(currRule.length())))) {
+                        || isPropertySeparator(param.charAt(currRule.length())))) {
                     currentAllowed = includesExcludesMap.get(currRule).booleanValue();
                 }
             }
@@ -125,9 +126,7 @@ public class ParameterFilterInterceptor extends AbstractInterceptor {
             }
         }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Params to remove: " + paramsToRemove);
-        }
+        LOG.debug("Params to remove: {}", paramsToRemove);
 
         for (Object aParamsToRemove : paramsToRemove) {
             parameters.remove(aParamsToRemove);
@@ -137,18 +136,18 @@ public class ParameterFilterInterceptor extends AbstractInterceptor {
     }
 
     /**
-     * Tests if the given char is a property seperator char <code>.([</code>.
+     * Tests if the given char is a property separator char <code>.([</code>.
      *
      * @param c the char
      * @return <tt>true</tt>, if char is property separator, <tt>false</tt> otherwise.
      */
-    private static boolean isPropSeperator(char c) {
+    private static boolean isPropertySeparator(char c) {
         return c == '.' || c == '(' || c == '[';
     }
 
     private Map<String, Boolean> getIncludesExcludesMap() {
         if (this.includesExcludesMap == null) {
-            this.includesExcludesMap = new TreeMap<String, Boolean>();
+            this.includesExcludesMap = new TreeMap<>();
 
             if (getAllowedCollection() != null) {
                 for (String e : getAllowedCollection()) {
@@ -228,7 +227,7 @@ public class ParameterFilterInterceptor extends AbstractInterceptor {
      * @return A collection from the comma delimited String. Returns <tt>null</tt> if the string is empty.
      */
     private Collection<String> asCollection(String commaDelim) {
-        if (commaDelim == null || commaDelim.trim().length() == 0) {
+        if (StringUtils.isBlank(commaDelim)) {
             return null;
         }
         return TextParseUtil.commaDelimitedStringToSet(commaDelim);

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptor.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptor.java
index 523831c..68bb154 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptor.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptor.java
@@ -18,8 +18,8 @@ package com.opensymphony.xwork2.interceptor;
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.util.TextParseUtil;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.util.Collections;
 import java.util.Map;
@@ -84,7 +84,6 @@ public class ParameterRemoverInterceptor extends AbstractInterceptor {
 	private static final long serialVersionUID = 1;
 
 	private Set<String> paramNames = Collections.emptySet();
-
 	private Set<String> paramValues = Collections.emptySet();
 
 	
@@ -107,18 +106,15 @@ public class ParameterRemoverInterceptor extends AbstractInterceptor {
                     if (parameters.containsKey(removeName)) {
 
                         try {
-                            String[] values = (String[]) parameters
-                                    .get(removeName);
-                            String value = values[0];
-                            if (null != value && this.paramValues.contains(value)) {
+							String[] values = (String[]) parameters.get(removeName);
+							String value = values[0];
+							if (null != value && this.paramValues.contains(value)) {
                                 parameters.remove(removeName);
                             }
                         } catch (Exception e) {
-                            if (LOG.isErrorEnabled()) {
-                                LOG.error("Failed to convert parameter to string", e);
-                            }
-                        }
-                    }
+							LOG.error("Failed to convert parameter to string", e);
+						}
+					}
                 }
 			}
 		}

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
index 78d873d..8496610 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
@@ -17,21 +17,18 @@ package com.opensymphony.xwork2.interceptor;
 
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.security.AcceptedPatternsChecker;
-import com.opensymphony.xwork2.security.ExcludedPatternsChecker;
 import com.opensymphony.xwork2.ValidationAware;
 import com.opensymphony.xwork2.XWorkConstants;
 import com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler;
 import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
 import com.opensymphony.xwork2.inject.Inject;
-import com.opensymphony.xwork2.util.ClearableValueStack;
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
-import com.opensymphony.xwork2.util.MemberAccessValueStack;
-import com.opensymphony.xwork2.util.ValueStack;
-import com.opensymphony.xwork2.util.ValueStackFactory;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
+import com.opensymphony.xwork2.security.AcceptedPatternsChecker;
+import com.opensymphony.xwork2.security.ExcludedPatternsChecker;
+import com.opensymphony.xwork2.util.*;
 import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.util.Collection;
 import java.util.Comparator;
@@ -155,7 +152,7 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
 
     @Inject(XWorkConstants.DEV_MODE)
     public void setDevMode(String mode) {
-        devMode = "true".equalsIgnoreCase(mode);
+        this.devMode = BooleanUtils.toBoolean(mode);
     }
 
     @Inject
@@ -207,7 +204,7 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
             final Map<String, Object> parameters = retrieveParameters(ac);
 
             if (LOG.isDebugEnabled()) {
-                LOG.debug("Setting params " + getParameterLogMap(parameters));
+                LOG.debug("Setting params {}", getParameterLogMap(parameters));
             }
 
             if (parameters != null) {
@@ -256,12 +253,12 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
         Map<String, Object> params;
         Map<String, Object> acceptableParameters;
         if (ordered) {
-            params = new TreeMap<String, Object>(getOrderedComparator());
-            acceptableParameters = new TreeMap<String, Object>(getOrderedComparator());
+            params = new TreeMap<>(getOrderedComparator());
+            acceptableParameters = new TreeMap<>(getOrderedComparator());
             params.putAll(parameters);
         } else {
-            params = new TreeMap<String, Object>(parameters);
-            acceptableParameters = new TreeMap<String, Object>();
+            params = new TreeMap<>(parameters);
+            acceptableParameters = new TreeMap<>();
         }
 
         for (Map.Entry<String, Object> entry : params.entrySet()) {
@@ -447,9 +444,7 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
         if (devMode) {
             LOG.warn(message, parameters);
         } else {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug(message, parameters);
-            }
+            LOG.debug(message, parameters);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ScopedModelDrivenInterceptor.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ScopedModelDrivenInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ScopedModelDrivenInterceptor.java
index 8cf10ac..9d32fbe 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ScopedModelDrivenInterceptor.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ScopedModelDrivenInterceptor.java
@@ -95,7 +95,7 @@ public class ScopedModelDrivenInterceptor extends AbstractInterceptor {
     }
     
     protected Object resolveModel(ObjectFactory factory, ActionContext actionContext, String modelClassName, String modelScope, String modelName) throws Exception {
-        Object model = null;
+        Object model;
         Map<String, Object> scopeMap = actionContext.getContextMap();
         if ("session".equals(modelScope)) {
             scopeMap = actionContext.getSession();

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/StaticParametersInterceptor.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/StaticParametersInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/StaticParametersInterceptor.java
index 67e121c..25fd8d6 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/StaticParametersInterceptor.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/StaticParametersInterceptor.java
@@ -19,13 +19,14 @@ import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.ValidationAware;
 import com.opensymphony.xwork2.XWorkConstants;
-import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.config.entities.Parameterizable;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.*;
 import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
-import org.apache.logging.log4j.Logger;
+import org.apache.commons.lang3.BooleanUtils;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.util.Collections;
 import java.util.Map;
@@ -84,8 +85,7 @@ public class StaticParametersInterceptor extends AbstractInterceptor {
     private boolean parse;
     private boolean overwrite;
     private boolean merge = true;
-
-    static boolean devMode = false;
+    private boolean devMode = false;
 
     private static final Logger LOG = LogManager.getLogger(StaticParametersInterceptor.class);
 
@@ -97,16 +97,16 @@ public class StaticParametersInterceptor extends AbstractInterceptor {
     }
 
     @Inject(XWorkConstants.DEV_MODE)
-    public static void setDevMode(String mode) {
-        devMode = "true".equals(mode);
+    public void setDevMode(String mode) {
+        devMode = BooleanUtils.toBoolean(mode);
     }    
 
     public void setParse(String value) {
-        this.parse = Boolean.valueOf(value).booleanValue();
+        this.parse = BooleanUtils.toBoolean(value);
     }
 
      public void setMerge(String value) {
-        this.merge = Boolean.valueOf(value).booleanValue();
+         this.merge = BooleanUtils.toBoolean(value);
     }
 
     /**
@@ -116,7 +116,7 @@ public class StaticParametersInterceptor extends AbstractInterceptor {
      * @param value
      */
     public void setOverwrite(String value) {
-        this.overwrite = Boolean.valueOf(value).booleanValue();
+        this.overwrite = BooleanUtils.toBoolean(value);
     }
 
     @Override
@@ -126,9 +126,7 @@ public class StaticParametersInterceptor extends AbstractInterceptor {
 
         final Map<String, String> parameters = config.getParams();
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Setting static parameters " + parameters);
-        }
+        LOG.debug("Setting static parameters: {}", parameters);
 
         // for actions marked as Parameterizable, pass the static parameters directly
         if (action instanceof Parameterizable) {
@@ -220,18 +218,18 @@ public class StaticParametersInterceptor extends AbstractInterceptor {
         Map<String, Object> combinedParams;
         if ( overwrite ) {
             if (previousParams != null) {
-                combinedParams = new TreeMap<String, Object>(previousParams);
+                combinedParams = new TreeMap<>(previousParams);
             } else {
-                combinedParams = new TreeMap<String, Object>();
+                combinedParams = new TreeMap<>();
             }
             if ( newParams != null) {
                 combinedParams.putAll(newParams);
             }
         } else {
             if (newParams != null) {
-                combinedParams = new TreeMap<String, Object>(newParams);
+                combinedParams = new TreeMap<>(newParams);
             } else {
-                combinedParams = new TreeMap<String, Object>();
+                combinedParams = new TreeMap<>();
             }
             if ( previousParams != null) {
                 combinedParams.putAll(previousParams);

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/TimerInterceptor.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/TimerInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/TimerInterceptor.java
index a52c092..7cc4918 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/TimerInterceptor.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/TimerInterceptor.java
@@ -16,8 +16,9 @@
 package com.opensymphony.xwork2.interceptor;
 
 import com.opensymphony.xwork2.ActionInvocation;
-import org.apache.logging.log4j.Logger;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 /**
  * <!-- START SNIPPET: description -->
@@ -138,7 +139,7 @@ public class TimerInterceptor extends AbstractInterceptor {
         StringBuilder message = new StringBuilder(100);
         message.append("Executed action [");
         String namespace = invocation.getProxy().getNamespace();
-        if ((namespace != null) && (namespace.trim().length() > 0)) {
+        if (StringUtils.isNotBlank(namespace)) {
             message.append(namespace).append("/");
         }
         message.append(invocation.getProxy().getActionName());

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationParameterFilterIntereptor.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationParameterFilterIntereptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationParameterFilterIntereptor.java
index 1660b07..f978e46 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationParameterFilterIntereptor.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationParameterFilterIntereptor.java
@@ -43,8 +43,8 @@ public class AnnotationParameterFilterIntereptor extends AbstractInterceptor {
         }
 
         boolean blockByDefault = action.getClass().isAnnotationPresent(BlockByDefault.class);
-        List<Field> annotatedFields = new ArrayList<Field>();
-        HashSet<String> paramsToRemove = new HashSet<String>();
+        List<Field> annotatedFields = new ArrayList<>();
+        HashSet<String> paramsToRemove = new HashSet<>();
 
         if (blockByDefault) {
             AnnotationUtils.addAllFields(Allowed.class, action.getClass(), annotatedFields);
@@ -75,7 +75,6 @@ public class AnnotationParameterFilterIntereptor extends AbstractInterceptor {
             }
 
             for (String paramName : parameters.keySet()) {
-
                 for (Field field : annotatedFields) {
                     //TODO only matches exact field names.  need to change to it matches start of ognl expression
                     //i.e take param name up to first . (period) and match against that

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptor.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptor.java
index 648a65a..665ed1c 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptor.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptor.java
@@ -113,7 +113,7 @@ public class AnnotationWorkflowInterceptor extends AbstractInterceptor implement
     public String intercept(ActionInvocation invocation) throws Exception {
         final Object action = invocation.getAction();
         invocation.addPreResultListener(this);
-        List<Method> methods = new ArrayList<Method>(AnnotationUtils.getAnnotatedMethods(action.getClass(), Before.class));
+        List<Method> methods = new ArrayList<>(AnnotationUtils.getAnnotatedMethods(action.getClass(), Before.class));
         if (methods.size() > 0) {
             // methods are only sorted by priority
             Collections.sort(methods, new Comparator<Method>() {
@@ -123,8 +123,7 @@ public class AnnotationWorkflowInterceptor extends AbstractInterceptor implement
                 }
             });
             for (Method m : methods) {
-                final String resultCode = (String) m
-                        .invoke(action, (Object[]) null);
+                final String resultCode = (String) m.invoke(action, (Object[]) null);
                 if (resultCode != null) {
                     // shortcircuit execution
                     return resultCode;

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/mock/MockActionInvocation.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/mock/MockActionInvocation.java b/xwork-core/src/main/java/com/opensymphony/xwork2/mock/MockActionInvocation.java
index b67b4ff..0749689 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/mock/MockActionInvocation.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/mock/MockActionInvocation.java
@@ -40,8 +40,8 @@ public class MockActionInvocation implements ActionInvocation {
     private Result result;
     private String resultCode;
     private ValueStack stack;
-    
-    private List<PreResultListener> preResultListeners = new ArrayList<PreResultListener>();
+
+    private List<PreResultListener> preResultListeners = new ArrayList<>();
 
     public Object getAction() {
         return action;

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/mock/MockActionProxy.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/mock/MockActionProxy.java b/xwork-core/src/main/java/com/opensymphony/xwork2/mock/MockActionProxy.java
index 9e8567c..f373591 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/mock/MockActionProxy.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/mock/MockActionProxy.java
@@ -20,6 +20,7 @@ import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.ActionProxy;
 import com.opensymphony.xwork2.config.Configuration;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
+import org.apache.commons.lang3.StringUtils;
 
 /**
  * Mock for an {@link ActionProxy}.
@@ -110,7 +111,7 @@ public class MockActionProxy implements ActionProxy {
 
     public void setMethod(String method) {
         this.method = method;
-        methodSpecified=method!=null && !"".equals(method);
+        methodSpecified = StringUtils.isNotEmpty(method);
     }
 
     public boolean isMethodSpecified()

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/mock/MockResult.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/mock/MockResult.java b/xwork-core/src/main/java/com/opensymphony/xwork2/mock/MockResult.java
index 16b2a21..571469c 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/mock/MockResult.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/mock/MockResult.java
@@ -34,11 +34,7 @@ public class MockResult implements Result {
             return true;
         }
 
-        if (!(o instanceof MockResult)) {
-            return false;
-        }
-
-        return true;
+        return o instanceof MockResult;
     }
 
     public void execute(ActionInvocation invocation) throws Exception {

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlTypeConverterWrapper.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlTypeConverterWrapper.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlTypeConverterWrapper.java
index 55a71be..ad79542 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlTypeConverterWrapper.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlTypeConverterWrapper.java
@@ -26,12 +26,12 @@ import java.util.Map;
 public class OgnlTypeConverterWrapper implements ognl.TypeConverter {
 
     private TypeConverter typeConverter;
-    
-    public OgnlTypeConverterWrapper(TypeConverter conv) {
-        if (conv == null) {
+
+    public OgnlTypeConverterWrapper(TypeConverter converter) {
+        if (converter == null) {
             throw new IllegalArgumentException("Wrapped type converter cannot be null");
         }
-        this.typeConverter = conv;
+        this.typeConverter = converter;
     }
     
     public Object convertValue(Map context, Object target, Member member,

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java
index a67ede9..45e9992 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java
@@ -23,27 +23,18 @@ import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor;
 import com.opensymphony.xwork2.util.CompoundRoot;
 import com.opensymphony.xwork2.util.TextParseUtil;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
 import com.opensymphony.xwork2.util.reflection.ReflectionException;
-import ognl.ClassResolver;
-import ognl.Ognl;
-import ognl.OgnlContext;
-import ognl.OgnlException;
-import ognl.OgnlRuntime;
-import ognl.SimpleNode;
-import ognl.TypeConverter;
+import ognl.*;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.beans.BeanInfo;
 import java.beans.IntrospectionException;
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
 import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.regex.Pattern;
@@ -58,16 +49,16 @@ import java.util.regex.Pattern;
 public class OgnlUtil {
 
     private static final Logger LOG = LogManager.getLogger(OgnlUtil.class);
-    private ConcurrentMap<String, Object> expressions = new ConcurrentHashMap<String, Object>();
-    private final ConcurrentMap<Class, BeanInfo> beanInfoCache = new ConcurrentHashMap<Class, BeanInfo>();
+    private ConcurrentMap<String, Object> expressions = new ConcurrentHashMap<>();
+    private final ConcurrentMap<Class, BeanInfo> beanInfoCache = new ConcurrentHashMap<>();
     private TypeConverter defaultConverter;
 
     private boolean devMode = false;
     private boolean enableExpressionCache = true;
     private boolean enableEvalExpression;
 
-    private Set<Class<?>> excludedClasses = new HashSet<Class<?>>();
-    private Set<Pattern> excludedPackageNamePatterns = new HashSet<Pattern>();
+    private Set<Class<?>> excludedClasses = new HashSet<>();
+    private Set<Pattern> excludedPackageNamePatterns = new HashSet<>();
 
     private Container container;
     private boolean allowStaticMethodAccess;
@@ -79,12 +70,12 @@ public class OgnlUtil {
 
     @Inject(XWorkConstants.DEV_MODE)
     public void setDevMode(String mode) {
-        devMode = "true".equals(mode);
+        this.devMode = BooleanUtils.toBoolean(mode);
     }
 
     @Inject(XWorkConstants.ENABLE_OGNL_EXPRESSION_CACHE)
     public void setEnableExpressionCache(String cache) {
-       enableExpressionCache = "true".equals(cache);
+        enableExpressionCache = BooleanUtils.toBoolean(cache);
     }
 
     @Inject(value = XWorkConstants.ENABLE_OGNL_EVAL_EXPRESSION, required = false)
@@ -249,12 +240,9 @@ public class OgnlUtil {
 
             try {
                 for (Object target : cr) {
-                    if (
-                            OgnlRuntime.hasSetProperty((OgnlContext) context, target, property)
-                                    ||
-                                    OgnlRuntime.hasGetProperty((OgnlContext) context, target, property)
-                                    ||
-                                    OgnlRuntime.getIndexedPropertyType((OgnlContext) context, target.getClass(), property) != OgnlRuntime.INDEXED_PROPERTY_NONE
+                    if (OgnlRuntime.hasSetProperty((OgnlContext) context, target, property)
+                            || OgnlRuntime.hasGetProperty((OgnlContext) context, target, property)
+                            || OgnlRuntime.getIndexedPropertyType((OgnlContext) context, target.getClass(), property) != OgnlRuntime.INDEXED_PROPERTY_NONE
                             ) {
                         return target;
                     }
@@ -269,7 +257,6 @@ public class OgnlUtil {
         return root;
     }
 
-
     /**
      * Wrapper around Ognl.setValue() to handle type conversion for collection elements.
      * Ideally, this should be handled by OGNL directly.
@@ -373,18 +360,15 @@ public class OgnlUtil {
      */
     public void copy(final Object from, final Object to, final Map<String, Object> context, Collection<String> exclusions, Collection<String> inclusions) {
         if (from == null || to == null) {
-            if (LOG.isWarnEnabled()) {
-                LOG.warn("Attempting to copy from or to a null source. This is illegal and is bein skipped. This may be due to an error in an OGNL expression, action chaining, or some other event.");
-            }
-
+            LOG.warn("Attempting to copy from or to a null source. This is illegal and is bein skipped. This may be due to an error in an OGNL expression, action chaining, or some other event.");
             return;
         }
 
-        TypeConverter conv = getTypeConverterFromContext(context);
+        TypeConverter converter = getTypeConverterFromContext(context);
         final Map contextFrom = createDefaultContext(from, null);
-        Ognl.setTypeConverter(contextFrom, conv);
+        Ognl.setTypeConverter(contextFrom, converter);
         final Map contextTo = createDefaultContext(to, null);
-        Ognl.setTypeConverter(contextTo, conv);
+        Ognl.setTypeConverter(contextTo, converter);
 
         PropertyDescriptor[] fromPds;
         PropertyDescriptor[] toPds;
@@ -393,13 +377,11 @@ public class OgnlUtil {
             fromPds = getPropertyDescriptors(from);
             toPds = getPropertyDescriptors(to);
         } catch (IntrospectionException e) {
-            if (LOG.isErrorEnabled()) {
-                LOG.error("An error occured", e);
-            }
+            LOG.error("An error occurred", e);
             return;
         }
 
-        Map<String, PropertyDescriptor> toPdHash = new HashMap<String, PropertyDescriptor>();
+        Map<String, PropertyDescriptor> toPdHash = new HashMap<>();
 
         for (PropertyDescriptor toPd : toPds) {
             toPdHash.put(toPd.getName(), toPd);
@@ -427,9 +409,7 @@ public class OgnlUtil {
                             });
 
                         } catch (OgnlException e) {
-                            if (LOG.isDebugEnabled()) {
-                                LOG.debug("Got OGNL exception", e);
-                            }
+                            LOG.debug("Got OGNL exception", e);
                         }
                     }
 
@@ -491,7 +471,7 @@ public class OgnlUtil {
      * @throws OgnlException          is thrown by OGNL if the property value could not be retrieved
      */
     public Map<String, Object> getBeanMap(final Object source) throws IntrospectionException, OgnlException {
-        Map<String, Object> beanMap = new HashMap<String, Object>();
+        Map<String, Object> beanMap = new HashMap<>();
         final Map sourceMap = createDefaultContext(source, null);
         PropertyDescriptor[] propertyDescriptors = getPropertyDescriptors(source);
         for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
index f4cc3fe..af7fbc5 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
@@ -27,11 +27,11 @@ import com.opensymphony.xwork2.util.ClearableValueStack;
 import com.opensymphony.xwork2.util.CompoundRoot;
 import com.opensymphony.xwork2.util.MemberAccessValueStack;
 import com.opensymphony.xwork2.util.ValueStack;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
-import com.opensymphony.xwork2.util.logging.LoggerUtils;
 import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
 import ognl.*;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.io.Serializable;
 import java.util.HashMap;
@@ -97,12 +97,12 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
 
     @Inject(XWorkConstants.DEV_MODE)
     public void setDevMode(String mode) {
-        devMode = "true".equalsIgnoreCase(mode);
+        this.devMode = BooleanUtils.toBoolean(mode);
     }
 
     @Inject(value = "logMissingProperties", required = false)
     public void setLogMissingProperties(String logMissingProperties) {
-        this.logMissingProperties = "true".equalsIgnoreCase(logMissingProperties);
+        this.logMissingProperties = BooleanUtils.toBoolean(logMissingProperties);
     }
 
     /**
@@ -207,11 +207,9 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
     	boolean shouldLog = shouldLogMissingPropertyWarning(e);
     	String msg = null;
     	if (throwExceptionOnFailure || shouldLog) {
-    		msg = ErrorMessageBuilder.create()
-                    .errorSettingExpressionWithValue(expr, value)
-                    .build();
-    	}
-    	if (shouldLog) {
+            msg = ErrorMessageBuilder.create().errorSettingExpressionWithValue(expr, value).build();
+        }
+        if (shouldLog) {
             LOG.warn(msg, e);
     	}
     	
@@ -451,7 +449,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
         XWorkConverter xworkConverter = cont.getInstance(XWorkConverter.class);
         CompoundRootAccessor accessor = (CompoundRootAccessor) cont.getInstance(PropertyAccessor.class, CompoundRoot.class.getName());
         TextProvider prov = cont.getInstance(TextProvider.class, "system");
-        boolean allow = "true".equals(cont.getInstance(String.class, XWorkConstants.ALLOW_STATIC_METHOD_ACCESS));
+        boolean allow = BooleanUtils.toBoolean(cont.getInstance(String.class, XWorkConstants.ALLOW_STATIC_METHOD_ACCESS));
         OgnlValueStack aStack = new OgnlValueStack(xworkConverter, accessor, prov, allow);
         aStack.setOgnlUtil(cont.getInstance(OgnlUtil.class));
         aStack.setRoot(xworkConverter, accessor, this.root, allow);

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStackFactory.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStackFactory.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStackFactory.java
index 2edfa9f..7617494 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStackFactory.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStackFactory.java
@@ -28,6 +28,7 @@ import com.opensymphony.xwork2.util.ValueStackFactory;
 import ognl.MethodAccessor;
 import ognl.OgnlRuntime;
 import ognl.PropertyAccessor;
+import org.apache.commons.lang3.BooleanUtils;
 
 import java.util.Map;
 import java.util.Set;
@@ -44,8 +45,8 @@ public class OgnlValueStackFactory implements ValueStackFactory {
     private boolean allowStaticMethodAccess;
 
     @Inject
-    public void setXWorkConverter(XWorkConverter conv) {
-        this.xworkConverter = conv;
+    public void setXWorkConverter(XWorkConverter converter) {
+        this.xworkConverter = converter;
     }
     
     @Inject("system")
@@ -55,7 +56,7 @@ public class OgnlValueStackFactory implements ValueStackFactory {
     
     @Inject(value="allowStaticMethodAccess", required=false)
     public void setAllowStaticMethodAccess(String allowStaticMethodAccess) {
-        this.allowStaticMethodAccess = "true".equalsIgnoreCase(allowStaticMethodAccess);
+        this.allowStaticMethodAccess = BooleanUtils.toBoolean(allowStaticMethodAccess);
     }
 
     public ValueStack createValueStack() {

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java
index 075237b..2afd3d6 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java
@@ -15,9 +15,9 @@
  */
 package com.opensymphony.xwork2.ognl;
 
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
 import ognl.DefaultMemberAccess;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.lang.reflect.Member;
 import java.lang.reflect.Modifier;
@@ -53,7 +53,7 @@ public class SecurityMemberAccess extends DefaultMemberAccess {
     @Override
     public boolean isAccessible(Map context, Object target, Member member, String propertyName) {
         if (checkEnumAccess(target, member)) {
-            LOG.trace("Allowing access to enum {}", target);
+            LOG.trace("Allowing access to enum: {}", target);
             return true;
         }
 
@@ -89,12 +89,12 @@ public class SecurityMemberAccess extends DefaultMemberAccess {
         }
 
         //failed static test
-        if (!allow)
+        if (!allow) {
             return false;
+        }
 
         // Now check for standard scope rules
-        return super.isAccessible(context, target, member, propertyName)
-                && isAcceptableProperty(propertyName);
+        return super.isAccessible(context, target, member, propertyName) && isAcceptableProperty(propertyName);
     }
 
     protected boolean checkStaticMethodAccess(Member member) {
@@ -109,8 +109,9 @@ public class SecurityMemberAccess extends DefaultMemberAccess {
     protected boolean checkEnumAccess(Object target, Member member) {
         if (target instanceof Class) {
             Class clazz = (Class) target;
-            if (Enum.class.isAssignableFrom(clazz) && member.getName().equals("values"))
+            if (Enum.class.isAssignableFrom(clazz) && member.getName().equals("values")) {
                 return true;
+            }
         }
         return false;
     }

http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/CompoundRootAccessor.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/CompoundRootAccessor.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/CompoundRootAccessor.java
index d02e84b..3beb14a 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/CompoundRootAccessor.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/accessor/CompoundRootAccessor.java
@@ -21,9 +21,10 @@ import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.ognl.OgnlValueStack;
 import com.opensymphony.xwork2.util.CompoundRoot;
 import com.opensymphony.xwork2.util.ValueStack;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
 import ognl.*;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.beans.IntrospectionException;
 import java.beans.PropertyDescriptor;
@@ -58,13 +59,12 @@ public class CompoundRootAccessor implements PropertyAccessor, MethodAccessor, C
 
     private final static Logger LOG = LogManager.getLogger(CompoundRootAccessor.class);
     private final static Class[] EMPTY_CLASS_ARRAY = new Class[0];
-    private static Map<MethodCall, Boolean> invalidMethods = new ConcurrentHashMap<MethodCall, Boolean>();
-
-    static boolean devMode = false;
+    private static Map<MethodCall, Boolean> invalidMethods = new ConcurrentHashMap<>();
+    private boolean devMode = false;
 
     @Inject(XWorkConstants.DEV_MODE)
-    public static void setDevMode(String mode) {
-        devMode = "true".equals(mode);
+    public void setDevMode(String mode) {
+        this.devMode = BooleanUtils.toBoolean(mode);
     }
 
     public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException {
@@ -121,7 +121,6 @@ public class CompoundRootAccessor implements PropertyAccessor, MethodAccessor, C
 
         if (name instanceof Integer) {
             Integer index = (Integer) name;
-
             return root.cutStack(index);
         } else if (name instanceof String) {
             if ("top".equals(name)) {
@@ -187,7 +186,7 @@ public class CompoundRootAccessor implements PropertyAccessor, MethodAccessor, C
                     }
                 }
 
-                SortedSet<String> set = new TreeSet<String>();
+                SortedSet<String> set = new TreeSet<>();
                 StringBuffer sb = new StringBuffer();
                 for (PropertyDescriptor pd : descriptors.values()) {
 
@@ -209,12 +208,9 @@ public class CompoundRootAccessor implements PropertyAccessor, MethodAccessor, C
                 }
 
                 return sb.toString();
-            } catch (IntrospectionException e) {
-                LOG.debug("Got exception in callMethod", e);
-            } catch (OgnlException e) {
+            } catch (IntrospectionException | OgnlException e) {
                 LOG.debug("Got exception in callMethod", e);
             }
-
             return null;
         }
 


Mime
View raw message