clearDocument: NullPointerException
Status: Beta
Brought to you by:
trainhappy
If you didn't load any Document into HtmlPanel but trying to call clearDocument, the Programm throws a NullPointerException!
The Problem is in HtmlPanel.class (l.278) :
private void clearDocumentImpl() {
HTMLDocumentImpl prevDocument = (HTMLDocumentImpl) this.rootNode;
if(prevDocument != null) {
...
}
The Code checks if it is null but first tries to cast it to HTMLDocumentImpl! Here the NullPointerException is throwen!
It has to be for example:
private void clearDocumentImpl() {
if (this.rootNode != null) {
HTMLDocumentImpl prevDocument = (HTMLDocumentImpl) this.rootNode;
if(prevDocument != null) {
prevDocument.removeDocumentNotificationListener(this.notificationListener);
}
}
...
}
I forgot, that you have to write
...
private volatile NodeImpl rootNode = null;
...
instead of
...
private volatile NodeImpl rootNode;
...
otherwise
public NodeImpl getRootNode() {
return this.rootNode;
}
throths a NullPointerException too!