Program: 58264
Project: 58264
Buggy source:
public static void writeWithEditorKit(FileInfo info) throws FileAccessException {
  EditorCookie cookie=info.getCookie();
  EditorKit kit=getEditorKit(info.getDataObject());
  StyledDocument document=null;
  int caretPosition;
  try {
    document=cookie.openDocument();
  }
 catch (  IOException ex) {
    throw new FileAccessException("String_Node_Str" + ex.getMessage());
  }
  try (InputStream is=new ByteArrayInputStream(info.getContentAsBytes())){
    Caret caret=info.getCaret();
    caretPosition=info.getCurrentCaretPosition();
    document.remove(0,document.getLength());
    LOG.log(Level.INFO,"String_Node_Str",is);
    LOG.log(Level.INFO,"String_Node_Str",is);
    kit.read(is,document,document.getLength());
    cookie.saveDocument();
    info.getFileObject().setAttribute(ENCODING_SETTING,info.getCharset().name());
    caretPosition-=info.getCaretOffset();
    if (caretPosition < document.getLength()) {
      LOG.log(Level.INFO,"String_Node_Str",new Object[]{caretPosition,document.getLength()});
      caret.setDot(caretPosition);
    }
  }
 catch (  BadLocationException|IOException ex) {
    throw new FileAccessException("String_Node_Str" + ex.getMessage());
  }
  Reformat reformat=Reformat.get(document);
  reformat.lock();
  try {
    reformat.reformat(0,document.getLength());
  }
 catch (  BadLocationException ex) {
    LOG.log(Level.SEVERE,"String_Node_Str",ex.getMessage());
  }
 finally {
    reformat.unlock();
    try {
      cookie.saveDocument();
    }
 catch (    IOException ex) {
      throw new FileAccessException("String_Node_Str" + ex.getMessage());
    }
  }
}

Fixed version (ground truth):
public static void writeWithEditorKit(FileInfo info) throws FileAccessException {
  EditorCookie cookie=info.getCookie();
  EditorKit kit=getEditorKit(info.getDataObject());
  StyledDocument document=null;
  int caretPosition;
  try {
    document=cookie.openDocument();
  }
 catch (  IOException ex) {
    throw new FileAccessException("String_Node_Str" + ex.getMessage());
  }
  try (InputStream is=new ByteArrayInputStream(info.getContentAsBytes())){
    Caret caret=info.getCaret();
    caretPosition=info.getCurrentCaretPosition();
    document.remove(0,document.getLength());
    LOG.log(Level.INFO,"String_Node_Str",is);
    LOG.log(Level.INFO,"String_Node_Str",document);
    kit.read(is,document,document.getLength());
    cookie.saveDocument();
    info.getFileObject().setAttribute(ENCODING_SETTING,info.getCharset().name());
    caretPosition-=info.getCaretOffset();
    if (caretPosition < document.getLength()) {
      LOG.log(Level.INFO,"String_Node_Str",new Object[]{caretPosition,document.getLength()});
      caret.setDot(caretPosition);
    }
  }
 catch (  BadLocationException|IOException ex) {
    throw new FileAccessException("String_Node_Str" + ex.getMessage());
  }
  Reformat reformat=Reformat.get(document);
  reformat.lock();
  try {
    reformat.reformat(0,document.getLength());
  }
 catch (  BadLocationException ex) {
    LOG.log(Level.SEVERE,"String_Node_Str",ex.getMessage());
  }
 finally {
    reformat.unlock();
    try {
      cookie.saveDocument();
    }
 catch (    IOException ex) {
      throw new FileAccessException("String_Node_Str" + ex.getMessage());
    }
  }
}