Program: 54317
Project: 54317
Buggy source:
protected void processConnection() throws IOException, BrowserChannelException {
  MessageType type=Message.readMessageType(getStreamFromOtherSide());
  String url=null;
  String tabKey=null;
  String sessionKey=null;
  byte[] iconBytes=null;
switch (type) {
case OLD_LOAD_MODULE:
    OldLoadModuleMessage oldLoadModule=OldLoadModuleMessage.receive(this);
  if (oldLoadModule.getProtoVersion() != 1) {
    throw new BrowserChannelException("String_Node_Str");
  }
moduleName=oldLoadModule.getModuleName();
userAgent=oldLoadModule.getUserAgent();
protocolVersion=1;
HelpInfo helpInfo=new HelpInfo(){
@Override public String getAnchorText(){
return "String_Node_Str";
}
@Override public URL getURL(){
try {
return new URL("String_Node_Str");
}
 catch (MalformedURLException e) {
return null;
}
}
}
;
logger.log(TreeLogger.WARN,"String_Node_Str" + "String_Node_Str",null,helpInfo);
break;
case CHECK_VERSIONS:
String connectError=null;
CheckVersionsMessage hello=CheckVersionsMessage.receive(this);
int minVersion=hello.getMinVersion();
int maxVersion=hello.getMaxVersion();
String hostedHtmlVersion=hello.getHostedHtmlVersion();
if (minVersion > PROTOCOL_VERSION_CURRENT || maxVersion < PROTOCOL_VERSION_OLDEST) {
connectError="String_Node_Str" + minVersion + "String_Node_Str"+ maxVersion+ "String_Node_Str"+ PROTOCOL_VERSION_OLDEST+ "String_Node_Str"+ PROTOCOL_VERSION_CURRENT;
}
 else {
if (!HostedHtmlVersion.validHostedHtmlVersion(logger,hostedHtmlVersion)) {
new FatalErrorMessage(this,"String_Node_Str").send();
return;
}
}
if (connectError != null) {
logger.log(TreeLogger.ERROR,"String_Node_Str" + connectError,null);
new FatalErrorMessage(this,connectError).send();
return;
}
protocolVersion=Math.min(PROTOCOL_VERSION_CURRENT,maxVersion);
new ProtocolVersionMessage(this,protocolVersion).send();
type=Message.readMessageType(getStreamFromOtherSide());
if (type == MessageType.CHOOSE_TRANSPORT) {
ChooseTransportMessage chooseTransport=ChooseTransportMessage.receive(this);
String transport=selectTransport(chooseTransport.getTransports());
String transportArgs=null;
if (transport != null) {
transportArgs=createTransport(transport);
}
new SwitchTransportMessage(this,transport,transportArgs).send();
type=Message.readMessageType(getStreamFromOtherSide());
}
if (type != MessageType.LOAD_MODULE) {
logger.log(TreeLogger.ERROR,"String_Node_Str" + type + "String_Node_Str");
return;
}
LoadModuleMessage loadModule=LoadModuleMessage.receive(this);
url=loadModule.getUrl();
tabKey=loadModule.getTabKey();
sessionKey=loadModule.getSessionKey();
moduleName=loadModule.getModuleName();
userAgent=loadModule.getUserAgent();
break;
case REQUEST_PLUGIN:
logger.log(TreeLogger.ERROR,"String_Node_Str");
new FatalErrorMessage(this,"String_Node_Str").send();
return;
default :
logger.log(TreeLogger.ERROR,"String_Node_Str" + type + "String_Node_Str");
return;
}
if (protocolVersion >= PROTOCOL_VERSION_GET_ICON) {
synchronized (cacheLock) {
if (iconCache.containsKey(userAgent)) {
iconBytes=iconCache.get(userAgent);
}
 else {
RequestIconMessage.send(this);
type=Message.readMessageType(getStreamFromOtherSide());
if (type != MessageType.USER_AGENT_ICON) {
logger.log(TreeLogger.ERROR,"String_Node_Str" + type + "String_Node_Str");
return;
}
UserAgentIconMessage uaIconMessage=UserAgentIconMessage.receive(this);
iconBytes=uaIconMessage.getIconBytes();
iconCache.put(userAgent,iconBytes);
}
}
}
Thread.currentThread().setName("String_Node_Str" + moduleName + "String_Node_Str"+ userAgent+ "String_Node_Str"+ url+ "String_Node_Str"+ sessionKey);
logger=handler.loadModule(this,moduleName,userAgent,url,tabKey,sessionKey,iconBytes);
try {
try {
ReturnMessage.send(this,false,new Value());
}
 catch (IOException e) {
throw new RemoteDeathError(e);
}
reactToMessages(handler);
}
 catch (RemoteDeathError e) {
if (!ignoreRemoteDeath) {
logger.log(TreeLogger.ERROR,e.getMessage(),e);
}
}
 finally {
handler.unloadModule(this,moduleName);
}
}

