You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mr...@apache.org on 2011/03/05 00:29:42 UTC

svn commit: r1078215 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java

Author: mrisaliti
Date: Fri Mar  4 23:29:42 2011
New Revision: 1078215

URL: http://svn.apache.org/viewvc?rev=1078215&view=rev
Log:
Remove some warning in TTLObject (OFBIZ-4102)

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java?rev=1078215&r1=1078214&r2=1078215&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java Fri Mar  4 23:29:42 2011
@@ -29,6 +29,7 @@ import java.util.concurrent.atomic.Atomi
 
 import org.ofbiz.base.lang.ObjectWrapper;
 import org.ofbiz.base.lang.SourceMonitored;
+import org.ofbiz.base.util.UtilGenerics;
 
 @SourceMonitored
 public abstract class TTLObject<T> implements ObjectWrapper<T> {
@@ -81,9 +82,9 @@ public abstract class TTLObject<T> imple
     }
 
     public enum State { INVALID, REGEN, REGENERATING, GENERATE, GENERATING, GENERATING_INITIAL, VALID, ERROR, ERROR_INITIAL, SET }
-    private volatile ValueAndState<T> object = new StandardValueAndState<T>(this, null, null, State.INVALID, 0, null, null);
-    private static final AtomicReferenceFieldUpdater<TTLObject, ValueAndState> objectAccessor = AtomicReferenceFieldUpdater.newUpdater(TTLObject.class, ValueAndState.class, "object");
-    private static final AtomicIntegerFieldUpdater<TTLObject> serialAccessor = AtomicIntegerFieldUpdater.newUpdater(TTLObject.class, "serial");
+    @SuppressWarnings("unchecked")
+    private static final AtomicReferenceFieldUpdater<TTLObject<?>, ValueAndState> objectAccessor = UtilGenerics.cast(AtomicReferenceFieldUpdater.newUpdater(TTLObject.class, ValueAndState.class, "object"));
+    private static final AtomicIntegerFieldUpdater<TTLObject<?>> serialAccessor = UtilGenerics.cast(AtomicIntegerFieldUpdater.newUpdater(TTLObject.class, "serial"));
     protected volatile int serial;
 
     protected static abstract class ValueAndState<T> {
@@ -138,6 +139,7 @@ public abstract class TTLObject<T> imple
         return new StandardValueAndState<T>(this, value, future, state, serial, t, pulse);
     }
 
