nus-yam/ex-repair huggingface dataset:
Program: 103366
Project: 103366
Buggy source:
/** 
 * Puts all <tt>MediaStream</tt>s in this handler locally on or off hold (according to the value of <tt>locallyOnHold</tt>). This would also be taken into account when the next update offer is generated.
 * @param locallyOnHold <tt>true</tt> if we are to make our audio streamstop transmitting and <tt>false</tt> if we are to start transmitting again.
 */
public void setLocallyOnHold(boolean locallyOnHold){
  this.locallyOnHold=locallyOnHold;
  if (locallyOnHold) {
    if (audioStream != null) {
      audioStream.setDirection(audioStream.getDirection().and(MediaDirection.SENDONLY));
      audioStream.setMute(locallyOnHold);
    }
    if (videoStream != null) {
      videoStream.setDirection(videoStream.getDirection().and(MediaDirection.SENDONLY));
      videoStream.setMute(locallyOnHold);
    }
  }
 else {
    if (audioStream != null) {
      audioStream.setDirection(audioStream.getDirection().or(MediaDirection.SENDONLY));
      audioStream.setMute(locallyOnHold);
    }
    if (videoStream != null && videoStream.getDirection() != MediaDirection.INACTIVE) {
      videoStream.setDirection(videoStream.getDirection().or(MediaDirection.SENDONLY));
      videoStream.setMute(locallyOnHold);
    }
  }
}

Fixed version (ground truth):
/** 
 * Puts all <tt>MediaStream</tt>s in this handler locally on or off hold (according to the value of <tt>locallyOnHold</tt>). This would also be taken into account when the next update offer is generated.
 * @param locallyOnHold <tt>true</tt> if we are to make our audio streamstop transmitting and <tt>false</tt> if we are to start transmitting again.
 */
public void setLocallyOnHold(boolean locallyOnHold){
  this.locallyOnHold=locallyOnHold;
  if (locallyOnHold) {
    if (audioStream != null) {
      audioStream.setDirection(audioStream.getDirection().and(MediaDirection.SENDONLY));
      audioStream.setMute(locallyOnHold);
    }
    if (videoStream != null) {
      videoStream.setDirection(videoStream.getDirection().and(MediaDirection.SENDONLY));
      videoStream.setMute(locallyOnHold);
    }
  }
 else {
    if (CallPeerState.ON_HOLD_MUTUALLY.equals(getPeer().getState())) {
      return;
    }
    if (audioStream != null) {
      audioStream.setDirection(audioStream.getDirection().or(MediaDirection.SENDONLY));
      audioStream.setMute(locallyOnHold);
    }
    if (videoStream != null && videoStream.getDirection() != MediaDirection.INACTIVE) {
      videoStream.setDirection(videoStream.getDirection().or(MediaDirection.SENDONLY));
      videoStream.setMute(locallyOnHold);
    }
  }
}
Program: 103367
Project: 103367
Buggy source:
/** 
 * Implements   {@link CsrcAudioLevelListener#audioLevelsReceived(long[][])}so that we could deliver to   {@link ConferenceMembersSoundLevelListener}s the events corresponding to the audio level changes that are being reported here.
 * @param audioLevels the levels that we need to dispatch to all registered<tt>ConferenceMemberSoundLevelListeners</tt>.
 */
public void audioLevelsReceived(long[] audioLevels){
  if (getConferenceMemberCount() == 0)   return;
  Map<ConferenceMember,Integer> levelsMap=new HashMap<ConferenceMember,Integer>();
  for (int i=0; i < audioLevels.length; i+=2) {
    ConferenceMember mmbr=findConferenceMember(audioLevels[i]);
    if (mmbr == null)     continue;
 else     levelsMap.put(mmbr,(int)audioLevels[i + 1]);
  }
  ConferenceMembersSoundLevelEvent evt=new ConferenceMembersSoundLevelEvent(this,levelsMap);
synchronized (conferenceMemberAudioLevelListeners) {
    int conferenceMemberAudioLevelListenerCount=conferenceMemberAudioLevelListeners.size();
    for (int i=0; i < conferenceMemberAudioLevelListenerCount; i++)     conferenceMemberAudioLevelListeners.get(i).soundLevelChanged(evt);
  }
}

Fixed version (ground truth):
/** 
 * Implements   {@link CsrcAudioLevelListener#audioLevelsReceived(long[])}so that we could deliver to   {@link ConferenceMembersSoundLevelListener}s the events corresponding to the audio level changes that are being reported here.
 * @param audioLevels the levels that we need to dispatch to all registered<tt>ConferenceMemberSoundLevelListeners</tt>.
 */
public void audioLevelsReceived(long[] audioLevels){
  if (getConferenceMemberCount() == 0)   return;
  Map<ConferenceMember,Integer> levelsMap=new HashMap<ConferenceMember,Integer>();
  for (int i=0; i < audioLevels.length; i+=2) {
    ConferenceMember mmbr=findConferenceMember(audioLevels[i]);
    if (mmbr == null)     continue;
 else     levelsMap.put(mmbr,(int)audioLevels[i + 1]);
  }
  ConferenceMembersSoundLevelEvent evt=new ConferenceMembersSoundLevelEvent(this,levelsMap);
synchronized (conferenceMemberAudioLevelListeners) {
    int conferenceMemberAudioLevelListenerCount=conferenceMemberAudioLevelListeners.size();
    for (int i=0; i < conferenceMemberAudioLevelListenerCount; i++)     conferenceMemberAudioLevelListeners.get(i).soundLevelChanged(evt);
  }
}
Program: 103368
Project: 103368
Buggy source:
public void handleQuit(ApplicationEvent event){
  ((FileMenu)userData).closeActionPerformed();
  event.setHandled(true);
}

Fixed version (ground truth):
public void handleQuit(ApplicationEvent event){
  ((FileMenu)userData).closeActionPerformed();
synchronized (this) {
    try {
      wait(15000);
    }
 catch (    InterruptedException ex) {
    }
  }
  event.setHandled(true);
}
Program: 103369
Project: 103369
Buggy source:
public static boolean run(final Object userData){
  Application application=Application.getApplication();
  if (application != null) {
    application.addApplicationListener(new ApplicationAdapter(){
      public void handleQuit(      ApplicationEvent event){
        ((FileMenu)userData).closeActionPerformed();
        event.setHandled(true);
      }
    }
);
    return true;
  }
  return false;
}

