Skip to content
This repository has been archived by the owner on Apr 3, 2018. It is now read-only.

Commit

Permalink
LANG: minor ExternalProcessHelper fix for StdErr redirect.
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-medeiros committed Aug 4, 2015
1 parent e9bf247 commit f40a2d1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,15 +11,9 @@
package melnorme.lang.ide.ui.dialogs; package melnorme.lang.ide.ui.dialogs;


import static melnorme.utilbox.core.Assert.AssertNamespace.assertNotNull; import static melnorme.utilbox.core.Assert.AssertNamespace.assertNotNull;
import static melnorme.utilbox.core.CoreUtil.assertInstance;


import java.net.URI; import java.net.URI;


import melnorme.lang.ide.core.LangCore;
import melnorme.lang.ide.core.utils.ResourceUtils;
import melnorme.lang.ide.ui.LangUIPlugin;
import melnorme.utilbox.core.CommonException;

import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
Expand All @@ -34,7 +28,6 @@
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardContainer; import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.Wizard; import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage; import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.ui.INewWizard; import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbench;
Expand All @@ -44,6 +37,11 @@
import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard; import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;


import melnorme.lang.ide.core.LangCore;
import melnorme.lang.ide.core.utils.ResourceUtils;
import melnorme.lang.ide.ui.LangUIPlugin;
import melnorme.utilbox.core.CommonException;

public abstract class LangNewProjectWizard extends Wizard public abstract class LangNewProjectWizard extends Wizard
implements INewWizard, IExecutableExtension, IPageChangingListener { implements INewWizard, IExecutableExtension, IPageChangingListener {


Expand Down Expand Up @@ -111,10 +109,10 @@ public IStructuredSelection getSelection() {
public void setContainer(IWizardContainer wizardContainer) { public void setContainer(IWizardContainer wizardContainer) {
super.setContainer(wizardContainer); super.setContainer(wizardContainer);


if(wizardContainer != null) { // if(wizardContainer != null) {
WizardDialog wizardDialog = assertInstance(wizardContainer, WizardDialog.class); // WizardDialog wizardDialog = assertInstance(wizardContainer, WizardDialog.class);
wizardDialog.addPageChangingListener(this); // wizardDialog.addPageChangingListener(this);
} // }
} }


/* ----------------- ----------------- */ /* ----------------- ----------------- */
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package melnorme.utilbox.process; package melnorme.utilbox.process;


import static melnorme.utilbox.core.Assert.AssertNamespace.assertFail; import static melnorme.utilbox.core.Assert.AssertNamespace.assertFail;
import static melnorme.utilbox.core.Assert.AssertNamespace.assertNotNull;
import static melnorme.utilbox.core.Assert.AssertNamespace.assertTrue; import static melnorme.utilbox.core.Assert.AssertNamespace.assertTrue;


import java.io.IOException; import java.io.IOException;
Expand Down Expand Up @@ -151,10 +152,12 @@ protected ByteArrayOutputStreamExt getStdOutBytes() {
return mainReader.byteArray; return mainReader.byteArray;
} }


protected ByteArrayOutputStreamExt getStdErrBytes() { protected ByteArrayOutputStreamExt getStdErrBytes2() {
assertTrue(areReadersTerminated()); assertTrue(areReadersTerminated());
assertTrue(readStdErr); if(readStdErr) {
return stderrReader.byteArray; return stderrReader.byteArray;
}
return null;
} }


public class ExternalProcessResult { public class ExternalProcessResult {
Expand All @@ -165,8 +168,8 @@ public class ExternalProcessResult {


public ExternalProcessResult(int exitValue, ByteArrayOutputStreamExt stdout, ByteArrayOutputStreamExt stderr) { public ExternalProcessResult(int exitValue, ByteArrayOutputStreamExt stdout, ByteArrayOutputStreamExt stderr) {
this.exitValue = exitValue; this.exitValue = exitValue;
this.stdout = stdout; this.stdout = assertNotNull(stdout);
this.stderr = stderr; this.stderr = stderr != null ? stderr : new ByteArrayOutputStreamExt();
} }


public IByteSequence getStdOutBytes() { public IByteSequence getStdOutBytes() {
Expand Down Expand Up @@ -206,12 +209,14 @@ public ExternalProcessResult awaitTerminationAndResult(int timeoutMs)


// Check for IOExceptions (although I'm not sure this scenario is possible) // Check for IOExceptions (although I'm not sure this scenario is possible)
mainReader.getResult(); mainReader.getResult();
stderrReader.getResult(); if(stderrReader != null) {
stderrReader.getResult();
}
} catch (Exception e) { } catch (Exception e) {
process.destroy(); process.destroy();
throw e; throw e;
} }
return new ExternalProcessResult(process.exitValue(), getStdOutBytes(), getStdErrBytes()); return new ExternalProcessResult(process.exitValue(), getStdOutBytes(), getStdErrBytes2());
} }


public ExternalProcessResult awaitTerminationAndResult_ce() throws CommonException, OperationCancellation { public ExternalProcessResult awaitTerminationAndResult_ce() throws CommonException, OperationCancellation {
Expand Down

0 comments on commit f40a2d1

Please sign in to comment.