Am 23.10.2016 um 22:18 schrieb [email protected]:
> Repository: commons-lang
> Updated Branches:
> refs/heads/master 96c8ea2fb -> dc53e49b4
>
>
> LANG-1144: Multiple calls of
> org.apache.commons.lang3.concurrent.LazyInitializer.initialize() are possible
>
> minimal clean-up
>
>
> Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
> Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/dc53e49b
> Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/dc53e49b
> Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/dc53e49b
>
> Branch: refs/heads/master
> Commit: dc53e49b4afa5d59c533cf2b4918402c37411fbd
> Parents: 96c8ea2
> Author: pascalschumacher <[email protected]>
> Authored: Sun Oct 23 22:18:47 2016 +0200
> Committer: pascalschumacher <[email protected]>
> Committed: Sun Oct 23 22:18:47 2016 +0200
>
> ----------------------------------------------------------------------
> .../commons/lang3/concurrent/LazyInitializer.java | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/commons-lang/blob/dc53e49b/src/main/java/org/apache/commons/lang3/concurrent/LazyInitializer.java
> ----------------------------------------------------------------------
> diff --git
> a/src/main/java/org/apache/commons/lang3/concurrent/LazyInitializer.java
> b/src/main/java/org/apache/commons/lang3/concurrent/LazyInitializer.java
> index a0f903c..ed84049 100644
> --- a/src/main/java/org/apache/commons/lang3/concurrent/LazyInitializer.java
> +++ b/src/main/java/org/apache/commons/lang3/concurrent/LazyInitializer.java
> @@ -78,11 +78,12 @@ package org.apache.commons.lang3.concurrent;
> * @param <T> the type of the object managed by this initializer class
> */
> public abstract class LazyInitializer<T> implements ConcurrentInitializer<T>
> {
> +
> + private static final Object noInit = new Object();
> +
> + @SuppressWarnings("unchecked")
> /** Stores the managed object. */
Minor nit: As the field is now a constant, it should - according to the
Sun coding conventions - be named in uppercase: NO_INIT.
Oliver
> -
> - private static final Object NoInit = new Object();
> -
> - private volatile T object = (T) NoInit;
> + private volatile T object = (T) noInit;
>
> /**
> * Returns the object wrapped by this instance. On first access the
> object
> @@ -98,10 +99,10 @@ public abstract class LazyInitializer<T> implements
> ConcurrentInitializer<T> {
> // volatile field
> T result = object;
>
> - if (result == NoInit) {
> + if (result == noInit) {
> synchronized (this) {
> result = object;
> - if (result == NoInit) {
> + if (result == noInit) {
> object = result = initialize();
> }
> }
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]