Fixed version (ground truth):
public static boolean run(final Object userData){
  Application application=Application.getApplication();
  if (application != null) {
    application.addApplicationListener(new ApplicationAdapter(){
      public void handleQuit(      ApplicationEvent event){
        ((FileMenu)userData).closeActionPerformed();
synchronized (this) {
          try {
            wait(15000);
          }
 catch (          InterruptedException ex) {
          }
        }
        event.setHandled(true);
      }
    }
);
    return true;
  }
  return false;
}
Program: 103371
Project: 103371
Buggy source:
/** 
 * Gets the matching output formats for a specific format.
 * @param in input format
 * @return array for formats matching input format
 */
private Format[] getMatchingOutputFormats(Format in){
  VideoFormat videoIn=(VideoFormat)in;
  return new Format[]{new ParameterizedVideoFormat(Constants.H264,videoIn.getSize(),Format.NOT_SPECIFIED,Format.byteArray,videoIn.getFrameRate(),ParameterizedVideoFormat.toMap(PACKETIZATION_MODE_FMTP,Integer.toString(packetizationMode)))};
}

Fixed version (ground truth):
/** 
 * Gets the matching output formats for a specific format.
 * @param in input format
 * @return array for formats matching input format
 */
private Format[] getMatchingOutputFormats(Format in){
  VideoFormat videoIn=(VideoFormat)in;
  String[] packetizationModes=(this.packetizationMode == null) ? new String[]{"String_Node_Str","String_Node_Str"} : new String[]{this.packetizationMode};
  Format[] matchingOutputFormats=new Format[packetizationModes.length];
  Dimension size=videoIn.getSize();
  float frameRate=videoIn.getFrameRate();
  for (int index=packetizationModes.length - 1; index >= 0; index--) {
    matchingOutputFormats[index]=new ParameterizedVideoFormat(Constants.H264,size,Format.NOT_SPECIFIED,Format.byteArray,frameRate,ParameterizedVideoFormat.toMap(PACKETIZATION_MODE_FMTP,packetizationModes[index]));
  }
  return matchingOutputFormats;
}
Program: 103372
Project: 103372
Buggy source:
/** 
 * Sets the packetization mode to be used for the H.264 RTP payload output by this <tt>JNIEncoder</tt> and the associated packetizer.
 * @param packetizationMode the packetization mode to be used for the H.264RTP payload output by this <tt>JNIEncoder</tt> and the associated packetizer
 */
