Program: 48842
Project: 48842
Buggy source:
@Test public void testSingleNode(){
  final int k=1;
  final Config config=new Config();
  TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(k);
  final HazelcastInstance[] instances=factory.newInstances(config);
  ISemaphore semaphore=instances[0].getSemaphore("String_Node_Str");
  int numberOfPermits=20;
  Assert.assertTrue(semaphore.init(numberOfPermits));
  try {
    for (int i=0; i < numberOfPermits; i++) {
      Assert.assertEquals(numberOfPermits - i,semaphore.availablePermits());
      semaphore.acquire();
    }
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
  Assert.assertEquals(semaphore.availablePermits(),0);
  for (int i=0; i < numberOfPermits; i++) {
    Assert.assertEquals(i,semaphore.availablePermits());
    semaphore.release();
  }
  Assert.assertEquals(semaphore.availablePermits(),numberOfPermits);
  Assert.assertFalse(semaphore.init(numberOfPermits));
  try {
    for (int i=0; i < numberOfPermits; i+=5) {
      Assert.assertEquals(numberOfPermits - i,semaphore.availablePermits());
      semaphore.acquire(5);
    }
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
  Assert.assertEquals(semaphore.availablePermits(),0);
  for (int i=0; i < numberOfPermits; i+=5) {
    Assert.assertEquals(i,semaphore.availablePermits());
    semaphore.release(5);
  }
  Assert.assertEquals(semaphore.availablePermits(),numberOfPermits);
  Assert.assertFalse(semaphore.init(numberOfPermits));
  try {
    semaphore.acquire(5);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
  int drainedPermits=semaphore.drainPermits();
  Assert.assertEquals(drainedPermits,numberOfPermits - 5);
  Assert.assertEquals(semaphore.availablePermits(),0);
  Assert.assertTrue(semaphore.init(numberOfPermits));
  for (int i=0; i < numberOfPermits; i+=5) {
    Assert.assertEquals(numberOfPermits - i,semaphore.availablePermits());
    semaphore.reducePermits(5);
  }
  Assert.assertEquals(semaphore.availablePermits(),0);
  Assert.assertTrue(semaphore.init(numberOfPermits));
  for (int i=0; i < numberOfPermits; i++) {
    Assert.assertEquals(numberOfPermits - i,semaphore.availablePermits());
    Assert.assertEquals(semaphore.tryAcquire(),true);
  }
  Assert.assertEquals(semaphore.availablePermits(),0);
  Assert.assertTrue(semaphore.init(numberOfPermits));
  for (int i=0; i < numberOfPermits; i+=5) {
    Assert.assertEquals(numberOfPermits - i,semaphore.availablePermits());
    Assert.assertEquals(semaphore.tryAcquire(5),true);
  }
  Assert.assertEquals(semaphore.availablePermits(),0);
}

Fixed version (ground truth):
@Test public void testSingleNode(){
  final int k=1;
  final Config config=new Config();
  TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(k);
  final HazelcastInstance[] instances=factory.newInstances(config);
  ISemaphore semaphore=instances[0].getSemaphore("String_Node_Str");
  int numberOfPermits=20;
  assertTrue(semaphore.init(numberOfPermits));
  try {
    for (int i=0; i < numberOfPermits; i++) {
      Assert.assertEquals(numberOfPermits - i,semaphore.availablePermits());
      semaphore.acquire();
    }
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
  Assert.assertEquals(semaphore.availablePermits(),0);
  for (int i=0; i < numberOfPermits; i++) {
    Assert.assertEquals(i,semaphore.availablePermits());
    semaphore.release();
  }
  Assert.assertEquals(semaphore.availablePermits(),numberOfPermits);
  Assert.assertFalse(semaphore.init(numberOfPermits));
  try {
    for (int i=0; i < numberOfPermits; i+=5) {
      Assert.assertEquals(numberOfPermits - i,semaphore.availablePermits());
      semaphore.acquire(5);
    }
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
  Assert.assertEquals(semaphore.availablePermits(),0);
  for (int i=0; i < numberOfPermits; i+=5) {
    Assert.assertEquals(i,semaphore.availablePermits());
    semaphore.release(5);
  }
  Assert.assertEquals(semaphore.availablePermits(),numberOfPermits);
  Assert.assertFalse(semaphore.init(numberOfPermits));
  try {
    semaphore.acquire(5);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
  int drainedPermits=semaphore.drainPermits();
  Assert.assertEquals(drainedPermits,numberOfPermits - 5);
  Assert.assertEquals(semaphore.availablePermits(),0);
  assertTrue(semaphore.init(numberOfPermits));
  for (int i=0; i < numberOfPermits; i+=5) {
    Assert.assertEquals(numberOfPermits - i,semaphore.availablePermits());
    semaphore.reducePermits(5);
  }
  Assert.assertEquals(semaphore.availablePermits(),0);
  assertTrue(semaphore.init(numberOfPermits));
  for (int i=0; i < numberOfPermits; i++) {
    Assert.assertEquals(numberOfPermits - i,semaphore.availablePermits());
    Assert.assertEquals(semaphore.tryAcquire(),true);
  }
  Assert.assertEquals(semaphore.availablePermits(),0);
  assertTrue(semaphore.init(numberOfPermits));
  for (int i=0; i < numberOfPermits; i+=5) {
    Assert.assertEquals(numberOfPermits - i,semaphore.availablePermits());
    Assert.assertEquals(semaphore.tryAcquire(5),true);
  }
  Assert.assertEquals(semaphore.availablePermits(),0);
}