nus-yam/ex-repair huggingface dataset:
Program: 4092
Project: 4092
Buggy source:
private void showPopup(Component c,int x,int y){
  menuEditItem=editItem;
  DownloadState state=menuEditItem.getState();
  pauseMenuItem.setVisible(state.isPausable());
  resumeMenuItem.setVisible(state.isResumable());
  cancelMenuItem.setVisible(state.isCancellable());
  tryAgainMenuItem.setVisible(state.isSearchAgainable());
  popupMenu.show(c,x,y);
}

Fixed version (ground truth):
public void showPopup(Component c,int x,int y){
  menuEditItem=editItem;
  DownloadState state=menuEditItem.getState();
  pauseMenuItem.setVisible(state.isPausable());
  resumeMenuItem.setVisible(state.isResumable());
  cancelMenuItem.setVisible(state.isCancellable());
  tryAgainMenuItem.setVisible(state.isSearchAgainable());
  popupMenu.show(c,x,y);
}
Program: 4094
Project: 4094
Buggy source:
/** 
 * Paints this component, including an icon and the default text when this component has focus and has no text value.
 */
@Override protected void paintComponent(Graphics g){
  Graphics2D g2d=(Graphics2D)g.create();
  if (icon == null) {
    g2d.drawLine(0,0,getWidth(),getHeight());
    g2d.drawLine(0,getHeight(),getWidth(),0);
  }
 else {
    Image image=((ImageIcon)icon).getImage();
    g2d.drawImage(image,0,0,Color.WHITE,null);
    g2d.translate(icon.getIconWidth(),0);
  }
  int iconWidth=icon.getIconWidth();
  g2d.translate(iconWidth,0);
  super.paintComponent(g2d);
  boolean valueEntered=getText().length() > 0;
  if (!hasFocus() && !valueEntered) {
    g2d.setColor(Color.LIGHT_GRAY);
    FontMetrics fm=g2d.getFontMetrics();
    int x=2;
    int y=fm.getAscent() + 2;
    g2d.drawString(defaultText,x,y);
  }
  g2d.dispose();
}

Fixed version (ground truth):
/** 
 * Paints this component, including an icon and the default text when this component has focus and has no text value.
 */
@Override protected void paintComponent(Graphics g){
  Graphics2D g2d=(Graphics2D)g.create();
  int iconWidth=icon == null ? getHeight() : icon.getIconWidth();
  if (icon == null) {
    g2d.drawLine(0,0,iconWidth,iconWidth);
    g2d.drawLine(0,iconWidth,iconWidth,0);
  }
 else {
    Image image=((ImageIcon)icon).getImage();
    g2d.drawImage(image,0,0,Color.WHITE,null);
  }
  g2d.translate(iconWidth,0);
  super.paintComponent(g2d);
  boolean valueEntered=getText().length() > 0;
  if (!hasFocus() && !valueEntered) {
    g2d.setColor(Color.LIGHT_GRAY);
    FontMetrics fm=g2d.getFontMetrics();
    int x=2;
    int y=fm.getAscent() + 2;
    g2d.drawString(defaultText,x,y);
  }
  g2d.dispose();
}
Program: 4095
Project: 4095
Buggy source:
private void layoutComponents(){
  setLayout(new GridBagLayout());
  GridBagConstraints gbc=new GridBagConstraints();
  gbc.insets=new Insets(2,2,2,10);
  add(filterBox,gbc);
  gbc.insets.right=5;
  add(sortLabel,gbc);
  add(sortBox,gbc);
  gbc.insets.left=gbc.insets.right=0;
  add(listViewToggleButton,gbc);
  add(tableViewToggleButton,gbc);
}

Fixed version (ground truth):
private void layoutComponents(){
  setLayout(new GridBagLayout());
  GridBagConstraints gbc=new GridBagConstraints();
  gbc.insets=new Insets(3,2,2,10);
  add(filterBox,gbc);
  gbc.insets.right=5;
  add(sortLabel,gbc);
  add(sortBox,gbc);
  gbc.insets.left=gbc.insets.right=0;
  add(listViewToggleButton,gbc);
  add(tableViewToggleButton,gbc);
}
Program: 4096
Project: 4096
Buggy source:
public boolean isAddressExternal(){
  if (!ConnectionSettings.LOCAL_IS_PRIVATE.getValue())   return true;
synchronized (AcceptorImpl.class) {
    return Arrays.equals(getAddress(true),_externalAddress);
  }
}

Fixed version (ground truth):
public boolean isAddressExternal(){
  if (!ConnectionSettings.LOCAL_IS_PRIVATE.getValue())   return true;
synchronized (ADDRESS_LOCK) {
    return Arrays.equals(getAddress(true),_externalAddress);
  }
}
Program: 4097
Project: 4097
Buggy source:
public void checkFirewall(InetAddress address){
  boolean changed=false;
  if (isOutsideConnection(address)) {
synchronized (AcceptorImpl.class) {
      changed=setIncoming(true);
      ConnectionSettings.EVER_ACCEPTED_INCOMING.setValue(true);
    }
  }
  if (changed)   networkManager.incomingStatusChanged();
}

Fixed version (ground truth):
public void checkFirewall(InetAddress address){
  boolean changed=false;
  if (isOutsideConnection(address)) {
synchronized (ADDRESS_LOCK) {
      changed=setIncoming(true);
      ConnectionSettings.EVER_ACCEPTED_INCOMING.setValue(true);
    }
  }
  if (changed)   networkManager.incomingStatusChanged();
}
Program: 4098
Project: 4098
Buggy source:
public void run(){
  boolean changed=false;
synchronized (AcceptorImpl.class) {
    changed=setIncoming(false);
  }
  if (changed)   networkManager.incomingStatusChanged();
}

Fixed version (ground truth):
public void run(){
  boolean changed=false;
synchronized (ADDRESS_LOCK) {
    changed=setIncoming(false);
  }
  if (changed)   networkManager.incomingStatusChanged();
}
Program: 4099
Project: 4099
Buggy source:
public byte[] getAddress(boolean checkForce){
  if (checkForce && ConnectionSettings.FORCE_IP_ADDRESS.getValue()) {
    String address=ConnectionSettings.FORCED_IP_ADDRESS_STRING.getValue();
    try {
      InetAddress ia=InetAddress.getByName(address);
      byte[] addr=ia.getAddress();
      if (addr != null)       return addr;
    }
 catch (    UnknownHostException err) {
    }
  }
synchronized (AcceptorImpl.class) {
    return _address;
  }
}

