Program: 74217
Project: 74217
Buggy source:
public RefiringData fire(ArrayToken arguments) throws IllegalActionException {
  RefiringData data=super.fire(arguments);
  Mode choice=(Mode)mode.getChosenValue();
  String text=message.stringValue();
  MessageHandler oldHandler;
switch (choice) {
case ERROR:
    oldHandler=MessageHandler.getMessageHandler();
  try {
    MessageHandler.setMessageHandler(_MESSAGE_HANDLER);
    MessageHandler.error(text);
  }
  finally {
    MessageHandler.setMessageHandler(oldHandler);
  }
break;
case MESSAGE:
oldHandler=MessageHandler.getMessageHandler();
try {
MessageHandler.setMessageHandler(_MESSAGE_HANDLER);
MessageHandler.message(text);
}
  finally {
MessageHandler.setMessageHandler(oldHandler);
}
break;
case EXCEPTION:
throw new RuntimeException(text);
case TABLEAU:
Effigy effigy=Configuration.findEffigy(toplevel());
if (effigy == null) {
return data;
}
Tableau tableau=_getTableau();
if (tableau != null && !(tableau.getFrame() instanceof TextEditor)) {
_setTableau(null);
_closeTableau(tableau);
tableau=null;
}
boolean openNewWindow=true;
String previousText=null;
if (tableau != null) {
JFrame frame=tableau.getFrame();
if (frame instanceof TextEditor) {
TextEditor editor=(TextEditor)frame;
if (editor.getEffigy() == null) {
previousText=editor.text.getText();
}
 else {
openNewWindow=false;
}
}
}
TextEditor frame;
if (openNewWindow) {
TextEffigy textEffigy;
try {
textEffigy=TextEffigy.newTextEffigy(effigy,"String_Node_Str");
}
 catch (Exception e) {
throw new IllegalActionException(this,e,"String_Node_Str" + "String_Node_Str");
}
try {
tableau=new Tableau(textEffigy,"String_Node_Str");
}
 catch (NameDuplicationException e) {
throw new IllegalActionException(this,e,"String_Node_Str" + "String_Node_Str");
}
frame=new TextEditor(tableau.getTitle(),textEffigy.getDocument());
frame.text.setColumns(((IntToken)columnsDisplayed.getToken()).intValue());
frame.text.setRows(((IntToken)rowsDisplayed.getToken()).intValue());
tableau.setFrame(frame);
frame.setTableau(tableau);
_setTableau(tableau);
frame.pack();
frame.setVisible(true);
if (previousText != null) {
frame.text.setText(previousText);
}
}
 else {
frame=(TextEditor)tableau.getFrame();
}
frame.text.append(text + "String_Node_Str");
try {
int lineOffset=frame.text.getLineStartOffset(frame.text.getLineCount() - 1);
frame.text.setCaretPosition(lineOffset);
}
 catch (BadLocationException ex) {
}
break;
case WARNING:
try {
oldHandler=MessageHandler.getMessageHandler();
try {
MessageHandler.setMessageHandler(_MESSAGE_HANDLER);
MessageHandler.warning(text);
}
  finally {
MessageHandler.setMessageHandler(oldHandler);
}
response.setToken(BooleanToken.TRUE);
}
 catch (CancelException e) {
response.setToken(BooleanToken.FALSE);
}
break;
case YES_OR_NO:
oldHandler=MessageHandler.getMessageHandler();
boolean success=false;
boolean answer;
try {
MessageHandler.setMessageHandler(_MESSAGE_HANDLER);
answer=MessageHandler.yesNoQuestion(text);
success=true;
}
  finally {
MessageHandler.setMessageHandler(oldHandler);
}
if (success) {
response.setToken(BooleanToken.getInstance(answer));
}
break;
default :
throw new IllegalActionException("String_Node_Str" + mode.getExpression() + "String_Node_Str");
}
return data;
}

Fixed version (ground truth):
public RefiringData fire(ArrayToken arguments) throws IllegalActionException {
  RefiringData data=super.fire(arguments);
  Mode choice=(Mode)mode.getChosenValue();
  String text=message.stringValue();
  MessageHandler oldHandler;
switch (choice) {
case ERROR:
    oldHandler=MessageHandler.getMessageHandler();
  try {
    MessageHandler.setMessageHandler(_MESSAGE_HANDLER);
    MessageHandler.error(text);
  }
  finally {
    MessageHandler.setMessageHandler(oldHandler);
  }
break;
case MESSAGE:
oldHandler=MessageHandler.getMessageHandler();
try {
MessageHandler.setMessageHandler(_MESSAGE_HANDLER);
MessageHandler.message(text);
}
  finally {
MessageHandler.setMessageHandler(oldHandler);
}
break;
case EXCEPTION:
throw new RuntimeException(text);
case TABLEAU:
Effigy effigy=GTEntityUtils.findToplevelEffigy(this);
if (effigy == null) {
return data;
}
Tableau tableau=_getTableau();
if (tableau != null && !(tableau.getFrame() instanceof TextEditor)) {
_setTableau(null);
_closeTableau(tableau);
tableau=null;
}
boolean openNewWindow=true;
String previousText=null;
if (tableau != null) {
JFrame frame=tableau.getFrame();
if (frame instanceof TextEditor) {
TextEditor editor=(TextEditor)frame;
if (editor.getEffigy() == null) {
previousText=editor.text.getText();
}
 else {
openNewWindow=false;
}
}
}
TextEditor frame;
if (openNewWindow) {
TextEffigy textEffigy;
try {
textEffigy=TextEffigy.newTextEffigy(effigy,"String_Node_Str");
}
 catch (Exception e) {
throw new IllegalActionException(this,e,"String_Node_Str" + "String_Node_Str");
}
try {
tableau=new Tableau(textEffigy,"String_Node_Str");
}
 catch (NameDuplicationException e) {
throw new IllegalActionException(this,e,"String_Node_Str" + "String_Node_Str");
}
frame=new TextEditor(tableau.getTitle(),textEffigy.getDocument());
frame.text.setColumns(((IntToken)columnsDisplayed.getToken()).intValue());
frame.text.setRows(((IntToken)rowsDisplayed.getToken()).intValue());
tableau.setFrame(frame);
frame.setTableau(tableau);
_setTableau(tableau);
frame.pack();
frame.setVisible(true);
if (previousText != null) {
frame.text.setText(previousText);
}
}
 else {
frame=(TextEditor)tableau.getFrame();
}
frame.text.append(text + "String_Node_Str");
try {
int lineOffset=frame.text.getLineStartOffset(frame.text.getLineCount() - 1);
frame.text.setCaretPosition(lineOffset);
}
 catch (BadLocationException ex) {
}
break;
case WARNING:
try {
oldHandler=MessageHandler.getMessageHandler();
try {
MessageHandler.setMessageHandler(_MESSAGE_HANDLER);
MessageHandler.warning(text);
}
  finally {
MessageHandler.setMessageHandler(oldHandler);
}
response.setToken(BooleanToken.TRUE);
}
 catch (CancelException e) {
response.setToken(BooleanToken.FALSE);
}
break;
case YES_OR_NO:
oldHandler=MessageHandler.getMessageHandler();
boolean success=false;
boolean answer;
try {
MessageHandler.setMessageHandler(_MESSAGE_HANDLER);
answer=MessageHandler.yesNoQuestion(text);
success=true;
}
  finally {
MessageHandler.setMessageHandler(oldHandler);
}
if (success) {
response.setToken(BooleanToken.getInstance(answer));
}
break;
default :
throw new IllegalActionException("String_Node_Str" + mode.getExpression() + "String_Node_Str");
}
return data;
}