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 112506 - "Not locked. Use Reformat.lock()." from IndentImpl.reformat running apisupport wizard
Summary: "Not locked. Use Reformat.lock()." from IndentImpl.reformat running apisuppor...
Status: RESOLVED FIXED
Alias: None
Product: apisupport
Classification: Unclassified
Component: Templates (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Martin Krauskopf
URL:
Keywords:
: 112484 (view as bug list)
Depends on:
Blocks: 65586
  Show dependency tree
 
Reported: 2007-08-09 21:06 UTC by Jesse Glick
Modified: 2007-08-14 09:06 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2007-08-09 21:06:07 UTC
070808, JDK 5, Ubuntu. In a fresh userdir on a new standalone module, I add an Action, keeping to defaults except for
label. I get on console:

SEVERE [org.netbeans.modules.editor.indent.IndentImpl]: Not locked. Use Reformat.lock().
java.lang.Exception
        at org.netbeans.modules.editor.indent.IndentImpl.reformat(IndentImpl.java:217)
        at org.netbeans.modules.editor.indent.FormatterImpl.reformat(FormatterImpl.java:120)
        at org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator.formatFile(BasicWizardIterator.java:341)
        at
org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator.getCreatedFiles(BasicWizardIterator.java:293)
        at org.netbeans.modules.apisupport.project.ui.wizard.action.NewActionIterator.instantiate(NewActionIterator.java:46)
[....]

I tried to fix as follows:

int reformattedLen;
try {
    Reformat.get(doc).lock();
    reformattedLen = doc.getFormatter().reformat(doc, pos, stopPos);
} finally {
    Reformat.get(doc).unlock();
}

(add dep on editor/indent)

but then I just get this instead:

java.lang.AssertionError: JavaSource.runCompileControlTask called under Document write lock.
        at org.netbeans.api.java.source.JavaSource.runUserActionTask(JavaSource.java:511)
        at org.netbeans.modules.java.source.save.Reformatter$Lock.lock(Reformatter.java:398)
        at org.netbeans.modules.editor.indent.TaskHandler$MimeItem.lock(TaskHandler.java:310)
        at org.netbeans.modules.editor.indent.TaskHandler.lock(TaskHandler.java:149)
        at org.netbeans.modules.editor.indent.IndentImpl.reformatLock(IndentImpl.java:131)
        at org.netbeans.api.editor.indent.Reformat.lock(Reformat.java:89)
        at org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator.formatFile(BasicWizardIterator.java:344)
[....]

I'm not exactly sure what it means, but apparently the copy-pasted code to reindent the doc is not working so well any more.
Comment 1 Jiri Prox 2007-08-10 10:39:07 UTC
*** Issue 112484 has been marked as a duplicate of this issue. ***
Comment 2 Martin Krauskopf 2007-08-10 11:32:49 UTC
I'll take a look at it next week. Will have a change to ask somebody from editor for the most right way to do this.
Comment 3 Martin Krauskopf 2007-08-14 09:06:29 UTC
I've just used code from the Reformatter Javadoc which seems to work nicely.

src/org/netbeans/modules/apisupport/project/ui/wizard/BasicWizardIterator.java;
new revision: 1.27; previous revision: 1.26
nbproject/project.xml;
new revision: 1.58; previous revision: 1.57