code: public static void closeQuietly(XMLStreamWriter writer) {
          if (writer != null) {
              try {
                  writer.close();
              } catch (XMLStreamException e) {
                  logger.warn("Error while closing", e);
              }
          }
      }
docs: Closes the given writer without throwing an exception on failure.
  Instead, a warning will be logged.
  
  @param writer the writer to close.