mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 13:32:24 +00:00
Merge pull request #4830 from jglick/StandardOutputSwapper-logging
An UnsatisfiedLinkError from StandardOutputSwapper.ChannelSwapper.swap need not be reported
This commit is contained in:
1 file changed
+14
-5
@@ -17,6 +17,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
@@ -31,8 +32,8 @@ public class StandardOutputSwapper extends ComputerListener {
|
||||
try {
|
||||
if (channel.call(new ChannelSwapper()))
|
||||
listener.getLogger().println("Evacuated stdout");
|
||||
} catch (Throwable e) {
|
||||
LOGGER.fine("Fatal problem swapping file descriptors " + c.getName());
|
||||
} catch (Exception x) {
|
||||
LOGGER.log(Level.FINE, "Fatal problem swapping file descriptors " + c.getName(), x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,20 +43,28 @@ public class StandardOutputSwapper extends ComputerListener {
|
||||
Channel c = getOpenChannelOrFail();
|
||||
StandardOutputStream sos = (StandardOutputStream) c.getProperty(StandardOutputStream.class);
|
||||
if (sos!=null) {
|
||||
swap(sos);
|
||||
_swap(sos);
|
||||
return true;
|
||||
}
|
||||
|
||||
OutputStream o = c.getUnderlyingOutput();
|
||||
if (o instanceof StandardOutputStream) {
|
||||
swap((StandardOutputStream) o);
|
||||
_swap((StandardOutputStream) o);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void swap(StandardOutputStream stdout) throws IOException, NoSuchMethodException, InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException {
|
||||
private void _swap(StandardOutputStream stdout) throws Exception {
|
||||
try {
|
||||
swap(stdout);
|
||||
} catch (LinkageError x) {
|
||||
throw new Exception(x);
|
||||
}
|
||||
}
|
||||
|
||||
private void swap(StandardOutputStream stdout) throws IOException, NoSuchMethodException, InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException, UnsatisfiedLinkError {
|
||||
// duplicate the OS file descriptor and create FileOutputStream around it
|
||||
int out = GNUCLibrary.LIBC.dup(1);
|
||||
if (out<0) throw new IOException("Failed to dup(1)");
|
||||
|
||||
Reference in new issue
Block a user