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.
I have gotton some reports (non-reproducible) of the following exception. Looking at the code, it would appear that the problem is that a different thread (presumambly the AWT-Event thread) modifies the blocks variable (through setBlocks?) at the same time that the Text-Layout thread is calling addBlock. Exception in thread "Text-Layout" java.lang.ArrayIndexOutOfBoundsException: 2 at org.netbeans.editor.DocumentFinder$AbstractBlocksFinder.addBlock(DocumentFinder.java:359) at org.netbeans.editor.DocumentFinder$AbstractBlocksFinder.closeBlocks(DocumentFinder.java:365) at org.netbeans.editor.DocumentFinder$AbstractBlocksFinder.getBlocks(DocumentFinder.java:342) at org.netbeans.editor.DocumentFinder.findBlocks(DocumentFinder.java:276) at org.netbeans.editor.FindSupport.getBlocks(FindSupport.java:149) at org.netbeans.editor.DrawLayerFactory$HighlightSearchLayer.init(DrawLayerFactory.java:274) at org.netbeans.editor.DrawEngine.initInfo(DrawEngine.java:175) at org.netbeans.editor.DrawEngine.draw(DrawEngine.java:1099) at org.netbeans.editor.DrawEngineLineView.getModel2ViewRect(DrawEngineLineView.java:284) at org.netbeans.editor.DrawEngineLineView.modelToView(DrawEngineLineView.java:308) at org.netbeans.editor.DrawEngineLineView.getPreferredSpan(DrawEngineLineView.java:260) at org.netbeans.editor.DrawEngineLineView.minorAxisUpdateLayout(DrawEngineLineView.java:554) at org.netbeans.editor.DrawEngineLineView.updateLayout(DrawEngineLineView.java:509) at org.netbeans.lib.editor.view.GapDocumentView$ChildrenUpdateTask.updateView(GapDocumentView.java:458) at org.netbeans.lib.editor.view.GapDocumentView$ChildrenUpdateTask.run(GapDocumentView.java:413) at org.netbeans.editor.view.spi.ViewLayoutQueue$LayoutThread.run(ViewLayoutQueue.java:184)
I see, it's likely a threading issue. BTW we should stop using the o.n.e.Finder (and its extensions) completely and scan the document's chars either through a segment or better as character sequence.
We keep getting reports of this bug. Is it possible to get it fixed in the next release? Thanks-- Christina
I am proposing the following change in DocumentFinder's findBlocks method: public static int[] findBlocks(BaseDocument doc, int startOffset, int endOffset, Map props, int blocks[]) throws BadLocationException{ BlocksFinder finder =(BlocksFinder) getFinder(doc, props, false, true); if (finder == null){ return blocks; } // CLA moved this out and added synchronized below for issue 71563. CharSequence cs = doc.getText(startOffset, endOffset - startOffset); if (cs==null){ return null; } synchronized (finder) { finder.reset(); finder.setBlocks(blocks); finder.find(startOffset, cs); int ret [] = finder.getBlocks(); return ret; } }
pls evaluate.
I have integrated the fix, sorry for delay. Fixed: db4968ace27a