static void bestEffortSetAttribute(TransformerFactory transformerFactory, AtomicBoolean flag,
                                     String name, Object value) {
    if (flag.get()) {
      try {
        transformerFactory.setAttribute(name, value);
      } catch (Throwable t) {
        flag.set(false);
        LOG.debug("Issue setting TransformerFactory attribute {}: {}", name, t.toString());
      }
    }
  }
@Test
  public void testBestEffortSetAttribute() throws Exception {
    TransformerFactory factory = TransformerFactory.newInstance();
    AtomicBoolean flag1 = new AtomicBoolean(true);
    XMLUtils.bestEffortSetAttribute(factory, flag1, "unsupportedAttribute false", "abc");
    Assert.assertFalse("unexpected attribute results in return of false?", flag1.get());
    AtomicBoolean flag2 = new AtomicBoolean(true);
    XMLUtils.bestEffortSetAttribute(factory, flag2, XMLConstants.ACCESS_EXTERNAL_DTD, "");
    Assert.assertTrue("expected attribute results in return of true?", flag2.get());
    AtomicBoolean flag3 = new AtomicBoolean(false);
    XMLUtils.bestEffortSetAttribute(factory, flag3, XMLConstants.ACCESS_EXTERNAL_DTD, "");
    Assert.assertFalse("expected attribute results in return of false if input flag is false?",
            flag3.get());
  }