At some point after this code was originally written, I/O in remoting
became asynchronous. So we need to sync with that before we swap out
the new log output stream, or else you cut off stuff at the wrong
moment.
Normally the command transfer in remoting is slow enough that
you get more or less synchronized output anyway, which is why
this poblem remained unnoticed.
But if the uncliamed buffer gets large, write operation will take a long
time, which makes this issue more likely to show up.
This fix address this problem by doing a proper sync.
The recycling of ByteArrayOutputStream is also disabled because it makes
synchronization tricky.
This might be a bug of its own that the unclaimed side buffer gets that long, but java.io.ByteArrayOutputStream really sucks as its bytes grow, and this does no harm
Exception class=[net.sourceforge.htmlunit.corejs.javascript.JavaScriptException]
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "parentNode" from null (http://localhost:38569/static/5bfaa01f/scripts/hudson-behavior.js#2430)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:528)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:529)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:536)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:424)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:399)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:892)
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeInlineScriptIfNeeded(HtmlScript.java:309)
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:364)
at com.gargoylesoftware.htmlunit.html.HtmlScript$1.execute(HtmlScript.java:223)
at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:238)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:699)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:657)
at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1132)
at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1034)
at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:206)
at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:329)
at org.cyberneko.html.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3058)
at org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:1994)
at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:907)
at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:499)
at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:452)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:901)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:350)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:304)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:134)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:101)
at org.jvnet.hudson.test.HudsonPageCreator.createPage(HudsonPageCreator.java:46)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:449)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:332)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:389)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:374)
at org.jvnet.hudson.test.HudsonTestCase$WebClient.goTo(HudsonTestCase.java:1744)
at org.jvnet.hudson.test.HudsonTestCase$WebClient.goTo(HudsonTestCase.java:1735)
at hudson.model.JobPropertyTest.assertJobPropertySummaryIsShownInIndexPage(JobPropertyTest.java:59)
at hudson.model.JobPropertyTest.testJobPropertySummaryIsShownInMatrixProjectIndexPage(JobPropertyTest.java:48)
at org.jvnet.hudson.test.HudsonTestCase.runTest(HudsonTestCase.java:386)
at org.jvnet.hudson.test.HudsonTestCase.runBare(HudsonTestCase.java:277)
at com.sun.maven.junit.LocalTestCaseRunner.runTests(LocalTestCaseRunner.java:142)
at com.sun.maven.junit.LocalTestCaseRunner.runTestCase(LocalTestCaseRunner.java:62)
at com.sun.maven.junit.LocalTestCaseRunner.runTestCase(LocalTestCaseRunner.java:58)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:274)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:255)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:215)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:270)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: net.sourceforge.htmlunit.corejs.javascript.JavaScriptException: TypeError: Cannot read property "parentNode" from null (http://localhost:38569/static/5bfaa01f/scripts/hudson-behavior.js#2430)
at script.(http://localhost:38569/static/5bfaa01f/scripts/hudson-behavior.js:2430)
at script.(http://localhost:38569/static/5bfaa01f/scripts/prototype.js:1126)
at script.(http://localhost:38569/static/5bfaa01f/scripts/prototype.js:1072)
at script.(http://localhost:38569/static/5bfaa01f/scripts/prototype.js:106)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:879)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:427)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:263)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3058)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:486)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.setState(XMLHttpRequest.java:171)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.doSend(XMLHttpRequest.java:445)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.access$000(XMLHttpRequest.java:61)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest$1$1.run(XMLHttpRequest.java:393)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:529)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:536)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest$1.execute(XMLHttpRequest.java:390)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.processPostponedActions(JavaScriptEngine.java:556)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$300(JavaScriptEngine.java:68)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:523)
Caused by: net.sourceforge.htmlunit.corejs.javascript.NativeError$NativeErrorException: Cannot read property "parentNode" from null
at net.sourceforge.htmlunit.corejs.javascript.NativeError.make(NativeError.java:99)
at net.sourceforge.htmlunit.corejs.javascript.NativeGlobal.execIdCall(NativeGlobal.java:242)
at net.sourceforge.htmlunit.corejs.javascript.IdFunctionObject.call(IdFunctionObject.java:129)
at net.sourceforge.htmlunit.corejs.javascript.BaseFunction.construct(BaseFunction.java:349)
at net.sourceforge.htmlunit.corejs.javascript.Context.newObject(Context.java:1541)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.newCatchScope(ScriptRuntime.java:3258)
at script.(http://localhost:38569/static/5bfaa01f/scripts/prototype.js:450)
at script.(http://localhost:38569/static/5bfaa01f/scripts/prototype.js:494)
at script.findElementsBySelector(http://localhost:38569/static/5bfaa01f/scripts/behavior.js:187)
at script.apply(http://localhost:38569/static/5bfaa01f/scripts/behavior.js:71)
at script.(http://localhost:38569/static/5bfaa01f/scripts/behavior.js:79)
at script.(http://localhost:38569/static/5bfaa01f/scripts/prototype.js:676)
at script.(http://localhost:38569/static/5bfaa01f/scripts/behavior.js:68)
at script.(http://localhost:38569/static/5bfaa01f/scripts/hudson-behavior.js:1518)
at script.(http://localhost:38569/static/5bfaa01f/scripts/prototype.js:1122)
Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot read property "parentNode" from null (http://localhost:38569/static/5bfaa01f/scripts/behavior.js#134)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3652)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3630)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3658)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3677)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3690)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1422)
at script.isAncestor(http://localhost:38569/static/5bfaa01f/scripts/behavior.js:134)
at script.(http://localhost:38569/static/5bfaa01f/scripts/behavior.js:187)
at script.(http://localhost:38569/static/5bfaa01f/scripts/prototype.js:495)
at script.(http://localhost:38569/static/5bfaa01f/scripts/prototype.js:451)
at script.(http://localhost:38569/static/5bfaa01f/scripts/prototype.js:676)
JavaScriptException value = TypeError: Cannot read property "parentNode" from null