Program: 51163
Project: 51163
Buggy source:
/** 
 * @param file
 */
private void openSchemaFrame(File file,boolean newFile){
  try {
    if (!newFile) {
      if (checkFileOpen(file)) {
        return;
      }
      if (!file.exists()) {
        JOptionPane.showMessageDialog(this,getResourceConverter().getFormattedString("String_Node_Str","String_Node_Str",new String[]{file.getAbsolutePath()}),getResourceConverter().getString("String_Node_Str","String_Node_Str"),JOptionPane.WARNING_MESSAGE);
        return;
      }
      if (!file.canWrite()) {
        JOptionPane.showMessageDialog(this,getResourceConverter().getFormattedString("String_Node_Str","String_Node_Str",new String[]{file.getAbsolutePath()}),getResourceConverter().getString("String_Node_Str","String_Node_Str"),JOptionPane.WARNING_MESSAGE);
        return;
      }
      try {
        String connectString="String_Node_Str" + "String_Node_Str" + jdbcConnectionUrl + "String_Node_Str"+ "String_Node_Str"+ file.toURL().toString()+ "String_Node_Str"+ "String_Node_Str"+ jdbcDriverClassName+ "String_Node_Str";
        if (jdbcUsername != null && jdbcUsername.length() > 0) {
          connectString=connectString + "String_Node_Str" + jdbcUsername+ "String_Node_Str";
        }
        if (jdbcPassword != null && jdbcPassword.length() > 0) {
          connectString=connectString + "String_Node_Str" + jdbcPassword+ "String_Node_Str";
        }
        DriverManager.getConnection(connectString,null);
      }
 catch (      Exception ex) {
        LOGGER.error("String_Node_Str" + file.getAbsolutePath() + "String_Node_Str"+ ex.getMessage(),ex);
      }
catch (      Error err) {
        LOGGER.error("String_Node_Str" + file.getAbsolutePath() + "String_Node_Str"+ err.getMessage(),err);
      }
    }
    final JInternalFrame schemaFrame=new JInternalFrame();
    schemaFrame.setTitle(getResourceConverter().getFormattedString("String_Node_Str","String_Node_Str",new String[]{file.getName()}));
    jdbcMetaData=new JDBCMetaData(this,jdbcDriverClassName,jdbcConnectionUrl,jdbcUsername,jdbcPassword);
    schemaFrame.getContentPane().add(new SchemaExplorer(this,file,jdbcMetaData,newFile,schemaFrame));
    String errorOpening=((SchemaExplorer)schemaFrame.getContentPane().getComponent(0)).getErrMsg();
    if (errorOpening != null) {
      JOptionPane.showMessageDialog(this,getResourceConverter().getFormattedString("String_Node_Str","String_Node_Str",new String[]{errorOpening}),getResourceConverter().getString("String_Node_Str","String_Node_Str"),JOptionPane.ERROR_MESSAGE);
      schemaFrame.setClosed(true);
      return;
    }
    schemaFrame.setBounds(0,0,1000,650);
    schemaFrame.setClosable(true);
    schemaFrame.setIconifiable(true);
    schemaFrame.setMaximizable(true);
    schemaFrame.setResizable(true);
    schemaFrame.setVisible(true);
    desktopPane.add(schemaFrame,javax.swing.JLayeredPane.DEFAULT_LAYER);
    schemaFrame.show();
    schemaFrame.setMaximum(true);
    if (jdbcMetaData.getErrMsg() != null) {
      JOptionPane.showMessageDialog(this,getResourceConverter().getFormattedString("String_Node_Str","String_Node_Str",new String[]{jdbcMetaData.getErrMsg()}),getResourceConverter().getString("String_Node_Str","String_Node_Str"),JOptionPane.WARNING_MESSAGE);
    }
    final javax.swing.JMenuItem schemaMenuItem=new javax.swing.JMenuItem();
    schemaMenuItem.setText(windowMenuMapIndex++ + "String_Node_Str" + file.getName());
    schemaMenuItem.addActionListener(new java.awt.event.ActionListener(){
      public void actionPerformed(      java.awt.event.ActionEvent evt){
        try {
          if (schemaFrame.isIcon()) {
            schemaFrame.setIcon(false);
          }
 else {
            schemaFrame.setSelected(true);
          }
        }
 catch (        Exception ex) {
          LOGGER.error("String_Node_Str",ex);
        }
      }
    }
);
    windowMenu.add(schemaMenuItem,0);
    windowMenu.setEnabled(true);
    windowMenu.add(jSeparator3,-1);
    windowMenu.add(cascadeMenuItem,-1);
    windowMenu.add(tileMenuItem,-1);
    windowMenu.add(minimizeMenuItem,-1);
    windowMenu.add(maximizeMenuItem,-1);
    windowMenu.add(closeAllMenuItem,-1);
    schemaWindowMap.put(schemaFrame,schemaMenuItem);
    updateMDXCatalogList();
    schemaFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    schemaFrame.addInternalFrameListener(new InternalFrameAdapter(){
      public void internalFrameClosing(      InternalFrameEvent e){
        if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) {
          SchemaExplorer se=(SchemaExplorer)schemaFrame.getContentPane().getComponent(0);
          int response=confirmFrameClose(schemaFrame,se);
          if (response == 3) {
            if (se.isNewFile()) {
              se.getSchemaFile().delete();
            }
            schemaWindowMap.remove(schemaFrame);
            updateMDXCatalogList();
            schemaFrame.dispose();
            windowMenu.remove(schemaMenuItem);
          }
        }
      }
    }
);
    schemaFrame.setFocusable(true);
    schemaFrame.addFocusListener(new FocusAdapter(){
      public void focusGained(      FocusEvent e){
        if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) {
          SchemaExplorer se=(SchemaExplorer)schemaFrame.getContentPane().getComponent(0);
          viewXMLMenuItem.setSelected(se.isEditModeXML());
        }
      }
      public void focusLost(      FocusEvent e){
        if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) {
          SchemaExplorer se=(SchemaExplorer)schemaFrame.getContentPane().getComponent(0);
          viewXMLMenuItem.setSelected(se.isEditModeXML());
        }
      }
    }
);
    viewXMLMenuItem.setSelected(false);
  }
 catch (  Exception ex) {
    LOGGER.error("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
/** 
 * @param file
 */
private void openSchemaFrame(File file,boolean newFile){
  try {
    if (!newFile) {
      if (checkFileOpen(file)) {
        return;
      }
      if (!file.exists()) {
        JOptionPane.showMessageDialog(this,getResourceConverter().getFormattedString("String_Node_Str","String_Node_Str",new String[]{file.getAbsolutePath()}),getResourceConverter().getString("String_Node_Str","String_Node_Str"),JOptionPane.WARNING_MESSAGE);
        return;
      }
      if (!file.canWrite()) {
        JOptionPane.showMessageDialog(this,getResourceConverter().getFormattedString("String_Node_Str","String_Node_Str",new String[]{file.getAbsolutePath()}),getResourceConverter().getString("String_Node_Str","String_Node_Str"),JOptionPane.WARNING_MESSAGE);
        return;
      }
      checkSchemaFile(file);
    }
    final JInternalFrame schemaFrame=new JInternalFrame();
    schemaFrame.setTitle(getResourceConverter().getFormattedString("String_Node_Str","String_Node_Str",new String[]{file.getName()}));
    jdbcMetaData=new JDBCMetaData(this,jdbcDriverClassName,jdbcConnectionUrl,jdbcUsername,jdbcPassword);
    schemaFrame.getContentPane().add(new SchemaExplorer(this,file,jdbcMetaData,newFile,schemaFrame));
    String errorOpening=((SchemaExplorer)schemaFrame.getContentPane().getComponent(0)).getErrMsg();
    if (errorOpening != null) {
      JOptionPane.showMessageDialog(this,getResourceConverter().getFormattedString("String_Node_Str","String_Node_Str",new String[]{errorOpening}),getResourceConverter().getString("String_Node_Str","String_Node_Str"),JOptionPane.ERROR_MESSAGE);
      schemaFrame.setClosed(true);
      return;
    }
    schemaFrame.setBounds(0,0,1000,650);
    schemaFrame.setClosable(true);
    schemaFrame.setIconifiable(true);
    schemaFrame.setMaximizable(true);
    schemaFrame.setResizable(true);
    schemaFrame.setVisible(true);
    desktopPane.add(schemaFrame,javax.swing.JLayeredPane.DEFAULT_LAYER);
    schemaFrame.show();
    schemaFrame.setMaximum(true);
    displayWarningOnFailedConnection();
    final javax.swing.JMenuItem schemaMenuItem=new javax.swing.JMenuItem();
    schemaMenuItem.setText(windowMenuMapIndex++ + "String_Node_Str" + file.getName());
    schemaMenuItem.addActionListener(new java.awt.event.ActionListener(){
      public void actionPerformed(      java.awt.event.ActionEvent evt){
        try {
          if (schemaFrame.isIcon()) {
            schemaFrame.setIcon(false);
          }
 else {
            schemaFrame.setSelected(true);
          }
        }
 catch (        Exception ex) {
          LOGGER.error("String_Node_Str",ex);
        }
      }
    }
);
    windowMenu.add(schemaMenuItem,0);
    windowMenu.setEnabled(true);
    windowMenu.add(jSeparator3,-1);
    windowMenu.add(cascadeMenuItem,-1);
    windowMenu.add(tileMenuItem,-1);
    windowMenu.add(minimizeMenuItem,-1);
    windowMenu.add(maximizeMenuItem,-1);
    windowMenu.add(closeAllMenuItem,-1);
    schemaWindowMap.put(schemaFrame,schemaMenuItem);
    updateMDXCatalogList();
    schemaFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    schemaFrame.addInternalFrameListener(new InternalFrameAdapter(){
      public void internalFrameClosing(      InternalFrameEvent e){
        if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) {
          SchemaExplorer se=(SchemaExplorer)schemaFrame.getContentPane().getComponent(0);
          int response=confirmFrameClose(schemaFrame,se);
          if (response == 3) {
            if (se.isNewFile()) {
              se.getSchemaFile().delete();
            }
            schemaWindowMap.remove(schemaFrame);
            updateMDXCatalogList();
            schemaFrame.dispose();
            windowMenu.remove(schemaMenuItem);
          }
        }
      }
    }
);
    schemaFrame.setFocusable(true);
    schemaFrame.addFocusListener(new FocusAdapter(){
      public void focusGained(      FocusEvent e){
        if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) {
          SchemaExplorer se=(SchemaExplorer)schemaFrame.getContentPane().getComponent(0);
          viewXMLMenuItem.setSelected(se.isEditModeXML());
        }
      }
      public void focusLost(      FocusEvent e){
        if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) {
          SchemaExplorer se=(SchemaExplorer)schemaFrame.getContentPane().getComponent(0);
          viewXMLMenuItem.setSelected(se.isEditModeXML());
        }
      }
    }
);
    viewXMLMenuItem.setSelected(false);
  }
 catch (  Exception ex) {
    LOGGER.error("String_Node_Str",ex);
  }
}