Kevin-

That is very odd! I also just reproduced the behavior you described (with Integer i = new Integer(1); Map map = new HashMap(); map.put(i, "x"); print(map.keySet().iterator().next() == i); ... it returns "false" for ibm-java2-i386-50, but "true" for Sun's and Apple's JRE). It looks to me like IBM's JRE might be doing special processing for Integer keys since it can short-circuit using hashCode buckets, and just go right ahead and use the Integer itself as the internal key. Or something like that.

You are also correct that it doesn't seem to happen for any other primitive wrapper (I tried with Long and the above returned "true"). If we were feeling lazy, we could just swap out all the offending Integer keys with Longs and call it a day.

Whether this is a bug with IBM's HashMap or not, I think we should probably fix it to use equals() correctly. Unfortunately, I don't really have much insight into what could be going wrong with other places where it might not doing proper equality comparison. Maybe just grepping for "==" in the code around Edge might shed some light on where we might be doing the wrong sort of equality checking?



On Jul 29, 2007, at 8:42 PM, Kevin Sutter wrote:

I've been able to spend some time with this problem and have figured out the source of the problem. I would like some input on how to go about fixing
it.

The problem is that the IBM JDK seems to want to create (copy) new Integer objects when used as keys to the HashMap.put(k,v) method. Any other key types are just used as is (no copy). But, Integer types as keys are copied
into new Integer objects.

So, when the Edge.getOther(Node n) method attempts to match up with either the _from or _to node, neither of the conditionals returns true because the
equality check is done via == instead of .equals().

I've looked through the javadoc for the HashMap and I can't tell whether the put(k,v) method has to use the input key or if it's okay to make a copy of the key. If making a copy is okay, then I would say that our getOther(n) method should be updated to use .equals instead of the == equality checking.

But, when I make this type of change, I am still failing the last two tests in TestDepthFirstAnalysis due to the assertions when checking for the number of edges for TYPE_BACK and TYPE_FORWARD. In testBackEdges, the assertion is
expecting 2, but there are 3 edges detected.  In testForwardEdges, the
assertion is expecting 2, but there is only 1 edge detected. There must be some other processing that is not expecting the new Integer objects to be
created, but I haven't nailed that down yet.

Thoughts on problems?

Thanks,
Kevin

On 7/19/07, Kevin Sutter <[EMAIL PROTECTED]> wrote:

Markus,
No such luck.  Still the same problem.  Sorry that I can't be of more
service at the moment -- busy with some other work activities...

Running org.apache.openjpa.lib.graph.TestDepthFirstAnalysis
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (init): node = 5 info =
[EMAIL PROTECTED]
DEBUG (init): node = 4 info =
[EMAIL PROTECTED]
DEBUG (init): node = 3 info =
[EMAIL PROTECTED]
DEBUG (init): node = 2 info =
[EMAIL PROTECTED]
DEBUG (init): node = 1 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 5 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 4 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 3 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 2 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 1 info =
[EMAIL PROTECTED]
DEBUG (visit): node = 5
DEBUG (visit): other = null otherInfo = null
DEBUG (init): node = 5 info =
[EMAIL PROTECTED]
DEBUG (init): node = 4 info =
[EMAIL PROTECTED]
DEBUG (init): node = 3 info =
[EMAIL PROTECTED]
DEBUG (init): node = 2 info =
[EMAIL PROTECTED]
DEBUG (init): node = 1 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 5 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 4 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 3 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 2 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 1 info =
[EMAIL PROTECTED]
DEBUG (visit): node = 5
DEBUG (visit): other = null otherInfo = null
Tests run: 4, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.015 sec
<<< FAILURE!
testBackEdges (org.apache.openjpa.lib.graph.TestDepthFirstAnalysis) Time
elapsed: 0.015 sec  <<< ERROR!
java.lang.NullPointerException
        at org.apache.openjpa.lib.graph.DepthFirstAnalysis.visit (
DepthFirstAnalysis.java:108)
        at org.apache.openjpa.lib.graph.DepthFirstAnalysis.<init>(
DepthFirstAnalysis.java:83)
at org.apache.openjpa.lib.graph.TestDepthFirstAnalysis.setUpGraph2
(TestDepthFirstAnalysis.java :88)
        at
org.apache.openjpa.lib.graph.TestDepthFirstAnalysis.testBackEdges(
TestDepthFirstAnalysis.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke (
NativeMethodAccessorImpl.java:64)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:615)
        at junit.framework.TestCase.runTest (TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected (TestResult.java :124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at org.apache.openjpa.lib.test.AbstractTestCase.run(
AbstractTestCase.java:178)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:615)
        at org.apache.maven.surefire.junit.JUnitTestSet.execute(
JUnitTestSet.java :210)
        at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTes tSet(
AbstractDirectoryTestSuite.java:135)
        at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(
AbstractDirectoryTestSuite.java :122)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java :64)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:615)
        at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess (
SurefireBooter.java:225)
        at org.apache.maven.surefire.booter.SurefireBooter.main(
SurefireBooter.java:747)

testForwardEdges(org.apache.openjpa.lib.graph.TestDepthFirstAnalysis)
Time elapsed: 0 sec  <<< ERROR!
java.lang.NullPointerException
        at org.apache.openjpa.lib.graph.DepthFirstAnalysis.visit(
DepthFirstAnalysis.java:108)
        at org.apache.openjpa.lib.graph.DepthFirstAnalysis.<init>(
DepthFirstAnalysis.java :83)
at org.apache.openjpa.lib.graph.TestDepthFirstAnalysis.setUpGraph2
(TestDepthFirstAnalysis.java:88)
        at
org.apache.openjpa.lib.graph.TestDepthFirstAnalysis.testForwardEdges(
TestDepthFirstAnalysis.java :141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:64)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke (
DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:615)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java :127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java: 124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at org.apache.openjpa.lib.test.AbstractTestCase.run(
AbstractTestCase.java:178)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:615)
        at org.apache.maven.surefire.junit.JUnitTestSet.execute(
JUnitTestSet.java:210)
        at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTes tSet(
AbstractDirectoryTestSuite.java:135)
        at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(
AbstractDirectoryTestSuite.java:122)
        at org.apache.maven.surefire.Surefire.run(Surefire.java :129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:64)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke (
DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:615)
        at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(
SurefireBooter.java:225)
        at org.apache.maven.surefire.booter.SurefireBooter.main(
SurefireBooter.java:747)


On 7/19/07, Markus Fuchs <[EMAIL PROTECTED] > wrote:

Kevin,

the failure might be caused by the field _dfa being initialized twice, once in setUp and again in testBackEdges/testForwardEdges. Please try
the attached patch to resolve the problem.

Thanks,

-- markus.

Kevin Sutter wrote:
Markus,
Here's the output after applying your diagnostic patch:  Hope it
helps!

Running org.apache.openjpa.lib.graph.TestDepthFirstAnalysis
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (init): node = 5 info =
[EMAIL PROTECTED]
DEBUG (init): node = 4 info =
[EMAIL PROTECTED]
DEBUG (init): node = 3 info =
[EMAIL PROTECTED]
DEBUG (init): node = 2 info =
[EMAIL PROTECTED]
DEBUG (init): node = 1 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 5 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 4 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 3 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 2 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 1 info =
[EMAIL PROTECTED]
DEBUG (visit): node = 5
DEBUG (visit): other = null otherInfo = null
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (after init): node = [EMAIL PROTECTED] info =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): node = [EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (visit): other = [EMAIL PROTECTED] otherInfo =
[EMAIL PROTECTED]
DEBUG (init): node = 5 info =
[EMAIL PROTECTED]
DEBUG (init): node = 4 info =
[EMAIL PROTECTED]
DEBUG (init): node = 3 info =
[EMAIL PROTECTED]
DEBUG (init): node = 2 info =
[EMAIL PROTECTED]
DEBUG (init): node = 1 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 5 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 4 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 3 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 2 info =
[EMAIL PROTECTED]
DEBUG (after init): node = 1 info =
[EMAIL PROTECTED]
DEBUG (visit): node = 5
DEBUG (visit): other = null otherInfo = null
Tests run: 4, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.016sec
<<< FAILURE!
testBackEdges (org.apache.openjpa.lib.graph.TestDepthFirstAnalysis) Time
elapsed: 0.016 sec  <<< ERROR!
java.lang.NullPointerException
       at org.apache.openjpa.lib.graph.DepthFirstAnalysis.visit(
DepthFirstAnalysis.java:108)
       at org.apache.openjpa.lib.graph.DepthFirstAnalysis.<init>(
DepthFirstAnalysis.java:83)
       at
org.apache.openjpa.lib.graph.TestDepthFirstAnalysis.setUpGraph2(
TestDepthFirstAnalysis.java :78)
       at
org.apache.openjpa.lib.graph.TestDepthFirstAnalysis.testBackEdges
(TestDepthFirstAnalysis.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:64)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke (Method.java:615)
       at junit.framework.TestCase.runTest(TestCase.java:154)
       at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java : 106) at junit.framework.TestResult.runProtected (TestResult.java:124)
       at junit.framework.TestResult.run(TestResult.java:109)
       at junit.framework.TestCase.run(TestCase.java:118)
       at org.apache.openjpa.lib.test.AbstractTestCase.run(
AbstractTestCase.java:178)
       at junit.framework.TestSuite.runTest(TestSuite.java:208)
       at junit.framework.TestSuite.run(TestSuite.java :203)
