OpenJPA
  1. OpenJPA
  2. OPENJPA-2328

NPE caused by one too many calls on the iterator inside the library.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.1.1, 2.2.0, 2.2.1
    • Fix Version/s: 2.3.0
    • Component/s: jdbc
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      We have just discovered a critical bug in the library preventing our program from operating. The problem comes from an NPE generated when there is one too many calls on the iterator of a collection, causing this type of stack trace:

      <openjpa-2.2.1-r422266:1396819 fatal store error> org.apache.openjpa.persistence.RollbackException: null
      at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:594)
      at com.qualiformed.qualinax.platform.dao.GenericDAO.update(GenericDAO.java:136)
      at com.qualiformed.qualinax.platform.dao.SettingDAO.persist(SettingDAO.java:54)
      at com.qualiformed.qualinax.application.QualinaxConfig.save(QualinaxConfig.java:509)
      at com.qualiformed.qualinax.application.model.LancerQualimagiQModel.supprimerSettingsQualimagiQ(LancerQualimagiQModel.java:103)
      at com.qualiformed.qualinax.application.controller.QualimagiqController.setupAnalysis(QualimagiqController.java:371)
      at com.qualiformed.qualinax.application.controller.QualimagiqProcessor$8$1.doInBackground(QualimagiqProcessor.java:449)
      at com.qualiformed.qualinax.application.controller.QualimagiqProcessor$8$1.doInBackground(QualimagiqProcessor.java:446)
      at javax.swing.SwingWorker$1.call(SwingWorker.java:277)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      at javax.swing.SwingWorker.run(SwingWorker.java:316)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
      Caused by: <openjpa-2.2.1-r422266:1396819 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: null
      at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:2000)
      at org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
      at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1516)
      at org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:933)
      at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:570)
      ... 14 more
      Caused by: java.util.NoSuchElementException
      at java.util.HashMap$HashIterator.nextEntry(HashMap.java:796)
      at java.util.HashMap$KeyIterator.next(HashMap.java:828)
      at org.apache.openjpa.jdbc.meta.strats.HandlerRelationMapTableFieldStrategy.update(HandlerRelationMapTableFieldStrategy.java:320)
      at org.apache.openjpa.jdbc.meta.FieldMapping.update(FieldMapping.java:699)
      at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.update(AbstractUpdateManager.java:343)
      at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.update(AbstractUpdateManager.java:370)
      at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.populateRowManager(AbstractUpdateManager.java:174)
      at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:97)
      at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:78)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:735)
      at org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
      at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2176)
      at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2074)
      at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1992)
      ... 18 more

      We have created a patch to correct the problem, but I haven't had the time to create the unitary test to reproduce it.

      1. OPENJPA-2328-JUNIT.patch
        6 kB
        Guillaume Chauvet
      2. OPENJPA-2328.patch
        0.8 kB
        Guillaume Chauvet

        Activity

        Guillaume Chauvet created issue -
        Guillaume Chauvet made changes -
        Field Original Value New Value
        Attachment OPENJPA-2328.patch [ 12567318 ]
        Hide
        Kevin Sutter added a comment -

        Nice catch, nice debugging, and nice patch. It looks like this patch not only prevents the NPE, but it's also correcting the expected processing for this value handler strategy. It looks like OpenJPA was accidentally skipping items via this iterator processing. I am surprised that this wasn't discovered previously just due to incorrect results... Thanks again.

        If you can provide a junit test case for this condition, it would be icing on the cake...

        Show
        Kevin Sutter added a comment - Nice catch, nice debugging, and nice patch. It looks like this patch not only prevents the NPE, but it's also correcting the expected processing for this value handler strategy. It looks like OpenJPA was accidentally skipping items via this iterator processing. I am surprised that this wasn't discovered previously just due to incorrect results... Thanks again. If you can provide a junit test case for this condition, it would be icing on the cake...
        Hide
        Guillaume Chauvet added a comment -

        Yes, I intend to send you a unit test soon (within 3 days, over the weekend)

        Show
        Guillaume Chauvet added a comment - Yes, I intend to send you a unit test soon (within 3 days, over the weekend)
        Hide
        Guillaume Chauvet added a comment -

        The expected unitary test.

        Show
        Guillaume Chauvet added a comment - The expected unitary test.
        Guillaume Chauvet made changes -
        Attachment OPENJPA-2328-JUNIT.patch [ 12567900 ]
        Hide
        Guillaume Chauvet added a comment -

        Please, can someone may check the correctness of our patch ? (fix + junit)

        Show
        Guillaume Chauvet added a comment - Please, can someone may check the correctness of our patch ? (fix + junit)
        Hide
        Rick Curtis added a comment -

        I'll try to take a look tomorrow.

        Show
        Rick Curtis added a comment - I'll try to take a look tomorrow.
        Rick Curtis made changes -
        Assignee Rick Curtis [ curtisr7 ]
        Rick Curtis made changes -
        Fix Version/s 2.3.0 [ 12319463 ]
        Hide
        ASF subversion and git services added a comment -

        Commit 1447955 from curtisr7
        [ https://svn.apache.org/r1447955 ]

        OPENJPA-2328: Fix NoSuchElementException when using HandlerRelationMapTableFieldStrategy. Patch contributed by Guillaume Chauvet.

        Show
        ASF subversion and git services added a comment - Commit 1447955 from curtisr7 [ https://svn.apache.org/r1447955 ] OPENJPA-2328 : Fix NoSuchElementException when using HandlerRelationMapTableFieldStrategy. Patch contributed by Guillaume Chauvet.
        Hide
        Rick Curtis added a comment -

        Committed revision 1447955 to trunk. Thanks for the patch Guillaume!

        Show
        Rick Curtis added a comment - Committed revision 1447955 to trunk. Thanks for the patch Guillaume!
        Hide
        Rick Curtis added a comment -

        Committed a UT and bug fix to trunk.

        Show
        Rick Curtis added a comment - Committed a UT and bug fix to trunk.
        Rick Curtis made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Albert Lee added a comment -

        OPENJPA-2378 opened to address test case failure introduced by this commit for Oracle.

        Show
        Albert Lee added a comment - OPENJPA-2378 opened to address test case failure introduced by this commit for Oracle.
        Hide
        Di Wu Lau added a comment -

        The reason is: Oracle does not support auto assign, so we need to exclude Oracle from the test. I post a patch for this change on OPENJPA-2378.

        Show
        Di Wu Lau added a comment - The reason is: Oracle does not support auto assign, so we need to exclude Oracle from the test. I post a patch for this change on OPENJPA-2378 .

          People

          • Assignee:
            Rick Curtis
            Reporter:
            Guillaume Chauvet
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development