public void setPacketizationMode(String packetizationMode){
  if ((packetizationMode == null) || "String_Node_Str".equals(packetizationMode))   this.packetizationMode=0;
 else   if ("String_Node_Str".equals(packetizationMode))   this.packetizationMode=1;
 else   throw new IllegalArgumentException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Sets the packetization mode to be used for the H.264 RTP payload output by this <tt>JNIEncoder</tt> and the associated packetizer.
 * @param packetizationMode the packetization mode to be used for the H.264RTP payload output by this <tt>JNIEncoder</tt> and the associated packetizer
 */
public void setPacketizationMode(String packetizationMode){
  if ((packetizationMode == null) || "String_Node_Str".equals(packetizationMode))   this.packetizationMode="String_Node_Str";
 else   if ("String_Node_Str".equals(packetizationMode))   this.packetizationMode="String_Node_Str";
 else   throw new IllegalArgumentException("String_Node_Str");
}
Program: 103373
Project: 103373
Buggy source:
/** 
 * Sets the <tt>Format</tt> in which this <tt>Codec</tt> is to output media data.
 * @param out the <tt>Format</tt> in which this <tt>Codec</tt> is tooutput media data
 * @return the <tt>Format</tt> in which this <tt>Codec</tt> is currentlyconfigured to output media data or <tt>null</tt> if <tt>format</tt> was found to be incompatible with this <tt>Codec</tt>
 */
@Override public Format setOutputFormat(Format out){
  if (!(out instanceof VideoFormat) || (null == AbstractCodecExt.matches(out,getMatchingOutputFormats(inputFormat))))   return null;
  VideoFormat videoOut=(VideoFormat)out;
  Dimension outSize=videoOut.getSize();
  if (outSize == null) {
    Dimension inSize=((VideoFormat)inputFormat).getSize();
    outSize=(inSize == null) ? new Dimension(Constants.VIDEO_WIDTH,Constants.VIDEO_HEIGHT) : inSize;
  }
  Map<String,String> fmtps=null;
  if (out instanceof ParameterizedVideoFormat)   fmtps=((ParameterizedVideoFormat)out).getFormatParameters();
  if (fmtps == null)   fmtps=new HashMap<String,String>();
  fmtps.put(PACKETIZATION_MODE_FMTP,Integer.toString(packetizationMode));
  outputFormat=new ParameterizedVideoFormat(videoOut.getEncoding(),outSize,Format.NOT_SPECIFIED,Format.byteArray,videoOut.getFrameRate(),fmtps);
  return outputFormat;
}

Fixed version (ground truth):
/** 
 * Sets the <tt>Format</tt> in which this <tt>Codec</tt> is to output media data.
 * @param out the <tt>Format</tt> in which this <tt>Codec</tt> is tooutput media data
 * @return the <tt>Format</tt> in which this <tt>Codec</tt> is currentlyconfigured to output media data or <tt>null</tt> if <tt>format</tt> was found to be incompatible with this <tt>Codec</tt>
 */
@Override public Format setOutputFormat(Format out){
  if (!(out instanceof VideoFormat) || (null == AbstractCodecExt.matches(out,getMatchingOutputFormats(inputFormat))))   return null;
  VideoFormat videoOut=(VideoFormat)out;
  Dimension outSize=videoOut.getSize();
  if (outSize == null) {
    Dimension inSize=((VideoFormat)inputFormat).getSize();
    outSize=(inSize == null) ? new Dimension(Constants.VIDEO_WIDTH,Constants.VIDEO_HEIGHT) : inSize;
  }
  Map<String,String> fmtps=null;
  if (out instanceof ParameterizedVideoFormat)   fmtps=((ParameterizedVideoFormat)out).getFormatParameters();
  if (fmtps == null)   fmtps=new HashMap<String,String>();
  if (packetizationMode != null)   fmtps.put(PACKETIZATION_MODE_FMTP,packetizationMode);
  outputFormat=new ParameterizedVideoFormat(videoOut.getEncoding(),outSize,Format.NOT_SPECIFIED,Format.byteArray,videoOut.getFrameRate(),fmtps);
  return outputFormat;
}
Program: 103375
Project: 103375
Buggy source:
/** 
 * Returns the list of formats supported at the output.
 * @param in input <tt>Format</tt> to determine corresponding output<tt>Format/tt>s
 * @return array of formats supported at output
 */
public Format[] getSupportedOutputFormats(Format in){
  if (in == null)   return SUPPORTED_OUTPUT_FORMATS;
  if (!(in instanceof VideoFormat) || (null == AbstractCodecExt.matches(in,inputFormats)))   return new Format[0];
  return getMatchingOutputFormats(in);
}

Fixed version (ground truth):
/** 
 * Returns the list of formats supported at the output.
 * @param in input <tt>Format</tt> to determine corresponding output<tt>Format</tt>s
 * @return array of formats supported at output
 */
public Format[] getSupportedOutputFormats(Format in){
  Format[] supportedOutputFormats;
  if (in == null)   supportedOutputFormats=SUPPORTED_OUTPUT_FORMATS;
 else   if (!(in instanceof VideoFormat) || (null == AbstractCodecExt.matches(in,inputFormats)))   supportedOutputFormats=new Format[0];
 else   supportedOutputFormats=getMatchingOutputFormats(in);
  return supportedOutputFormats;
}
Program: 103376
Project: 103376
Buggy source:
/** 
 * Finds the first <tt>Format</tt> instance in a specific list of <tt>Format</tt>s which matches a specific <tt>Format</tt>. The implementation considers a pair of <tt>Format</tt>s matching if they have the same encoding.
 * @param formats the array of <tt>Format</tt>s to be searched for a matchto the specified <tt>format</tt>
 * @param format the <tt>Format</tt> to search for a match in the specified<tt>formats</tt>
 * @return the first element of <tt>formats</tt> which matches<tt>format</tt> i.e. is of the same encoding
 */
private static Format findFirstMatchingFormat(Format[] formats,Format format){
  double formatSampleRate=(format instanceof AudioFormat) ? ((AudioFormat)format).getSampleRate() : Format.NOT_SPECIFIED;
  for (  Format match : formats) {
    if (match.isSameEncoding(format)) {
      if ((formatSampleRate != Format.NOT_SPECIFIED) && (match instanceof AudioFormat)) {
        double matchSampleRate=((AudioFormat)match).getSampleRate();
        if ((matchSampleRate != Format.NOT_SPECIFIED) && (matchSampleRate != formatSampleRate))         continue;
      }
      return match;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Finds the first <tt>Format</tt> instance in a specific list of <tt>Format</tt>s which matches a specific <tt>Format</tt>. The implementation considers a pair of <tt>Format</tt>s matching if they have the same encoding.
 * @param formats the array of <tt>Format</tt>s to be searched for a matchto the specified <tt>format</tt>
 * @param format the <tt>Format</tt> to search for a match in the specified<tt>formats</tt>
 * @return the first element of <tt>formats</tt> which matches<tt>format</tt> i.e. is of the same encoding
 */
private static Format findFirstMatchingFormat(Format[] formats,Format format){
  double formatSampleRate=(format instanceof AudioFormat) ? ((AudioFormat)format).getSampleRate() : Format.NOT_SPECIFIED;
  ParameterizedVideoFormat parameterizedVideoFormat=(format instanceof ParameterizedVideoFormat) ? (ParameterizedVideoFormat)format : null;
  for (  Format match : formats) {
    if (match.isSameEncoding(format)) {
      if (match instanceof AudioFormat) {
        if (formatSampleRate != Format.NOT_SPECIFIED) {
          double matchSampleRate=((AudioFormat)match).getSampleRate();
          if ((matchSampleRate != Format.NOT_SPECIFIED) && (matchSampleRate != formatSampleRate))           continue;
        }
      }
 else       if (match instanceof ParameterizedVideoFormat) {
        if (!((ParameterizedVideoFormat)match).formatParametersMatch(format))         continue;
      }
 else       if (parameterizedVideoFormat != null) {
        if (!parameterizedVideoFormat.formatParametersMatch(match))         continue;
      }
      return match;
    }
  }
  return null;
}
Program: 103377
Project: 103377
Buggy source:
/** 
 * Creates a new <tt>MediaFormat</tt> instance for a specific JMF <tt>Format</tt> and assigns it specific clock rate and set of format-specific parameters.
 * @param format the JMF <tt>Format</tt> the new instance is to provide animplementation of <tt>MediaFormat</tt> for
 * @param clockRate the clock rate of the new instance
 * @param formatParameters the set of format-specific parameters of the newinstance
 * @param advancedAttrs advanced attributes of the new instance
 * @return a new <tt>MediaFormat</tt> instance for the specified JMF<tt>Format</tt> and with the specified clock rate and set of format-specific parameters
 */
public static MediaFormatImpl<? extends Format> createInstance(Format format,double clockRate,Map<String,String> formatParameters,Map<String,String> advancedAttrs){
  if (format instanceof AudioFormat) {
    AudioFormat audioFormat=(AudioFormat)format;
    AudioFormat clockRateAudioFormat=new AudioFormat(audioFormat.getEncoding(),clockRate,audioFormat.getSampleSizeInBits(),audioFormat.getChannels());
    return new AudioMediaFormatImpl((AudioFormat)clockRateAudioFormat.intersects(audioFormat),formatParameters,advancedAttrs);
  }
  if (format instanceof VideoFormat)   return new VideoMediaFormatImpl((VideoFormat)format,clockRate,-1,formatParameters,advancedAttrs);
  return null;
}

Fixed version (ground truth):
/** 
 * Creates a new <tt>MediaFormat</tt> instance for a specific JMF <tt>Format</tt> and assigns it specific clock rate and set of format-specific parameters.
 * @param format the JMF <tt>Format</tt> the new instance is to provide animplementation of <tt>MediaFormat</tt> for
 * @param clockRate the clock rate of the new instance
 * @param formatParameters the set of format-specific parameters of the newinstance
 * @param advancedAttrs advanced attributes of the new instance
 * @return a new <tt>MediaFormat</tt> instance for the specified JMF<tt>Format</tt> and with the specified clock rate and set of format-specific parameters
 */
public static MediaFormatImpl<? extends Format> createInstance(Format format,double clockRate,Map<String,String> formatParameters,Map<String,String> advancedAttrs){
  if (format instanceof AudioFormat) {
    AudioFormat audioFormat=(AudioFormat)format;
    AudioFormat clockRateAudioFormat=new AudioFormat(audioFormat.getEncoding(),clockRate,audioFormat.getSampleSizeInBits(),audioFormat.getChannels());
    return new AudioMediaFormatImpl((AudioFormat)clockRateAudioFormat.intersects(audioFormat),formatParameters,advancedAttrs);
  }
 else   if (format instanceof VideoFormat)   return new VideoMediaFormatImpl((VideoFormat)format,clockRate,-1,formatParameters,advancedAttrs);
 else   return null;
}
Program: 103378
Project: 103378
Buggy source:
/** 
 * Determines whether a specific format matches this instance i.e. whether their attributes match according to the definition of "match" given by  {@link Format#matches(Format)}.
 * @param format the <tt>Format</tt> to compare to this instance
 * @return <tt>true</tt> if the specified <tt>format</tt> matches this one;otherwise, <tt>false</tt>
 */
@Override public boolean matches(Format format){
  if (!super.matches(format))   return false;
  Map<String,String> formatFmtps=null;
  if (format instanceof ParameterizedVideoFormat)   formatFmtps=((ParameterizedVideoFormat)format).getFormatParameters();
  return VideoMediaFormatImpl.formatParametersMatch(getEncoding(),getFormatParameters(),formatFmtps);
}

Fixed version (ground truth):
/** 
 * Determines whether a specific format matches this instance i.e. whether their attributes match according to the definition of "match" given by  {@link Format#matches(Format)}.
 * @param format the <tt>Format</tt> to compare to this instance
 * @return <tt>true</tt> if the specified <tt>format</tt> matches this one;otherwise, <tt>false</tt>
 */
@Override public boolean matches(Format format){
  if (!super.matches(format))   return false;
  return formatParametersMatch(format);
}
Program: 103379
Project: 103379
Buggy source:
/** 
 * Initializes a new <tt>VideoMediaFormatImpl</tt> instance which is to provide an implementation of <tt>VideoMediaFormat</tt> for a specific JMF <tt>VideoFormat</tt> and to have specific clock rate and set of format-specific parameters.
 * @param format the JMF <tt>VideoFormat</tt> the new instance is to wrapand provide an implementation of <tt>VideoMediaFormat</tt> for
 * @param clockRate the clock rate of the new <tt>VideoMediaFormatImpl</tt>instance
 * @param frameRate the frame rate of the new <tt>VideoMediaFormatImpl</tt>instance
 * @param formatParameters the set of format-specific parameters of the newinstance
 * @param advancedParameters set of advanced parameters of the new instance
 */
VideoMediaFormatImpl(VideoFormat format,double clockRate,float frameRate,Map<String,String> formatParameters,Map<String,String> advancedParameters){
  super(new VideoFormat(format.getEncoding(),format.getSize(),format.getMaxDataLength(),format.getDataType(),frameRate),formatParameters,advancedParameters);
  this.clockRate=clockRate;
}

Fixed version (ground truth):
/** 
 * Initializes a new <tt>VideoMediaFormatImpl</tt> instance which is to provide an implementation of <tt>VideoMediaFormat</tt> for a specific JMF <tt>VideoFormat</tt> and to have specific clock rate and set of format-specific parameters.
 * @param format the JMF <tt>VideoFormat</tt> the new instance is to wrapand provide an implementation of <tt>VideoMediaFormat</tt> for
 * @param clockRate the clock rate of the new <tt>VideoMediaFormatImpl</tt>instance
 * @param frameRate the frame rate of the new <tt>VideoMediaFormatImpl</tt>instance
 * @param formatParameters the set of format-specific parameters of the newinstance
 * @param advancedParameters set of advanced parameters of the new instance
 */
VideoMediaFormatImpl(VideoFormat format,double clockRate,float frameRate,Map<String,String> formatParameters,Map<String,String> advancedParameters){
  super(new ParameterizedVideoFormat(format.getEncoding(),format.getSize(),format.getMaxDataLength(),format.getDataType(),frameRate,formatParameters),formatParameters,advancedParameters);
  this.clockRate=clockRate;
}
Program: 103380
Project: 103380
Buggy source:
/** 
 * Clear saved password. Used when we are in situation that saved username and password are no longer valid.
 */
public void clear(){
  if (usedScope != null) {
    if (passwordPropertyName == null)     passwordPropertyName=getCredentialProperty(usedScope);
    if (usernamePropertyName == null)     usernamePropertyName=getCredentialProperty(usedScope);
    HttpUtilActivator.getConfigurationService().removeProperty(usernamePropertyName);
    HttpUtilActivator.getCredentialsService().removePassword(passwordPropertyName);
  }
}

Fixed version (ground truth):
/** 
 * Clear saved password. Used when we are in situation that saved username and password are no longer valid.
 */
public void clear(){
  if (usedScope != null) {
    if (passwordPropertyName == null)     passwordPropertyName=getCredentialProperty(usedScope);
    if (usernamePropertyName == null)     usernamePropertyName=getCredentialProperty(usedScope);
    HttpUtilActivator.getConfigurationService().removeProperty(usernamePropertyName);
    HttpUtilActivator.getCredentialsService().removePassword(passwordPropertyName);
  }
  this.challengedForCredentials=false;
}
Program: 103381
Project: 103381
Buggy source:
/** 
 * Get the   {@link org.apache.http.auth.Credentials credentials} for thegiven authentication scope.
 * @param authscope the {@link org.apache.http.auth.AuthScope authentication scope}
 * @return the credentials
 * @see #setCredentials(org.apache.http.auth.AuthScope,org.apache.http.auth.Credentials)
 */
public Credentials getCredentials(AuthScope authscope){
  this.usedScope=authscope;
  if (passwordPropertyName == null)   passwordPropertyName=getCredentialProperty(authscope);
  if (usernamePropertyName == null)   usernamePropertyName=getCredentialProperty(authscope);
  String pass=HttpUtilActivator.getCredentialsService().loadPassword(passwordPropertyName);
  if (pass == null) {
    AuthenticationWindow authWindow=new AuthenticationWindow(authscope.getHost(),true,null);
    authWindow.setVisible(true);
    if (!authWindow.isCanceled()) {
      Credentials cred=new UsernamePasswordCredentials(authWindow.getUserName(),new String(authWindow.getPassword()));
      if (authWindow.isRememberPassword()) {
        HttpUtilActivator.getConfigurationService().setProperty(usernamePropertyName,authWindow.getUserName());
        HttpUtilActivator.getCredentialsService().storePassword(passwordPropertyName,new String(authWindow.getPassword()));
      }
      return cred;
    }
    retry=false;
  }
 else {
    return new UsernamePasswordCredentials(HttpUtilActivator.getConfigurationService().getString(usernamePropertyName),pass);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Get the   {@link org.apache.http.auth.Credentials credentials} for thegiven authentication scope.
 * @param authscope the {@link org.apache.http.auth.AuthScope authentication scope}
 * @return the credentials
 * @see #setCredentials(org.apache.http.auth.AuthScope,org.apache.http.auth.Credentials)
 */
public Credentials getCredentials(AuthScope authscope){
  this.usedScope=authscope;
  this.challengedForCredentials=true;
  if (passwordPropertyName == null)   passwordPropertyName=getCredentialProperty(authscope);
  if (usernamePropertyName == null)   usernamePropertyName=getCredentialProperty(authscope);
  String pass=HttpUtilActivator.getCredentialsService().loadPassword(passwordPropertyName);
  if (pass == null) {
    AuthenticationWindow authWindow=new AuthenticationWindow(authscope.getHost(),true,null);
    authWindow.setVisible(true);
    if (!authWindow.isCanceled()) {
      Credentials cred=new UsernamePasswordCredentials(authWindow.getUserName(),new String(authWindow.getPassword()));
      if (authWindow.isRememberPassword()) {
        HttpUtilActivator.getConfigurationService().setProperty(usernamePropertyName,authWindow.getUserName());
        HttpUtilActivator.getCredentialsService().storePassword(passwordPropertyName,new String(authWindow.getPassword()));
      }
      return cred;
    }
    retry=false;
  }
 else {
    return new UsernamePasswordCredentials(HttpUtilActivator.getConfigurationService().getString(usernamePropertyName),pass);
  }
  return null;
}
Program: 103384
Project: 103384
Buggy source:
/** 
 * Overrides Object#hashCode() because Object#equals(Object) is overridden.
 * @return a hash code value for this <tt>MediaFormat</tt>.
 */
@Override public int hashCode(){
  return (getFormat().hashCode() | getFormatParameters().hashCode());
}

Fixed version (ground truth):
/** 
 * Overrides Object#hashCode() because Object#equals(Object) is overridden.
 * @return a hash code value for this <tt>MediaFormat</tt>.
 */
@Override public int hashCode(){
  return getJMFEncoding().hashCode() | getFormatParameters().hashCode();
}
Program: 103385
Project: 103385
Buggy source:
/** 
 * Indicates whether some other object is "equal to" this one. <p>
 * @param obj   the reference object with which to compare.
 * @return  <tt>true</tt> if this object is the same as the objargument; <tt>false</tt> otherwise.
 */
@Override public boolean equals(Object obj){
  if (obj == null || !(obj instanceof String || (obj instanceof ContactJabberImpl)))   return false;
  if (obj != null && obj instanceof ContactJabberImpl && !(((ContactJabberImpl)obj).getAddress().equalsIgnoreCase(getAddress()) && ((ContactJabberImpl)obj).getProtocolProvider() == getProtocolProvider()))   return false;
  if (obj != null && obj instanceof String && !(getAddress().substring(0,getAddress().indexOf("String_Node_Str")).equals(obj)))   return false;
  return true;
}

Fixed version (ground truth):
/** 
 * Indicates whether some other object is "equal to" this one. <p>
 * @param obj   the reference object with which to compare.
 * @return  <tt>true</tt> if this object is the same as the objargument; <tt>false</tt> otherwise.
 */
@Override public boolean equals(Object obj){
  if (obj == null || !(obj instanceof String || (obj instanceof ContactJabberImpl)))   return false;
  if (obj instanceof ContactJabberImpl && ((ContactJabberImpl)obj).getAddress().equalsIgnoreCase(getAddress()) && ((ContactJabberImpl)obj).getProtocolProvider() == getProtocolProvider()) {
    return true;
  }
  if (obj instanceof String) {
    int atIndex=getAddress().indexOf("String_Node_Str");
    if (atIndex > 0) {
      if (getAddress().equalsIgnoreCase((String)obj) || getAddress().substring(0,atIndex).equalsIgnoreCase((String)obj)) {
        return true;
      }
    }
 else     if (getAddress().equalsIgnoreCase((String)obj))     return true;
  }
  return false;
}
Program: 103386
Project: 103386
Buggy source:
/** 
 * Creates an instance of <tt>MainFrame</tt>.
 */
public MainFrame(){
  if (!ConfigurationManager.isWindowDecorated()) {
    this.setUndecorated(true);
  }
  this.searchField=new SearchField(this);
  this.contactListPanel=new ContactListPane(this);
  this.accountStatusPanel=new AccountStatusPanel(this);
  menu=new MainMenu(this);
  this.addWindowListener(new WindowAdapter(){
    /** 
 * Invoked when a window has been closed.
 */
    public void windowClosed(    WindowEvent event){
      MainFrame.this.windowClosed(event);
    }
    /** 
 * Invoked when a window has been opened.
 */
    public void windowOpened(    WindowEvent e){
      GuiActivator.getContactList().requestFocusInWindow();
    }
  }
);
  this.initTitleFont();
  ResourceManagementService resources=GuiActivator.getResources();
  String applicationName=resources.getSettingsString("String_Node_Str");
  this.setTitle(applicationName);
  this.mainPanel.setBackground(new Color(GuiActivator.getResources().getColor("String_Node_Str")));
  KeyboardFocusManager keyManager=KeyboardFocusManager.getCurrentKeyboardFocusManager();
  keyManager.addKeyEventDispatcher(new MainKeyDispatcher(keyManager));
  this.init();
  this.initPluginComponents();
}

Fixed version (ground truth):
/** 
 * Creates an instance of <tt>MainFrame</tt>.
 */
public MainFrame(){
  if (!ConfigurationManager.isWindowDecorated()) {
    this.setUndecorated(true);
  }
  this.searchField=new SearchField(this);
  this.contactListPanel=new ContactListPane(this);
  this.accountStatusPanel=new AccountStatusPanel(this);
  menu=new MainMenu(this);
  this.addWindowListener(new WindowAdapter(){
    /** 
 * Invoked when a window has been closed.
 */
    public void windowClosed(    WindowEvent event){
      MainFrame.this.windowClosed(event);
    }
    /** 
 * Invoked when a window has been opened.
 */
    public void windowOpened(    WindowEvent e){
      GuiActivator.getContactList().requestFocusInWindow();
    }
  }
);
  this.initTitleFont();
  ResourceManagementService resources=GuiActivator.getResources();
  String applicationName=resources.getSettingsString("String_Node_Str");
  this.setTitle(applicationName);
  try {
    Toolkit xToolkit=Toolkit.getDefaultToolkit();
    java.lang.reflect.Field awtAppClassNameField=xToolkit.getClass().getDeclaredField("String_Node_Str");
    awtAppClassNameField.setAccessible(true);
    awtAppClassNameField.set(xToolkit,applicationName);
  }
 catch (  Throwable t) {
  }
  this.mainPanel.setBackground(new Color(GuiActivator.getResources().getColor("String_Node_Str")));
  KeyboardFocusManager keyManager=KeyboardFocusManager.getCurrentKeyboardFocusManager();
  keyManager.addKeyEventDispatcher(new MainKeyDispatcher(keyManager));
  this.init();
  this.initPluginComponents();
}
Program: 103389
Project: 103389
Buggy source:
/** 
 * Dispatches the given mouse <tt>event</tt> to the underlying buttons.
 * @param event the <tt>MouseEvent</tt> to dispatch
 */
private void dispatchEventToButtons(MouseEvent event){
  TreePath mousePath=this.getPathForLocation(event.getX(),event.getY());
  if (mousePath == null || !mousePath.equals(this.getSelectionPath()))   return;
  JPanel renderer=(JPanel)getCellRenderer().getTreeCellRendererComponent(this,mousePath.getLastPathComponent(),true,true,true,this.getRowForPath(mousePath),true);
  Rectangle r=this.getPathBounds(mousePath);
  int translatedX=event.getX() - r.x;
  int translatedY=event.getY() - r.y;
  Component mouseComponent=renderer.findComponentAt(translatedX,translatedY);
  if (logger.isInfoEnabled())   logger.info("String_Node_Str" + mouseComponent + "String_Node_Str"+ translatedX+ "String_Node_Str"+ translatedY);
  if (mouseComponent instanceof SIPCommButton) {
    MouseEvent evt=new MouseEvent(mouseComponent,event.getID(),event.getWhen(),event.getModifiers(),5,5,event.getClickCount(),event.isPopupTrigger());
    mouseComponent.dispatchEvent(evt);
    this.repaint();
  }
}

Fixed version (ground truth):
/** 
 * Dispatches the given mouse <tt>event</tt> to the underlying buttons.
 * @param event the <tt>MouseEvent</tt> to dispatch
 */
private void dispatchEventToButtons(MouseEvent event){
  TreePath mousePath=this.getPathForLocation(event.getX(),event.getY());
  if (mousePath == null || !mousePath.equals(this.getSelectionPath()))   return;
  JPanel renderer=(JPanel)getCellRenderer().getTreeCellRendererComponent(this,mousePath.getLastPathComponent(),true,true,true,this.getRowForPath(mousePath),true);
  Rectangle r=this.getPathBounds(mousePath);
  int translatedX=event.getX() - r.x;
  int translatedY=event.getY() - r.y;
  Component mouseComponent=renderer.findComponentAt(translatedX,translatedY);
  if (logger.isDebugEnabled())   logger.debug("String_Node_Str" + mouseComponent.getClass().getName() + "String_Node_Str"+ mouseComponent.getBounds()+ "String_Node_Str"+ translatedX+ "String_Node_Str"+ translatedY);
  if (mouseComponent instanceof SIPCommButton) {
    MouseEvent evt=new MouseEvent(mouseComponent,event.getID(),event.getWhen(),event.getModifiers(),5,5,event.getClickCount(),event.isPopupTrigger());
    mouseComponent.dispatchEvent(evt);
    this.repaint();
  }
}
Program: 103393
Project: 103393
Buggy source:
/** 
 * Finds the attributes shared by two matching <tt>Format</tt>s. If the specified <tt>Format</tt> does not match this one, the result is undefined.
 * @param format the matching <tt>Format</tt> to intersect with this one
 * @return a <tt>Format</tt> with its attributes set to the attributescommon to this instance and the specified <tt>format</tt>
 */
@Override public Format intersects(Format format){
  Format intersection=super.intersects(format);
  if (intersection == null)   return null;
  if (!(format instanceof AVFrameFormat))   return intersection;
  ((AVFrameFormat)intersection).pixFmt=(pixFmt == NOT_SPECIFIED) ? ((AVFrameFormat)format).pixFmt : pixFmt;
  return intersection;
}

Fixed version (ground truth):
/** 
 * Finds the attributes shared by two matching <tt>Format</tt>s. If the specified <tt>Format</tt> does not match this one, the result is undefined.
 * @param format the matching <tt>Format</tt> to intersect with this one
 * @return a <tt>Format</tt> with its attributes set to the attributescommon to this instance and the specified <tt>format</tt>
 */
@Override public Format intersects(Format format){
  Format intersection=super.intersects(format);
  if (intersection == null)   return null;
  AVFrameFormat avFrameFormatIntersection=(AVFrameFormat)intersection;
  avFrameFormatIntersection.pixFmt=((pixFmt == NOT_SPECIFIED) && (format instanceof AVFrameFormat)) ? ((AVFrameFormat)format).pixFmt : pixFmt;
  return intersection;
}
Program: 103394
Project: 103394
Buggy source:
/** 
 * Method called back in the RemoteListener to notify listener of all RTP Remote Events.RemoteEvents are one of ReceiverReportEvent, SenderReportEvent or RemoteCollisionEvent
 * @param remoteEvent the event
 */
public void update(RemoteEvent remoteEvent){
  if (!logger.isInfoEnabled())   return;
  if (remoteEvent instanceof SenderReportEvent) {
    numberOfReceivedSenderReports++;
    SenderReport report=((SenderReportEvent)remoteEvent).getReport();
    if (report.getFeedbackReports().size() > 0) {
      Feedback feedback=(Feedback)report.getFeedbackReports().get(0);
      long remoteJitter=feedback.getJitter();
      if (remoteJitter < minRemoteInterArrivalJitter || minRemoteInterArrivalJitter == -1)       minRemoteInterArrivalJitter=remoteJitter;
      if (maxRemoteInterArrivalJitter < remoteJitter)       maxRemoteInterArrivalJitter=remoteJitter;
      if (numberOfReceivedSenderReports % 4 != 1)       return;
      StringBuilder buff=new StringBuilder(StatisticsEngine.RTP_STAT_PREFIX);
      buff.append("String_Node_Str").append(getFormat().getMediaType().toString()).append("String_Node_Str").append(getLocalSourceID()).append("String_Node_Str").append(report.getSenderPacketCount()).append("String_Node_Str").append(report.getSenderByteCount()).append("String_Node_Str").append(remoteJitter).append("String_Node_Str").append(feedback.getNumLost()).append("String_Node_Str").append((int)(feedback.getDLSR() / 65.536)).append("String_Node_Str");
      logger.info(buff);
    }
  }
}

Fixed version (ground truth):
/** 
 * Method called back in the RemoteListener to notify listener of all RTP Remote Events.RemoteEvents are one of ReceiverReportEvent, SenderReportEvent or RemoteCollisionEvent
 * @param remoteEvent the event
 */
public void update(RemoteEvent remoteEvent){
  if (!logger.isInfoEnabled())   return;
  if (remoteEvent instanceof SenderReportEvent) {
    numberOfReceivedSenderReports++;
    SenderReport report=((SenderReportEvent)remoteEvent).getReport();
    if (report.getFeedbackReports().size() > 0) {
      Feedback feedback=(Feedback)report.getFeedbackReports().get(0);
      long remoteJitter=feedback.getJitter();
      if (remoteJitter < minRemoteInterArrivalJitter || minRemoteInterArrivalJitter == -1)       minRemoteInterArrivalJitter=remoteJitter;
      if (maxRemoteInterArrivalJitter < remoteJitter)       maxRemoteInterArrivalJitter=remoteJitter;
      if (numberOfReceivedSenderReports % 4 != 1)       return;
      StringBuilder buff=new StringBuilder(StatisticsEngine.RTP_STAT_PREFIX);
      buff.append("String_Node_Str").append(getFormat() != null ? getFormat().getMediaType().toString() : "String_Node_Str").append("String_Node_Str").append(getLocalSourceID()).append("String_Node_Str").append(report.getSenderPacketCount()).append("String_Node_Str").append(report.getSenderByteCount()).append("String_Node_Str").append(remoteJitter).append("String_Node_Str").append(feedback.getNumLost()).append("String_Node_Str").append((int)(feedback.getDLSR() / 65.536)).append("String_Node_Str");
      logger.info(buff);
    }
  }
}
Program: 103396
Project: 103396
Buggy source:
/** 
 * Retrieve photo of a contact. Adapted from Google sample.
 * @param photoLink photo link
 * @param service
 * @return byte array containing image photo or null if problem happened
 */
public static byte[] downloadPhoto(ILink photoLink,ContactsService service){
  try {
    if (photoLink != null) {
      GDataRequest request=service.createLinkQueryRequest(photoLink);
      request.execute();
      InputStream in=request.getResponseStream();
      ByteArrayOutputStream out=new ByteArrayOutputStream();
      byte[] buffer=new byte[4096];
      for (int read=0; (read=in.read(buffer)) != -1; out.write(buffer,0,read))       ;
      return out.toByteArray();
    }
  }
 catch (  Exception e) {
    logger.info("String_Node_Str",e);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Retrieve photo of a contact. Adapted from Google sample.
 * @param photoLink photo link
 * @param service
 * @return byte array containing image photo or null if problem happened
 */
public static byte[] downloadPhoto(ILink photoLink,ContactsService service){
  try {
    if (photoLink != null) {
      GDataRequest request=service.createLinkQueryRequest(photoLink);
      request.execute();
      InputStream in=request.getResponseStream();
      ByteArrayOutputStream out=new ByteArrayOutputStream();
      byte[] buffer=new byte[4096];
      for (int read=0; (read=in.read(buffer)) != -1; out.write(buffer,0,read))       ;
      return out.toByteArray();
    }
  }
 catch (  Exception e) {
    logger.debug("String_Node_Str",e);
  }
  return null;
}
Program: 103397
Project: 103397
Buggy source:
/** 
 * Removes the <tt>ConferenceMemberPanel</tt> corresponding to the given <tt>member</tt>.
 * @param member the <tt>ConferenceMember</tt>, which panel to remove
 */
private void removeConferenceMemberPanel(ConferenceMember member){
  ConferenceMemberPanel memberPanel=conferenceMembersPanels.get(member);
  if (memberPanel != null) {
    this.remove(memberPanel);
    conferenceMembersPanels.remove(member);
    member.removePropertyChangeListener(memberPanel);
  }
}

Fixed version (ground truth):
/** 
 * Removes the <tt>ConferenceMemberPanel</tt> corresponding to the given <tt>member</tt>.
 * @param member the <tt>ConferenceMember</tt>, which panel to remove
 */
private void removeConferenceMemberPanel(ConferenceMember member){
  ConferenceMemberPanel memberPanel=conferenceMembersPanels.get(member);
  if (memberPanel != null) {
    int i=0;
    this.remove(memberPanel);
    conferenceMembersPanels.remove(member);
    member.removePropertyChangeListener(memberPanel);
    for (    Map.Entry<ConferenceMember,ConferenceMemberPanel> m : conferenceMembersPanels.entrySet()) {
      GridBagConstraints constraints=new GridBagConstraints();
      ConferenceMemberPanel mV=m.getValue();
      this.remove(mV);
      constraints.fill=GridBagConstraints.BOTH;
      constraints.gridx=0;
      constraints.gridy=i;
      constraints.weightx=1;
      constraints.weighty=0;
      constraints.insets=new Insets(10,0,0,0);
      this.add(mV,constraints);
      i++;
    }
  }
}
Program: 103398
Project: 103398
Buggy source:
/** 
 * Removes listeners registered for audio level changes with the specified receive  <tt>stream</tt>.
 * @param stream the stream whose listeners we'd like to get rid of.
 */
public void removeStreamAudioLevelListener(ReceiveStream stream){
synchronized (streamAudioLevelListeners) {
    AudioLevelEventDispatcher dispatcher=streamAudioLevelListeners.remove(stream);
    dispatcher.setAudioLevelListener(null);
  }
}

Fixed version (ground truth):
/** 
 * Removes listeners registered for audio level changes with the specified receive  <tt>stream</tt>.
 * @param stream the stream whose listeners we'd like to get rid of.
 */
public void removeStreamAudioLevelListener(ReceiveStream stream){
synchronized (streamAudioLevelListeners) {
    AudioLevelEventDispatcher dispatcher=streamAudioLevelListeners.remove(stream);
    if (dispatcher != null) {
      dispatcher.setAudioLevelListener(null);
    }
  }
}
Program: 103399
Project: 103399
Buggy source:
/** 
 * Notifies all CallPeer associated with and established in a specific call for conference information.
 * @param call the <tt>Call</tt>
 */
protected void notifyAll(Call call){
  if (!call.isConferenceFocus()) {
    return;
  }
synchronized (objSync) {
    Iterator<? extends CallPeer> it=call.getCallPeers();
    while (it.hasNext()) {
      CallPeer callPeer=it.next();
      System.out.print(callPeer.getAddress());
      notify(callPeer);
    }
    version++;
  }
}

Fixed version (ground truth):
/** 
 * Notifies all CallPeer associated with and established in a specific call for conference information.
 * @param call the <tt>Call</tt>
 */
protected void notifyAll(Call call){
  if (!call.isConferenceFocus()) {
    return;
  }
synchronized (objSync) {
    Iterator<? extends CallPeer> it=call.getCallPeers();
    while (it.hasNext()) {
      CallPeer callPeer=it.next();
      notify(callPeer);
    }
    version++;
  }
}
Program: 103401
Project: 103401
Buggy source:
/** 
 * Remove capabilities for the given contacts.
 * @param contact the <tt>Contact</tt>, which capabilities we remove
 * @param opSets the new updated set of operation sets
 */
private void removeCapabilities(Contact contact,Map<String,? extends OperationSet> opSets){
  Iterator<String> caps=this.capabilities.keySet().iterator();
  Set<String> contactNewCaps=opSets.keySet();
  while (caps.hasNext()) {
    String opSetName=caps.next();
    List<Contact> contactsForCap=capabilities.get(opSetName);
    if (contactsForCap.contains(contact) && !contactNewCaps.contains(opSetName)) {
      contactsForCap.remove(contact);
      if (contactsForCap.size() == 0)       capabilities.remove(opSetName);
    }
  }
}

Fixed version (ground truth):
/** 
 * Remove capabilities for the given contacts.
 * @param contact the <tt>Contact</tt>, which capabilities we remove
 * @param opSets the new updated set of operation sets
 */
private void removeCapabilities(Contact contact,Map<String,? extends OperationSet> opSets){
  Iterator<Map.Entry<String,List<Contact>>> caps=this.capabilities.entrySet().iterator();
  Set<String> contactNewCaps=opSets.keySet();
  while (caps.hasNext()) {
    Map.Entry<String,List<Contact>> entry=caps.next();
    String opSetName=entry.getKey();
    List<Contact> contactsForCap=entry.getValue();
    if (contactsForCap.contains(contact) && !contactNewCaps.contains(opSetName)) {
      contactsForCap.remove(contact);
      if (contactsForCap.size() == 0)       caps.remove();
    }
  }
}
Program: 103402
Project: 103402
Buggy source:
/** 
 * Handles the change when we turn on/off local video streaming such as creating/releasing visual component.
 * @param listener Listener that will be callbacked
 */
private void handleLocalVideoStreamingChange(VideoTelephonyListener listener){
synchronized (videoContainers) {
    if (videoTelephony == null)     return;
    if (videoTelephony.isLocalVideoStreaming(callPeer.getCall())) {
      try {
        videoTelephony.createLocalVisualComponent(callPeer,listener);
      }
 catch (      OperationFailedException ex) {
        logger.error("String_Node_Str",ex);
      }
    }
 else     if (localVideo != null) {
      videoTelephony.disposeLocalVisualComponent(callPeer,localVideo);
      localVideo=null;
    }
  }
}

Fixed version (ground truth):
/** 
 * Handles the change when we turn on/off local video streaming such as creating/releasing visual component.
 * @param listener Listener that will be called back
 */
private void handleLocalVideoStreamingChange(VideoTelephonyListener listener){
synchronized (videoContainers) {
    if (videoTelephony == null)     return;
    if (videoTelephony.isLocalVideoStreaming(callPeer.getCall())) {
      try {
        videoTelephony.createLocalVisualComponent(callPeer,listener);
      }
 catch (      OperationFailedException ex) {
        logger.error("String_Node_Str",ex);
      }
    }
 else     if (localVideo != null) {
      videoTelephony.disposeLocalVisualComponent(callPeer,localVideo);
      localVideo=null;
    }
  }
}