Status: New
Owner: ----

New issue 694 by [email protected]: JpaPersistService.end() doesn't call entityManager.remove() in finally block
http://code.google.com/p/google-guice/issues/detail?id=694

This is the JpaPersistService.end() method as copied from the source code:

public void end() {
    EntityManager em = entityManager.get();

    // Let's not penalize users for calling end() multiple times.
    if (null == em) {
      return;
    }

    em.close();
    entityManager.remove();
 }

The call to em.close() could fail sometimes. In my particular case it failed because I tried to save an object with byte[] field having more then 500 bytes. This coused the last line to be skipped. Effectively this thread could no longer be used to serve requests because the begin() method of JpaPersistService would always fail.

The fix is to simply surround the em.close() invocation with try-finally block

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en.

Reply via email to