Twig unit tests failing with Java 7

44 views
Skip to first unread message

AndyD

unread,
Jun 7, 2013, 4:37:55 PM6/7/13
to twig-p...@googlegroups.com
I'm doing some Java 7 testing today, and ran into a problem which matched the one reported here: https://groups.google.com/forum/?fromgroups#!topic/twig-persist/gbfZE6KtN8w.

I'd been running with a pretty old build, so I fetched the latest code today and ran a maven build with Java 7.  However, it's currently failing a handful of unit tests with the same symptom reported in the post I linked to.

Tests in error: 
  noActivationEmbedded(com.vercer.engine.persist.ActivationTest): Cannot compare [SimpleProperty value=[com_vercer_engine_persist_ActivationTest$B(3), com_vercer_engine_persist_ActivationTest$B(4)] path=bs indexed=false]
  testStoreLoadEnumSet(com.vercer.engine.persist.EnumSetTest): Cannot compare [SimpleProperty value=[HELLO, THERE] path=theEnumSet indexed=false]
  activationDepth(com.vercer.engine.persist.festival.MusicFestivalTestCase): Cannot compare [SimpleProperty value=[com_vercer_engine_persist_festival_RockBand("Led Zeppelin"), com_vercer_engine_persist_festival_RockBand("The Firm"), com_vercer_engine_persist_festival_DanceBand("Soulwax")] path=bands indexed=false]
  testNoKeysWithAncestor(com.vercer.engine.persist.festival.MusicFestivalTestCase): Cannot compare [SimpleProperty value=[com_vercer_engine_persist_festival_Album("Jane Says")] path=albums indexed=false]
  testLists(com.vercer.engine.persist.festival.MusicFestivalTestCase): Cannot compare [SimpleProperty value=[0.0] path=tracks.length indexed=false]
  testLoadDifferentEqualInstances(com.vercer.engine.persist.festival.MusicFestivalTestCase): Cannot compare [SimpleProperty value=[com_vercer_engine_persist_festival_RockBand("Led Zeppelin"), com_vercer_engine_persist_festival_RockBand("The Firm"), com_vercer_engine_persist_festival_DanceBand("Soulwax")] path=bands indexed=false]
  test(com.vercer.engine.persist.SerializeCollectionsTest): Cannot compare [SimpleProperty value=<Blob: 201 bytes> path=classes indexed=false]

John, can you reproduce this?

-Andy

AndyD

unread,
Jun 7, 2013, 6:25:42 PM6/7/13
to twig-p...@googlegroups.com
Upon closer inspection, the problem seems to arise in StrategyObjectDatastore.entityToInstance, where it does:

properties = new TreeSet<Property>(properties);

If the Property objects in properties don't contain values which implement Comparable, and they have comparable paths, then this error will happen, because TreeSet's constructor ends up calling Treemap.put, which compares to-be-added elements to themselves (hence the path match).  This call to compare was added in the Java 7 implementation of TreeMap.put (see http://hariharanselvarajan-java.blogspot.com/2013/02/treemap-in-java-6-and-java-7.html).

-Andy

AndyD

unread,
Jun 10, 2013, 11:29:43 AM6/10/13
to twig-p...@googlegroups.com
Oops, sorry, false alarm.  Due to my unfamiliarity with mercurial, I was on the wrong branch.  Whew!

-Andy

John Patterson

unread,
Jun 10, 2013, 6:54:01 PM6/10/13
to twig-p...@googlegroups.com
Good to hear!  Yes this was a bug that is only hit in Java 7


--
You received this message because you are subscribed to the Google Groups "twig-persist" group.
To unsubscribe from this group and stop receiving emails from it, send an email to twig-persist...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages