Created
November 9, 2010 22:31
-
-
Save enebo/669967 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/ext/org/jruby/ext/RefQueueLibrary.java b/ext/org/jruby/ext/RefQueueLibrary.java | |
index 97abe89..9ca8ff6 100644 | |
--- a/ext/org/jruby/ext/RefQueueLibrary.java | |
+++ b/ext/org/jruby/ext/RefQueueLibrary.java | |
@@ -72,28 +72,26 @@ public class RefQueueLibrary implements Library { | |
@JRubyMethod | |
public IRubyObject remove() { | |
- try { | |
- return returnable(queue.remove()); | |
- } catch (InterruptedException ie) { | |
- // ignore | |
- return getRuntime().getNil(); | |
- } | |
+ return remove(0L); | |
} | |
@JRubyMethod | |
public IRubyObject remove(IRubyObject timeout) { | |
+ return remove(timeout.convertToInteger().getLongValue()); | |
+ } | |
+ | |
+ private IRubyObject remove(long timeout) { | |
try { | |
- return returnable(queue.remove(timeout.convertToInteger().getLongValue())); | |
- } catch (InterruptedException ie) { | |
- // ignore | |
- return getRuntime().getNil(); | |
- } | |
+ return returnable(queue.remove(timeout)); | |
+ } catch (InterruptedException ie) { } // fall-through | |
+ | |
+ return getRuntime().getNil(); | |
} | |
private IRubyObject returnable(Object result) { | |
RubyWeakReference ref = (RubyWeakReference)result; | |
- if (ref == null) return getRuntime().getNil(); | |
- return ref.getWeakRef(); | |
+ | |
+ return ref != null ? ref.getWeakRef() : getRuntime().getNil(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment