Bug 108456 - IPackageFragmentRoot#getPackageFragment() should not accept invalid package names
Summary: IPackageFragmentRoot#getPackageFragment() should not accept invalid package n...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M2   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-31 04:38 EDT by Markus Keller CLA
Modified: 2007-09-17 12:02 EDT (History)
1 user (show)

See Also:


Attachments
jdt.ui (64.32 KB, patch)
2005-08-31 04:38 EDT, Markus Keller CLA
no flags Details | Diff
jdt.ui.tests.refactoring (10.93 KB, patch)
2005-08-31 04:39 EDT, Markus Keller CLA
no flags Details | Diff
Proposed fix and regression tests (4.02 KB, patch)
2007-08-24 05:21 EDT, 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 Markus Keller CLA 2005-08-31 04:38:15 EDT
I20050830-0800

IPackageFragmentRoot#getPackageFragment(String) should not accept invalid
package names. Currently, it e.g. accepts "p1/".

This leads to strange effects with buffers. I accidentally passed such a package
name. I asked the returned IPackageFragment for a compilation unit, and called
cu.getSource(). This returned not the current contents of the CU, but the
previous version (which has been deleted on the file system by then).

I'll attach patches for jdt.ui and jdt.ui.tests.refactoring in case you'd like
to reproduce the problem. Run RenamePackageTests, and test1 will fail, because
it got the wrong contents for p1/A.java (the contents from test0).

The bug in the test (wrong package name passed) is marked with //XXX: bug
Comment 1 Markus Keller CLA 2005-08-31 04:38:48 EDT
Created attachment 26690 [details]
jdt.ui
Comment 2 Markus Keller CLA 2005-08-31 04:39:09 EDT
Created attachment 26691 [details]
jdt.ui.tests.refactoring
Comment 3 Markus Keller CLA 2005-08-31 04:55:46 EDT
The problem with the wrong buffer may or may not have something to do with bug
77204.
Comment 4 Frederic Fusier CLA 2006-10-07 15:13:45 EDT
Comment on attachment 26690 [details]
jdt.ui

Unfortunately this patch cannot longer be applied => set as obsolete
Comment 5 Frederic Fusier CLA 2006-10-07 15:14:06 EDT
Comment on attachment 26691 [details]
jdt.ui.tests.refactoring

Unfortunately this patch cannot longer be applied => set as obsolete
Comment 6 Markus Keller CLA 2007-06-20 08:45:14 EDT
Strengthening the precondition of #getPackageFragment() would be a breaking change. I guess the best fix would be to make sure that such packages (and their children) don't exist.
Comment 7 Jerome Lanneluc CLA 2007-08-24 05:21:03 EDT
Created attachment 76885 [details]
Proposed fix and regression tests
Comment 8 Jerome Lanneluc CLA 2007-08-27 04:49:20 EDT
Fix and tests released for 3.4M2 in HEAD.
Comment 9 Frederic Fusier CLA 2007-09-17 12:02:16 EDT
Verified for 3.4 M2 using I20070917-0010.