Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 341515 - [api] Element returns null instead of empty string for undefined attributes (regression)
Summary: [api] Element returns null instead of empty string for undefined attributes (...
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.html (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Nick Sandonato CLA
QA Contact: Nick Sandonato CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-31 11:50 EDT by Yahor Radtsevich CLA
Modified: 2011-04-01 11:47 EDT (History)
2 users (show)

See Also:


Attachments
patch (1.37 KB, patch)
2011-03-31 13:48 EDT, Nick Sandonato CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.