Fixed version (ground truth):
public byte[] getAddress(boolean checkForce){
  if (checkForce && ConnectionSettings.FORCE_IP_ADDRESS.getValue()) {
    String address=ConnectionSettings.FORCED_IP_ADDRESS_STRING.getValue();
    try {
      InetAddress ia=InetAddress.getByName(address);
      byte[] addr=ia.getAddress();
      if (addr != null)       return addr;
    }
 catch (    UnknownHostException err) {
    }
  }
synchronized (ADDRESS_LOCK) {
    return _address;
  }
}
Program: 4100
Project: 4100
Buggy source:
public void setAddress(InetAddress address){
  byte[] byteAddr=address.getAddress();
  if (!NetworkUtils.isValidAddress(byteAddr))   return;
  if (byteAddr[0] == 127 && ConnectionSettings.LOCAL_IS_PRIVATE.getValue()) {
    return;
  }
  boolean addrChanged=false;
synchronized (AcceptorImpl.class) {
    if (!Arrays.equals(_address,byteAddr)) {
      _address=byteAddr;
      addrChanged=true;
    }
  }
  if (addrChanged)   networkManager.addressChanged();
}

Fixed version (ground truth):
public void setAddress(InetAddress address){
  byte[] byteAddr=address.getAddress();
  if (!NetworkUtils.isValidAddress(byteAddr))   return;
  if (byteAddr[0] == 127 && ConnectionSettings.LOCAL_IS_PRIVATE.getValue()) {
    return;
  }
  boolean addrChanged=false;
synchronized (ADDRESS_LOCK) {
    if (!Arrays.equals(_address,byteAddr)) {
      _address=byteAddr;
      addrChanged=true;
    }
  }
  if (addrChanged)   networkManager.addressChanged();
}
Program: 4101
Project: 4101
Buggy source:
public byte[] getExternalAddress(){
synchronized (AcceptorImpl.class) {
    return _externalAddress;
  }
}

Fixed version (ground truth):
public byte[] getExternalAddress(){
synchronized (ADDRESS_LOCK) {
    return _externalAddress;
  }
}
Program: 4102
Project: 4102
Buggy source:
public void setExternalAddress(InetAddress address){
  byte[] byteAddr=address.getAddress();
  if (byteAddr[0] == 127 && ConnectionSettings.LOCAL_IS_PRIVATE.getValue()) {
    return;
  }
synchronized (AcceptorImpl.class) {
    _externalAddress=byteAddr;
  }
}

Fixed version (ground truth):
public void setExternalAddress(InetAddress address){
  byte[] byteAddr=address.getAddress();
  if (byteAddr[0] == 127 && ConnectionSettings.LOCAL_IS_PRIVATE.getValue()) {
    return;
  }
synchronized (ADDRESS_LOCK) {
    _externalAddress=byteAddr;
  }
}
Program: 4103
Project: 4103
Buggy source:
/** 
 * Starts listening for UDP messages & allowing UDP messages to be written.
 */
public void start(){
  DatagramChannel channel;
synchronized (this) {
    _started=true;
    channel=_channel;
  }
  if (channel != null)   NIODispatcher.instance().registerReadWrite(channel,this);
}

Fixed version (ground truth):
/** 
 * Starts listening for UDP messages & allowing UDP messages to be written.
 */
public void start(){
  if (!_started)   scheduleServices();
  DatagramChannel channel;
synchronized (this) {
    _started=true;
    channel=_channel;
  }
  if (channel != null)   NIODispatcher.instance().registerReadWrite(channel,this);
}
Program: 4104
Project: 4104
Buggy source:
@Inject public UDPService(NetworkManager networkManager,Provider<MessageDispatcher> messageDispatcher,@Named("String_Node_Str") Provider<IPFilter> hostileFilter,Provider<ConnectionManager> connectionManager,Provider<MessageRouter> messageRouter,Provider<Acceptor> acceptor,Provider<QueryUnicaster> queryUnicaster,@Named("String_Node_Str") ScheduledExecutorService backgroundExecutor,ConnectionServices connectionServices,MessageFactory messageFactory,PingRequestFactory pingRequestFactory,NetworkInstanceUtils networkInstanceUtils){
  this.networkManager=networkManager;
  this.messageDispatcher=messageDispatcher;
  this.hostileFilter=hostileFilter;
  this.connectionManager=connectionManager;
  this.messageRouter=messageRouter;
  this.acceptor=acceptor;
  this.queryUnicaster=queryUnicaster;
  this.backgroundExecutor=backgroundExecutor;
  this.connectionServices=connectionServices;
  this.messageFactory=messageFactory;
  this.pingRequestFactory=pingRequestFactory;
  this.networkInstanceUtils=networkInstanceUtils;
  OUTGOING_MSGS=new LinkedList<SendBundle>();
  byte[] backing=new byte[BUFFER_SIZE];
  BUFFER=ByteBuffer.wrap(backing);
  scheduleServices();
}

Fixed version (ground truth):
@Inject public UDPService(NetworkManager networkManager,Provider<MessageDispatcher> messageDispatcher,@Named("String_Node_Str") Provider<IPFilter> hostileFilter,Provider<ConnectionManager> connectionManager,Provider<MessageRouter> messageRouter,Provider<Acceptor> acceptor,Provider<QueryUnicaster> queryUnicaster,@Named("String_Node_Str") ScheduledExecutorService backgroundExecutor,ConnectionServices connectionServices,MessageFactory messageFactory,PingRequestFactory pingRequestFactory,NetworkInstanceUtils networkInstanceUtils){
  this.networkManager=networkManager;
  this.messageDispatcher=messageDispatcher;
  this.hostileFilter=hostileFilter;
  this.connectionManager=connectionManager;
  this.messageRouter=messageRouter;
  this.acceptor=acceptor;
  this.queryUnicaster=queryUnicaster;
  this.backgroundExecutor=backgroundExecutor;
  this.connectionServices=connectionServices;
  this.messageFactory=messageFactory;
  this.pingRequestFactory=pingRequestFactory;
  this.networkInstanceUtils=networkInstanceUtils;
  OUTGOING_MSGS=new LinkedList<SendBundle>();
  byte[] backing=new byte[BUFFER_SIZE];
  BUFFER=ByteBuffer.wrap(backing);
}
Program: 4105
Project: 4105
Buggy source:
/** 
 * Test to make sure that the query route tables are forwarded correctly between Ultrapeers.
 */
