提交 adb616b6 编写于 作者: J Juergen Hoeller

JRubyScriptUtils defensively handles null Nodes in findClassNode (fails...

JRubyScriptUtils defensively handles null Nodes in findClassNode (fails against JRuby 1.7.12 otherwise)

Issue: SPR-11747
上级 c124d3b6
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -25,7 +25,6 @@ import java.util.List;
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyException;
import org.jruby.RubyNil;
import org.jruby.ast.ClassNode;
import org.jruby.ast.Colon2Node;
......@@ -116,10 +115,12 @@ public abstract class JRubyScriptUtils {
/**
* Find the first {@link ClassNode} under the supplied {@link Node}.
* @return the found {@code ClassNode}, or {@code null}
* if no {@link ClassNode} is found
* @return the corresponding {@code ClassNode}, or {@code null} if none found
*/
private static ClassNode findClassNode(Node node) {
if (node == null) {
return null;
}
if (node instanceof ClassNode) {
return (ClassNode) node;
}
......@@ -229,9 +230,6 @@ public abstract class JRubyScriptUtils {
/**
* Exception thrown in response to a JRuby {@link RaiseException}
* being thrown from a JRuby method invocation.
* <p>Introduced because the {@code RaiseException} class does not
* have useful {@link Object#toString()}, {@link Throwable#getMessage()},
* and {@link Throwable#printStackTrace} implementations.
*/
@SuppressWarnings("serial")
public static class JRubyExecutionException extends NestedRuntimeException {
......@@ -242,12 +240,7 @@ public abstract class JRubyScriptUtils {
* @param ex the cause (must not be {@code null})
*/
public JRubyExecutionException(RaiseException ex) {
super(buildMessage(ex), ex);
}
private static String buildMessage(RaiseException ex) {
RubyException rubyEx = ex.getException();
return (rubyEx != null && rubyEx.message != null) ? rubyEx.message.toString() : "Unexpected JRuby error";
super(ex.getMessage(), ex);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册