at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke (Method.java:615)
       at org.apache.maven.surefire.junit.JUnitTestSet.execute(
JUnitTestSet.java:210)
       at

org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTe stSet(


AbstractDirectoryTestSuite.java:)
       at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(
AbstractDirectoryTestSuite.java:122)
at org.apache.maven.surefire.Surefire.run (Surefire.java: 129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:64)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:615)
       at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess (
SurefireBooter.java:225)
       at org.apache.maven.surefire.booter.SurefireBooter.main(
SurefireBooter.java:747)

testForwardEdges (org.apache.openjpa.lib.graph.TestDepthFirstAnalysis )
Time
elapsed: 0 sec  <<< ERROR!
java.lang.NullPointerException
       at org.apache.openjpa.lib.graph.DepthFirstAnalysis.visit(
DepthFirstAnalysis.java:108)
       at org.apache.openjpa.lib.graph.DepthFirstAnalysis.<init>(
DepthFirstAnalysis.java:83)
       at
org.apache.openjpa.lib.graph.TestDepthFirstAnalysis.setUpGraph2(
TestDepthFirstAnalysis.java :78)
       at
org.apache.openjpa.lib.graph.TestDepthFirstAnalysis.testForwardEdge s(
TestDepthFirstAnalysis.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:64)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:615)
       at junit.framework.TestCase.runTest(TestCase.java:154)
       at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect (TestResult.java: 106) at junit.framework.TestResult.runProtected (TestResult.java:124)
       at junit.framework.TestResult.run(TestResult.java:109)
       at junit.framework.TestCase.run(TestCase.java :118)
       at org.apache.openjpa.lib.test.AbstractTestCase.run(
AbstractTestCase.java:178)
       at junit.framework.TestSuite.runTest(TestSuite.java:208)
       at junit.framework.TestSuite.run (TestSuite.java:203)
at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:615)
       at org.apache.maven.surefire.junit.JUnitTestSet.execute(
JUnitTestSet.java:210)
       at

org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTe stSet(

AbstractDirectoryTestSuite.java:)
       at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(
AbstractDirectoryTestSuite.java:122)
at org.apache.maven.surefire.Surefire.run (Surefire.java: 129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:64)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:615)
       at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess (
SurefireBooter.java:225)
       at org.apache.maven.surefire.booter.SurefireBooter.main(
SurefireBooter.java:747)


On 7/18/07, Markus Fuchs < [EMAIL PROTECTED]> wrote:

Thanks Marc. I added debug statements the the code accessing the
_nodeInfo Map. Could somebody please try the attached patch!

-- markus.

Marc Prud'hommeaux wrote:

As a random shot in the dark (I can't reproduce the error on my
machine), I notice that the _nodeInfo Map is relying on keys being
of
type java.util.Collection, and the javadoc for Collection.equals()
does not actually require that equality be evaluated based on the
content of the collection (although java.util.List.equals() does).

So if somehow there is an IBM-specific list that is being put in
there
as a key, then a lookup using an equivalent collection might not be
succeeding, resulting in _nodeInfo.get(other) returning null.

Anyway, just a guess. Some debug statements would very quickly show
it
that might be the case or not.





On Jul 18, 2007, at 8:59 AM, Patrick Linskey wrote:

