#fixed code
                              @Test
  public void testExceptionForOperatioOverEndedProcess() throws Exception {
    final JBBPOut out = BeginBin();
    out.ByteOrder(JBBPByteOrder.BIG_ENDIAN).Long(0x0102030405060708L).End();
    try{
      out.Align();
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }
    
    try{
      out.Align(3);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bit(true);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bit(true,false);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bit((byte)34);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bit((byte)34,(byte)12);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bit(34,12);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bits(JBBPNumberOfBits.BITS_3, 12);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bits(JBBPNumberOfBits.BITS_3, 12,13,14);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bits(JBBPNumberOfBits.BITS_3, (byte)1,(byte)2,(byte)3);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bool(true);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bool(true,false);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Byte((byte)1,(byte)2,(byte)3);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Byte(1);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Byte(1,2,3);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.ByteOrder(JBBPByteOrder.BIG_ENDIAN);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Flush();
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Int(1);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Int(1,2);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Long(1L);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Long(1L,2L);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Short(1);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Short(1,2,3);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Short((short)1,(short)2,(short)3);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.End();
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }
  }
#vulnerable code 
                              @Test
  public void testExceptionForOperatioOverEndedProcess() throws Exception {
    final JBBPOut out = binStart();
    out.ByteOrder(JBBPByteOrder.BIG_ENDIAN).Long(0x0102030405060708L).end();
    try{
      out.Align();
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }
    
    try{
      out.Align(3);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bit(true);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bit(true,false);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bit((byte)34);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bit((byte)34,(byte)12);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bit(34,12);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bits(JBBPNumberOfBits.BITS_3, 12);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bits(JBBPNumberOfBits.BITS_3, 12,13,14);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bits(JBBPNumberOfBits.BITS_3, (byte)1,(byte)2,(byte)3);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bool(true);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Bool(true,false);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Byte((byte)1,(byte)2,(byte)3);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Byte(1);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Byte(1,2,3);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.ByteOrder(JBBPByteOrder.BIG_ENDIAN);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Flush();
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Int(1);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Int(1,2);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Long(1L);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Long(1L,2L);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Short(1);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Short(1,2,3);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.Short((short)1,(short)2,(short)3);
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }

    try{
      out.end();
      fail("Must throw ISE");
    }catch(IllegalStateException ex){
    }
  } 
                            #location 9 
                            #vulnerability type RESOURCE_LEAK