[rfc][icedtea-web] remove rare deadlock in logging console

Jiri Vanek jvanek at redhat.com
Thu Mar 13 08:21:24 UTC 2014


I think this synchronisation is redundant.
If not, then maybe  invokeLater should become invokeAndWait? But it is locking too...
Also, the importList is synchronized in only model-touching block[1].

So this really should be ok to go.


Only case where I have seen the deadlock occur is in elluminate with CONSOLE ON and VISIBLE, It 
appeared in aprox 1/3 of cases.
It did not appeared after the fix. Anyway - anybody who is running head - may you try to run apps 
(and elluminat wit/without fix) with cosnole on and visibele for a while?

J


[0]here is whole block:

     /**
      * when various threads update (and it can be)underlying jeditorpane
      * simultanouskly, then it can lead to unpredictible issues synchroisation
      * is doen in invoe later
      */
     private AtomicBoolean done = new AtomicBoolean(true);

     private synchronized void updatePane(final boolean reset) {
         if (!done.get()) {
             return;
         }
         done.set(false);
         java.awt.EventQueue.invokeLater(new Runnable() {

             @Override
             public void run() {
                 try {
                     refreshPaneBody(reset);
                 } catch (Exception ex) {
                     OutputController.getLogger().log(ex);
                 } finally {
                     done.set(true);
                 }
             }
         });
     }

     private void refreshPaneBody(final boolean reset) throws BadLocationException, IOException {
         if (reset) {
             jEditorPane1.setText(model.importList(0));
         } else {
     ....

[1]
  String importList(boolean mark, int start, int sortByLocal) {
         int added = start;
         StringBuilder sb = new StringBuilder();
         if (mark) {
             sb.append("<div style='");
             if (!wordWrap) {
                 sb.append("white-space:nowrap;");
             }
             sb.append("font-family:\"Monospaced\"'>");
         }

         List<MessageWithHeader> sortedList;
         synchronized (dataProvider.getData()) {
             if (start == 0) {
                 sortedList = preSort(dataProvider.getData(), sortByLocal);
             } else {
                 sortedList = 
preSort(Collections.synchronizedList(dataProvider.getData().subList(start, 
dataProvider.getData().size())), sortByLocal);
             }
         }
    ....
-------------- next part --------------
A non-text attachment was scrubbed...
Name: removePotentialDeadlock.patch
Type: text/x-patch
Size: 628 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20140313/908f4aba/removePotentialDeadlock.patch>


More information about the distro-pkg-dev mailing list