nus-yam/ex-repair huggingface dataset:
Program: 195569
Project: 195569
Buggy source:
@Override public ParcelFileDescriptor openInputPort(int portNumber){
  if (portNumber < 0 || portNumber >= mInputPortCount) {
    Log.e(TAG,"String_Node_Str" + portNumber);
    return null;
  }
  ParcelFileDescriptor result=null;
  MidiOutputPort newOutputPort=null;
synchronized (mInputPortSenders) {
    if (mInputPortSenders[portNumber] != null) {
      Log.d(TAG,"String_Node_Str" + portNumber + "String_Node_Str");
      return null;
    }
    try {
      ParcelFileDescriptor[] pair=ParcelFileDescriptor.createSocketPair(OsConstants.SOCK_SEQPACKET);
      newOutputPort=new ServerOutputPort(pair[0],portNumber);
      mInputPortSenders[portNumber]=newOutputPort;
      result=pair[1];
    }
 catch (    IOException e) {
      Log.e(TAG,"String_Node_Str");
      return null;
    }
    if (newOutputPort != null) {
      ArrayList<MidiReceiver> receivers=mInputPortReceivers[portNumber];
synchronized (receivers) {
        for (int i=0; i < receivers.size(); i++) {
          newOutputPort.connect(receivers.get(i));
        }
      }
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public ParcelFileDescriptor openInputPort(int portNumber){
  if (portNumber < 0 || portNumber >= mInputPortCount) {
    Log.e(TAG,"String_Node_Str" + portNumber);
    return null;
  }
  ParcelFileDescriptor result=null;
synchronized (mInputPortSenders) {
    if (mInputPortSenders[portNumber] != null) {
      Log.d(TAG,"String_Node_Str" + portNumber + "String_Node_Str");
      return null;
    }
    try {
      ParcelFileDescriptor[] pair=ParcelFileDescriptor.createSocketPair(OsConstants.SOCK_SEQPACKET);
      MidiOutputPort newOutputPort=new ServerOutputPort(pair[0],portNumber);
      mInputPortSenders[portNumber]=newOutputPort;
      result=pair[1];
      ArrayList<MidiReceiver> receivers=mInputPortReceivers[portNumber];
synchronized (receivers) {
        for (int i=0; i < receivers.size(); i++) {
          newOutputPort.connect(receivers.get(i));
        }
      }
    }
 catch (    IOException e) {
      Log.e(TAG,"String_Node_Str");
      return null;
    }
  }
  return result;
}
Program: 195570
Project: 195570
Buggy source:
@Override public void run(){
  byte[] buffer=new byte[MAX_PACKED_MESSAGE_SIZE];
  ArrayList<MidiReceiver> deadReceivers=new ArrayList<MidiReceiver>();
  try {
    while (true) {
      int count=mInputStream.read(buffer);
      if (count < MIN_PACKED_MESSAGE_SIZE || count > MAX_PACKED_MESSAGE_SIZE) {
        Log.e(TAG,"String_Node_Str" + count);
        break;
      }
      int offset=getMessageOffset(buffer,count);
      int size=getMessageSize(buffer,count);
      long timestamp=getMessageTimeStamp(buffer,count);
synchronized (mReceivers) {
        for (int i=0; i < mReceivers.size(); i++) {
          MidiReceiver receiver=mReceivers.get(i);
          try {
            receiver.onPost(buffer,offset,size,timestamp);
          }
 catch (          IOException e) {
            Log.e(TAG,"String_Node_Str");
            deadReceivers.add(receiver);
          }
        }
        if (deadReceivers.size() > 0) {
          for (          MidiReceiver receiver : deadReceivers) {
            mReceivers.remove(receiver);
            mReceiverCount--;
          }
          deadReceivers.clear();
        }
        if (mReceiverCount == 0) {
          break;
        }
      }
    }
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str");
    IoUtils.closeQuietly(mInputStream);
    onIOException();
  }
}

Fixed version (ground truth):
@Override public void run(){
  byte[] buffer=new byte[MAX_PACKED_MESSAGE_SIZE];
  ArrayList<MidiReceiver> deadReceivers=new ArrayList<MidiReceiver>();
  try {
    while (true) {
      int count=mInputStream.read(buffer);
      if (count < 0) {
        break;
      }
 else       if (count < MIN_PACKED_MESSAGE_SIZE || count > MAX_PACKED_MESSAGE_SIZE) {
        Log.e(TAG,"String_Node_Str" + count);
        continue;
      }
      int offset=getMessageOffset(buffer,count);
      int size=getMessageSize(buffer,count);
      long timestamp=getMessageTimeStamp(buffer,count);
synchronized (mReceivers) {
        for (int i=0; i < mReceivers.size(); i++) {
          MidiReceiver receiver=mReceivers.get(i);
          try {
            receiver.onPost(buffer,offset,size,timestamp);
          }
 catch (          IOException e) {
            Log.e(TAG,"String_Node_Str");
            deadReceivers.add(receiver);
          }
        }
        if (deadReceivers.size() > 0) {
          for (          MidiReceiver receiver : deadReceivers) {
            mReceivers.remove(receiver);
            mReceiverCount--;
          }
          deadReceivers.clear();
        }
        if (mReceiverCount == 0) {
          break;
        }
      }
    }
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str");
    IoUtils.closeQuietly(mInputStream);
    onIOException();
  }
}
Program: 195571
Project: 195571
Buggy source:
@Override public void run(){
  byte[] buffer=new byte[3];
  try {
    while (true) {
      for (int index=0; index < mPollFDs.length; index++) {
        StructPollfd pfd=mPollFDs[index];
        if ((pfd.revents & OsConstants.POLLIN) != 0) {
          pfd.revents=0;
          int count=readMessage(buffer,index);
          mOutputPortReceivers[index].onPost(buffer,0,count,System.nanoTime());
        }
      }
      Os.poll(mPollFDs,-1);
    }
  }
 catch (  IOException e) {
    Log.d(TAG,"String_Node_Str");
  }
catch (  ErrnoException e) {
    Log.d(TAG,"String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void run(){
  byte[] buffer=new byte[3];
  try {
    boolean done=false;
    while (!done) {
      for (int index=0; index < mPollFDs.length; index++) {
        StructPollfd pfd=mPollFDs[index];
        if ((pfd.revents & OsConstants.POLLIN) != 0) {
          pfd.revents=0;
          int count=readMessage(buffer,index);
          mOutputPortReceivers[index].onPost(buffer,0,count,System.nanoTime());
        }
 else         if ((pfd.revents & (OsConstants.POLLERR | OsConstants.POLLHUP)) != 0) {
          done=true;
        }
      }
      Os.poll(mPollFDs,-1);
    }
  }
 catch (  IOException e) {
    Log.d(TAG,"String_Node_Str");
  }
catch (  ErrnoException e) {
    Log.d(TAG,"String_Node_Str");
  }
}
Program: 195573
Project: 195573
Buggy source:
@Override public ParcelFileDescriptor openInputPort(int portNumber){
  if (portNumber < 0 || portNumber >= mInputPortCount) {
    Log.e(TAG,"String_Node_Str" + portNumber);
    return null;
  }
  ParcelFileDescriptor result=null;
  MidiOutputPort newOutputPort=null;
synchronized (mInputPortSenders) {
    if (mInputPortSenders[portNumber] != null) {
      Log.d(TAG,"String_Node_Str" + portNumber + "String_Node_Str");
      return null;
    }
    try {
      ParcelFileDescriptor[] pair=ParcelFileDescriptor.createSocketPair(OsConstants.SOCK_SEQPACKET);
      newOutputPort=new ServerOutputPort(pair[0],portNumber);
      mInputPortSenders[portNumber]=newOutputPort;
      result=pair[1];
    }
 catch (    IOException e) {
      Log.e(TAG,"String_Node_Str");
      return null;
    }
    if (newOutputPort != null) {
      ArrayList<MidiReceiver> receivers=mInputPortReceivers[portNumber];
synchronized (receivers) {
        for (int i=0; i < receivers.size(); i++) {
          newOutputPort.connect(receivers.get(i));
        }
      }
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public ParcelFileDescriptor openInputPort(int portNumber){
  if (portNumber < 0 || portNumber >= mInputPortCount) {
    Log.e(TAG,"String_Node_Str" + portNumber);
    return null;
  }
  ParcelFileDescriptor result=null;
synchronized (mInputPortSenders) {
    if (mInputPortSenders[portNumber] != null) {
      Log.d(TAG,"String_Node_Str" + portNumber + "String_Node_Str");
      return null;
    }
    try {
      ParcelFileDescriptor[] pair=ParcelFileDescriptor.createSocketPair(OsConstants.SOCK_SEQPACKET);
      MidiOutputPort newOutputPort=new ServerOutputPort(pair[0],portNumber);
      mInputPortSenders[portNumber]=newOutputPort;
      result=pair[1];
      ArrayList<MidiReceiver> receivers=mInputPortReceivers[portNumber];
synchronized (receivers) {
        for (int i=0; i < receivers.size(); i++) {
          newOutputPort.connect(receivers.get(i));
        }
      }
    }
 catch (    IOException e) {
      Log.e(TAG,"String_Node_Str");
      return null;
    }
  }
  return result;
}
Program: 195574
Project: 195574
Buggy source:
@Override public void run(){
  byte[] buffer=new byte[MAX_PACKED_MESSAGE_SIZE];
  ArrayList<MidiReceiver> deadReceivers=new ArrayList<MidiReceiver>();
  try {
    while (true) {
      int count=mInputStream.read(buffer);
      if (count < MIN_PACKED_MESSAGE_SIZE || count > MAX_PACKED_MESSAGE_SIZE) {
        Log.e(TAG,"String_Node_Str" + count);
        break;
      }
      int offset=getMessageOffset(buffer,count);
      int size=getMessageSize(buffer,count);
      long timestamp=getMessageTimeStamp(buffer,count);
synchronized (mReceivers) {
        for (int i=0; i < mReceivers.size(); i++) {
          MidiReceiver receiver=mReceivers.get(i);
          try {
            receiver.onPost(buffer,offset,size,timestamp);
          }
 catch (          IOException e) {
            Log.e(TAG,"String_Node_Str");
            deadReceivers.add(receiver);
          }
        }
        if (deadReceivers.size() > 0) {
          for (          MidiReceiver receiver : deadReceivers) {
            mReceivers.remove(receiver);
            mReceiverCount--;
          }
          deadReceivers.clear();
        }
        if (mReceiverCount == 0) {
          break;
        }
      }
    }
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str");
    IoUtils.closeQuietly(mInputStream);
    onIOException();
  }
}

Fixed version (ground truth):
@Override public void run(){
  byte[] buffer=new byte[MAX_PACKED_MESSAGE_SIZE];
  ArrayList<MidiReceiver> deadReceivers=new ArrayList<MidiReceiver>();
  try {
    while (true) {
      int count=mInputStream.read(buffer);
      if (count < 0) {
        break;
      }
 else       if (count < MIN_PACKED_MESSAGE_SIZE || count > MAX_PACKED_MESSAGE_SIZE) {
        Log.e(TAG,"String_Node_Str" + count);
        continue;
      }
      int offset=getMessageOffset(buffer,count);
      int size=getMessageSize(buffer,count);
      long timestamp=getMessageTimeStamp(buffer,count);
synchronized (mReceivers) {
        for (int i=0; i < mReceivers.size(); i++) {
          MidiReceiver receiver=mReceivers.get(i);
          try {
            receiver.onPost(buffer,offset,size,timestamp);
          }
 catch (          IOException e) {
            Log.e(TAG,"String_Node_Str");
            deadReceivers.add(receiver);
          }
        }
        if (deadReceivers.size() > 0) {
          for (          MidiReceiver receiver : deadReceivers) {
            mReceivers.remove(receiver);
            mReceiverCount--;
          }
          deadReceivers.clear();
        }
        if (mReceiverCount == 0) {
          break;
        }
      }
    }
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str");
    IoUtils.closeQuietly(mInputStream);
    onIOException();
  }
}
Program: 195575
Project: 195575
Buggy source:
@Override public void run(){
  byte[] buffer=new byte[3];
  try {
    while (true) {
      for (int index=0; index < mPollFDs.length; index++) {
        StructPollfd pfd=mPollFDs[index];
        if ((pfd.revents & OsConstants.POLLIN) != 0) {
          pfd.revents=0;
          int count=readMessage(buffer,index);
          mOutputPortReceivers[index].onPost(buffer,0,count,System.nanoTime());
        }
      }
      Os.poll(mPollFDs,-1);
    }
  }
 catch (  IOException e) {
    Log.d(TAG,"String_Node_Str");
  }
catch (  ErrnoException e) {
    Log.d(TAG,"String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void run(){
  byte[] buffer=new byte[3];
  try {
    boolean done=false;
    while (!done) {
      for (int index=0; index < mPollFDs.length; index++) {
        StructPollfd pfd=mPollFDs[index];
        if ((pfd.revents & OsConstants.POLLIN) != 0) {
          pfd.revents=0;
          int count=readMessage(buffer,index);
          mOutputPortReceivers[index].onPost(buffer,0,count,System.nanoTime());
        }
 else         if ((pfd.revents & (OsConstants.POLLERR | OsConstants.POLLHUP)) != 0) {
          done=true;
        }
      }
      Os.poll(mPollFDs,-1);
    }
  }
 catch (  IOException e) {
    Log.d(TAG,"String_Node_Str");
  }
catch (  ErrnoException e) {
    Log.d(TAG,"String_Node_Str");
  }
}
Program: 195577
Project: 195577
Buggy source:
/** 
 * Constructs a new   {@code PrintWriter} with {@code pr} as its targetprinter and a custom buffer size.  Because a  {@link Printer} is line-base,autoflush is always enabled.
 * @param pr the target writer.
 * @param bufferLen specifies the size of the FastPrintWriter's internal buffer; the default is 512.
 * @throws NullPointerException if  {@code pr} is {@code null}.
 */
public FastPrintWriter(Printer pr,int bufferLen){
  super(sDummyWriter,true);
  if (pr == null) {
    throw new NullPointerException("String_Node_Str");
  }
  mBufferLen=bufferLen;
  mText=new char[bufferLen];
  mBytes=null;
  mOutputStream=null;
  mWriter=null;
  mPrinter=pr;
  mAutoFlush=true;
  mSeparator=System.lineSeparator();
  initDefaultEncoder();
}

Fixed version (ground truth):
/** 
 * Constructs a new   {@code PrintWriter} with {@code pr} as its targetprinter and a custom buffer size.  Because a  {@link Printer} is line-base,autoflush is always enabled.
 * @param pr the target writer.
 * @param bufferLen specifies the size of the FastPrintWriter's internal buffer; the default is 512.
 * @throws NullPointerException if  {@code pr} is {@code null}.
 */
public FastPrintWriter(Printer pr,int bufferLen){
  super(new DummyWriter(),true);
  if (pr == null) {
    throw new NullPointerException("String_Node_Str");
  }
  mBufferLen=bufferLen;
  mText=new char[bufferLen];
  mBytes=null;
  mOutputStream=null;
  mWriter=null;
  mPrinter=pr;
  mAutoFlush=true;
  mSeparator=System.lineSeparator();
  initDefaultEncoder();
}
Program: 195580
Project: 195580
Buggy source:
@Override public void addPackageDependency(String packageName){
synchronized (this) {
    int callingPid=Binder.getCallingPid();
    if (callingPid == Process.myPid()) {
      Slog.w(TAG,"String_Node_Str");
      return;
    }
    ProcessRecord proc;
synchronized (mPidsSelfLocked) {
      proc=mPidsSelfLocked.get(Binder.getCallingPid());
    }
    if (proc != null) {
      if (proc.pkgDeps == null) {
        proc.pkgDeps=new ArraySet<String>(1);
      }
      proc.pkgDeps.add(packageName);
    }
  }
}

Fixed version (ground truth):
@Override public void addPackageDependency(String packageName){
synchronized (this) {
    int callingPid=Binder.getCallingPid();
    if (callingPid == Process.myPid()) {
      return;
    }
    ProcessRecord proc;
synchronized (mPidsSelfLocked) {
      proc=mPidsSelfLocked.get(Binder.getCallingPid());
    }
    if (proc != null) {
      if (proc.pkgDeps == null) {
        proc.pkgDeps=new ArraySet<String>(1);
      }
      proc.pkgDeps.add(packageName);
    }
  }
}
Program: 195583
Project: 195583
Buggy source:
@Override protected void onServiceAdded(ManagedServiceInfo info){
  Slog.d(TAG,"String_Node_Str" + info);
  final IConditionProvider provider=provider(info);
  try {
    provider.onConnected();
  }
 catch (  RemoteException e) {
  }
synchronized (mMutex) {
    if (info.component.equals(mExitConditionComponent)) {
      final ConditionRecord manualRecord=getRecordLocked(mExitCondition.id,mExitConditionComponent);
      manualRecord.isManual=true;
    }
    final int N=mRecords.size();
    for (int i=0; i < N; i++) {
      final ConditionRecord r=mRecords.get(i);
      if (!r.component.equals(info.component))       continue;
      r.info=info;
      if (r.isAutomatic || r.isManual) {
        subscribeLocked(r);
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void onServiceAdded(ManagedServiceInfo info){
  final IConditionProvider provider=provider(info);
  try {
    provider.onConnected();
  }
 catch (  RemoteException e) {
  }
synchronized (mMutex) {
    if (info.component.equals(mExitConditionComponent)) {
      final ConditionRecord manualRecord=getRecordLocked(mExitCondition.id,mExitConditionComponent);
      manualRecord.isManual=true;
    }
    final int N=mRecords.size();
    for (int i=0; i < N; i++) {
      final ConditionRecord r=mRecords.get(i);
      if (!r.component.equals(info.component))       continue;
      r.info=info;
      if (r.isAutomatic || r.isManual) {
        subscribeLocked(r);
      }
    }
  }
}
Program: 195584
Project: 195584
Buggy source:
/** 
 * Constructs a new   {@code PrintWriter} with {@code pr} as its targetprinter and a custom buffer size.  Because a  {@link Printer} is line-base,autoflush is always enabled.
 * @param pr the target writer.
 * @param bufferLen specifies the size of the FastPrintWriter's internal buffer; the default is 512.
 * @throws NullPointerException if  {@code pr} is {@code null}.
 */
public FastPrintWriter(Printer pr,int bufferLen){
  super(sDummyWriter,true);
  if (pr == null) {
    throw new NullPointerException("String_Node_Str");
  }
  mBufferLen=bufferLen;
  mText=new char[bufferLen];
  mBytes=null;
  mOutputStream=null;
  mWriter=null;
  mPrinter=pr;
  mAutoFlush=true;
  mSeparator=System.lineSeparator();
  initDefaultEncoder();
}

Fixed version (ground truth):
/** 
 * Constructs a new   {@code PrintWriter} with {@code pr} as its targetprinter and a custom buffer size.  Because a  {@link Printer} is line-base,autoflush is always enabled.
 * @param pr the target writer.
 * @param bufferLen specifies the size of the FastPrintWriter's internal buffer; the default is 512.
 * @throws NullPointerException if  {@code pr} is {@code null}.
 */
public FastPrintWriter(Printer pr,int bufferLen){
  super(new DummyWriter(),true);
  if (pr == null) {
    throw new NullPointerException("String_Node_Str");
  }
  mBufferLen=bufferLen;
  mText=new char[bufferLen];
  mBytes=null;
  mOutputStream=null;
  mWriter=null;
  mPrinter=pr;
  mAutoFlush=true;
  mSeparator=System.lineSeparator();
  initDefaultEncoder();
}
Program: 195587
Project: 195587
Buggy source:
@Override public void addPackageDependency(String packageName){
synchronized (this) {
    int callingPid=Binder.getCallingPid();
    if (callingPid == Process.myPid()) {
      Slog.w(TAG,"String_Node_Str");
      return;
    }
    ProcessRecord proc;
synchronized (mPidsSelfLocked) {
      proc=mPidsSelfLocked.get(Binder.getCallingPid());
    }
    if (proc != null) {
      if (proc.pkgDeps == null) {
        proc.pkgDeps=new ArraySet<String>(1);
      }
      proc.pkgDeps.add(packageName);
    }
  }
}

Fixed version (ground truth):
@Override public void addPackageDependency(String packageName){
synchronized (this) {
    int callingPid=Binder.getCallingPid();
    if (callingPid == Process.myPid()) {
      return;
    }
    ProcessRecord proc;
synchronized (mPidsSelfLocked) {
      proc=mPidsSelfLocked.get(Binder.getCallingPid());
    }
    if (proc != null) {
      if (proc.pkgDeps == null) {
        proc.pkgDeps=new ArraySet<String>(1);
      }
      proc.pkgDeps.add(packageName);
    }
  }
}
Program: 195590
Project: 195590
Buggy source:
@Override protected void onServiceAdded(ManagedServiceInfo info){
  Slog.d(TAG,"String_Node_Str" + info);
  final IConditionProvider provider=provider(info);
  try {
    provider.onConnected();
  }
 catch (  RemoteException e) {
  }
synchronized (mMutex) {
    if (info.component.equals(mExitConditionComponent)) {
      final ConditionRecord manualRecord=getRecordLocked(mExitCondition.id,mExitConditionComponent);
      manualRecord.isManual=true;
    }
    final int N=mRecords.size();
    for (int i=0; i < N; i++) {
      final ConditionRecord r=mRecords.get(i);
      if (!r.component.equals(info.component))       continue;
      r.info=info;
      if (r.isAutomatic || r.isManual) {
        subscribeLocked(r);
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void onServiceAdded(ManagedServiceInfo info){
  final IConditionProvider provider=provider(info);
  try {
    provider.onConnected();
  }
 catch (  RemoteException e) {
  }
synchronized (mMutex) {
    if (info.component.equals(mExitConditionComponent)) {
      final ConditionRecord manualRecord=getRecordLocked(mExitCondition.id,mExitConditionComponent);
      manualRecord.isManual=true;
    }
    final int N=mRecords.size();
    for (int i=0; i < N; i++) {
      final ConditionRecord r=mRecords.get(i);
      if (!r.component.equals(info.component))       continue;
      r.info=info;
      if (r.isAutomatic || r.isManual) {
        subscribeLocked(r);
      }
    }
  }
}
Program: 195591
Project: 195591
Buggy source:
/** 
 * Constructs a new   {@code PrintWriter} with {@code pr} as its targetprinter and a custom buffer size.  Because a  {@link Printer} is line-base,autoflush is always enabled.
 * @param pr the target writer.
 * @param bufferLen specifies the size of the FastPrintWriter's internal buffer; the default is 512.
 * @throws NullPointerException if  {@code pr} is {@code null}.
 */
public FastPrintWriter(Printer pr,int bufferLen){
  super(sDummyWriter,true);
  if (pr == null) {
    throw new NullPointerException("String_Node_Str");
  }
  mBufferLen=bufferLen;
  mText=new char[bufferLen];
  mBytes=null;
  mOutputStream=null;
  mWriter=null;
  mPrinter=pr;
  mAutoFlush=true;
  mSeparator=System.lineSeparator();
  initDefaultEncoder();
}

Fixed version (ground truth):
/** 
 * Constructs a new   {@code PrintWriter} with {@code pr} as its targetprinter and a custom buffer size.  Because a  {@link Printer} is line-base,autoflush is always enabled.
 * @param pr the target writer.
 * @param bufferLen specifies the size of the FastPrintWriter's internal buffer; the default is 512.
 * @throws NullPointerException if  {@code pr} is {@code null}.
 */
public FastPrintWriter(Printer pr,int bufferLen){
  super(new DummyWriter(),true);
  if (pr == null) {
    throw new NullPointerException("String_Node_Str");
  }
  mBufferLen=bufferLen;
  mText=new char[bufferLen];
  mBytes=null;
  mOutputStream=null;
  mWriter=null;
  mPrinter=pr;
  mAutoFlush=true;
  mSeparator=System.lineSeparator();
  initDefaultEncoder();
}
Program: 195594
Project: 195594
Buggy source:
@Override public void addPackageDependency(String packageName){
synchronized (this) {
    int callingPid=Binder.getCallingPid();
    if (callingPid == Process.myPid()) {
      Slog.w(TAG,"String_Node_Str");
      return;
    }
    ProcessRecord proc;
synchronized (mPidsSelfLocked) {
      proc=mPidsSelfLocked.get(Binder.getCallingPid());
    }
    if (proc != null) {
      if (proc.pkgDeps == null) {
        proc.pkgDeps=new ArraySet<String>(1);
      }
      proc.pkgDeps.add(packageName);
    }
  }
}

Fixed version (ground truth):
@Override public void addPackageDependency(String packageName){
synchronized (this) {
    int callingPid=Binder.getCallingPid();
    if (callingPid == Process.myPid()) {
      return;
    }
    ProcessRecord proc;
synchronized (mPidsSelfLocked) {
      proc=mPidsSelfLocked.get(Binder.getCallingPid());
    }
    if (proc != null) {
      if (proc.pkgDeps == null) {
        proc.pkgDeps=new ArraySet<String>(1);
      }
      proc.pkgDeps.add(packageName);
    }
  }
}
Program: 195597
Project: 195597
Buggy source:
@Override protected void onServiceAdded(ManagedServiceInfo info){
  Slog.d(TAG,"String_Node_Str" + info);
  final IConditionProvider provider=provider(info);
  try {
    provider.onConnected();
  }
 catch (  RemoteException e) {
  }
synchronized (mMutex) {
    if (info.component.equals(mExitConditionComponent)) {
      final ConditionRecord manualRecord=getRecordLocked(mExitCondition.id,mExitConditionComponent);
      manualRecord.isManual=true;
    }
    final int N=mRecords.size();
    for (int i=0; i < N; i++) {
      final ConditionRecord r=mRecords.get(i);
      if (!r.component.equals(info.component))       continue;
      r.info=info;
      if (r.isAutomatic || r.isManual) {
        subscribeLocked(r);
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void onServiceAdded(ManagedServiceInfo info){
  final IConditionProvider provider=provider(info);
  try {
    provider.onConnected();
  }
 catch (  RemoteException e) {
  }
synchronized (mMutex) {
    if (info.component.equals(mExitConditionComponent)) {
      final ConditionRecord manualRecord=getRecordLocked(mExitCondition.id,mExitConditionComponent);
      manualRecord.isManual=true;
    }
    final int N=mRecords.size();
    for (int i=0; i < N; i++) {
      final ConditionRecord r=mRecords.get(i);
      if (!r.component.equals(info.component))       continue;
      r.info=info;
      if (r.isAutomatic || r.isManual) {
        subscribeLocked(r);
      }
    }
  }
}
Program: 195598
Project: 195598
Buggy source:
/** 
 * Constructs a new   {@code PrintWriter} with {@code pr} as its targetprinter and a custom buffer size.  Because a  {@link Printer} is line-base,autoflush is always enabled.
 * @param pr the target writer.
 * @param bufferLen specifies the size of the FastPrintWriter's internal buffer; the default is 512.
 * @throws NullPointerException if  {@code pr} is {@code null}.
 */
public FastPrintWriter(Printer pr,int bufferLen){
  super(sDummyWriter,true);
  if (pr == null) {
    throw new NullPointerException("String_Node_Str");
  }
  mBufferLen=bufferLen;
  mText=new char[bufferLen];
  mBytes=null;
  mOutputStream=null;
  mWriter=null;
  mPrinter=pr;
  mAutoFlush=true;
  mSeparator=System.lineSeparator();
  initDefaultEncoder();
}

Fixed version (ground truth):
/** 
 * Constructs a new   {@code PrintWriter} with {@code pr} as its targetprinter and a custom buffer size.  Because a  {@link Printer} is line-base,autoflush is always enabled.
 * @param pr the target writer.
 * @param bufferLen specifies the size of the FastPrintWriter's internal buffer; the default is 512.
 * @throws NullPointerException if  {@code pr} is {@code null}.
 */
public FastPrintWriter(Printer pr,int bufferLen){
  super(new DummyWriter(),true);
  if (pr == null) {
    throw new NullPointerException("String_Node_Str");
  }
  mBufferLen=bufferLen;
  mText=new char[bufferLen];
  mBytes=null;
  mOutputStream=null;
  mWriter=null;
  mPrinter=pr;
  mAutoFlush=true;
  mSeparator=System.lineSeparator();
  initDefaultEncoder();
}
Program: 195601
Project: 195601
Buggy source:
@Override public void addPackageDependency(String packageName){
synchronized (this) {
    int callingPid=Binder.getCallingPid();
    if (callingPid == Process.myPid()) {
      Slog.w(TAG,"String_Node_Str");
      return;
    }
    ProcessRecord proc;
synchronized (mPidsSelfLocked) {
      proc=mPidsSelfLocked.get(Binder.getCallingPid());
    }
    if (proc != null) {
      if (proc.pkgDeps == null) {
        proc.pkgDeps=new ArraySet<String>(1);
      }
      proc.pkgDeps.add(packageName);
    }
  }
}

Fixed version (ground truth):
@Override public void addPackageDependency(String packageName){
synchronized (this) {
    int callingPid=Binder.getCallingPid();
    if (callingPid == Process.myPid()) {
      return;
    }
    ProcessRecord proc;
synchronized (mPidsSelfLocked) {
      proc=mPidsSelfLocked.get(Binder.getCallingPid());
    }
    if (proc != null) {
      if (proc.pkgDeps == null) {
        proc.pkgDeps=new ArraySet<String>(1);
      }
      proc.pkgDeps.add(packageName);
    }
  }
}
Program: 195604
Project: 195604
Buggy source:
@Override protected void onServiceAdded(ManagedServiceInfo info){
  Slog.d(TAG,"String_Node_Str" + info);
  final IConditionProvider provider=provider(info);
  try {
    provider.onConnected();
  }
 catch (  RemoteException e) {
  }
synchronized (mMutex) {
    if (info.component.equals(mExitConditionComponent)) {
      final ConditionRecord manualRecord=getRecordLocked(mExitCondition.id,mExitConditionComponent);
      manualRecord.isManual=true;
    }
    final int N=mRecords.size();
    for (int i=0; i < N; i++) {
      final ConditionRecord r=mRecords.get(i);
      if (!r.component.equals(info.component))       continue;
      r.info=info;
      if (r.isAutomatic || r.isManual) {
        subscribeLocked(r);
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void onServiceAdded(ManagedServiceInfo info){
  final IConditionProvider provider=provider(info);
  try {
    provider.onConnected();
  }
 catch (  RemoteException e) {
  }
synchronized (mMutex) {
    if (info.component.equals(mExitConditionComponent)) {
      final ConditionRecord manualRecord=getRecordLocked(mExitCondition.id,mExitConditionComponent);
      manualRecord.isManual=true;
    }
    final int N=mRecords.size();
    for (int i=0; i < N; i++) {
      final ConditionRecord r=mRecords.get(i);
      if (!r.component.equals(info.component))       continue;
      r.info=info;
      if (r.isAutomatic || r.isManual) {
        subscribeLocked(r);
      }
    }
  }
}
Program: 195605
Project: 195605
Buggy source:
/** 
 * Constructs a new   {@code PrintWriter} with {@code pr} as its targetprinter and a custom buffer size.  Because a  {@link Printer} is line-base,autoflush is always enabled.
 * @param pr the target writer.
 * @param bufferLen specifies the size of the FastPrintWriter's internal buffer; the default is 512.
 * @throws NullPointerException if  {@code pr} is {@code null}.
 */
public FastPrintWriter(Printer pr,int bufferLen){
  super(sDummyWriter,true);
  if (pr == null) {
    throw new NullPointerException("String_Node_Str");
  }
  mBufferLen=bufferLen;
  mText=new char[bufferLen];
  mBytes=null;
  mOutputStream=null;
  mWriter=null;
  mPrinter=pr;
  mAutoFlush=true;
  mSeparator=System.lineSeparator();
  initDefaultEncoder();
}

Fixed version (ground truth):
/** 
 * Constructs a new   {@code PrintWriter} with {@code pr} as its targetprinter and a custom buffer size.  Because a  {@link Printer} is line-base,autoflush is always enabled.
 * @param pr the target writer.
 * @param bufferLen specifies the size of the FastPrintWriter's internal buffer; the default is 512.
 * @throws NullPointerException if  {@code pr} is {@code null}.
 */
public FastPrintWriter(Printer pr,int bufferLen){
  super(new DummyWriter(),true);
  if (pr == null) {
    throw new NullPointerException("String_Node_Str");
  }
  mBufferLen=bufferLen;
  mText=new char[bufferLen];
  mBytes=null;
  mOutputStream=null;
  mWriter=null;
  mPrinter=pr;
  mAutoFlush=true;
  mSeparator=System.lineSeparator();
  initDefaultEncoder();
}
Program: 195608
Project: 195608
Buggy source:
@Override public void addPackageDependency(String packageName){
synchronized (this) {
    int callingPid=Binder.getCallingPid();
    if (callingPid == Process.myPid()) {
      Slog.w(TAG,"String_Node_Str");
      return;
    }
    ProcessRecord proc;
synchronized (mPidsSelfLocked) {
      proc=mPidsSelfLocked.get(Binder.getCallingPid());
    }
    if (proc != null) {
      if (proc.pkgDeps == null) {
        proc.pkgDeps=new ArraySet<String>(1);
      }
      proc.pkgDeps.add(packageName);
    }
  }
}

Fixed version (ground truth):
@Override public void addPackageDependency(String packageName){
synchronized (this) {
    int callingPid=Binder.getCallingPid();
    if (callingPid == Process.myPid()) {
      return;
    }
    ProcessRecord proc;
synchronized (mPidsSelfLocked) {
      proc=mPidsSelfLocked.get(Binder.getCallingPid());
    }
    if (proc != null) {
      if (proc.pkgDeps == null) {
        proc.pkgDeps=new ArraySet<String>(1);
      }
      proc.pkgDeps.add(packageName);
    }
  }
}
Program: 195611
Project: 195611
Buggy source:
@Override protected void onServiceAdded(ManagedServiceInfo info){
  Slog.d(TAG,"String_Node_Str" + info);
  final IConditionProvider provider=provider(info);
  try {
    provider.onConnected();
  }
 catch (  RemoteException e) {
  }
synchronized (mMutex) {
    if (info.component.equals(mExitConditionComponent)) {
      final ConditionRecord manualRecord=getRecordLocked(mExitCondition.id,mExitConditionComponent);
      manualRecord.isManual=true;
    }
    final int N=mRecords.size();
    for (int i=0; i < N; i++) {
      final ConditionRecord r=mRecords.get(i);
      if (!r.component.equals(info.component))       continue;
      r.info=info;
      if (r.isAutomatic || r.isManual) {
        subscribeLocked(r);
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void onServiceAdded(ManagedServiceInfo info){
  final IConditionProvider provider=provider(info);
  try {
    provider.onConnected();
  }
 catch (  RemoteException e) {
  }
synchronized (mMutex) {
    if (info.component.equals(mExitConditionComponent)) {
      final ConditionRecord manualRecord=getRecordLocked(mExitCondition.id,mExitConditionComponent);
      manualRecord.isManual=true;
    }
    final int N=mRecords.size();
    for (int i=0; i < N; i++) {
      final ConditionRecord r=mRecords.get(i);
      if (!r.component.equals(info.component))       continue;
      r.info=info;
      if (r.isAutomatic || r.isManual) {
        subscribeLocked(r);
      }
    }
  }
}
Program: 195615
Project: 195615
Buggy source:
public void shutdownLocked(){
  writeSyncLocked();
  mShuttingDown=true;
}

Fixed version (ground truth):
public void shutdownLocked(){
  recordShutdownLocked(SystemClock.elapsedRealtime(),SystemClock.uptimeMillis());
  writeSyncLocked();
  mShuttingDown=true;
}
Program: 195616
Project: 195616
Buggy source:
@Override public UserInfo getProfileParent(int userHandle){
  checkManageUsersPermission("String_Node_Str");
synchronized (mPackagesLock) {
    UserInfo profile=getUserInfoLocked(userHandle);
    int parentUserId=profile.profileGroupId;
    if (parentUserId == UserInfo.NO_PROFILE_GROUP_ID) {
      return null;
    }
 else {
      return getUserInfoLocked(parentUserId);
    }
  }
}

Fixed version (ground truth):
@Override public UserInfo getProfileParent(int userHandle){
  checkManageUsersPermission("String_Node_Str");
synchronized (mPackagesLock) {
    UserInfo profile=getUserInfoLocked(userHandle);
    if (profile == null) {
      return null;
    }
    int parentUserId=profile.profileGroupId;
    if (parentUserId == UserInfo.NO_PROFILE_GROUP_ID) {
      return null;
    }
 else {
      return getUserInfoLocked(parentUserId);
    }
  }
}
Program: 195620
Project: 195620
Buggy source:
public void shutdownLocked(){
  writeSyncLocked();
  mShuttingDown=true;
}

Fixed version (ground truth):
public void shutdownLocked(){
  recordShutdownLocked(SystemClock.elapsedRealtime(),SystemClock.uptimeMillis());
  writeSyncLocked();
  mShuttingDown=true;
}
Program: 195621
Project: 195621
Buggy source:
@Override public UserInfo getProfileParent(int userHandle){
  checkManageUsersPermission("String_Node_Str");
synchronized (mPackagesLock) {
    UserInfo profile=getUserInfoLocked(userHandle);
    int parentUserId=profile.profileGroupId;
    if (parentUserId == UserInfo.NO_PROFILE_GROUP_ID) {
      return null;
    }
 else {
      return getUserInfoLocked(parentUserId);
    }
  }
}

Fixed version (ground truth):
@Override public UserInfo getProfileParent(int userHandle){
  checkManageUsersPermission("String_Node_Str");
synchronized (mPackagesLock) {
    UserInfo profile=getUserInfoLocked(userHandle);
    if (profile == null) {
      return null;
    }
    int parentUserId=profile.profileGroupId;
    if (parentUserId == UserInfo.NO_PROFILE_GROUP_ID) {
      return null;
    }
 else {
      return getUserInfoLocked(parentUserId);
    }
  }
}
Program: 195625
Project: 195625
Buggy source:
public void shutdownLocked(){
  writeSyncLocked();
  mShuttingDown=true;
}

Fixed version (ground truth):
public void shutdownLocked(){
  recordShutdownLocked(SystemClock.elapsedRealtime(),SystemClock.uptimeMillis());
  writeSyncLocked();
  mShuttingDown=true;
}
Program: 195626
Project: 195626
Buggy source:
@Override public UserInfo getProfileParent(int userHandle){
  checkManageUsersPermission("String_Node_Str");
synchronized (mPackagesLock) {
    UserInfo profile=getUserInfoLocked(userHandle);
    int parentUserId=profile.profileGroupId;
    if (parentUserId == UserInfo.NO_PROFILE_GROUP_ID) {
      return null;
    }
 else {
      return getUserInfoLocked(parentUserId);
    }
  }
}

Fixed version (ground truth):
@Override public UserInfo getProfileParent(int userHandle){
  checkManageUsersPermission("String_Node_Str");
synchronized (mPackagesLock) {
    UserInfo profile=getUserInfoLocked(userHandle);
    if (profile == null) {
      return null;
    }
    int parentUserId=profile.profileGroupId;
    if (parentUserId == UserInfo.NO_PROFILE_GROUP_ID) {
      return null;
    }
 else {
      return getUserInfoLocked(parentUserId);
    }
  }
}
Program: 195630
Project: 195630
Buggy source:
public void shutdownLocked(){
  writeSyncLocked();
  mShuttingDown=true;
}

Fixed version (ground truth):
public void shutdownLocked(){
  recordShutdownLocked(SystemClock.elapsedRealtime(),SystemClock.uptimeMillis());
  writeSyncLocked();
  mShuttingDown=true;
}
Program: 195631
Project: 195631
Buggy source:
@Override public UserInfo getProfileParent(int userHandle){
  checkManageUsersPermission("String_Node_Str");
synchronized (mPackagesLock) {
    UserInfo profile=getUserInfoLocked(userHandle);
    int parentUserId=profile.profileGroupId;
    if (parentUserId == UserInfo.NO_PROFILE_GROUP_ID) {
      return null;
    }
 else {
      return getUserInfoLocked(parentUserId);
    }
  }
}

Fixed version (ground truth):
@Override public UserInfo getProfileParent(int userHandle){
  checkManageUsersPermission("String_Node_Str");
synchronized (mPackagesLock) {
    UserInfo profile=getUserInfoLocked(userHandle);
    if (profile == null) {
      return null;
    }
    int parentUserId=profile.profileGroupId;
    if (parentUserId == UserInfo.NO_PROFILE_GROUP_ID) {
      return null;
    }
 else {
      return getUserInfoLocked(parentUserId);
    }
  }
}
Program: 195635
Project: 195635
Buggy source:
public void shutdownLocked(){
  writeSyncLocked();
  mShuttingDown=true;
}

Fixed version (ground truth):
public void shutdownLocked(){
  recordShutdownLocked(SystemClock.elapsedRealtime(),SystemClock.uptimeMillis());
  writeSyncLocked();
  mShuttingDown=true;
}
Program: 195636
Project: 195636
Buggy source:
@Override public UserInfo getProfileParent(int userHandle){
  checkManageUsersPermission("String_Node_Str");
synchronized (mPackagesLock) {
    UserInfo profile=getUserInfoLocked(userHandle);
    int parentUserId=profile.profileGroupId;
    if (parentUserId == UserInfo.NO_PROFILE_GROUP_ID) {
      return null;
    }
 else {
      return getUserInfoLocked(parentUserId);
    }
  }
}

Fixed version (ground truth):
@Override public UserInfo getProfileParent(int userHandle){
  checkManageUsersPermission("String_Node_Str");
synchronized (mPackagesLock) {
    UserInfo profile=getUserInfoLocked(userHandle);
    if (profile == null) {
      return null;
    }
    int parentUserId=profile.profileGroupId;
    if (parentUserId == UserInfo.NO_PROFILE_GROUP_ID) {
      return null;
    }
 else {
      return getUserInfoLocked(parentUserId);
    }
  }
}
Program: 195642
Project: 195642
Buggy source:
private void positionSelector(int position,View sel,boolean manageHotspot,float x,float y){
  final boolean positionChanged=position != mSelectorPosition;
  if (position != INVALID_POSITION) {
    mSelectorPosition=position;
  }
  final Rect selectorRect=mSelectorRect;
  selectorRect.set(sel.getLeft(),sel.getTop(),sel.getRight(),sel.getBottom());
  if (sel instanceof SelectionBoundsAdjuster) {
    ((SelectionBoundsAdjuster)sel).adjustListItemSelectionBounds(selectorRect);
  }
  selectorRect.left-=mSelectionLeftPadding;
  selectorRect.top-=mSelectionTopPadding;
  selectorRect.right+=mSelectionRightPadding;
  selectorRect.bottom+=mSelectionBottomPadding;
  final Drawable selector=mSelector;
  if (selector != null) {
    if (positionChanged) {
      selector.setVisible(false,false);
      selector.setState(StateSet.NOTHING);
    }
    selector.setBounds(selectorRect);
    if (positionChanged) {
      if (getVisibility() == VISIBLE) {
        selector.setVisible(true,false);
      }
      selector.setState(getDrawableState());
    }
    if (manageHotspot) {
      selector.setHotspot(x,y);
    }
  }
  final boolean isChildViewEnabled=mIsChildViewEnabled;
  if (sel.isEnabled() != isChildViewEnabled) {
    mIsChildViewEnabled=!isChildViewEnabled;
    if (getSelectedItemPosition() != INVALID_POSITION) {
      refreshDrawableState();
    }
  }
}

Fixed version (ground truth):
private void positionSelector(int position,View sel,boolean manageHotspot,float x,float y){
  final boolean positionChanged=position != mSelectorPosition;
  if (position != INVALID_POSITION) {
    mSelectorPosition=position;
  }
  final Rect selectorRect=mSelectorRect;
  selectorRect.set(sel.getLeft(),sel.getTop(),sel.getRight(),sel.getBottom());
  if (sel instanceof SelectionBoundsAdjuster) {
    ((SelectionBoundsAdjuster)sel).adjustListItemSelectionBounds(selectorRect);
  }
  selectorRect.left-=mSelectionLeftPadding;
  selectorRect.top-=mSelectionTopPadding;
  selectorRect.right+=mSelectionRightPadding;
  selectorRect.bottom+=mSelectionBottomPadding;
  final Drawable selector=mSelector;
  if (selector != null) {
    if (positionChanged) {
      selector.setVisible(false,false);
      selector.setState(StateSet.NOTHING);
    }
    selector.setBounds(selectorRect);
    if (positionChanged) {
      if (getVisibility() == VISIBLE) {
        selector.setVisible(true,false);
      }
      updateSelectorState();
    }
    if (manageHotspot) {
      selector.setHotspot(x,y);
    }
  }
  final boolean isChildViewEnabled=mIsChildViewEnabled;
  if (sel.isEnabled() != isChildViewEnabled) {
    mIsChildViewEnabled=!isChildViewEnabled;
    if (getSelectedItemPosition() != INVALID_POSITION) {
      refreshDrawableState();
    }
  }
}
Program: 195643
Project: 195643
Buggy source:
private void positionSelector(int position,View sel,boolean manageHotspot,float x,float y){
  final boolean positionChanged=position != mSelectorPosition;
  if (position != INVALID_POSITION) {
    mSelectorPosition=position;
  }
  final Rect selectorRect=mSelectorRect;
  selectorRect.set(sel.getLeft(),sel.getTop(),sel.getRight(),sel.getBottom());
  if (sel instanceof SelectionBoundsAdjuster) {
    ((SelectionBoundsAdjuster)sel).adjustListItemSelectionBounds(selectorRect);
  }
  selectorRect.left-=mSelectionLeftPadding;
  selectorRect.top-=mSelectionTopPadding;
  selectorRect.right+=mSelectionRightPadding;
  selectorRect.bottom+=mSelectionBottomPadding;
  final Drawable selector=mSelector;
  if (selector != null) {
    if (positionChanged) {
      selector.setVisible(false,false);
      selector.setState(StateSet.NOTHING);
    }
    selector.setBounds(selectorRect);
    if (positionChanged) {
      if (getVisibility() == VISIBLE) {
        selector.setVisible(true,false);
      }
      selector.setState(getDrawableState());
    }
    if (manageHotspot) {
      selector.setHotspot(x,y);
    }
  }
  final boolean isChildViewEnabled=mIsChildViewEnabled;
  if (sel.isEnabled() != isChildViewEnabled) {
    mIsChildViewEnabled=!isChildViewEnabled;
    if (getSelectedItemPosition() != INVALID_POSITION) {
      refreshDrawableState();
    }
  }
}

Fixed version (ground truth):
private void positionSelector(int position,View sel,boolean manageHotspot,float x,float y){
  final boolean positionChanged=position != mSelectorPosition;
  if (position != INVALID_POSITION) {
    mSelectorPosition=position;
  }
  final Rect selectorRect=mSelectorRect;
  selectorRect.set(sel.getLeft(),sel.getTop(),sel.getRight(),sel.getBottom());
  if (sel instanceof SelectionBoundsAdjuster) {
    ((SelectionBoundsAdjuster)sel).adjustListItemSelectionBounds(selectorRect);
  }
  selectorRect.left-=mSelectionLeftPadding;
  selectorRect.top-=mSelectionTopPadding;
  selectorRect.right+=mSelectionRightPadding;
  selectorRect.bottom+=mSelectionBottomPadding;
  final Drawable selector=mSelector;
  if (selector != null) {
    if (positionChanged) {
      selector.setVisible(false,false);
      selector.setState(StateSet.NOTHING);
    }
    selector.setBounds(selectorRect);
    if (positionChanged) {
      if (getVisibility() == VISIBLE) {
        selector.setVisible(true,false);
      }
      updateSelectorState();
    }
    if (manageHotspot) {
      selector.setHotspot(x,y);
    }
  }
  final boolean isChildViewEnabled=mIsChildViewEnabled;
  if (sel.isEnabled() != isChildViewEnabled) {
    mIsChildViewEnabled=!isChildViewEnabled;
    if (getSelectedItemPosition() != INVALID_POSITION) {
      refreshDrawableState();
    }
  }
}
Program: 195644
Project: 195644
Buggy source:
private void positionSelector(int position,View sel,boolean manageHotspot,float x,float y){
  final boolean positionChanged=position != mSelectorPosition;
  if (position != INVALID_POSITION) {
    mSelectorPosition=position;
  }
  final Rect selectorRect=mSelectorRect;
  selectorRect.set(sel.getLeft(),sel.getTop(),sel.getRight(),sel.getBottom());
  if (sel instanceof SelectionBoundsAdjuster) {
    ((SelectionBoundsAdjuster)sel).adjustListItemSelectionBounds(selectorRect);
  }
  selectorRect.left-=mSelectionLeftPadding;
  selectorRect.top-=mSelectionTopPadding;
  selectorRect.right+=mSelectionRightPadding;
  selectorRect.bottom+=mSelectionBottomPadding;
  final Drawable selector=mSelector;
  if (selector != null) {
    if (positionChanged) {
      selector.setVisible(false,false);
      selector.setState(StateSet.NOTHING);
    }
    selector.setBounds(selectorRect);
    if (positionChanged) {
      if (getVisibility() == VISIBLE) {
        selector.setVisible(true,false);
      }
      selector.setState(getDrawableState());
    }
    if (manageHotspot) {
      selector.setHotspot(x,y);
    }
  }
  final boolean isChildViewEnabled=mIsChildViewEnabled;
  if (sel.isEnabled() != isChildViewEnabled) {
    mIsChildViewEnabled=!isChildViewEnabled;
    if (getSelectedItemPosition() != INVALID_POSITION) {
      refreshDrawableState();
    }
  }
}

Fixed version (ground truth):
private void positionSelector(int position,View sel,boolean manageHotspot,float x,float y){
  final boolean positionChanged=position != mSelectorPosition;
  if (position != INVALID_POSITION) {
    mSelectorPosition=position;
  }
  final Rect selectorRect=mSelectorRect;
  selectorRect.set(sel.getLeft(),sel.getTop(),sel.getRight(),sel.getBottom());
  if (sel instanceof SelectionBoundsAdjuster) {
    ((SelectionBoundsAdjuster)sel).adjustListItemSelectionBounds(selectorRect);
  }
  selectorRect.left-=mSelectionLeftPadding;
  selectorRect.top-=mSelectionTopPadding;
  selectorRect.right+=mSelectionRightPadding;
  selectorRect.bottom+=mSelectionBottomPadding;
  final Drawable selector=mSelector;
  if (selector != null) {
    if (positionChanged) {
      selector.setVisible(false,false);
      selector.setState(StateSet.NOTHING);
    }
    selector.setBounds(selectorRect);
    if (positionChanged) {
      if (getVisibility() == VISIBLE) {
        selector.setVisible(true,false);
      }
      updateSelectorState();
    }
    if (manageHotspot) {
      selector.setHotspot(x,y);
    }
  }
  final boolean isChildViewEnabled=mIsChildViewEnabled;
  if (sel.isEnabled() != isChildViewEnabled) {
    mIsChildViewEnabled=!isChildViewEnabled;
    if (getSelectedItemPosition() != INVALID_POSITION) {
      refreshDrawableState();
    }
  }
}