Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 365243

Summary: XML Content outline blocks Structured Editor (WebPage/XHTML/HTML/JSP editors) while retrieving DTDs using a wrong addresses or public Ids
Product: [WebTools] WTP Common Tools Reporter: Nick Sandonato <nsand.dev>
Component: wst.internetAssignee: Nitin Dahyabhai <thatnitind>
Status: RESOLVED FIXED QA Contact: Tim deBoer <deboer>
Severity: normal    
Priority: P3 CC: keith.chong.ca, thatnitind
Version: 3.3.1Keywords: api, performance
Target Milestone: 3.4 M6Flags: thatnitind: review+
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on:    
Bug Blocks: 356400    
Attachments:
Description Flags
patch
none
patch - no sysouts
none
patch thatnitind: iplog+

Description Nick Sandonato CLA 2011-11-30 16:00:51 EST
Created attachment 207759 [details]
patch

While there are some problems in Source Editor, there's also some problems when accessing the cache. The problem is with opening the inputstream to certain resources can take an extremely long time to connect. The solution I'm proposing, to avoid raising the min Java version, implements its own timeout mechanism.

I figured I could consolidate this functionality in URIHelper. The Cache now uses this timeout mechanism. SSE will make use of it as well in the places that could block on this long wait.
 
+++ This bug was initially created as a clone of Bug #356400 +++

Build Identifier: I20110613-1736

XML Content Outline blocks Structured Editor for a while when retrieving the DTDs in case of wrong (not available) addresses or public IDs specified. 

For example, create a test XHTML file and paste the following content into it:
{code}
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTMLs 1.0 Transitional//EN"
    "http://hans-moleman.w3.org/TR/xhtml1/DTD/xhtml1S-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    template="layout/template.xhtml">
</ui:composition>
{code}
Right after pasting the code the WebPage editor will be blocked for a while.

Perform save and close on the editor. Try to open that file again - The eclipse will be blocked again before the editor will be opened.

Debug shows that the thread [main] is blocked by socket reading operation:

{code}
Thread [main] (Suspended)	
	SocketInputStream.socketRead0(FileDescriptor, byte[], int, int, int) line: not available [native method]	
	SocketInputStream.read(byte[], int, int) line: 146	
	BufferedInputStream.fill() line: 235	
	BufferedInputStream.read1(byte[], int, int) line: 275	
	BufferedInputStream.read(byte[], int, int) line: 334	
	HttpClient.parseHTTPHeader(MessageHeader, ProgressSource, HttpURLConnection) line: 688	
	HttpClient.parseHTTP(MessageHeader, ProgressSource, HttpURLConnection) line: 633	
	HttpURLConnection.getInputStream() line: 1162	
	URIHelper.isReadableURI(String, boolean) line: 484	
	DTDParser.parse(String) line: 119	
	DTDUtil.parse(ResourceSet, String) line: 102	
	DTDImpl.buildDTDModel(String) line: 88	
	DTDImpl.buildCMDocument(String) line: 79	
	CMDocumentFactoryDTD.createCMDocument(String) line: 37	
	ContentModelManager.createCMDocument(String, String) line: 56	
	CMDocumentManagerImpl.buildCMDocument(String, String, String) line: 284	
	CMDocumentManagerImpl.loadCMDocument(String, String, String, boolean) line: 259	
	CMDocumentManagerImpl.getCMDocument(String, String, String) line: 195	
	XMLModelQueryAssociationProvider(XMLAssociationProvider).getCMDocument(String, String, String) line: 157	
	XMLModelQueryAssociationProvider(XMLAssociationProvider).getCorrespondingCMDocument(Node, boolean) line: 116	
	XMLModelQueryAssociationProvider(XMLAssociationProvider).getCMElementDeclaration(Element) line: 190	
	HTMLModelQueryImpl.getCMElementDeclaration(Element) line: 156	
	CMUtil.getElementDeclaration(Element) line: 272	
	CMUtil.getElementNamespaceURI(Element) line: 332	
	DTManager.getTagConverter(Element, int, IDOMDocument) line: 61	
	ElementEditPart.getTagConverter(Element) line: 163	
	ElementEditPart.setModel(Object) line: 84	
	HTMLEditPartsFactory.createEditPart(EditPart, Object) line: 69	
	DocumentEditPart(AbstractEditPart).createChild(Object) line: 269	
	DocumentEditPart(AbstractEditPart).refreshChildren() line: 780	
	DocumentEditPart.refreshChildren(boolean) line: 134	
	DocumentEditPart.refreshChildren() line: 126	
	DocumentEditPart(AbstractEditPart).refresh() line: 726	
	DocumentEditPart(AbstractGraphicalEditPart).refresh() line: 644	
	DocumentEditPart.refresh() line: 114	
	DocumentEditPart(AbstractEditPart).addNotify() line: 253	
	DocumentEditPart(AbstractGraphicalEditPart).addNotify() line: 223	
	DocumentEditPart(NodeEditPart).addNotify() line: 104	
	ScalableRootEditPart(AbstractEditPart).addChild(EditPart, int) line: 212	
	ScalableRootEditPart(SimpleRootEditPart).setContents(EditPart) line: 105	
	HTMLGraphicalViewer(AbstractEditPartViewer).setContents(EditPart) line: 617	
	HTMLGraphicalViewer(AbstractEditPartViewer).setContents(Object) line: 626	
	SimpleGraphicalEditor.setModel(IStructuredModel) line: 425	
	HTMLEditor.connectDesignPage() line: 364	
	HTMLEditor.createPages() line: 444	
	HTMLEditor(MultiPageEditorPart).createPartControl(Composite) line: 348	
	EditorReference.createPartHelper() line: 670	
	EditorReference.createPart() line: 465	
	EditorReference(WorkbenchPartReference).getPart(boolean) line: 595	
	EditorReference.getEditor(boolean) line: 289	
	WorkbenchPage.busyOpenEditorBatched(IEditorInput, String, boolean, int, IMemento) line: 2945	
	WorkbenchPage.busyOpenEditor(IEditorInput, String, boolean, int, IMemento) line: 2850	
	WorkbenchPage.access$11(WorkbenchPage, IEditorInput, String, boolean, int, IMemento) line: 2842	
	WorkbenchPage$10.run() line: 2793	
	BusyIndicator.showWhile(Display, Runnable) line: 70	
	WorkbenchPage.openEditor(IEditorInput, String, boolean, int, IMemento) line: 2789	
	WorkbenchPage.openEditor(IEditorInput, String, boolean, int) line: 2773	
	OpenWithMenu.openEditor(IEditorDescriptor, boolean) line: 331	
	OpenWithMenu$2.handleEvent(Event) line: 179	
	EventTable.sendEvent(Event) line: 84	
	MenuItem(Widget).sendEvent(Event) line: 1258	
	Display.runDeferredEvents() line: 3588	
	Display.readAndDispatch() line: 3209	
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2696	
	Workbench.runUI() line: 2660	
	Workbench.access$4(Workbench) line: 2494	
	Workbench$7.run() line: 674	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 667	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	IDEApplication.start(IApplicationContext) line: 123	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 110	
	EclipseAppLauncher.start(Object) line: 79	
	EclipseStarter.run(Object) line: 344	
	EclipseStarter.run(String[], Runnable) line: 179	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43	
	Method.invoke(Object, Object...) line: 616	
	Main.invokeFramework(String[], URL[]) line: 622	
	Main.basicRun(String[]) line: 577	
	Main.run(String[]) line: 1410	
	Main.main(String[]) line: 1386	
{code}

Reproducible: Always

Steps to Reproduce:
1. Create XHTML file with the content described in details (it contains wrong public ID and address in DOCTYPE.
2. Play with Web Page Editor trying to open/edit and save the text to see the how editor have being blocked for a while on these operations.
Comment 1 Nick Sandonato CLA 2011-11-30 16:04:08 EST
Created attachment 207761 [details]
patch - no sysouts
Comment 2 Nick Sandonato CLA 2011-11-30 16:07:17 EST
Created attachment 207762 [details]
patch
Comment 3 Nitin Dahyabhai CLA 2012-03-07 14:59:14 EST
Released as new API (org.eclipse.wst.common.uriresolver incremented to 1.2.0).

Thanks, Nick!