So our new JRuby console is pretty sporty. Created inside an Emissary P2P Workflow node, made accessible by our custom MVC stuff over Jetty, nice CSS and Javascript that makes it pretty nice to use, including command history on the up-arrow.

But there is a small problem that is driving me bonkers.

Sometimes, more often while debugging something and doing a Shift-Reload on the JRuby Console web page, but sometimes without that — I get TWO JRuby environments and the interactions using AJAX alternate between them. Like this:

=> i=5
5
=> i=6
6
=> i
5
=> i
6

This doesn’t happen all the time and I really don’t know what is going on. There could very well be some fundamental thing about the Bean Scripting Framework’s BSFManager that I just don’t grok. In fact, after looking into the BSFManager a little, I’m worried about the multi-threaded nature of running that inside the emissary node. We could have multiple users each creating a JRuby console which could be living on separate HttpSessions. Should be ok as far as all of my code goes, but that BSFManager factory/singleton is starting to look suspiciously like an anti-pattern I once knew.