Bug 177621

Summary: XML log might be corrupted if an exception occurs while extracting problem context
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: sonia_dimitrov
Version: 3.3   
Target Milestone: 3.3 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix none

Description Olivier Thomann CLA 2007-03-15 14:56:27 EDT
Compiling the org.eclipse.core.tests.resources project on Linux using the default UTF-8 encoding might lead to an xml log being corrupted because of an AIOOBE in the problem context extraction.
Here is the end of the xml log:
		<source output="/builds/N200703151001/src/plugins/org.eclipse.core.tests.resources/temp.folder/resourcestests.jar.bin" path="/builds/N200703151001/src/plugins/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/SymlinkTest.java">
			<problems errors="1" problems="1" warnings="0">
				<problem charEnd="0" charStart="0" id="InvalidEncoding" line="1" severity="ERROR">
					<message value="Cannot read the source from /builds/N200703151001/src/plugins/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/SymlinkTest.java; either the file uses a different encoding than UTF-8 or it is corrupted"/>
				</sources>
				<exception class="class java.lang.ArrayIndexOutOfBoundsException" message="-1
java.lang.ArrayIndexOutOfBoundsException: -1
	at org.eclipse.jdt.internal.compiler.batch.Main$Logger.extractContext(Main.java(Compiled Code))
	at org.eclipse.jdt.internal.compiler.batch.Main$Logger.logXmlProblem(Main.java(Compiled Code))
	at org.eclipse.jdt.internal.compiler.batch.Main$Logger.logProblems(Main.java(Compiled Code))
"/>
			</compiler>

The <source> element is not properly closed.
Comment 1 Olivier Thomann CLA 2007-03-16 09:51:04 EDT
Created attachment 61091 [details]
Proposed fix

When the source unit is empty, there is nothing to do.
Patch is safe.
Comment 2 Olivier Thomann CLA 2007-03-16 09:51:51 EDT
Released for 3.3M6.
Comment 3 David Audel CLA 2007-03-21 10:33:03 EDT
Verified for 3.3 M6 using build I20070321-0010

Verified by patching jdtcore to force CompilationUnit#getContents() to throw a CharConversionException