Fixed version (ground truth):
protected void processConnection() throws IOException, BrowserChannelException {
  MessageType type=Message.readMessageType(getStreamFromOtherSide());
  String url=null;
  String tabKey=null;
  String sessionKey=null;
  byte[] iconBytes=null;
switch (type) {
case OLD_LOAD_MODULE:
    OldLoadModuleMessage oldLoadModule=OldLoadModuleMessage.receive(this);
  if (oldLoadModule.getProtoVersion() != 1) {
    throw new BrowserChannelException("String_Node_Str");
  }
moduleName=oldLoadModule.getModuleName();
userAgent=oldLoadModule.getUserAgent();
protocolVersion=1;
HelpInfo helpInfo=new HelpInfo(){
@Override public String getAnchorText(){
return "String_Node_Str";
}
@Override public URL getURL(){
try {
return new URL("String_Node_Str");
}
 catch (MalformedURLException e) {
return null;
}
}
}
;
logger.log(TreeLogger.WARN,"String_Node_Str" + "String_Node_Str",null,helpInfo);
break;
case CHECK_VERSIONS:
String connectError=null;
CheckVersionsMessage hello=CheckVersionsMessage.receive(this);
int minVersion=hello.getMinVersion();
int maxVersion=hello.getMaxVersion();
String hostedHtmlVersion=hello.getHostedHtmlVersion();
if (minVersion > PROTOCOL_VERSION_CURRENT || maxVersion < PROTOCOL_VERSION_OLDEST) {
connectError="String_Node_Str" + minVersion + "String_Node_Str"+ maxVersion+ "String_Node_Str"+ PROTOCOL_VERSION_OLDEST+ "String_Node_Str"+ PROTOCOL_VERSION_CURRENT;
}
 else {
if (!HostedHtmlVersion.validHostedHtmlVersion(logger,hostedHtmlVersion)) {
new FatalErrorMessage(this,"String_Node_Str").send();
return;
}
}
if (connectError != null) {
logger.log(TreeLogger.ERROR,"String_Node_Str" + connectError,null);
new FatalErrorMessage(this,connectError).send();
return;
}
protocolVersion=Math.min(PROTOCOL_VERSION_CURRENT,maxVersion);
new ProtocolVersionMessage(this,protocolVersion).send();
type=Message.readMessageType(getStreamFromOtherSide());
if (type == MessageType.CHOOSE_TRANSPORT) {
ChooseTransportMessage chooseTransport=ChooseTransportMessage.receive(this);
String transport=selectTransport(chooseTransport.getTransports());
String transportArgs=null;
if (transport != null) {
transportArgs=createTransport(transport);
}
new SwitchTransportMessage(this,transport,transportArgs).send();
type=Message.readMessageType(getStreamFromOtherSide());
}
if (type != MessageType.LOAD_MODULE) {
logger.log(TreeLogger.ERROR,"String_Node_Str" + type + "String_Node_Str");
return;
}
LoadModuleMessage loadModule=LoadModuleMessage.receive(this);
url=loadModule.getUrl();
tabKey=loadModule.getTabKey();
sessionKey=loadModule.getSessionKey();
moduleName=loadModule.getModuleName();
userAgent=loadModule.getUserAgent();
break;
case REQUEST_PLUGIN:
logger.log(TreeLogger.ERROR,"String_Node_Str");
new FatalErrorMessage(this,"String_Node_Str").send();
return;
default :
logger.log(TreeLogger.ERROR,"String_Node_Str" + type + "String_Node_Str");
return;
}
if (protocolVersion >= PROTOCOL_VERSION_GET_ICON) {
synchronized (cacheLock) {
if (iconCache.containsKey(userAgent)) {
iconBytes=iconCache.get(userAgent);
}
 else {
RequestIconMessage.send(this);
type=Message.readMessageType(getStreamFromOtherSide());
if (type != MessageType.USER_AGENT_ICON) {
logger.log(TreeLogger.ERROR,"String_Node_Str" + type + "String_Node_Str");
return;
}
UserAgentIconMessage uaIconMessage=UserAgentIconMessage.receive(this);
iconBytes=uaIconMessage.getIconBytes();
iconCache.put(userAgent,iconBytes);
}
}
}
Thread.currentThread().setName("String_Node_Str" + moduleName + "String_Node_Str"+ userAgent+ "String_Node_Str"+ url+ "String_Node_Str"+ sessionKey);
logger=handler.loadModule(this,moduleName,userAgent,url,tabKey,sessionKey,iconBytes);
if (logger == null) {
try {
Value errMsg=new Value();
errMsg.setString("String_Node_Str" + moduleName);
ReturnMessage.send(this,true,errMsg);
return;
}
 catch (IOException e) {
throw new RemoteDeathError(e);
}
}
try {
try {
ReturnMessage.send(this,false,new Value());
}
 catch (IOException e) {
throw new RemoteDeathError(e);
}
reactToMessages(handler);
}
 catch (RemoteDeathError e) {
if (!ignoreRemoteDeath) {
logger.log(TreeLogger.ERROR,e.getMessage(),e);
}
}
 finally {
handler.unloadModule(this,moduleName);
}
}