This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | <java inputstring="..."> when run inside IDE causes java output not to be displayed | ||
---|---|---|---|
Product: | projects | Reporter: | rongoldman <rongoldman> |
Component: | Ant | Assignee: | Jesse Glick <jglick> |
Status: | VERIFIED FIXED | ||
Severity: | normal | Keywords: | REGRESSION |
Priority: | P3 | ||
Version: | 6.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | 68770, 168153 | ||
Bug Blocks: | 121512, 167279 | ||
Attachments: | Suggested patch |
Description
rongoldman
2011-01-09 10:37:00 UTC
Looking at the definition of the ForkedJavaOverride class (in package org.apache.tools.ant.module.bridge.impl) I think the problem is caused because both setInput() & setInputString() call useStandardRedirector(): public @Override void setInput(File input) { useStandardRedirector(); super.setInput(input); } public @Override void setInputString(String inputString) { useStandardRedirector(); super.setInputString(inputString); } I think that useStandardRedirector() should only be called when the output is being redirected via setOutput(), setOutputProperty(), setError() or setErrorProperty(). If the java target is only redirecting the input, then the output should go to the normal place, the Output Window. A simple fix might be to change setInput(), setInputString() & useStandardRedirector() to something like: private File useInput = null; private String useInputString = null; public @Override void setInput(File input) { useInput = input; super.setInput(input); } public @Override void setInputString(String inputString) { useInputString = inputString; super.setInputString(inputString); } private void useStandardRedirector() { // #121512, #168153 if (redirector instanceof NbRedirector) { redirector = new Redirector(this); if (useInput != null) super.setInput(useInput); if (useInputString != null) super.setInputString(useInputString); } } I'll see if I can reproduce and if a fix like you suggest works and causes no apparent regressions elsewhere. (Dealing with Ant's I/O system is rather tricky.) Created attachment 105845 [details] Suggested patch Does not work; when test case from bug #121512 comment #1 is run, process just hangs waiting for input. Seems to have regressed in 6.8. Perhaps the fix of bug #168153 was responsible, but I cannot get it to work in 7.0 even using the class as it existed in 6.7. Nor does using an older version of Ant help (both 6.7 and 6.8 use 1.7.1 so that's not surprising). Even disabling ForkedJavaOverride completely does not help. hg bisect says: The first bad revision is: changeset: 135936:8147e07a4e5d parent: 135879:96071a38dc62 user: Tomas Holy <t_h@netbeans.org> date: Tue Jun 23 12:28:24 2009 +0200 summary: #167279: Double echo on output in Output window I think I have a fix. Try: core-main #8f9fd1b9dfaf Failing that, the simplest workaround seems to be: <taskdef name="_java" classname="org.apache.tools.ant.taskdefs.Java"/> <_java ... inputstring="some text"/> If bug #68770 is implemented this and related issues would be obsolete. Both the fix & the workaround solve the problem! Many thanks. Good. By the way, the fix is clumsy in that it sets a flag which will be present for the rest of the project's execution, possibly causing bug #167279 to regress for _subsequent_ <java> invocations. I hope this is rare; if not, it should be possible to somehow unset the flag when the task is done. I initially tried calling setTaskName("origjava") but this had no apparent effect on Event.getTaskName(); that would be a cleaner fix if it can be made to work. Integrated into 'main-golden', will be available in build *201102160501* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/8f9fd1b9dfaf User: Jesse Glick <jglick@netbeans.org> Log: #194151: <java inputstring="..."/> fails to print any output. |