+    @SuppressWarnings("hiding")
     private class StandardValueAndState<T> extends ValueAndState<T> {
         protected final T value;
 



Re: svn commit: r1078215 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java

Posted by Adam Heath <do...@brainfood.com>.
On 06/25/2011 03:16 AM, Erwan de FERRIERES wrote:
> Le 24/06/2011 20:16, Adam Heath a écrit :
>> On 03/04/2011 05:29 PM, mrisaliti@apache.org wrote:
>>> Author: mrisaliti
>>> Date: Fri Mar 4 23:29:42 2011
>>> New Revision: 1078215
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1078215&view=rev
>>> Log:
>>> Remove some warning in TTLObject (OFBIZ-4102)
>>>
>>> Modified:
>>> ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java
>>>
>>> Modified:
>>> ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java
>>> URL:
>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java?rev=1078215&r1=1078214&r2=1078215&view=diff
>>>
>>>
>>> ==============================================================================
>>>
>>>
>>> ---
>>> ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java
>>> (original)
>>>
>>> +++
>>> ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java
>>> Fri
>>> Mar 4 23:29:42 2011
>>> @@ -29,6 +29,7 @@ import java.util.concurrent.atomic.Atomi
>>>
>>> import org.ofbiz.base.lang.ObjectWrapper;
>>> import org.ofbiz.base.lang.SourceMonitored;
>>> +import org.ofbiz.base.util.UtilGenerics;
>>>
>>> @SourceMonitored
>>> public abstract class TTLObject<T> implements ObjectWrapper<T> {
>>> @@ -81,9 +82,9 @@ public abstract class TTLObject<T> imple
>>> }
>>>
>>> public enum State { INVALID, REGEN, REGENERATING, GENERATE,
>>> GENERATING, GENERATING_INITIAL, VALID, ERROR, ERROR_INITIAL, SET }
>>> - private volatile ValueAndState<T> object = new
>>> StandardValueAndState<T>(this, null, null, State.INVALID, 0, null,
>>> null);
>>> - private static final AtomicReferenceFieldUpdater<TTLObject,
>>> ValueAndState> objectAccessor =
>>> AtomicReferenceFieldUpdater.newUpdater(TTLObject.class,
>>> ValueAndState.class, "object");
>>> - private static final AtomicIntegerFieldUpdater<TTLObject>
>>> serialAccessor = AtomicIntegerFieldUpdater.newUpdater(TTLObject.class,
>>> "serial");
>>> + @SuppressWarnings("unchecked")
>>> + private static final AtomicReferenceFieldUpdater<TTLObject<?>,
>>> ValueAndState> objectAccessor =
>>> UtilGenerics.cast(AtomicReferenceFieldUpdater.newUpdater(TTLObject.class,
>>>
>>> ValueAndState.class, "object"));
>>> + private static final AtomicIntegerFieldUpdater<TTLObject<?>>
>>> serialAccessor =
>>> UtilGenerics.cast(AtomicIntegerFieldUpdater.newUpdater(TTLObject.class,
>>> "serial"));
>>>
>>> protected volatile int serial;
>>
>> <rant>
>> NONONONONO. You removed the 'object' variable, which is accessed *only*
>> thru the updater.
>>
>> PLEASE UNDERSTAND WHAT YOU ARE DOING.
>> </rant>
>>
>> When you see a @SourceMonitored tag, that means that there are test
>> cases for the class(at the least). Try to find said test cases, and run
>> them.
>>
>> In this case, run 'ant tests' in framework/base, and you'll see that
>> there is a class initialization error, due to this change.
>>
> what do you think of :
>
> ofbiz]$ svn di build.xml
> Index: build.xml
> ===================================================================
> --- build.xml (révision 1139499)
> +++ build.xml (copie de travail)
> @@ -682,6 +682,7 @@
> </target>
> <target name="run-tests" depends="build"
> description="Run OFBiz default tests, execute ant run-install before and
> see results in runtime/logs/test-results/html/all-tests.html.">
> + <antcall target="tests"/>
> <java jar="ofbiz.jar" fork="true" resultproperty="test.result">
> <jvmarg value="${memory.initial.param}"/>
> <jvmarg value="${memory.max.param}"/>

Good enough for me, I should have thought it.  I'll check it in, since 
I was the one that complained.

I'll queue that in my next commit batch, which should happen today.

>
>


Re: svn commit: r1078215 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java

Posted by Erwan de FERRIERES <er...@nereide.fr>.
Le 24/06/2011 20:16, Adam Heath a écrit :
> On 03/04/2011 05:29 PM, mrisaliti@apache.org wrote:
>> Author: mrisaliti
>> Date: Fri Mar 4 23:29:42 2011
>> New Revision: 1078215
>>
>> URL: http://svn.apache.org/viewvc?rev=1078215&view=rev
>> Log:
>> Remove some warning in TTLObject (OFBIZ-4102)
>>
>> Modified:
>> ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java
>>
>> Modified:
>> ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java?rev=1078215&r1=1078214&r2=1078215&view=diff
>>
>> ==============================================================================
>>
>> ---
>> ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java (original)
>>
>> +++
>> ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java Fri
>> Mar 4 23:29:42 2011
>> @@ -29,6 +29,7 @@ import java.util.concurrent.atomic.Atomi
>>
>> import org.ofbiz.base.lang.ObjectWrapper;
>> import org.ofbiz.base.lang.SourceMonitored;
>> +import org.ofbiz.base.util.UtilGenerics;
>>
>> @SourceMonitored
>> public abstract class TTLObject<T> implements ObjectWrapper<T> {
>> @@ -81,9 +82,9 @@ public abstract class TTLObject<T> imple
>> }
>>
>> public enum State { INVALID, REGEN, REGENERATING, GENERATE,
>> GENERATING, GENERATING_INITIAL, VALID, ERROR, ERROR_INITIAL, SET }
>> - private volatile ValueAndState<T> object = new
>> StandardValueAndState<T>(this, null, null, State.INVALID, 0, null, null);
>> - private static final AtomicReferenceFieldUpdater<TTLObject,
>> ValueAndState> objectAccessor =
>> AtomicReferenceFieldUpdater.newUpdater(TTLObject.class,
>> ValueAndState.class, "object");
>> - private static final AtomicIntegerFieldUpdater<TTLObject>
>> serialAccessor = AtomicIntegerFieldUpdater.newUpdater(TTLObject.class,
>> "serial");
>> + @SuppressWarnings("unchecked")
>> + private static final AtomicReferenceFieldUpdater<TTLObject<?>,
>> ValueAndState> objectAccessor =
>> UtilGenerics.cast(AtomicReferenceFieldUpdater.newUpdater(TTLObject.class,
>> ValueAndState.class, "object"));
>> + private static final AtomicIntegerFieldUpdater<TTLObject<?>>
>> serialAccessor =
>> UtilGenerics.cast(AtomicIntegerFieldUpdater.newUpdater(TTLObject.class, "serial"));
>>
>> protected volatile int serial;
>
> <rant>
> NONONONONO. You removed the 'object' variable, which is accessed *only*
> thru the updater.
>
> PLEASE UNDERSTAND WHAT YOU ARE DOING.
> </rant>
>
> When you see a @SourceMonitored tag, that means that there are test
> cases for the class(at the least). Try to find said test cases, and run
> them.
>
> In this case, run 'ant tests' in framework/base, and you'll see that
> there is a class initialization error, due to this change.
>
what do you think of :