public void testIntraUltrapeerForwardQueryRouteTables() throws Exception {
  Injector injector=createInjectorAndInitialize(new AbstractModule(){
    @Override protected void configure(){
      bind(ConnectionManager.class).to(TestConnectionManager.class);
      bind(FileManager.class).to(TestFileManager.class);
    }
  }
);
  TestConnectionManager tcm=(TestConnectionManager)injector.getInstance(ConnectionManager.class);
  tcm.resetAndInitialize();
  messageRouterImpl.forwardQueryRouteTables();
  List connections=tcm.getInitializedConnections();
  Iterator iter=connections.iterator();
  while (iter.hasNext()) {
    TestConnection tc=(TestConnection)iter.next();
    QueryRouteTable qrt=tc.getQueryRouteTable();
    assertTrue("String_Node_Str",tcm.runQRPMatch(qrt));
  }
}

Fixed version (ground truth):
/** 
 * Test to make sure that the query route tables are forwarded correctly between Ultrapeers.
 */
public void testIntraUltrapeerForwardQueryRouteTables() throws Exception {
  Injector injector=createInjectorAndInitialize(new AbstractModule(){
    @Override protected void configure(){
      bind(ConnectionManager.class).to(TestConnectionManager.class);
      bind(QRPUpdater.class).to(TestQRPUpdater.class);
    }
  }
);
  TestConnectionManager tcm=(TestConnectionManager)injector.getInstance(ConnectionManager.class);
  tcm.resetAndInitialize();
  messageRouterImpl.forwardQueryRouteTables();
  List connections=tcm.getInitializedConnections();
  Iterator iter=connections.iterator();
  while (iter.hasNext()) {
    TestConnection tc=(TestConnection)iter.next();
    QueryRouteTable qrt=tc.getQueryRouteTable();
    assertTrue("String_Node_Str",tcm.runQRPMatch(qrt));
  }
}
Program: 4106
Project: 4106
Buggy source:
/** 
 * Tests the method for adding query routing entries to the QRP table for this node, adding the leaves' QRP tables if we're an Ultrapeer.
 */
public void testCreateRouteTable() throws Exception {
  Injector injector=createInjectorAndInitialize(new AbstractModule(){
    @Override protected void configure(){
      bind(ConnectionManager.class).to(TestConnectionManager.class);
      bind(FileManager.class).to(TestFileManager.class);
    }
  }
);
  TestConnectionManager tcm=(TestConnectionManager)injector.getInstance(ConnectionManager.class);
  tcm.resetAndInitialize();
  QueryRouteTable qrt=messageRouterImpl.createRouteTable();
  tcm.runQRPMatch(qrt);
}

Fixed version (ground truth):
/** 
 * Tests the method for adding query routing entries to the QRP table for this node, adding the leaves' QRP tables if we're an Ultrapeer.
 */
public void testCreateRouteTable() throws Exception {
  Injector injector=createInjectorAndInitialize(new AbstractModule(){
    @Override protected void configure(){
      bind(ConnectionManager.class).to(TestConnectionManager.class);
    }
  }
);
  TestConnectionManager tcm=(TestConnectionManager)injector.getInstance(ConnectionManager.class);
  tcm.resetAndInitialize();
  QueryRouteTable qrt=messageRouterImpl.createRouteTable();
  tcm.runQRPMatch(qrt);
}
Program: 4107
Project: 4107
Buggy source:
public BrowseHostHandler doAsynchronousBrowseHost(final Connectable host,GUID guid,GUID serventID,final Set<? extends IpPort> proxies,final boolean canDoFWTransfer){
  final BrowseHostHandler handler=browseHostHandlerManager.createBrowseHostHandler(guid,serventID);
  ThreadExecutor.startThread(new Runnable(){
    public void run(){
      handler.browseHost(host,proxies,canDoFWTransfer);
    }
  }
,"String_Node_Str");
  return handler;
}

Fixed version (ground truth):
public BrowseHostHandler doAsynchronousBrowseHost(final Connectable host,GUID guid,GUID serventID,final Set<? extends IpPort> proxies,final boolean canDoFWTransfer){
  final BrowseHostHandler handler=browseHostHandlerManager.createBrowseHostHandler(guid,serventID);
  ThreadExecutor.startThread(new DebugRunnable(new Runnable(){
    public void run(){
      handler.browseHost(host,proxies,canDoFWTransfer);
    }
  }
),"String_Node_Str");
  return handler;
}
Program: 4108
Project: 4108
Buggy source:
/** 
 * Strips out results that don't seem to be valid due to territory, radius, or other restriction.
 */
