Wicket
  1. Wicket
  2. WICKET-3910

o.a.w.pageStore.AsynchronousDataStore#getData() returns null if the StoreEntryRunnable is currently running

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5-RC5.1
    • Fix Version/s: 1.5-RC6
    • Component/s: wicket
    • Labels:
      None
    • Environment:
      Hostspot 1.6.0_26, 1.5.0_22

      Description

      I am running "mvn clean package" on the command line and based on the jdk I get different results (reproducable).

      With jdk6 the test fails and the following is logged:
      ERROR - DiskDataStoreTest - data[] should never be null
      ERROR - DiskDataStoreTest - Detected error number: 1
      ERROR - DiskDataStoreTest - data[] should never be null
      ERROR - DiskDataStoreTest - Detected error number: 2
      Exception in thread "Thread-22" java.lang.NullPointerException
      at org.apache.wicket.page.persistent.disk.DiskDataStoreTest$Read1Runnable.run(DiskDataStoreTest.java:231)
      at java.lang.Thread.run(Thread.java:662)
      Exception in thread "Thread-42" java.lang.NullPointerException
      at org.apache.wicket.page.persistent.disk.DiskDataStoreTest$Read2Runnable.run(DiskDataStoreTest.java:264)
      at java.lang.Thread.run(Thread.java:662)

      With jdk5 everything goes fine and above message is not logged.

      The datastore in the test is returning null in the Read1Runnable and Read2Runnable which is causing the NPE.

      1. fix-WICKET-3910.patch
        5 kB
        Attila Király
      2. modify-test-WICKET-3910.patch
        3 kB
        Attila Király

        Activity

        Hide
        Martin Grigorov added a comment -

        The test fails at Apache Jenkins as well but I can't make it fail locally ...
        I tried with Maven 2/3, JDK 1.5/6, en_US/bg_BG locales.

        Show
        Martin Grigorov added a comment - The test fails at Apache Jenkins as well but I can't make it fail locally ... I tried with Maven 2/3, JDK 1.5/6, en_US/bg_BG locales.
        Hide
        Attila Király added a comment -

        Attaching a patch that modifies the test to fail more consistently (start reading threads before the saving ones).

        Also note that junit can not handle well some aspects of multi thread tests: in this case an exception thrown in a runnable does not cause the junit test to fail. So I modified that too to store exception thrown in runnables and fail test in main test thread.

        Show
        Attila Király added a comment - Attaching a patch that modifies the test to fail more consistently (start reading threads before the saving ones). Also note that junit can not handle well some aspects of multi thread tests: in this case an exception thrown in a runnable does not cause the junit test to fail. So I modified that too to store exception thrown in runnables and fail test in main test thread.
        Hide
        Attila Király added a comment -

        Attaching a fix.

        This is a timing issue in the AsynchronousDataStore (and I only had the luck that the two different jdk produced different timing in my env).

        It seems that if the following happens the error is raised:

        • SaveRunnable passes file to datastore (dataStore.storeData...)
        • SaveRunnable puts file on the read1 queue (filesToRead1.add...)
        • Read1Runnable reads the file from its queue
        • Read1Runnable tries to get the data for the file from the dataSource but gets null, because the asynch thread for saving the data in the datastore is currently running so it is not on the asynch work queue anymore and the data is still not in the underlying datastore either.

        So the fix adds a Set to Asynch data store to track all waiting, running runnables in one place.

        Show
        Attila Király added a comment - Attaching a fix. This is a timing issue in the AsynchronousDataStore (and I only had the luck that the two different jdk produced different timing in my env). It seems that if the following happens the error is raised: SaveRunnable passes file to datastore (dataStore.storeData...) SaveRunnable puts file on the read1 queue (filesToRead1.add...) Read1Runnable reads the file from its queue Read1Runnable tries to get the data for the file from the dataSource but gets null, because the asynch thread for saving the data in the datastore is currently running so it is not on the asynch work queue anymore and the data is still not in the underlying datastore either. So the fix adds a Set to Asynch data store to track all waiting, running runnables in one place.
        Hide
        Martin Grigorov added a comment -

        With this fix AsynchronousDataStore looks like its previous impl.
        The previous impl was stable and it works even with your improvement in the test, so I'll revert to the previous impl.

        Show
        Martin Grigorov added a comment - With this fix AsynchronousDataStore looks like its previous impl. The previous impl was stable and it works even with your improvement in the test, so I'll revert to the previous impl.
        Hide
        Martin Grigorov added a comment -

        With r1148226 I reverted to the previous impl of AsynchronousDataStore.

        Show
        Martin Grigorov added a comment - With r1148226 I reverted to the previous impl of AsynchronousDataStore.
        Hide
        Andrea Del Bene added a comment -

        Should we reopen WICKET-3876 ?

        Show
        Andrea Del Bene added a comment - Should we reopen WICKET-3876 ?
        Hide
        Martin Grigorov added a comment -

        There are no known problems at the moment. The problem in the 3876 has been fixed before introducing your impl.

        Show
        Martin Grigorov added a comment - There are no known problems at the moment. The problem in the 3876 has been fixed before introducing your impl.

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Attila Király
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development