From: SourceForge.net <no...@so...> - 2004-09-07 19:47:27
|
Bugs item #1020806, was opened at 2004-09-01 23:07 Message generated for change (Comment added) made by hexsel You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=113153&aid=1020806&group_id=13153 Category: DOM Support Group: None >Status: Open Resolution: None Priority: 5 Submitted By: Gustavo Hexsel (hexsel) Assigned to: fabrizio giustina (fgiust) Summary: NPE when PPPrint'ing changed DOM tree Initial Comment: I get a NPE when printing a DOM tree I changed. I traced it down to the 'lexer' variable being null at PPrint.class, method pprintTree (sorry, lost the stack trace). Can't seem to ByteArrayOutputStream modifiedContent = new ByteArrayOutputStream(clipping.getContent().length()); Tidy parser = new Tidy(); Document node = parser.parseDOM(new ByteArrayInputStream(content.getBytes()), null); processNode(contentURI, node); parser.pprint(node, modifiedContent); ---------------------------------------------------------------------- >Comment By: Gustavo Hexsel (hexsel) Date: 2004-09-07 19:47 Message: Logged In: YES user_id=269024 Different area and probably slightly different error: ---- ... java.lang.NullPointerException java.lang.String.checkBounds(String.java:286) java.lang.String.<init>(String.java:319) org.w3c.tidy.Lexer.getString(Lexer.java:575) org.w3c.tidy.PPrint.hasCDATA(PPrint.java:1781) org.w3c.tidy.PPrint.printScriptStyle(PPrint.java:1848) org.w3c.tidy.PPrint.printTree(PPrint.java:2122) org.w3c.tidy.PPrint.printTree(PPrint.java:2231) org.w3c.tidy.PPrint.printTree(PPrint.java:2231) org.w3c.tidy.PPrint.printTree(PPrint.java:2021) org.w3c.tidy.Tidy.pprint(Tidy.java:1676) org.w3c.tidy.Tidy.pprint(Tidy.java:1634) ....DefaultRetriever.retrieve(DefaultRetriever.java:100) ----- The problem is still the same, it is trying to use the Lexer for deciding on an input that is null (unless JTidy is setting it). This is being called on a modified document, so I'm calling pprint directly. I've changed the code in a couple of functions to test if lexer.lexbuf was not null, seems to be working for now. ---------------------------------------------------------------------- Comment By: fabrizio giustina (fgiust) Date: 2004-09-02 22:02 Message: Logged In: YES user_id=798060 testcase added and fixed in cvs (along with other related problems when pprinting a doctype changed by tidy). ---------------------------------------------------------------------- Comment By: Gustavo Hexsel (hexsel) Date: 2004-09-02 15:50 Message: Logged In: YES user_id=269024 There we go, more info: this is the piece of code that throws the exception: // #603128 tidy adds newslines after </html> tag // Fix by Fabrizio Giustina 12-02-2004 // fix is different from the one in original tidy if (!lexer.seenEndHtml) { flushLine(fout, indent); } It throws a NPE because Tidy.pprint invokes the method with an explicit null as the argument for the lexer, as seen below (its reformatted to use less space here): /** * Pretty-prints a tidy Node. * @param node org.w3c.tidy.Node * @param out output stream */ private void pprint(Node node, OutputStream out) { Out o = new OutImpl(this.configuration); PPrint pprint; o.setState(StreamIn.FSM_ASCII); o.setEncoding(configuration.outCharEncoding); if (out != null) { pprint = new PPrint(configuration); o.setOut(out); if (configuration.xmlTags) { pprint.printXMLTree(o, (short) 0, 0, null, node); } else { pprint.printTree(o, (short) 0, 0, null, node); } pprint.flushLine(o, 0); } } For now I'm going to change the lines locally on the PPrint class to: if ((lexer != null) && !lexer.seenEndHtml) { flushLine(fout, indent); } That should solve the NPE, but I don't know about the bug #603128 annotated before that code. ---------------------------------------------------------------------- Comment By: Gustavo Hexsel (hexsel) Date: 2004-09-02 15:37 Message: Logged In: YES user_id=269024 Here is the stack trace. The version is the 30/Aug/03 snapshot. java.lang.NullPointerException at org.w3c.tidy.PPrint.printTree(PPrint.java:2257) at org.w3c.tidy.PPrint.printTree(PPrint.java:2231) at org.w3c.tidy.PPrint.printTree(PPrint.java:2231) at org.w3c.tidy.PPrint.printTree(PPrint.java:2021) at org.w3c.tidy.Tidy.pprint(Tidy.java:1669) at org.w3c.tidy.Tidy.pprint(Tidy.java:1626) at com.sagebrushcorp.oberon.clipping.server.dependency.DefaultRetriever.retrieve(DefaultRetriever.java:100) at com.sagebrushcorp.oberon.clipping.server.dependency.DefaultRetrieverTest.testCompleteClipping(DefaultRetrieverTest.java:169) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=113153&aid=1020806&group_id=13153 |