On Wed, Sep 23, 2015 at 12:00 AM, Rowan Worth <rowanw at dugeo.com> wrote:

> > SIndex sidx is just a boxed immutable integer.
>
> If it were me I'd be reviewing this assumption very carefully. The sequence
> of events:
>

public class SIndex {
private final int _i;

public SIndex(int i) {
_i = i;
}

public int getInt() {
return _i;
}

@Override
public String toString() {
return Integer.toString(getInt());
}
}

The way these objects are created ensures that the integer value is always
strictly positive.


> 1. SIndex.getInt() returns 0
> 2. SIndex.toString() returns "1"
> 3. SIndex.getInt() returns 1
>
You forgot step 0 where getInt() returns 1


> Has many possible explanations.
>
I can't think of any that is consistent with the Java specification.

Interestingly enough, I ran into something even weirder over the course of
my testing: in some cases the SIndex captured inside the first lambda
(UPDATE statement) appeared to be null even though it wasn't null in the
enclosing scope (setVersion_) and the second lambda (INSERT statement). I
don't have time to dig into JVM internals so I just opted to remove all
uses of lambdas in DB code.

Reply via email to