Bug 233165 - Fix logic of tesing for existing resources which underlie models
Summary: Fix logic of tesing for existing resources which underlie models
Status: RESOLVED FIXED
Alias: None
Product: WTP Java EE Tools
Classification: WebTools
Component: jst.j2ee (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P1 critical (vote)
Target Milestone: 3.1   Edit
Assignee: Carl Anderson CLA
QA Contact: Chuck Bridgham CLA
URL:
Whiteboard:
Keywords:
Depends on: 231430
Blocks: 233244 247162
  Show dependency tree
 
Reported: 2008-05-21 04:45 EDT by Xiaoying Gu CLA
Modified: 2008-09-12 10:12 EDT (History)
9 users (show)

See Also:


Attachments
error log (2.82 KB, application/octet-stream)
2008-05-21 04:45 EDT, Xiaoying Gu CLA
no flags Details
screenshot (128.02 KB, image/pjpeg)
2008-05-21 04:48 EDT, Xiaoying Gu CLA
no flags Details
Add checks to see if the component file has content (1.51 KB, patch)
2008-05-21 15:28 EDT, Carl Anderson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Xiaoying Gu CLA 2008-05-21 04:45:51 EDT
Created attachment 101204 [details]
error log

BuildId:
 I20080516-1333

Steps to reproduce:
1. Install below RC1 projects:
    dtp-1.6RC1-200805200500.zip
    eclipse-SDK-3.4RC1-win32.zip
    emf-runtime-2.4.0RC1.zip
    GEF-SDK-3.4.0RC1.zip
    xsd-runtime-2.4.0RC1.zip
    wtp-S-3.0RC1-20080519195353.zip
2. New->Project->Web->Dynamic Web Project
3. Enter project name and leave other settings as default value. Click "finish"


Expect result:
Dynamic Web project can be created successfully

Actual result:
NPE thrown out. 

Error Log:

Please see the attachment
Comment 1 Xiaoying Gu CLA 2008-05-21 04:48:30 EDT
Created attachment 101205 [details]
screenshot
Comment 2 David Williams CLA 2008-05-21 08:36:47 EDT
I can reproduce this when using 
emf-runtime-2.4.0RC1.zip, 
but not when using 
emf-runtime-I200805121800.zip

We'll investigate and narrow down where the problem is. We might just have to re-compile with this final version of EMF ... or, maybe there's some other bug? 

Thanks for reporting so quickly. (These compressed schedules are hard! :) 

Comment 3 Kaloyan Raev CLA 2008-05-21 09:12:39 EDT
This bug is valid for all project creation wizards, even for the Static Web project. I believe the problem is introduced by the Common project, so I move it to this component. 

I haven't observed this problem during the RC1 smoke testing, so it should be introduced with a later change. 
Comment 4 Carl Anderson CLA 2008-05-21 13:41:58 EDT
Please note that the missing metadata file is due to an EMF change:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=231430
We are working with the EMF team to find a proper solution.
Comment 5 David Williams CLA 2008-05-21 15:21:56 EDT
I've opened bug 233322 to request EMF to revert their fix for RC1 and re-introduce it in early RC2 driver, to give us time to adjust our code and test. 

Comment 6 Carl Anderson CLA 2008-05-21 15:28:18 EDT
Created attachment 101351 [details]
Add checks to see if the component file has content

In discussion with Ed Merks, their bug fix makes resource.isLoaded() return true even if the file doesn't exist.  That makes our code need to have an additional check - resource.getContents().isEmpty() - to see if there really was something there.
Comment 7 Chuck Bridgham CLA 2008-05-21 16:33:57 EDT
I'm ok with this for now...   but we need to keep investigating the impact of returning a loaded EMF Resource even if the file doesn't exist.
Comment 8 David Williams CLA 2008-05-22 00:42:38 EDT
Before marking approved, I think we need to investigate a bit more, and have a bit more discussion with EMF team to see if they have the right solution for original problem. 

Comment 9 Ed Merks CLA 2008-05-22 09:08:25 EDT
I'm okay with deferring the change to EMF 2.5, but I think this change has revealed bad assumptions in the downstream code.  I.e., isLoaded should never be false after calling load and even in this case where it was, isLoaded() == false does not mean "resource doesn't exist".  So if some logic is relying on the detecting when a resource doesn't exist, it should check that accurately with the new APIs provided in the URI converter in EMF 2.4 for exactly that purpose.
Comment 10 Chuck Bridgham CLA 2008-05-22 09:53:08 EDT
I agree with your comments regarding a better way to check existence of the file before we attempt to load - but what about any other load failure? will it be the same? - An exception occured loading - we should react, but will "isLoaded()" still return true?   Is this change only different in the "file doesn't exists" case?
Comment 11 Ed Merks CLA 2008-05-22 10:11:50 EDT
The goal of the change in EMF was to ensure that after load() (either version) is called isLoaded will always be true.  Currently, the only case for which this wasn't true was the case that the one argument version wasn't able to create an input stream and now that hole is patched.  Ideally WTP would be able to accommodate this change, but if not for this release, we can defer this to 2.5.

Note that on linux, you could fail to create an input stream because you don't have group read permission.  I believe the WTP logic would attempt overwrite the existing file in this case because it's assuming this state implies the file doesn't exits; this might even succeed if the directory has write access, though I'm not sure about that.  So there seems to be a lurking bug here.
Comment 12 David Williams CLA 2008-05-22 13:45:56 EDT
Thanks Ed for agreeing to wait on pushing your change into this release. 
That's the safest thing to do, even if we do need to improve our logic (it's not caused any problems "in the field" so far, so hate to introduce change at this point, without longer discussions and investigations). 

I'm "resetting" this bug, and changing title since it's no longer a "blocking" problem but an issue to address in maintenance or future release. 

Chuck and Carl, feel free to correct me if you have another opinon and want to introduce some change now. 

Comment 13 Carl Anderson CLA 2008-08-02 14:25:23 EDT
I put in an initial patch, but we need to review *ALL* of our uses of this.
Comment 14 David Williams CLA 2008-09-12 10:12:28 EDT
Since main part of this 'critical' bug has been fixed, I'm marking "fixed" but opened a cloned bug 247162 to track the "checking of all cases" that Carl mentioned in previous comment.