ofbiz]$ svn di build.xml
Index: build.xml
===================================================================
--- build.xml	(révision 1139499)
+++ build.xml	(copie de travail)
@@ -682,6 +682,7 @@
      </target>
      <target name="run-tests" depends="build"
            description="Run OFBiz default tests, execute ant 
run-install before and see results in 
runtime/logs/test-results/html/all-tests.html.">
+        <antcall target="tests"/>
          <java jar="ofbiz.jar" fork="true" resultproperty="test.result">
              <jvmarg value="${memory.initial.param}"/>
              <jvmarg value="${memory.max.param}"/>


-- 
Erwan de FERRIERES
www.nereide.biz

Re: svn commit: r1078215 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java

Posted by Adam Heath <do...@brainfood.com>.
On 06/24/2011 01:16 PM, Adam Heath wrote:
> On 03/04/2011 05:29 PM, mrisaliti@apache.org wrote:
>> Author: mrisaliti
>> Date: Fri Mar 4 23:29:42 2011
>> New Revision: 1078215
>>
>> URL: http://svn.apache.org/viewvc?rev=1078215&view=rev
>> Log:
>> Remove some warning in TTLObject (OFBIZ-4102)
>>
>> Modified:
>> ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java
>>
>> Modified:
>> ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java?rev=1078215&r1=1078214&r2=1078215&view=diff
>>
>> ==============================================================================
>>
>> ---
>> ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java (original)
>>
>> +++
>> ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java Fri
>> Mar 4 23:29:42 2011
>> @@ -29,6 +29,7 @@ import java.util.concurrent.atomic.Atomi
>>
>> import org.ofbiz.base.lang.ObjectWrapper;
>> import org.ofbiz.base.lang.SourceMonitored;
>> +import org.ofbiz.base.util.UtilGenerics;
>>
>> @SourceMonitored
>> public abstract class TTLObject<T> implements ObjectWrapper<T> {
>> @@ -81,9 +82,9 @@ public abstract class TTLObject<T> imple
>> }
>>
>> public enum State { INVALID, REGEN, REGENERATING, GENERATE,
>> GENERATING, GENERATING_INITIAL, VALID, ERROR, ERROR_INITIAL, SET }
>> - private volatile ValueAndState<T> object = new
>> StandardValueAndState<T>(this, null, null, State.INVALID, 0, null, null);
>> - private static final AtomicReferenceFieldUpdater<TTLObject,
>> ValueAndState> objectAccessor =
>> AtomicReferenceFieldUpdater.newUpdater(TTLObject.class,
>> ValueAndState.class, "object");
>> - private static final AtomicIntegerFieldUpdater<TTLObject>
>> serialAccessor = AtomicIntegerFieldUpdater.newUpdater(TTLObject.class,
>> "serial");
>> + @SuppressWarnings("unchecked")
>> + private static final AtomicReferenceFieldUpdater<TTLObject<?>,
>> ValueAndState> objectAccessor =
>> UtilGenerics.cast(AtomicReferenceFieldUpdater.newUpdater(TTLObject.class,
>> ValueAndState.class, "object"));
>> + private static final AtomicIntegerFieldUpdater<TTLObject<?>>
>> serialAccessor =
>> UtilGenerics.cast(AtomicIntegerFieldUpdater.newUpdater(TTLObject.class, "serial"));
>>
>> protected volatile int serial;
>
> <rant>
> NONONONONO. You removed the 'object' variable, which is accessed *only*
> thru the updater.
>
> PLEASE UNDERSTAND WHAT YOU ARE DOING.
> </rant>
>
> When you see a @SourceMonitored tag, that means that there are test
> cases for the class(at the least). Try to find said test cases, and run
> them.
>
> In this case, run 'ant tests' in framework/base, and you'll see that
> there is a class initialization error, due to this change.
>
> I have already fixed this in ?

That should say 1139396.

> As an aside, can we get the build-bot to run ant tests in
> framework/base, before running the container tests?


Re: svn commit: r1078215 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java

Posted by Adam Heath <do...@brainfood.com>.
On 03/04/2011 05:29 PM, mrisaliti@apache.org wrote:
> Author: mrisaliti
> Date: Fri Mar  4 23:29:42 2011
> New Revision: 1078215
>
> URL: http://svn.apache.org/viewvc?rev=1078215&view=rev
> Log:
> Remove some warning in TTLObject (OFBIZ-4102)
>
> Modified:
>      ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java
>
> Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java?rev=1078215&r1=1078214&r2=1078215&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java (original)
> +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java Fri Mar  4 23:29:42 2011
> @@ -29,6 +29,7 @@ import java.util.concurrent.atomic.Atomi
>
>   import org.ofbiz.base.lang.ObjectWrapper;
>   import org.ofbiz.base.lang.SourceMonitored;
> +import org.ofbiz.base.util.UtilGenerics;
>
>   @SourceMonitored
>   public abstract class TTLObject<T>  implements ObjectWrapper<T>  {
> @@ -81,9 +82,9 @@ public abstract class TTLObject<T>  imple
>       }
>
>       public enum State { INVALID, REGEN, REGENERATING, GENERATE, GENERATING, GENERATING_INITIAL, VALID, ERROR, ERROR_INITIAL, SET }
> -    private volatile ValueAndState<T>  object = new StandardValueAndState<T>(this, null, null, State.INVALID, 0, null, null);
> -    private static final AtomicReferenceFieldUpdater<TTLObject, ValueAndState>  objectAccessor = AtomicReferenceFieldUpdater.newUpdater(TTLObject.class, ValueAndState.class, "object");
> -    private static final AtomicIntegerFieldUpdater<TTLObject>  serialAccessor = AtomicIntegerFieldUpdater.newUpdater(TTLObject.class, "serial");
> +    @SuppressWarnings("unchecked")
> +    private static final AtomicReferenceFieldUpdater<TTLObject<?>, ValueAndState>  objectAccessor = UtilGenerics.cast(AtomicReferenceFieldUpdater.newUpdater(TTLObject.class, ValueAndState.class, "object"));
> +    private static final AtomicIntegerFieldUpdater<TTLObject<?>>  serialAccessor = UtilGenerics.cast(AtomicIntegerFieldUpdater.newUpdater(TTLObject.class, "serial"));
>       protected volatile int serial;

<rant>
NONONONONO.  You removed the 'object' variable, which is accessed 
*only* thru the updater.

PLEASE UNDERSTAND WHAT YOU ARE DOING.
</rant>

When you see a @SourceMonitored tag, that means that there are test 
cases for the class(at the least).  Try to find said test cases, and 
run them.

In this case, run 'ant tests' in framework/base, and you'll see that 
there is a class initialization error, due to this change.

I have already fixed this in ?

As an aside, can we get the build-bot to run ant tests in 
framework/base, before running the container tests?