List of usage examples for org.apache.commons.pool.impl GenericObjectPool invalidateObject
public void invalidateObject(Object obj) throws Exception
Invalidates the given object instance.
From source file:org.cipango.sipatra.SipatraServlet.java
private void invokeMethod(SipServletMessage message, String methodName) { ScriptingContainer container = null; try {/*from w w w .j a va 2 s. c o m*/ GenericObjectPool pool = (GenericObjectPool) message.getSession().getServletContext() .getAttribute(Attributes.POOL); container = (ScriptingContainer) pool.borrowObject(); long beginTime = System.currentTimeMillis(); try { Object app = container.runScriptlet("Sipatra::Application::new"); container.callMethod(app, "set_bindings", new Object[] { message.getSession().getServletContext(), message.getSession().getServletContext().getAttribute(SipServlet.SIP_FACTORY), message.getSession(), message, _log }); container.callMethod(app, methodName); } catch (Exception e) { pool.invalidateObject(container); container = null; } finally { if (container != null) { pool.returnObject(container); } _log.trace("Processed '%s' (%s, %s) in %dms", new Object[] { message.getMethod(), message.getSession().getId(), message.getCallId(), System.currentTimeMillis() - beginTime }); } } catch (Exception e) { _log.error("ERROR >> Failed to borrow a JRuby Runtime ", e); // TODO: failed to borrow a runtime... What should we do? //throw e? } }