Skip to content

Commit

Permalink
Cache type but reset when object is set from Ruby.
Browse files Browse the repository at this point in the history
Better fix for #4178.
  • Loading branch information
headius committed Sep 28, 2016
1 parent 2481b86 commit 37234e1
Showing 1 changed file with 5 additions and 2 deletions.
Expand Up @@ -102,8 +102,7 @@ protected void updateByJavaObject(final Ruby runtime, Object... values) {
} else if (values.length > 1) {
javaType = (Class) values[1];
} else {
// When a new object comes in without a target type, clear out cached type
javaType = null;
javaType = javaObject.getClass();
}
irubyObject = JavaEmbedUtils.javaToRuby(runtime, javaObject);
fromRuby = false;
Expand All @@ -112,6 +111,7 @@ protected void updateByJavaObject(final Ruby runtime, Object... values) {
protected void updateRubyObject(final IRubyObject rubyObject) {
if ( rubyObject == null ) return;
this.irubyObject = rubyObject;
this.javaType = null;
// NOTE: quite weird - but won't pass tests otherwise !?!
//this.javaObject = null;
// delays updating javaObject for performance.
Expand Down Expand Up @@ -142,6 +142,9 @@ public Object getJavaObject() {
}
else { // Ruby originated variables
javaObject = irubyObject.toJava(Object.class);
if (javaObject != null) {
javaType = javaObject.getClass();
}
}
return javaObject;
}
Expand Down

0 comments on commit 37234e1

Please sign in to comment.