AbstractMDCPutFilter extends OncePerRequestFilter { protected String cutValue(String value) { if (value != null && maxMDCValueLength >= 0 && value .length() > maxMDCValueLength) { return value.substring(0, maxMDCValueLength); } else { return value; } }  void setRemoveValue(boolean removeValue); void setMaxMDCValueLength(int maxMDCValueLength);  }
@Test public void testCutValueNull() throws ServletException, IOException { this.testTarget = new AbstractMDCPutFilter() { @Override protected String getMDCKey(HttpServletRequest request, HttpServletResponse response) { return "MDCKey"; } @Override protected String getMDCValue(HttpServletRequest request, HttpServletResponse response) { return "MDCValue"; } }; assertThat(testTarget.cutValue(null), is(nullValue())); }