이상한 방식으로 NPE를 얻고 있습니다. 다음으로있는이 일어나고 있기 때문에 메서드 호출입니다 : 나는 내부의 시도/catch 블록 주석을 제거하면컴파일 중 groovy 메서드의 NPE
String exec(String command) {
if (command == null || isConnected()) return null;
Session session = null;
boolean error = false;
try {
session = ssh.startSession();
// try {
// final Session.Command cmd = session.exec(command);
// String result = cmd.getOutputAsString();
// if (cmd.getExitStatus() != null && cmd.getExitStatus() != 0){
// //TODO:command execution failure should be logged
// error = true;
// } else {
// return result;
// }
// } catch (Exception ex){
// //TODO:command execution failure should be logged
// ex.printStackTrace();
// error = true;
// }
} catch (Exception ex) {
// TODO:session creation failure should be logged
ex.printStackTrace();
error = true;
} finally {
session.close();
if (error) return null;
}
}
는 (심지어 선언 만) 나는 끝내에 의해 생성 된 NPE는 다음과 얻을 같이
java.lang.NullPointerException
at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source)
at org.objectweb.asm.MethodAdapter.visitMaxs(Unknown Source)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:605)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:696)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1039)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:276)
at org.codehaus.groovy.control.CompilationUnit$12.call(CompilationUnit.java:748)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:942)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:519)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:497)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:474)
at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:43)
at org.jetbrains.groovy.compiler.rt.GroovycRunner.main(GroovycRunner.java:128)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:75)
코드 아무것도 특별하지 않습니다. ssh 변수가 null이 아닙니다. 그러나 나는 도대체 무슨 일이 일어나는지 알 수 없다.
어떤 Groovy 버전을 사용하고 있습니까? –
어떤 SSH 라이브러리를 사용하고 있습니까? –
@Emil, 1.7.10; @tim_yates, 당신이 실제로 필요하지 않은 것들에 들어가려고하지 마십시오. –