pombreda / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 1 forks source link

JpaPersistService.end() doesn't call entityManager.remove() in finally block #694

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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

Original issue reported on code.google.com by hristo.s...@gmail.com on 20 Mar 2012 at 5:53

GoogleCodeExporter commented 9 years ago

Original comment by cgruber@google.com on 27 Mar 2012 at 6:10

GoogleCodeExporter commented 9 years ago

Original comment by cgruber@google.com on 27 Mar 2012 at 6:25

GoogleCodeExporter commented 9 years ago
Any chance this will be fixed for 4.0?

Original comment by m...@lucidfox.org on 8 Oct 2013 at 11:31