This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 141014

Summary: Netbeans crashes when editing properties
Product: utilities Reporter: dana_k <dana_k>
Component: PropertiesAssignee: Marian Petras <mpetras>
Status: RESOLVED FIXED    
Severity: blocker Keywords: RANDOM, THREAD
Priority: P3    
Version: 6.x   
Hardware: All   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:
Attachments: Thread dump issue 141014

Description dana_k 2008-07-21 15:48:49 UTC
Hello,

in my application I´m using properties files as an resource bundle (descriptions.properties, descriptions_de.properties
and descriptions_en.properties).
Almost every time when I edit the key contents in the multiple view (that means, I see 4 columns: key, default language,
german, english), Netbeans freezes and I can exit it only by the task manager. It seems to me that it doesn`t make any
difference if I edit the content in the text area ("value") or directly in the table cell. 
After restarting Netbeans the last changes are gone.

best regards,

dana_k
Comment 1 Marian Petras 2008-07-21 17:09:46 UTC
dana_k, I have never heard of such a freeze and I have no idea about what might cause it. It would help me a lot if you
generated a thread dump once you experience the crash. Instructions on how to generate at thread dump are available
here: http://wiki.netbeans.org/GenerateThreadDump
Comment 2 dana_k 2008-08-08 10:31:44 UTC
Created attachment 66893 [details]
Thread dump issue 141014
Comment 3 dana_k 2008-08-08 10:33:25 UTC
please see attached thread dump!
Comment 4 Marian Petras 2008-08-08 10:51:39 UTC
Thanks! There is a threading bug, indeed.
Comment 5 Marian Petras 2008-09-03 14:01:17 UTC
The bug is in method PropertiesOpen.ModifiedListener.save():

    public void save() throws ... {
        stopEditing();
        // ...
        saveDocument();
    }

This method seems to be perfectly valid if executed from the AWT event-dispatching thread. But it may cause the reported
deadlock if executed from any other thread. Because it really is executed from some other thread ("Module-Actions"), it
actually causes the deadlock (randomly).

How to fix it:
The core problem is that method stopEditing() modifies the UI - and it does so from a event-dispatching thread (I will
call it "AWT thread" in the text below for simplicity). But it also saves the value of the cell, that is currently being
edited, to the data model and this save action should not be rescheduled to another thread. In summary, the saving must
be done in the current thread (without any delay) but the UI manipulation should not. So I will extract the data-saving
functionality to a separate method and then schedule the UI update actions so the AWT thread:

    public void save() throws ... {
        saveEditorValues();
        // ...
        saveDocument();
        // ...
        updateUI();
    }
Comment 6 Marian Petras 2008-09-03 14:26:20 UTC
Fixed.

Changeset Id:
8e2fce7e185d
(http://hg.netbeans.org/main/rev/8e2fce7e185d)
Comment 7 Quality Engineering 2008-09-04 06:01:35 UTC
Integrated into 'main-golden', will be available in build *200809040201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/8e2fce7e185d
User: Marian Petras <mpetras@netbeans.org>
Log: fixed bug #141014 - "Netbeans crashes when editing properties"