docs: public static XMLStreamReader configureReader(XMLStreamReader reader, Integer maxChildElements,
                                         Integer maxElementDepth, Integer maxAttributeCount,
                                         Integer maxAttributeSize, Integer maxTextLength,
                                         Long maxElementCount, Long maxXMLCharacters)
          throws XMLStreamException {
          //CHECKSTYLE:ON
  
          // We currently ONLY support Woodstox 4.2.x for most of this other than a few things
          // that we can handle via a wrapper.
          try {
              DocumentDepthProperties p = null;
              if (maxChildElements != null) {
                  try {
                      setProperty(reader, "com.ctc.wstx.maxChildrenPerElement", maxChildElements);
                  } catch (Throwable t) {
                      //we can handle this via a wrapper
                      p = new DocumentDepthProperties();
                      p.setInnerElementCountThreshold(maxChildElements);
                  }
              }
              if (maxElementDepth != null) {
                  try {
                      setProperty(reader, "com.ctc.wstx.maxElementDepth", maxElementDepth);
                  } catch (Throwable t) {
                      //we can handle this via a wrapper
                      if (p == null) {
                          p = new DocumentDepthProperties();
                      }
                      p.setInnerElementLevelThreshold(maxElementDepth);
                  }
              }
              if (maxAttributeCount != null) {
                  setProperty(reader, "com.ctc.wstx.maxAttributesPerElement", maxAttributeCount);
              }
              if (maxAttributeSize != null) {
                  setProperty(reader, "com.ctc.wstx.maxAttributeSize", maxAttributeSize);
              }
              if (maxTextLength != null) {
                  setProperty(reader, "com.ctc.wstx.maxTextLength", maxTextLength);
              }
              if (maxElementCount != null) {
                  try {
                      setProperty(reader, "com.ctc.wstx.maxElementCount", maxElementCount);
                  } catch (Throwable t) {
                      //we can handle this via a wrapper
                      if (p == null) {
                          p = new DocumentDepthProperties();
                      }
                      p.setElementCountThreshold(maxElementCount.intValue());
                  }
              }
              if (maxXMLCharacters != null) {
                  setProperty(reader, "com.ctc.wstx.maxCharacters", maxXMLCharacters);
              }
              if (p != null) {
                  reader = new DepthRestrictingStreamReader(reader, p);
              }
          } catch (ClassCastException cce) {
              //not an XMLStreamReader2
              if (allowInsecureParser) {
                  LOG.warning("INSTANCE_NOT_XMLSTREAMREADER2");
              } else {
                  throw new XMLStreamException(cce.getMessage(), cce);
              }
          } catch (IllegalArgumentException cce) {
              //not a property supported by this version of woodstox
              if (allowInsecureParser) {
                  LOG.log(Level.WARNING, "SECURE_PROPERTY_NOT_SUPPORTED", cce.getMessage());
              } else {
                  throw new XMLStreamException(cce.getMessage(), cce);
              }
          }
          return reader;
      }