private void removeInvalidResults(List<QueryResult> results){
  for (  QueryResult result : new ArrayList<QueryResult>(results)) {
    PromotionMessageContainer promo=result.getPromotionMessageContainer();
    List<GeoRestriction> restrictions=promo.getGeoRestrictions();
    if (restrictions.size() > 0) {
      if (userLatLon == null) {
        results.remove(result);
        continue;
      }
 else {
        boolean matchedAtLeastOneRestriction=false;
        for (        GeoRestriction restriction : restrictions) {
          if (restriction.contains(userLatLon)) {
            matchedAtLeastOneRestriction=true;
            break;
          }
        }
        if (!matchedAtLeastOneRestriction) {
          results.remove(result);
          continue;
        }
      }
    }
    Locale[] territories=promo.getTerritories();
    if (territories.length > 0) {
      if (userTerritory == null) {
        results.remove(result);
        continue;
      }
 else {
        boolean matchAtLeastOneTerritory=false;
        for (        Locale territory : territories) {
          if (userTerritory.equalsIgnoreCase(territory.getCountry())) {
            matchAtLeastOneTerritory=true;
            break;
          }
        }
        if (!matchAtLeastOneTerritory) {
          results.remove(result);
          continue;
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Strips out results that don't seem to be valid due to territory, radius, or other restriction.
 */
private void removeInvalidResults(List<QueryResult> results,Date timeQueried){
  for (  QueryResult result : new ArrayList<QueryResult>(results)) {
    PromotionMessageContainer promo=result.getPromotionMessageContainer();
    List<GeoRestriction> restrictions=promo.getGeoRestrictions();
    if (restrictions.size() > 0) {
      if (userLatLon == null) {
        results.remove(result);
        continue;
      }
 else {
        boolean matchedAtLeastOneRestriction=false;
        for (        GeoRestriction restriction : restrictions) {
          if (restriction.contains(userLatLon)) {
            matchedAtLeastOneRestriction=true;
            break;
          }
        }
        if (!matchedAtLeastOneRestriction) {
          results.remove(result);
          continue;
        }
      }
    }
    Locale[] territories=promo.getTerritories();
    if (territories.length > 0) {
      if (userTerritory == null) {
        results.remove(result);
        continue;
      }
 else {
        boolean matchAtLeastOneTerritory=false;
        for (        Locale territory : territories) {
          if (userTerritory.equalsIgnoreCase(territory.getCountry())) {
            matchAtLeastOneTerritory=true;
            break;
          }
        }
        if (!matchAtLeastOneTerritory) {
          results.remove(result);
          continue;
        }
      }
    }
    if (!isMessageValid(result.getPromotionMessageContainer(),result.getBinderUniqueName(),timeQueried.getTime())) {
      results.remove(result);
      continue;
    }
  }
}
Program: 4109
Project: 4109
Buggy source:
public void run(){
  final Date timeQueried=new Date();
  PromotionBinder binder=null;
  List<QueryResult> results=null;
  binder=promotionBinderRepository.getBinderForBucket(keywordUtil.getHashValue(normalizedQuery));
  try {
    if (binder != null) {
      searcherDatabase.ingest(binder);
    }
    searcherDatabase.expungeExpired();
    results=searcherDatabase.query(normalizedQuery);
  }
 catch (  DatabaseExecutionException e) {
    promotionServices.shutDown();
  }
  if (results == null) {
    return;
  }
  removeInvalidResults(results);
  int shownResults=0;
  for (  QueryResult result : results) {
    final float probability=result.getPromotionMessageContainer().getProbability();
    if (Math.random() <= probability) {
      if (isMessageValid(result.getPromotionMessageContainer(),result.getBinderUniqueName(),timeQueried.getTime())) {
        if (!result.getPromotionMessageContainer().isImpressionOnly()) {
          shownResults++;
          callback.process(result.getPromotionMessageContainer());
        }
        impressionsCollector.recordImpression(query,timeQueried,new Date(),result.getPromotionMessageContainer(),result.getBinderUniqueName());
      }
    }
    if (shownResults >= maxNumberOfResults)     break;
  }
}

Fixed version (ground truth):
public void run(){
  final Date timeQueried=new Date();
  PromotionBinder binder=null;
  List<QueryResult> results=null;
  binder=promotionBinderRepository.getBinderForBucket(keywordUtil.getHashValue(normalizedQuery));
  try {
    if (binder != null) {
      searcherDatabase.ingest(binder);
    }
    searcherDatabase.expungeExpired();
    results=searcherDatabase.query(normalizedQuery);
  }
 catch (  DatabaseExecutionException e) {
    promotionServices.shutDown();
  }
  if (results == null) {
    return;
  }
  removeInvalidResults(results,timeQueried);
  List<QueryResult> visibleResults=new ArrayList<QueryResult>(results.size());
  for (  QueryResult result : results) {
    if (result.getPromotionMessageContainer().isImpressionOnly()) {
      impressionsCollector.recordImpression(query,timeQueried,new Date(),result.getPromotionMessageContainer(),result.getBinderUniqueName());
    }
 else {
      visibleResults.add(result);
    }
  }
  int shownResults=0;
  int idx=0;
  for (  QueryResult result : visibleResults) {
    final float probability=result.getPromotionMessageContainer().getProbability();
    int remainingToIterateThrough=visibleResults.size() - idx;
    int remainingMaxToShow=maxNumberOfResults - shownResults;
    if (remainingToIterateThrough <= remainingMaxToShow || Math.random() <= probability) {
      shownResults++;
      callback.process(result.getPromotionMessageContainer());
      impressionsCollector.recordImpression(query,timeQueried,new Date(),result.getPromotionMessageContainer(),result.getBinderUniqueName());
    }
    idx++;
    if (shownResults >= maxNumberOfResults)     break;
  }
}
Program: 4110
Project: 4110
Buggy source:
public void run(){
  try {
    ServerSocket ss=new ServerSocket(PORT);
    Socket s=ss.accept();
    InputStream in=s.getInputStream();
    BufferedReader BR=new BufferedReader(new InputStreamReader(in));
    String input=null;
    int length=0;
    while ((input=BR.readLine()).length() != 0) {
      if (input.toLowerCase().startsWith("String_Node_Str")) {
        length=Integer.parseInt(input.substring(input.indexOf("String_Node_Str") + 2));
      }
    }
    char[] content=new char[length];
    BR.read(content,0,length);
    String contentAsString=new String(content);
    userComments=contentAsString.substring(contentAsString.indexOf("String_Node_Str") + 4);
    OutputStream out=s.getOutputStream();
    String response;
    response="String_Node_Str";
    out.write(response.getBytes());
    out.flush();
    response="String_Node_Str";
    out.write(response.getBytes());
    out.flush();
    s.close();
  }
 catch (  IOException ex) {
    fail(ex);
  }
}

Fixed version (ground truth):
public void run(){
  try {
    ServerSocket ss=new ServerSocket(port);
    Socket s=ss.accept();
    InputStream in=s.getInputStream();
    BufferedReader BR=new BufferedReader(new InputStreamReader(in));
    String input=null;
    int length=0;
    while ((input=BR.readLine()).length() != 0) {
      if (input.toLowerCase().startsWith("String_Node_Str")) {
        length=Integer.parseInt(input.substring(input.indexOf("String_Node_Str") + 2));
      }
    }
    char[] content=new char[length];
    BR.read(content,0,length);
    contentAsString=new String(content);
    OutputStream out=s.getOutputStream();
    String response;
    response="String_Node_Str";
    out.write(response.getBytes());
    out.flush();
    response="String_Node_Str";
    out.write(response.getBytes());
    out.flush();
    s.close();
  }
 catch (  IOException ex) {
    fail(ex);
  }
}
Program: 4111
Project: 4111
Buggy source:
@Override protected void readTag(AudioFile audioFile,Tag tag){
  if (tag != null) {
    audioData.setTitle(tag.getFirstTitle());
    audioData.setArtist(tag.getFirstArtist());
    audioData.setAlbum(tag.getFirstAlbum());
    audioData.setYear(tag.getFirstYear());
    audioData.setComment(tag.getFirstComment());
    audioData.setGenre(tag.getFirstGenre());
    try {
      audioData.setTrack(tag.getFirstTrack());
    }
 catch (    UnsupportedOperationException e) {
    }
    if (!(tag instanceof ID3v1Tag)) {
      audioData.setLicense(tag.getFirst(ID3v24Frames.FRAME_ID_COPYRIGHTINFO));
      MP3File mp3File=((MP3File)audioFile);
      audioData.setGenre(parseGenre(tag.getFirstGenre()));
      AbstractID3v2Tag vTag=mp3File.getID3v2Tag();
      if (vTag != null) {
        List<TagField> license=vTag.get(PRIV_ID);
        List<TagField> priv=vTag.get(PRIV_ID);
        Iterator<TagField> iter=license.iterator();
        while (iter.hasNext()) {
          TagField t=iter.next();
          checkLWS(t.toString());
        }
        iter=priv.iterator();
        while (iter.hasNext()) {
          TagField t=iter.next();
          checkLWS(t.toString());
          try {
            isPRIVCheck(t.getRawContent());
          }
 catch (          UnsupportedEncodingException e) {
          }
        }
        AbstractID3v2Frame frame=vTag.getFirstField(ID3v24Frames.FRAME_ID_COPYRIGHTINFO);
        if (frame != null && !frame.isEmpty() && frame.getBody() instanceof AbstractFrameBodyTextInfo)         audioData.setLicense(((AbstractFrameBodyTextInfo)frame.getBody()).getText());
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void readTag(AudioFile audioFile,Tag tag){
  MP3File mp3File=((MP3File)audioFile);
  mp3File.getID3v1Tag();
  AbstractID3v2Tag v2Tag=mp3File.getID3v2Tag();
  ID3v1Tag v1Tag=mp3File.getID3v1Tag();
  if (v2Tag != null)   readV2Tag(v2Tag);
  if (v1Tag != null)   readV1Tag(v1Tag);
}
Program: 4112
Project: 4112
Buggy source:
/** 
 * Some genres in ID3v2 tags are displaying (XXX) numbers along side the genre. If this exists it hides the number from the user
 * @param genre
 * @return
 */
private String parseGenre(String genre){
  if (genre == null || genre.length() <= 0)   return genre;
  String cleanGenre=genre;
  if (genre.charAt(0) == '(') {
    int startIndex=0;
    for (int i=0; i < genre.length(); i++) {
      if (genre.charAt(i) == ')') {
        startIndex=i + 1;
      }
    }
    cleanGenre=genre.substring(startIndex);
  }
  return cleanGenre;
}

Fixed version (ground truth):
/** 
 * Some genres in ID3v2 tags are displaying (XXX) numbers along side the genre. If this exists it hides the number from the user
 */
private String parseGenre(String genre){
  if (genre == null || genre.length() <= 0)   return genre;
  String cleanGenre=genre;
  if (genre.charAt(0) == '(') {
    int startIndex=0;
    for (int i=0; i < genre.length(); i++) {
      if (genre.charAt(i) == ')') {
        startIndex=i + 1;
      }
    }
    cleanGenre=genre.substring(startIndex);
  }
  return cleanGenre;
}
Program: 4113
Project: 4113
Buggy source:
/** 
 * Creates MetaData for the file, if possible. 
 */
public MetaReader parse(File f) throws IOException {
  try {
    if (LimeXMLUtils.isSupportedAudioFormat(f))     return parseAudioFile(f);
 else     if (LimeXMLUtils.isSupportedVideoFormat(f))     return parseVideoMetaData(f);
 else     if (LimeXMLUtils.isSupportedMultipleFormat(f))     return parseMultipleFormat(f);
  }
 catch (  OutOfMemoryError e) {
    LOG.warn("String_Node_Str",e);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Creates MetaData for the file, if possible. 
 */
public MetaReader parse(File f) throws IOException {
  try {
    if (LimeXMLUtils.isSupportedAudioFormat(f))     return parseAudioFile(f);
 else     if (LimeXMLUtils.isSupportedVideoFormat(f))     return parseVideoMetaData(f);
 else     if (LimeXMLUtils.isSupportedMultipleFormat(f))     return parseMultipleFormat(f);
  }
 catch (  OutOfMemoryError e) {
    LOG.warn("String_Node_Str",e);
  }
catch (  IllegalArgumentException e) {
    return null;
  }
  return null;
}
Program: 4114
Project: 4114
Buggy source:
/** 
 * Reads the meta data for the audio file if LimeWire can parse it, otherwise return null if file type is not supported
 */
private MetaReader parseAudioFile(File f) throws IOException {
  if (LimeXMLUtils.isMP3File(f))   return new MP3MetaData(f);
  if (LimeXMLUtils.isOGGFile(f))   return new OGGMetaData(f);
  if (LimeXMLUtils.isFLACFile(f))   return new AudioDataReader(f);
  if (LimeXMLUtils.isM4AFile(f))   return new AudioDataReader(f);
  if (LimeXMLUtils.isWMAFile(f))   return new WMAMetaData(f);
  return null;
}

Fixed version (ground truth):
/** 
 * Reads the meta data for the audio file if LimeWire can parse it, otherwise return null if file type is not supported
 */
private MetaReader parseAudioFile(File f) throws IOException, IllegalArgumentException {
  if (LimeXMLUtils.isMP3File(f))   return new MP3MetaData(f);
  if (LimeXMLUtils.isOGGFile(f))   return new OGGMetaData(f);
  if (LimeXMLUtils.isFLACFile(f))   return new AudioDataReader(f);
  if (LimeXMLUtils.isM4AFile(f))   return new AudioDataReader(f);
  if (LimeXMLUtils.isWMAFile(f))   return new WMAMetaData(f);
  return null;
}
Program: 4115
Project: 4115
Buggy source:
public AudioDataReader(File f) throws IOException {
  audioData=new AudioMetaData();
  parseFile(f);
}

Fixed version (ground truth):
public AudioDataReader(File f) throws IOException, IllegalArgumentException {
  audioData=new AudioMetaData();
  parseFile(f);
}
Program: 4116
Project: 4116
Buggy source:
/** 
 * Handles the reading and parsing of this file
 * @param file - file to read
 * @throws IOException - thrown if the file can't be read, is corrupted, etc..
 */
private void parseFile(File file) throws IOException {
  try {
    AudioFile audioFile=AudioFileIO.read(file);
    readHeader(audioFile.getAudioHeader());
    readTag(audioFile,audioFile.getTag());
  }
 catch (  CannotReadException e) {
    throw (IOException)new IOException().initCause(e);
  }
catch (  TagException e) {
    throw (IOException)new IOException().initCause(e);
  }
catch (  ReadOnlyFileException e) {
    throw (IOException)new IOException().initCause(e);
  }
catch (  InvalidAudioFrameException e) {
    throw (IOException)new IOException().initCause(e);
  }
}

Fixed version (ground truth):
/** 
 * Handles the reading and parsing of this file
 * @param file - file to read
 * @throws IOException - thrown if the file can't be read, is corrupted, etc..
 */
private void parseFile(File file) throws IOException, IllegalArgumentException {
  try {
    AudioFile audioFile=AudioFileIO.read(file);
    readHeader(audioFile.getAudioHeader());
    readTag(audioFile,audioFile.getTag());
  }
 catch (  CannotReadException e) {
    throw (IOException)new IOException().initCause(e);
  }
catch (  TagException e) {
    throw (IOException)new IOException().initCause(e);
  }
catch (  ReadOnlyFileException e) {
    throw (IOException)new IOException().initCause(e);
  }
catch (  InvalidAudioFrameException e) {
    throw (IOException)new IOException().initCause(e);
  }
}
Program: 4117
Project: 4117
Buggy source:
public MP3MetaData(File f) throws IOException {
  super(f);
}

Fixed version (ground truth):
public MP3MetaData(File f) throws IOException, IllegalArgumentException {
  super(f);
}
Program: 4118
Project: 4118
Buggy source:
public OGGMetaData(File f) throws IOException {
  super(f);
}

Fixed version (ground truth):
public OGGMetaData(File f) throws IOException, IllegalArgumentException {
  super(f);
}
Program: 4119
Project: 4119
Buggy source:
/** 
 * decodes an interval set encoded with: http://www.limewire.org/wiki/index.php?title=HashTreeRangeEncoding
 * @param maxSize the size of the file
 * @param id integers from the encoding
 */
public void decode(long maxSize,Integer... id){
  long numLeafs=getNumLeafs(maxSize);
  TreeStorage ts=new TreeStorage(null,new NodeGenerator.NullGenerator(),(int)numLeafs);
  for (  int i : id) {
    if (!ts.isValidId(i))     continue;
    int[] nodes=ts.nodeToFileId(i);
    Range r=Range.createRange(nodes[0] * 1024L,Math.min((nodes[1] + 1) * 1024L - 1,maxSize - 1));
    add(r);
  }
}

Fixed version (ground truth):
/** 
 * decodes an interval set encoded with: http://www.limewire.org/wiki/index.php?title=HashTreeRangeEncoding
 * @param maxSize the size of the file
 * @param id integers from the encoding
 */
public void decode(long maxSize,Integer... id){
  long numLeafs=getNumLeafs(maxSize);
  TreeStorage ts=new TreeStorage(null,new NodeGenerator.NullGenerator(),(int)numLeafs);
  for (  int i : id) {
    int[] nodes=ts.nodeToFileId(i);
    if (nodes == null)     continue;
    Range r=Range.createRange(nodes[0] * 1024L,Math.min((nodes[1] + 1) * 1024L - 1,maxSize - 1));
    add(r);
  }
}
Program: 4120
Project: 4120
Buggy source:
/** 
 * @param nodeId node from the tree
 * @return the start and end index of the chunks from the filethe node maps to
 */
public int[] nodeToFileId(int nodeId){
  if (!isValidId(nodeId))   throw new IllegalArgumentException("String_Node_Str" + nodeId + "String_Node_Str"+ maxId);
  int power=Math.max(1,0x1 << (log2Ceil(maxId) - 1));
  if (nodeId == 1)   return new int[]{0,maxId - power};
  int[] ret=new int[2];
  int times=0;
  while (nodeId < power) {
    times++;
    nodeId<<=1;
  }
  ret[0]=nodeId - power;
  ret[1]=Math.min(maxId - power,ret[0] + (0x1 << times) - 1);
  return ret;
}

Fixed version (ground truth):
/** 
 * @param nodeId node from the tree
 * @return the start and end index of the chunks from the filethe node maps to or null if id is invalid.
 */
public int[] nodeToFileId(int nodeId){
  if (nodeId < 1 || nodeId > maxId)   return null;
  int power=Math.max(1,0x1 << (log2Ceil(maxId) - 1));
  if (nodeId == 1)   return new int[]{0,maxId - power};
  int[] ret=new int[2];
  int times=0;
  while (nodeId < power) {
    times++;
    nodeId<<=1;
  }
  if (nodeId > maxId)   return null;
  ret[0]=nodeId - power;
  ret[1]=Math.min(maxId - power,ret[0] + (0x1 << times) - 1);
  return ret;
}
Program: 4121
Project: 4121
Buggy source:
/** 
 * @return an IntervalSet contained in this GGEP.  Null if none.
 */
public static IntervalSet decode(long size,GGEP ggep) throws BadGGEPPropertyException {
  if (ggep.hasKey(GGEP.GGEP_HEADER_PARTIAL_RESULT_PREFIX + "String_Node_Str"))   return new IntervalSet();
  IntervalSet ret=null;
  for (int i=1; i <= 4; i++) {
    String key=GGEP.GGEP_HEADER_PARTIAL_RESULT_PREFIX + i;
    if (ggep.hasKey(key)) {
      byte[] b=ggep.get(key);
      if (b == null)       continue;
      if (ret == null)       ret=new IntervalSet();
      if (b.length % i != 0)       return null;
      for (int j=0; j < b.length; j+=i) {
        int nodeId=0;
        for (int k=0; k < i; k++) {
          nodeId<<=8;
          nodeId|=(b[j + k] & 0xFF);
        }
        try {
          ret.decode(size,nodeId);
        }
 catch (        IllegalArgumentException bad) {
          if (!BugSettings.SEND_TREE_STORAGE_BUGS.getValue())           continue;
          StringBuilder report=new StringBuilder();
          report.append("String_Node_Str");
          report.append("String_Node_Str").append(size).append("String_Node_Str").append(nodeId);
          report.append("String_Node_Str").append(key).append("String_Node_Str").append(Base32.encode(b));
          report.append("String_Node_Str").append(i).append("String_Node_Str").append(j);
          report.append("String_Node_Str").append(ret);
          throw new IllegalArgumentException(report.toString(),bad);
        }
      }
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * @return an IntervalSet contained in this GGEP.  Null if none.
 */
public static IntervalSet decode(long size,GGEP ggep) throws BadGGEPPropertyException {
  if (ggep.hasKey(GGEP.GGEP_HEADER_PARTIAL_RESULT_PREFIX + "String_Node_Str"))   return new IntervalSet();
  IntervalSet ret=null;
  for (int i=1; i <= 4; i++) {
    String key=GGEP.GGEP_HEADER_PARTIAL_RESULT_PREFIX + i;
    if (ggep.hasKey(key)) {
      byte[] b=ggep.get(key);
      if (b == null)       continue;
      if (ret == null)       ret=new IntervalSet();
      if (b.length % i != 0)       return null;
      for (int j=0; j < b.length; j+=i) {
        int nodeId=0;
        for (int k=0; k < i; k++) {
          nodeId<<=8;
          nodeId|=(b[j + k] & 0xFF);
        }
        ret.decode(size,nodeId);
      }
    }
  }
  return ret;
}
Program: 4122
Project: 4122
Buggy source:
public void testInvalid() throws Exception {
  GGEP g=new GGEP();
  byte[] pr1=new byte[]{2,100};
  g.put("String_Node_Str",pr1);
  IntervalSet decoded=IntervalEncoder.decode(2048,g);
  assertEquals(1,decoded.getNumberOfIntervals());
  assertEquals(0,decoded.getFirst().getLow());
  assertEquals(1023,decoded.getFirst().getHigh());
}

Fixed version (ground truth):
public void testInvalid() throws Exception {
  GGEP g=new GGEP();
  byte[] pr1=new byte[]{2,100};
  g.put("String_Node_Str",pr1);
  IntervalSet decoded=IntervalEncoder.decode(2048,g);
  assertEquals(1,decoded.getNumberOfIntervals());
  assertEquals(0,decoded.getFirst().getLow());
  assertEquals(1023,decoded.getFirst().getHigh());
  String encoded="String_Node_Str";
  byte[] pr3=Base32.decode(encoded);
  g=new GGEP();
  g.put("String_Node_Str",pr3);
  IntervalEncoder.decode(734147846L,g);
}
Program: 4123
Project: 4123
Buggy source:
/** 
 * implements interface <tt>Token</tt>
 */
public double getImportance(){
  double importance=_importance;
  if (importance == Double.NaN) {
    importance=(_age * -100.0 * (0.1 + Math.pow(1.0 - getRating(),0.1)));
    _importance=importance;
  }
  return importance;
}

Fixed version (ground truth):
/** 
 * implements interface <tt>Token</tt>
 */
public double getImportance(){
  double importance=_importance;
  if (Double.isNaN(importance)) {
    importance=(_age * -100.0 * (0.1 + Math.pow(1.0 - getRating(),0.1)));
    _importance=importance;
  }
  return importance;
}
Program: 4124
Project: 4124
Buggy source:
public static void encode(long size,GGEP g,IntervalSet s){
  List<Integer> bytes=new ArrayList<Integer>();
  List<Integer> shorts=new ArrayList<Integer>();
  List<Integer> b24=new ArrayList<Integer>();
  List<Integer> ints=new ArrayList<Integer>();
  for (  int i : s.encode(size)) {
    long l=i & 0xFFFFFFFF;
    if (l > 0xFFFFFFL)     ints.add(i);
 else     if (l > 0xFFFF)     b24.add(i);
 else     if (l > 0xFF)     shorts.add(i);
 else     bytes.add(i);
  }
  byte[] bytesB=new byte[bytes.size()];
  for (int i=0; i < bytesB.length; i++)   bytesB[i]=(byte)bytes.get(i).intValue();
  byte[] shortsB=new byte[shorts.size() * 2];
  for (int i=0; i < shorts.size(); i++)   ByteOrder.short2beb(shorts.get(i).shortValue(),shortsB,i * 2);
  byte[] b24B=new byte[b24.size() * 3];
  for (int i=0; i < b24.size(); i++) {
    int value=b24.get(i);
    b24B[i]=(byte)((value & 0xFF0000) >> 16);
    b24B[i + 1]=(byte)((value & 0xFF00) >> 8);
    b24B[i + 2]=(byte)(value & 0xFF);
  }
  byte[] intsB=new byte[ints.size() * 4];
  for (int i=0; i < ints.size(); i++)   ByteOrder.int2beb(ints.get(i).intValue(),intsB,i * 4);
  int availableSpace=SharingSettings.MAX_PARTIAL_ENCODING_SIZE.getValue();
  availableSpace=addIfSpace(bytesB,g,1,availableSpace);
  availableSpace=addIfSpace(shortsB,g,2,availableSpace);
  availableSpace=addIfSpace(b24B,g,3,availableSpace);
  addIfSpace(intsB,g,4,availableSpace);
  if (bytes.size() + shorts.size() + b24.size()+ ints.size() == 0)   g.put(GGEP.GGEP_HEADER_PARTIAL_RESULT_PREFIX + "String_Node_Str");
}

Fixed version (ground truth):
public static void encode(long size,GGEP g,IntervalSet s){
  List<Integer> bytes=new ArrayList<Integer>();
  List<Integer> shorts=new ArrayList<Integer>();
  List<Integer> b24=new ArrayList<Integer>();
  List<Integer> ints=new ArrayList<Integer>();
  for (  int i : s.encode(size)) {
    long l=i & 0xFFFFFFFF;
    if (l > 0xFFFFFFL)     ints.add(i);
 else     if (l > 0xFFFF)     b24.add(i);
 else     if (l > 0xFF)     shorts.add(i);
 else     bytes.add(i);
  }
  byte[] bytesB=new byte[bytes.size()];
  for (int i=0; i < bytesB.length; i++)   bytesB[i]=(byte)bytes.get(i).intValue();
  byte[] shortsB=new byte[shorts.size() * 2];
  for (int i=0; i < shorts.size(); i++)   ByteOrder.short2beb(shorts.get(i).shortValue(),shortsB,i * 2);
  byte[] b24B=new byte[b24.size() * 3];
  for (int i=0; i < b24.size(); i++) {
    int value=b24.get(i);
    b24B[i * 3]=(byte)((value & 0xFF0000) >> 16);
    b24B[i * 3 + 1]=(byte)((value & 0xFF00) >> 8);
    b24B[i * 3 + 2]=(byte)(value & 0xFF);
  }
  byte[] intsB=new byte[ints.size() * 4];
  for (int i=0; i < ints.size(); i++)   ByteOrder.int2beb(ints.get(i).intValue(),intsB,i * 4);
  int availableSpace=SharingSettings.MAX_PARTIAL_ENCODING_SIZE.getValue();
  availableSpace=addIfSpace(bytesB,g,1,availableSpace);
  availableSpace=addIfSpace(shortsB,g,2,availableSpace);
  availableSpace=addIfSpace(b24B,g,3,availableSpace);
  addIfSpace(intsB,g,4,availableSpace);
  if (bytes.size() + shorts.size() + b24.size()+ ints.size() == 0)   g.put(GGEP.GGEP_HEADER_PARTIAL_RESULT_PREFIX + "String_Node_Str");
}
Program: 4125
Project: 4125
Buggy source:
/** 
 * Sets the new incoming status. Returns whether or not the status changed.
 */
boolean setIncoming(boolean canReceiveIncoming){
  if (_acceptedIncoming == canReceiveIncoming)   return false;
  if (canReceiveIncoming) {
    Future<?> resetter=resetterFuture;
    if (resetter != null)     resetter.cancel(false);
  }
  _acceptedIncoming=canReceiveIncoming;
  activityCallback.get().acceptedIncomingChanged(canReceiveIncoming);
  return true;
}

Fixed version (ground truth):
/** 
 * Sets the new incoming status. Returns whether or not the status changed.
 */
boolean setIncoming(boolean canReceiveIncoming){
  if (canReceiveIncoming) {
    Future<?> resetter=resetterFuture;
    if (resetter != null)     resetter.cancel(false);
  }
  if (_acceptedIncoming == canReceiveIncoming)   return false;
  _acceptedIncoming=canReceiveIncoming;
  activityCallback.get().acceptedIncomingChanged(canReceiveIncoming);
  return true;
}
Program: 4127
Project: 4127
Buggy source:
/** 
 * Initializes this TLSLayer, using the given address and enabling the given cipherSuites. If clientMode is disabled, client authentication can be turned on/off.
 * @param addr
 * @param cipherSuites
 */
void initialize(SocketAddress addr,String[] cipherSuites,boolean clientMode,boolean needClientAuth){
synchronized (initLock) {
    if (shutdown) {
      LOG.debug("String_Node_Str");
      return;
    }
    if (addr != null) {
      if (!(addr instanceof InetSocketAddress))       throw new IllegalArgumentException("String_Node_Str");
      InetSocketAddress iaddr=(InetSocketAddress)addr;
      String host=iaddr.getAddress().getHostAddress();
      int port=iaddr.getPort();
      engine=context.createSSLEngine(host,port);
    }
 else {
      engine=context.createSSLEngine();
    }
    engine.setEnabledCipherSuites(cipherSuites);
    engine.setUseClientMode(clientMode);
    if (!clientMode) {
      engine.setWantClientAuth(needClientAuth);
      engine.setNeedClientAuth(needClientAuth);
    }
    SSLSession session=engine.getSession();
    readIncoming=byteBufferCache.getHeap(session.getApplicationBufferSize());
    writeOutgoing=byteBufferCache.getHeap(session.getPacketBufferSize());
    if (LOG.isTraceEnabled())     LOG.trace("String_Node_Str" + engine + "String_Node_Str"+ session);
  }
}

Fixed version (ground truth):
/** 
 * Initializes this TLSLayer, using the given address and enabling the given cipherSuites. If clientMode is disabled, client authentication can be turned on/off.
 * @param addr
 * @param cipherSuites
 */
void initialize(SocketAddress addr,String[] cipherSuites,boolean clientMode,boolean needClientAuth){
synchronized (initLock) {
    if (shutdown) {
      LOG.debug("String_Node_Str");
      return;
    }
    if (addr != null) {
      if (!(addr instanceof InetSocketAddress))       throw new IllegalArgumentException("String_Node_Str");
      InetSocketAddress iaddr=(InetSocketAddress)addr;
      String host=iaddr.getAddress().getHostAddress();
      int port=iaddr.getPort();
      engine=context.createSSLEngine(host,port);
    }
 else {
      engine=context.createSSLEngine();
    }
    engine.setEnabledCipherSuites(cipherSuites);
    engine.setUseClientMode(clientMode);
    if (!clientMode) {
      engine.setWantClientAuth(needClientAuth);
      engine.setNeedClientAuth(needClientAuth);
    }
    SSLSession session=engine.getSession();
    readIncoming=byteBufferCache.getHeap(session.getPacketBufferSize());
    writeOutgoing=byteBufferCache.getHeap(session.getPacketBufferSize());
    if (LOG.isTraceEnabled())     LOG.trace("String_Node_Str" + engine + "String_Node_Str"+ session);
  }
}
Program: 4128
Project: 4128
Buggy source:
/** 
 * Returns true if the folder is completely shared, false otherwise
 */
public boolean isFolderShared(File f){
  return _sharedDirectories.containsKey(f);
}

Fixed version (ground truth):
/** 
 * Returns true if the folder is completely shared, false otherwise
 */
public boolean isFolderShared(File f){
  if (SharingSettings.DIRECTORIES_TO_SHARE.contains(f))   return true;
  while (f != null && f.getParentFile() != null) {
    f=f.getParentFile();
    if (SharingSettings.DIRECTORIES_TO_SHARE.contains(f))     return true;
  }
  return false;
}
Program: 4129
Project: 4129
Buggy source:
/** 
 * Returns true if this folder is sharable. <p> Unsharable folders include: <ul> <li>A non-directory or unreadable folder</li> <li>The incomplete directory</li> <li>The 'application special share directory'</li> <li>Any root directory</li> <li>Any directory listed in 'directories not to share' (<i>Only if includeExcludedDirectories is true</i>)</li> </ul>
 * @param folder The folder to check for sharability
 * @param includeExcludedDirectories True if this should exclude the folderfrom sharability if it is listed in DIRECTORIES_NOT_TO_SHARE
 * @return true if the folder can be shared
 */
public boolean isFolderShareable(File folder,boolean includeExcludedDirectories){
  if (!folder.isDirectory() || !folder.canRead())   return false;
  if (folder.equals(SharingSettings.INCOMPLETE_DIRECTORY.getValue()))   return false;
  if (isApplicationSpecialShareDirectory(folder)) {
    return false;
  }
  if (includeExcludedDirectories && _data.DIRECTORIES_NOT_TO_SHARE.contains(folder))   return false;
  File[] faRoots=File.listRoots();
  if (faRoots != null && faRoots.length > 0) {
    for (int i=0; i < faRoots.length; i++) {
      if (folder.equals(faRoots[i]))       return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Returns true if this folder is sharable. <p> Unsharable folders include: <ul> <li>A non-directory or unreadable folder</li> <li>The incomplete directory</li> <li>The 'application special share directory'</li> <li>Any root directory</li> <li>Any directory listed in 'directories not to share' (<i>Only if includeExcludedDirectories is true</i>)</li> </ul>
 * @param folder The folder to check for sharability
 * @param includeExcludedDirectories True if this should exclude the folderfrom sharability if it is listed in DIRECTORIES_NOT_TO_SHARE
 * @return true if the folder can be shared
 */
public boolean isFolderShareable(File folder,boolean includeExcludedDirectories){
  if (!folder.isDirectory() || !folder.canRead())   return false;
  if (folder.equals(SharingSettings.INCOMPLETE_DIRECTORY.getValue()))   return false;
  if (isApplicationSpecialShareDirectory(folder)) {
    return false;
  }
  if (includeExcludedDirectories && _data.DIRECTORIES_NOT_TO_SHARE.contains(folder))   return false;
  File[] faRoots=File.listRoots();
  if (faRoots != null && faRoots.length > 0) {
    for (int i=0; i < faRoots.length; i++) {
      if (folder.equals(faRoots[i]))       return false;
    }
  }
  String name=folder.getName().toLowerCase(Locale.US);
  if (name.equals("String_Node_Str"))   return false;
 else   if (name.equals("String_Node_Str")) {
    String parent=folder.getParent();
    if (parent != null && parent.toLowerCase(Locale.US).equals("String_Node_Str"))     return false;
  }
  return true;
}