Refine search
private MDC() { java1 = Loader.isJava1(); if(!java1) { tlm = new ThreadLocalMap(); } try { removeMethod = ThreadLocal.class.getMethod("remove", null); } catch (NoSuchMethodException e) { // don't do anything - java prior 1.5 } }
private void clear0() { if(!java1 && tlm != null) { Hashtable ht = (Hashtable) ((ThreadLocalMap)tlm).get(); if(ht != null) { ht.clear(); } if(removeMethod != null) { // java 1.3/1.4 does not have remove - will suffer from a memory leak try { removeMethod.invoke(tlm, null); } catch (IllegalAccessException e) { // should not happen } catch (InvocationTargetException e) { // should not happen } } } }
private T setInitialValue() { T value = initialValue(); Thread t = Thread.currentThread(); ThreadLocalMap map = getMap(t); if (map != null) map.set(this, value); else createMap(t, value); return value; }
private Hashtable getContext0() { if(java1 || tlm == null) { return null; } else { return (Hashtable) ((ThreadLocalMap)tlm).get(); } }
private void clear0() { if (!java1 && tlm != null) { Hashtable ht = (Hashtable) ((ThreadLocalMap) tlm).get(); if (ht != null) { ht.clear(); } if (removeMethod != null) { // java 1.3/1.4 does not have remove - will suffer from a memory leak try { removeMethod.invoke(tlm, null); } catch (IllegalAccessException e) { // should not happen } catch (InvocationTargetException e) { // should not happen } } } } }
public void set(T value) { Thread t = Thread.currentThread(); ThreadLocalMap map = getMap(t); if (map != null) map.set(this, value); else createMap(t, value); }
private Hashtable getContext0() { if (java1 || tlm == null) { return null; } else { return (Hashtable) ((ThreadLocalMap) tlm).get(); } }
private void clear0() { if(!java1 && tlm != null) { Hashtable ht = (Hashtable) ((ThreadLocalMap)tlm).get(); if(ht != null) { ht.clear(); } if(removeMethod != null) { // java 1.3/1.4 does not have remove - will suffer from a memory leak try { removeMethod.invoke(tlm, null); } catch (IllegalAccessException e) { // should not happen } catch (InvocationTargetException e) { // should not happen } } } }
public static void fixForJava9() { if (MDC.mdc.tlm == null) { MDC.mdc.tlm = new ThreadLocalMap(); MDC.mdc.java1 = false; setRemoveMethod(MDC.mdc); } }
private T setInitialValue() { T value = initialValue(); Thread t = Thread.currentThread(); ThreadLocalMap map = getMap(t); if (map != null) map.set(this, value); else createMap(t, value); return value; }
private Hashtable getContext0() { if(java1 || tlm == null) { return null; } else { return (Hashtable) ((ThreadLocalMap)tlm).get(); } }