W3C home > Mailing lists > Public > public-mobileok-checker@w3.org > November 2007

Two more NullPointerExceptions

From: Guido García Bernardo <ggarciab@itdeusto.com>
Date: Fri, 30 Nov 2007 13:20:42 +0100
Message-ID: <4750001A.1090302@itdeusto.com>
To: public-mobileok-checker <public-mobileok-checker@w3.org>

Hi,

I'd like to share with you some lines I've had to fix to run mobileok 
without problems:


A. Class HTTPXHTMLResource

In the validateMarkup and validateMobile methods, calls to getBody() 
cause a NullPointerException when the body property is null :

xmlReader.parse(new InputSource(new StringReader(getBody())));

Maybe a check could be added:

String body = getBody();
if (body != null) {
	xmlReader.parse(new InputSource(new StringReader(body)));
}


B. Class HTTPXHTMLResource

In the extractImages method, if the srcAttribute is null, it causes a 
NullPointerException :

final Node srcAttribute = node.getAttributes().getNamedItem("src");
// TODO look for right kind of links
try {
	uris.add(new URI(srcAttribute.getNodeValue()));
} catch ...
}

Maybe a check could also be added:

final Node srcAttribute = node.getAttributes().getNamedItem("src");
if (srcAttribute != null) {
	// TODO look for right kind of links
	try {
		uris.add(new URI(srcAttribute.getNodeValue()));
	} catch ...
	}
}


C. CharacterEncodingSupportTest

When testing pages like
http://www.cheaperthanhotels.co.uk/United-Kingdom/London/Earls-Court/Lord-Jim-Hotel-London-L22244R.htm

That have more than two Content-Type meta tags in the html headers:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

That makes CharacterEncodingSupportTest to fail:

org.w3c.mwi.mobileok.basic.TestException: CharacterEncodingSupportTest 
at 
org.w3c.mwi.mobileok.basic.AbstractXSLTTestImplementation.runTest(AbstractXSLTTestImplementation.java:45)
at
...

Caused by: net.sf.saxon.trans.DynamicError: A sequence of more than one 
item is not allowed as the first argument of lower-case() ("text/html; 
charset=utf-8", "text/html; charset=utf-8")

It is not a very common case, but it'd be great to fix it if possible.


Thank you very much,
--
Guido García Bernardo
IT Deusto
Received on Friday, 30 November 2007 12:23:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:13:04 GMT