# HG changeset patch # User Vladimir Kvashin # Date 1474928637 25200 # Node ID d295ad62d580c4f12c98e440c5ab3517927ca92b # Parent 1a523d1488257824bb1c0afe9892c8b605b858be fixed #268153 - NullPointerException at org.netbeans.modules.nativeexecution.api.util.ProcessUtils.execute diff -r 1a523d148825 -r d295ad62d580 dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/ProcessUtils.java --- a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/ProcessUtils.java Thu Sep 22 20:02:41 2016 +0000 +++ b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/ProcessUtils.java Mon Sep 26 15:23:57 2016 -0700 @@ -67,6 +67,7 @@ import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory; import org.netbeans.modules.nativeexecution.api.NativeProcess; import org.netbeans.modules.nativeexecution.api.NativeProcessBuilder; +import org.netbeans.modules.nativeexecution.support.MiscUtils; import org.netbeans.modules.nativeexecution.support.NativeTaskExecutorService; import org.openide.util.Exceptions; import org.openide.util.RequestProcessor; @@ -589,10 +590,10 @@ } result = new ExitStatus(process.waitFor(), output.get(), (error == null) ? null : error.get()); } catch (InterruptedException ex) { - result = new ExitStatus(-100, null, Arrays.asList(ex.getMessage().split("\n"))); //NOI18N + result = new ExitStatus(-100, null, MiscUtils.getMessageAsList(ex)); } catch (Throwable th) { org.netbeans.modules.nativeexecution.support.Logger.getInstance().log(Level.INFO, th.getMessage(), th); - result = new ExitStatus(-200, null, Arrays.asList(th.getMessage().split("\n"))); //NOI18N + result = new ExitStatus(-200, null, MiscUtils.getMessageAsList(th)); } return result; @@ -655,10 +656,10 @@ } result = new ExitStatus(process.waitFor(), output.get(), (error == null) ? null : error.get()); } catch (InterruptedException ex) { - result = new ExitStatus(-100, null, Arrays.asList(ex.getMessage().split("\n"))); + result = new ExitStatus(-100, null, MiscUtils.getMessageAsList(ex)); } catch (Throwable th) { org.netbeans.modules.nativeexecution.support.Logger.getInstance().log(Level.INFO, th.getMessage(), th); - result = new ExitStatus(-200, null, Arrays.asList(th.getMessage().split("\n"))); + result = new ExitStatus(-200, null, MiscUtils.getMessageAsList(th)); } return result; diff -r 1a523d148825 -r d295ad62d580 dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/MiscUtils.java --- a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/MiscUtils.java Thu Sep 22 20:02:41 2016 +0000 +++ b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/MiscUtils.java Mon Sep 26 15:23:57 2016 -0700 @@ -44,6 +44,9 @@ import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.SftpException; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import org.netbeans.modules.nativeexecution.spi.support.NativeExecutionUserNotification; import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; @@ -95,4 +98,13 @@ // well, let's be conservative return e.id != ChannelSftp.SSH_FX_NO_SUCH_FILE && e.id != ChannelSftp.SSH_FX_PERMISSION_DENIED; } + + public static List getMessageAsList(Throwable ex) { + String msg = ex.getMessage(); + if (msg == null) { + return Collections.emptyList(); + } else { + return Arrays.asList(msg.split("\n")); //NOI18N + } + } } diff -r 1a523d148825 -r d295ad62d580 dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/ShellSession.java --- a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/ShellSession.java Thu Sep 22 20:02:41 2016 +0000 +++ b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/ShellSession.java Mon Sep 26 15:23:57 2016 -0700 @@ -166,7 +166,7 @@ } } catch (InterruptedException ex) { Thread.currentThread().interrupt(); - return new ExitStatus(-1, null, Arrays.asList(ex.getMessage().split("\n"))); // NOI18N + return new ExitStatus(-1, null, MiscUtils.getMessageAsList(ex)); } } }