/** * Shutdown {@link HystrixRequestVariableDefault} objects in this context. * <p> * <b>NOTE: This must be called if <code>initializeContext()</code> was called or a memory leak will occur.</b> */ public void shutdown() { if (state != null) { for (HystrixRequestVariableDefault<?> v : state.keySet()) { // for each RequestVariable we call 'remove' which performs the shutdown logic try { HystrixRequestVariableDefault.remove(this, v); } catch (Throwable t) { HystrixRequestVariableDefault.logger.error("Error in shutdown, will continue with shutdown of other variables", t); } } // null out so it can be garbage collected even if the containing object is still // being held in ThreadLocals on threads that weren't cleaned up state = null; } }
/** * Removes the value of the HystrixRequestVariable from the current request. * <p> * This will invoke {@link #shutdown} if implemented. * <p> * If the value is subsequently fetched in the thread, the {@link #initialValue} method will be called again. */ public void remove() { if (HystrixRequestContext.getContextForCurrentThread() != null) { remove(HystrixRequestContext.getContextForCurrentThread(), this); } }
/** * Shutdown {@link HystrixRequestVariableDefault} objects in this context. * <p> * <b>NOTE: This must be called if <code>initializeContext()</code> was called or a memory leak will occur.</b> */ public void shutdown() { if (state != null) { for (HystrixRequestVariableDefault<?> v : state.keySet()) { // for each RequestVariable we call 'remove' which performs the shutdown logic try { HystrixRequestVariableDefault.remove(this, v); } catch (Throwable t) { HystrixRequestVariableDefault.logger.error("Error in shutdown, will continue with shutdown of other variables", t); } } // null out so it can be garbage collected even if the containing object is still // being held in ThreadLocals on threads that weren't cleaned up state = null; } }
/** * Removes the value of the HystrixRequestVariable from the current request. * <p> * This will invoke {@link #shutdown} if implemented. * <p> * If the value is subsequently fetched in the thread, the {@link #initialValue} method will be called again. */ public void remove() { if (HystrixRequestContext.getContextForCurrentThread() != null) { remove(HystrixRequestContext.getContextForCurrentThread(), this); } }
/** * {@inheritDoc} */ @Override public void removeCurrentContext() { currentRequestContext.get().shutdownHystrixRequestContext(); currentRequestContext.remove(); } }