From the source:

            otherInfo = (NodeInfo) _nodeInfo.get(other);
            if (otherInfo.color == NodeInfo.COLOR_WHITE) {

Assuming that the class constant is non-null, that leaves
otherInfo.
_nodeInfo is populated during construction based on the graph
passed
to the constructor. It looks like the null must be coming from
Graph.java:154 or Graph.java :162.

-Patrick

On 7/18/07, Craig L Russell <[EMAIL PROTECTED]> wrote:
So it's either a bug in the IBM vm or a bug in our code that
exploits
some loophole in the spec that the Sun JDK doesn't fail on...

Craig

On Jul 18, 2007, at 8:38 AM, Kevin Sutter wrote:

Yes, and the Sun JDK works just fine.  So, for the majority of
the
folks,
there is no problem...  :-(

On 7/18/07, Craig L Russell <[EMAIL PROTECTED]> wrote:

I don't suppose you have run this with the Sun JDK (that I've
tested
on).

Craig

On Jul 18, 2007, at 8:00 AM, Kevin Sutter wrote:

Craig,
I haven't taken the time to figure out the source of the
problem
yet, but I
am experiencing two NPE's in our test bucket when running
with
the
IBM JDK (
1.5.0 SR5).  I thought I would post a heads-up for any IBM
JDK
users...

Craig Russell
Architect, Sun Java Enterprise System
http://java.sun.com/products/jdo
408 276-5638 mailto:[EMAIL PROTECTED]
P.S. A good JDO? O, Gasp!





--Patrick Linskey
202 669 5907





Index:
openjpa-lib/src/test/java/org/apache/openjpa/lib/graph/ TestDepthFirstAnalysis.java
===================================================================
---
openjpa-lib/src/test/java/org/apache/openjpa/lib/graph/ TestDepthFirstAnalysis.java (revision
557093)
+++
openjpa-lib/src/test/java/org/apache/openjpa/lib/graph/ TestDepthFirstAnalysis.java (working
copy)
@@ -35,7 +35,6 @@
     private DepthFirstAnalysis _dfa = null;

     public void setUp() {
-        setUpGraph1();
     }

     public void setUpGraph1() {
@@ -58,30 +57,30 @@

     public void setUpGraph2() {
         Graph graph = new Graph();
-        Integer node1 = new Integer(5);
-        Integer node2 = new Integer(4);
+        Integer node5 = new Integer(5);
+        Integer node4 = new Integer(4);
         Integer node3 = new Integer(3);
-        Integer node4 = new Integer(2);
-        Integer node5 = new Integer(1);
+        Integer node2 = new Integer(2);
+        Integer node1 = new Integer(1);
+        graph.addNode(node5);
+        graph.addNode(node4);
+        graph.addNode(node3);
+        graph.addNode(node2);
         graph.addNode(node1);
-        graph.addNode(node2);
-        graph.addNode(node3);
-        graph.addNode(node4);
-        graph.addNode(node5);
-        graph.addEdge(new Edge(node1, node2, true));
-        graph.addEdge(new Edge(node2, node3, true));
+        graph.addEdge(new Edge(node5, node4, true));
+        graph.addEdge(new Edge(node4, node3, true));
         graph.addEdge(new Edge(node3, node3, true));
-        graph.addEdge(new Edge(node3, node4, true));
-        graph.addEdge(new Edge(node4, node1, true));
-        graph.addEdge(new Edge(node4, node2, true));
-        graph.addEdge(new Edge(node5, node2, true));
+        graph.addEdge(new Edge(node3, node2, true));
+        graph.addEdge(new Edge(node2, node5, true));
+        graph.addEdge(new Edge(node2, node4, true));
+        graph.addEdge(new Edge(node1, node4, true));
         _dfa = new DepthFirstAnalysis(graph);
     }

     public void testNodeSorting() {
+        setUpGraph1();
         Collection nodes = _dfa.getSortedNodes();
         assertEquals(4, nodes.size ());
-
         int time = 0;
         Object node;
         for (Iterator itr = nodes.iterator(); itr.hasNext();) {
@@ -92,6 +91,7 @@
     }

     public void testEdgeTyping() {
+        setUpGraph1();
         Collection edges = _dfa.getEdges(Edge.TYPE_BACK);
         assertEquals(2, edges.size());
         Iterator itr = edges.iterator();




Reply via email to