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

Bug 341515

Summary: [api] Element returns null instead of empty string for undefined attributes (regression)
Product: [WebTools] WTP Source Editing Reporter: Yahor Radtsevich <yahorr>
Component: wst.htmlAssignee: Nick Sandonato <nsand.dev>
Status: RESOLVED FIXED QA Contact: Nick Sandonato <nsand.dev>
Severity: normal    
Priority: P3 CC: thatnitind, yahorr
Version: unspecified   
Target Milestone: 3.3 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
patch none

Description Yahor Radtsevich CLA 2011-03-31 11:50:34 EDT
Build Identifier: WTP 3.3.0M6

org.eclipse.wst.xml.core.internal.document.ElementImpl.getAttribute(String) returns null in some cases, but it must never return null.
This is regression to https://bugs.eclipse.org/bugs/show_bug.cgi?id=272378

It seems like this is caused by the recent changes in
org.eclipse.wst.xml.core.internal.document.ElementImpl.getAttribute(String
name):
lines
  String defaultValue = getDefaultValue(name);
  return (defaultValue != null) ? defaultValue : NodeImpl.EMPTY_STRING;
were replaced by
  return getDefaultValue(name, NodeImpl.EMPTY_STRING);
, but the method getDefaultValue(String, String) may return null.

Reproducible: Always

Steps to Reproduce:
1. Create new Dynamic Web Project
2. Create NewFile.jsp page with one line inside:
<html></html>
3. Check 'id' attribute of the <html> element programmatically (call
htmlElement.getAttribute("id")).
ACTUAL RESULT:
htmlElement.getAttribute("id") returns null.
EXPECTED RESULT:
htmlElement.getAttribute("id") returns "".
Comment 1 Nick Sandonato CLA 2011-03-31 13:15:06 EDT
Thank you for spotting this. But I don't think this meets the definition of
Critical which is "crashes, loss of data, severe memory leak"
Comment 2 Nick Sandonato CLA 2011-03-31 13:48:33 EDT
Created attachment 192307 [details]
patch
Comment 3 Nick Sandonato CLA 2011-04-01 11:47:22 EDT
Code checked in.