[Building Sakai] Tests in Kernel with OpenJDK 7

Earle Nietzel earle.nietzel at gmail.com
Fri Mar 2 06:35:22 PST 2012


Hi everyone,

Looking for some input on the following test when compiling kernel
trunk with OpenJDK 7.

The following test is failing:

ContentHostingServiceTest

You can run just that test with the following:
mvn test -Dtest=ContentHostingServiceTest -DfailIfNoTests=false


It is all related to this method in BaseContentService:

       protected ContentCollection findCollection(String id) throws
TypeException
       {
               ContentCollection collection = null;
               try
               {
                       collection = (ContentCollection)
threadLocalManager.get("findCollection@" + id);

This returns null since it doesn't find the key in
ThreadLocalComponent bindings map.
WARN ThreadLocalComponent:183 - get: key not found:
findCollection@/admin/沒有已選要刪除的附件/

               }
               catch(ClassCastException e)
               {
                       throw new TypeException(id);
               }

               if(collection == null)
               {
                       collection = m_storage.getCollection(id);

Then it tries to perform a lookup from storage but this also fails
because ThreadLocalComponent does not contain the following key.
WARN ThreadLocalComponent:183 - get: key not found:
sqlService:transaction_connection

                       if(collection != null)
                       {

threadLocalManager.set("findCollection@" + id, collection);     // new
BaseCollectionEdit(collection));
                       }
               }
               else
               {
                       collection = new BaseCollectionEdit(collection);
               }

               return collection;

       } // findCollection

Then the following exception occurs:
org.sakaiproject.exception.IdUnusedException id=/admin/沒有已選要刪除的附件/
       at org.sakaiproject.content.impl.BaseContentService.checkCollection(BaseContentService.java:2230)

To me it looks as though ThreadLocalComponent did not get setup properly.

Funny part about all of this is I cannot reproduce this in the
debugger remotely connected to maven surefire

mvn test -Dtest=ContentHostingServiceTest -DfailIfNoTests=false
-Dmaven.surefire.debug

but when running without debugging it happens almost every time:

mvn test -Dtest=ContentHostingServiceTest -DfailIfNoTests=false

Thanks for any ideas?

Earle

I've had the following comments from a different list:

I've just been looking at caching and was noticing the ThreadLocals
dropping (it seemed, at least) values with no special characters. The
puts were issued and subsequent gets in the same thread were falling
through. An example is in a simple getUserByEid() call for admin. The
Ehcache set up through the MemoryService (second layer; maybe the
first is unneeded in this case) was catching all gets in the "call
cache".

This is unrelated to OpenJDK or JDK7, as I am using sun-java6-jdk on
Ubuntu 11.10. So, there may be a couple of things to pull apart here:
general ThreadLocal behavior on standard infrastructure and JDK7
effect on ThreadLocal behavior / UTF8 strings / queries.

Thanks,
-Noah


There's also the thorny issue that the use of threadloacal in a service
is less than ideal and can lead to memory leaks (and the CHS ones have
in the past)

David Horowitz


More information about the sakai-dev mailing list