Bug 138882 - Should surface failure to get CU's contents
Summary: Should surface failure to get CU's contents
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M5   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-27 06:43 EDT by Jerome Lanneluc CLA
Modified: 2020-05-06 11:14 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix and regression tests (30.28 KB, patch)
2008-01-15 11:10 EST, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jerome Lanneluc CLA 2006-04-27 06:43:41 EDT
N20060427

org.eclipse.jdt.internal.core.CompilationUnit#getContents() currently returns an empty char array in the following cases:
- the CU is in working copy mode and the working copy's buffer is being closed
- the CU is in compilation unit mode and the underlying file is being deleted
- the CU is in compilation unit mode and there is an encoding problem leading to an IOException

We should surface this kind of problem during search, reconcile, etc... so as to not create unexpected errors.

The batch compiler does surface this kind of problem (see org.eclipse.jdt.ineternal.compiler.batch.CompilationUnit#getContents())
Comment 1 Philipe Mulet CLA 2007-12-17 06:10:45 EST
see bug 130980 for context near surfacing the encoding issues
Comment 2 Philipe Mulet CLA 2007-12-17 06:13:01 EST
also see bug 192880
Comment 3 Jerome Lanneluc CLA 2008-01-15 11:10:08 EST
Created attachment 86948 [details]
Proposed fix and regression tests

This fix reports problem to read the working copy/compilation unit's contents to the problem requestor if reconciling, otherwise it logs the problem to the .log file.

Note that there is no regression test for the encoding problem case since on Windows encoding problems are not reported. Thus this test would be Linux specific . It means that a developer running on Windows only would not see that s/he broke the test. This could cause integration builds failures.
Comment 4 Jerome Lanneluc CLA 2008-01-16 06:54:02 EST
Fix and tests released for 3.4M5
Comment 5 Eric Jodet CLA 2008-02-05 01:09:26 EST
Verified in the code for 3.4M5 using build I20080204-0010