nus-yam/ex-repair huggingface dataset:
Program: 178367
Project: 178367
Buggy source:
@Override public Collection<ClanID> selectIDs(){
  return database.query(new SelectListQuery<ClanID,Integer,ClanID,QClan>(QClan.clan,mapper.getIDMapper(QClan.clan)){
    @Override protected OQueryContextNative query(    OQueryContextNative record,    QClan e){
      return record;
    }
  }
);
}

Fixed version (ground truth):
@Override public Collection<ClanID> selectIDs(){
  return database.query(new SelectListQuery<ClanID,Integer,ClanID,QClan>(QClan.clan,mapper.getIDMapper(QClan.clan)){
    @Override protected OQueryContextNative query(    OQueryContextNative record,    QClan e){
      return null;
    }
  }
);
}
Program: 178368
Project: 178368
Buggy source:
@Override public Collection<ItemID> selectIDs(){
  return database.query(new SelectListQuery<ItemID,Integer,ItemID,QItem>(QItem.item,mapper.getIDMapper(QItem.item)){
    @Override protected OQueryContextNative query(    OQueryContextNative record,    QItem e){
      return record;
    }
  }
);
}

Fixed version (ground truth):
@Override public Collection<ItemID> selectIDs(){
  return database.query(new SelectListQuery<ItemID,Integer,ItemID,QItem>(QItem.item,mapper.getIDMapper(QItem.item)){
    @Override protected OQueryContextNative query(    OQueryContextNative record,    QItem e){
      return null;
    }
  }
);
}
Program: 178369
Project: 178369
Buggy source:
@Override public Collection<NPCID> selectIDs(){
  return database.query(new SelectListQuery<NPCID,Integer,NPCID,QNPC>(QNPC.npc,mapper.getIDMapper(QNPC.npc)){
    @Override protected OQueryContextNative query(    OQueryContextNative record,    QNPC e){
      return record;
    }
  }
);
}

Fixed version (ground truth):
@Override public Collection<NPCID> selectIDs(){
  return database.query(new SelectListQuery<NPCID,Integer,NPCID,QNPC>(QNPC.npc,mapper.getIDMapper(QNPC.npc)){
    @Override protected OQueryContextNative query(    OQueryContextNative record,    QNPC e){
      return null;
    }
  }
);
}
Program: 178370
Project: 178370
Buggy source:
/** 
 * @param name The name of the new character
 * @param sex The sex of the new character
 * @param characterClass The class of the new character
 * @param hairStyle The new character hair style
 * @param hairColor The new character hair color
 * @param face The new character face
 * @return the newly created {@link L2Character} object
 * @throws CharacterInvalidNameException if the character name contains invalid characters, too long or not long enough
 * @throws CharacterInvalidAppearanceException if the appearance sent by the client is not valid
 * @throws CharacterNameAlreadyExistsException the character name is already being used
 */
L2Character create(String name,ActorSex sex,CharacterClass characterClass,CharacterHairStyle hairStyle,CharacterHairColor hairColor,CharacterFace face) throws CharacterInvalidNameException, CharacterInvalidAppearanceException, CharacterNameAlreadyExistsException ;

Fixed version (ground truth):
/** 
 * @param name The name of the new character
 * @param accountID the account ID to be used
 * @param sex The sex of the new character
 * @param characterClass The class of the new character
 * @param hairStyle The new character hair style
 * @param hairColor The new character hair color
 * @param face The new character face
 * @return the newly created {@link L2Character} object
 * @throws CharacterInvalidNameException if the character name contains invalid characters, too long or not long enough
 * @throws CharacterInvalidAppearanceException if the appearance sent by the client is not valid
 * @throws CharacterNameAlreadyExistsException the character name is already being used
 */
L2Character create(String name,AccountID accountID,ActorSex sex,CharacterClass characterClass,CharacterHairStyle hairStyle,CharacterHairColor hairColor,CharacterFace face) throws CharacterInvalidNameException, CharacterInvalidAppearanceException, CharacterNameAlreadyExistsException ;
Program: 178371
Project: 178371
Buggy source:
@Override public L2Character create(String name,ActorSex sex,CharacterClass characterClass,CharacterHairStyle hairStyle,CharacterHairColor hairColor,CharacterFace face) throws CharacterInvalidNameException, CharacterInvalidAppearanceException, CharacterNameAlreadyExistsException {
  log.debug("String_Node_Str",new Object[]{name,sex,characterClass,hairStyle,hairColor,face});
  if ((name.length() < 1) || (name.length() > 16)) {
    throw new CharacterInvalidNameException();
  }
  if (sex == null || hairStyle == null || hairColor == null || face == null)   throw new CharacterInvalidAppearanceException();
  log.debug("String_Node_Str",name);
  final L2Character existenceCheck=characterDao.selectByName(name);
  if (existenceCheck != null)   throw new CharacterNameAlreadyExistsException();
  final CharacterTemplateID templateId=charTemplateIdProvider.resolveID(characterClass.id);
  final CharacterTemplate template=templateId.getTemplate();
  log.debug("String_Node_Str",template);
  final CharacterID id=charIdProvider.createID();
  final L2Character character=template.create();
  log.debug("String_Node_Str",id,character);
  character.setID(id);
  character.setName(name);
  character.setSex(sex);
  character.getAppearance().setHairStyle(hairStyle);
  character.getAppearance().setHairColor(hairColor);
  character.getAppearance().setFace(face);
  if (characterDao.save(character) > 0)   return character;
  return null;
}

Fixed version (ground truth):
@Override public L2Character create(String name,AccountID accountID,ActorSex sex,CharacterClass characterClass,CharacterHairStyle hairStyle,CharacterHairColor hairColor,CharacterFace face) throws CharacterInvalidNameException, CharacterInvalidAppearanceException, CharacterNameAlreadyExistsException {
  log.debug("String_Node_Str",new Object[]{name,sex,characterClass,hairStyle,hairColor,face});
  if ((name.length() < 1) || (name.length() > 16)) {
    throw new CharacterInvalidNameException();
  }
  if (sex == null || hairStyle == null || hairColor == null || face == null)   throw new CharacterInvalidAppearanceException();
  log.debug("String_Node_Str",name);
  final L2Character existenceCheck=characterDao.selectByName(name);
  if (existenceCheck != null)   throw new CharacterNameAlreadyExistsException();
  final CharacterTemplateID templateId=charTemplateIdProvider.resolveID(characterClass.id);
  final CharacterTemplate template=templateId.getTemplate();
  log.debug("String_Node_Str",template);
  final CharacterID id=charIdProvider.createID();
  final L2Character character=template.create();
  log.debug("String_Node_Str",id,character);
  character.setID(id);
  character.setName(name);
  character.setAccountID(accountID);
  character.setSex(sex);
  character.setPoint(Point3D.fromXYZA(146783,25808,-2008,0));
  character.getAppearance().setHairStyle(hairStyle);
  character.getAppearance().setHairColor(hairColor);
  character.getAppearance().setFace(face);
  if (characterDao.save(character) > 0)   return character;
  return null;
}
Program: 178372
Project: 178372
Buggy source:
/** 
 * Load the pre-existing ids
 * @param ids an collection of ids
 */
private void load(Collection<? extends ObjectID<?>> ids){
  Preconditions.checkNotNull(ids,"String_Node_Str");
  log.debug("String_Node_Str",ids.size());
  for (  final ObjectID<?> id : ids) {
    log.debug("String_Node_Str",id);
    allocator.allocate(id.getID());
    add(id);
  }
}

Fixed version (ground truth):
/** 
 * Load the pre-existing ids
 * @param ids an collection of ids
 */
private void load(Collection<? extends ObjectID<?>> ids){
  Preconditions.checkNotNull(ids,"String_Node_Str");
  log.info("String_Node_Str",ids.size());
  for (  final ObjectID<?> id : ids) {
    log.debug("String_Node_Str",id);
    allocator.allocate(id.getID());
    add(id);
  }
}
Program: 178373
Project: 178373
Buggy source:
@Override protected void doStart() throws ServiceStartException {
  pool=createThreadPool("String_Node_Str",20);
  threadPools=CollectionFactory.newMap();
  pool.async(50,TimeUnit.MILLISECONDS,50,new Runnable(){
    @Override public void run(){
      for (      final Entry<String,ThreadPoolImpl> entry : threadPools.entrySet()) {
        entry.getValue().notifyListeners();
      }
    }
  }
);
}

Fixed version (ground truth):
@Override protected void doStart() throws ServiceStartException {
  threadPools=CollectionFactory.newMap();
  pool=createThreadPool("String_Node_Str",20);
  pool.async(50,TimeUnit.MILLISECONDS,50,new Runnable(){
    @Override public void run(){
      for (      final Entry<String,ThreadPoolImpl> entry : threadPools.entrySet()) {
        entry.getValue().notifyListeners();
      }
    }
  }
);
}
Program: 178374
Project: 178374
Buggy source:
/** 
 * Sends a   {@link SystemMessage} to this client
 * @param message the  {@link SystemMessage}
 * @param args the arguments of the message, they will be automatically detected and inserted. See  {@link SM_SYSTEM_MESSAGE} for moreabout supported formats.
 * @return the {@link ChannelFuture} that will be notified once the packethas been written.
 * @see SM_SYSTEM_MESSAGE
 */
public ChannelFuture sendSystemMessage(SystemMessage message,Object... args){
  final SM_SYSTEM_MESSAGE packet=new SM_SYSTEM_MESSAGE(message);
  for (  final Object obj : args) {
    if (obj instanceof String)     packet.addString((String)obj);
 else     if (obj instanceof ItemTemplate)     packet.addItem((ItemTemplate)obj);
 else     if (obj instanceof Item)     packet.addItem((Item)obj);
 else     if (obj instanceof Number)     packet.addNumber((Integer)obj);
  }
  return write(packet);
}

Fixed version (ground truth):
/** 
 * Sends a   {@link SystemMessage} to this client
 * @param message the  {@link SystemMessage}
 * @param args the arguments of the message, they will be automatically detected and inserted. See  {@link SM_SYSTEM_MESSAGE} for moreabout supported formats.
 * @return the {@link ChannelFuture} that will be notified once the packethas been written.
 * @see SM_SYSTEM_MESSAGE
 */
public ChannelFuture sendSystemMessage(SystemMessage message,Object... args){
  final SM_SYSTEM_MESSAGE packet=new SM_SYSTEM_MESSAGE(message);
  for (  final Object obj : args) {
    if (obj instanceof String)     packet.addString((String)obj);
 else     if (obj instanceof ItemTemplate)     packet.addItem((ItemTemplate)obj);
 else     if (obj instanceof Item)     packet.addItem((Item)obj);
 else     if (obj instanceof Number)     packet.addNumber((Integer)obj);
 else     if (obj instanceof Skill)     packet.addSkill((Skill)obj);
 else     if (obj instanceof Fort)     packet.addFort((Fort)obj);
  }
  return write(packet);
}
Program: 178375
Project: 178375
Buggy source:
/** 
 * Creates a new instance
 * @param worldService the world service
 * @param networkService the network service
 * @param channel the channel
 */
public Lineage2Client(WorldService worldService,NetworkService networkService,Channel channel){
  this.worldService=worldService;
  this.networkService=networkService;
  this.channel=channel;
}

Fixed version (ground truth):
/** 
 * Creates a new instance
 * @param channel the channel
 */
public Lineage2Client(Channel channel){
  this.channel=channel;
}
Program: 178376
Project: 178376
Buggy source:
@Override public ChannelPipeline getPipeline() throws Exception {
  final ChannelPipeline pipeline=pipeline();
  pipeline.addLast("String_Node_Str",new Lineage2FrameEncoder());
  pipeline.addLast("String_Node_Str",new Lineage2FrameDecoder());
  pipeline.addLast(Lineage2Encrypter.HANDLER_NAME,new Lineage2Encrypter());
  pipeline.addLast(Lineage2Decrypter.HANDLER_NAME,new Lineage2Decrypter());
  pipeline.addLast(Lineage2PacketWriter.HANDLER_NAME,new Lineage2PacketWriter());
  pipeline.addLast(Lineage2PacketReader.HANDLER_NAME,new Lineage2PacketReader(injector));
  pipeline.addLast("String_Node_Str",new LoggingHandler(InternalLogLevel.DEBUG,true));
  final Lineage2TimeoutHandler timeoutHandler=new Lineage2TimeoutHandler();
  pipeline.addLast("String_Node_Str",new Lineage2PacketHandler(nettyNetworkService,worldService,timeoutHandler));
  return pipeline;
}

Fixed version (ground truth):
@Override public ChannelPipeline getPipeline() throws Exception {
  final ChannelPipeline pipeline=pipeline();
  pipeline.addLast("String_Node_Str",new Lineage2FrameEncoder());
  pipeline.addLast("String_Node_Str",new Lineage2FrameDecoder());
  pipeline.addLast(Lineage2Encrypter.HANDLER_NAME,new Lineage2Encrypter());
  pipeline.addLast(Lineage2Decrypter.HANDLER_NAME,new Lineage2Decrypter());
  pipeline.addLast(Lineage2PacketWriter.HANDLER_NAME,new Lineage2PacketWriter());
  pipeline.addLast(Lineage2PacketReader.HANDLER_NAME,new Lineage2PacketReader(injector));
  pipeline.addLast("String_Node_Str",new LoggingHandler(InternalLogLevel.DEBUG,true));
  final Lineage2TimeoutHandler timeoutHandler=new Lineage2TimeoutHandler();
  pipeline.addLast("String_Node_Str",new Lineage2PacketHandler(nettyNetworkService,timeoutHandler));
  return pipeline;
}
Program: 178377
Project: 178377
Buggy source:
/** 
 * Creates a new instance of this pipeline
 * @param injector the  {@link Guice} {@link Injector}
 * @param networkService the network service
 * @param worldService the world service
 */
@Inject public Lineage2PipelineFactory(Injector injector,NetworkService networkService,WorldService worldService){
  this.injector=injector;
  this.nettyNetworkService=(NettyNetworkService)networkService;
  this.worldService=worldService;
}

Fixed version (ground truth):
/** 
 * Creates a new instance of this pipeline
 * @param injector the  {@link Guice} {@link Injector}
 * @param networkService the network service
 */
@Inject public Lineage2PipelineFactory(Injector injector,NetworkService networkService){
  this.injector=injector;
  this.nettyNetworkService=(NettyNetworkService)networkService;
}
Program: 178378
Project: 178378
Buggy source:
/** 
 * Creates a new instance of the packet handler
 * @param nettyNetworkService the netty network service
 * @param worldService the world service
 * @param timeoutHandler the timeout handler
 */
public Lineage2PacketHandler(NettyNetworkService nettyNetworkService,WorldService worldService,Lineage2TimeoutHandler timeoutHandler){
  this.nettyNetworkService=nettyNetworkService;
  this.worldService=worldService;
  this.timeoutHandler=timeoutHandler;
}

Fixed version (ground truth):
/** 
 * Creates a new instance of the packet handler
 * @param nettyNetworkService the netty network service
 * @param timeoutHandler the timeout handler
 */
public Lineage2PacketHandler(NettyNetworkService nettyNetworkService,Lineage2TimeoutHandler timeoutHandler){
  this.nettyNetworkService=nettyNetworkService;
  this.timeoutHandler=timeoutHandler;
}
Program: 178379
Project: 178379
Buggy source:
@Override public void channelOpen(ChannelHandlerContext ctx,ChannelStateEvent e) throws Exception {
  connection=new Lineage2Client(worldService,nettyNetworkService,e.getChannel());
  connection.getPacketWriter().setConnection(connection);
  timeoutHandler.setConnection(connection);
  nettyNetworkService.register(connection);
  super.channelOpen(ctx,e);
}

Fixed version (ground truth):
@Override public void channelOpen(ChannelHandlerContext ctx,ChannelStateEvent e) throws Exception {
  connection=new Lineage2Client(e.getChannel());
  connection.getPacketWriter().setConnection(connection);
  timeoutHandler.setConnection(connection);
  nettyNetworkService.register(connection);
  super.channelOpen(ctx,e);
}
Program: 178380
Project: 178380
Buggy source:
@Override public void write(Lineage2Client conn,ChannelBuffer buffer){
  buffer.writeShort((showWindow ? 0x01 : 0x00));
  buffer.writeShort(inventory.getItemCount());
  int slot=0;
  for (  Item item : inventory) {
    if (item.getLocation() == ItemLocation.WAREHOUSE || item.getLocation() == ItemLocation.GROUND || item.getLocation() == null) {
      continue;
    }
    buffer.writeInt(item.getID().getID());
    buffer.writeInt(item.getTemplateID().getID());
    buffer.writeInt(slot);
    buffer.writeLong(item.getCount());
    buffer.writeShort(0x00);
    buffer.writeShort(0x00);
    buffer.writeShort((item.getLocation() == ItemLocation.PAPERDOLL ? 0x01 : 0x00));
    buffer.writeInt((item.getPaperdoll() != null ? item.getPaperdoll().id : 0));
    buffer.writeShort(127);
    buffer.writeShort(0x00);
    buffer.writeInt(0x00);
    buffer.writeInt(0x00);
    buffer.writeInt(-9999);
    buffer.writeShort(0x00);
    buffer.writeShort(0x00);
    for (byte i=0; i < 6; i++) {
      buffer.writeShort(0x00);
    }
    buffer.writeShort(0x00);
    buffer.writeShort(0x00);
    buffer.writeShort(0x00);
    slot++;
  }
  buffer.writeShort(0x00);
}

Fixed version (ground truth):
@Override public void write(Lineage2Client conn,ChannelBuffer buffer){
  buffer.writeShort((showWindow ? 0x01 : 0x00));
  buffer.writeShort(inventory.getItemCount());
  int slot=0;
  for (  Item item : inventory) {
    buffer.writeInt(item.getID().getID());
    buffer.writeInt(item.getTemplateID().getID());
    buffer.writeInt(slot);
    buffer.writeLong(item.getCount());
    buffer.writeShort(0x00);
    buffer.writeShort(0x00);
    buffer.writeShort((item.getLocation() == ItemLocation.PAPERDOLL ? 0x01 : 0x00));
    buffer.writeInt((item.getPaperdoll() != null ? item.getPaperdoll().id : 0));
    buffer.writeShort(127);
    buffer.writeShort(0x00);
    buffer.writeInt(0x00);
    buffer.writeInt(0x00);
    buffer.writeInt(-9999);
    buffer.writeShort(0x00);
    buffer.writeShort(0x00);
    for (byte i=0; i < 6; i++) {
      buffer.writeShort(0x00);
    }
    buffer.writeShort(0x00);
    buffer.writeShort(0x00);
    buffer.writeShort(0x00);
    slot++;
  }
  buffer.writeShort(0x00);
}
Program: 178381
Project: 178381
Buggy source:
@Override protected void doStart() throws ServiceStartException {
  items=itemDao.loadDroppedItems();
  try {
    for (    final Item item : items) {
      spawnService.spawn(item,null);
    }
  }
 catch (  SpawnPointNotFoundServiceException e) {
    throw new ServiceStartException(e);
  }
catch (  AlreadySpawnedServiceException e) {
    throw new ServiceStartException(e);
  }
}

Fixed version (ground truth):
@Override protected void doStart() throws ServiceStartException {
  items=itemDao.selectDroppedItems();
  try {
    for (    final Item item : items) {
      spawnService.spawn(item,null);
    }
  }
 catch (  SpawnPointNotFoundServiceException e) {
    throw new ServiceStartException(e);
  }
catch (  AlreadySpawnedServiceException e) {
    throw new ServiceStartException(e);
  }
}
Program: 178382
Project: 178382
Buggy source:
/** 
 * @param configService the configuration service
 * @param injector the  {@link Guice} {@link Injector}
 * @param worldService the world service
 */
@Inject public NettyNetworkService(ConfigurationService configService,Injector injector,WorldService worldService){
  this.config=configService.get(NetworkConfiguration.class);
  this.injector=injector;
  this.worldService=worldService;
  InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
}

Fixed version (ground truth):
/** 
 * @param configService the configuration service
 * @param injector the  {@link Guice} {@link Injector}
 */
@Inject public NettyNetworkService(ConfigurationService configService,Injector injector){
  this.config=configService.get(NetworkConfiguration.class);
  this.injector=injector;
  InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
}
Program: 178383
Project: 178383
Buggy source:
@Override protected void doStart(){
  server=new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool()));
  server.setPipelineFactory(new Lineage2PipelineFactory(injector,this,worldService));
  channel=(ServerChannel)server.bind(config.getListenAddress());
}

Fixed version (ground truth):
@Override protected void doStart(){
  server=new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool()));
  server.setPipelineFactory(new Lineage2PipelineFactory(injector,this));
  channel=(ServerChannel)server.bind(config.getListenAddress());
}
Program: 178384
Project: 178384
Buggy source:
@Override protected void configure(){
  install(new ServiceModule());
  install(new IDFactoryModule());
  install(new DAOModuleMySQL5());
}

Fixed version (ground truth):
@Override protected void configure(){
  install(new ServiceModule());
  install(new IDFactoryModule());
  install(new MySQL5DAOModule());
}
Program: 178385
Project: 178385
Buggy source:
public Lineage2CryptographyKey copy(){
  return new Lineage2CryptographyKey(key);
}

Fixed version (ground truth):
public Lineage2CryptographyKey copy(){
  return new Lineage2CryptographyKey(Arrays.copyOf(key,key.length));
}
Program: 178386
Project: 178386
Buggy source:
@Override protected Object encode(ChannelHandlerContext ctx,Channel channel,Object msg) throws Exception {
  if (!(msg instanceof ChannelBuffer))   return msg;
  if (!enabled)   return msg;
  final ChannelBuffer buffer=(ChannelBuffer)msg;
  final int offset=buffer.readerIndex() + 2;
  final int size=buffer.readableBytes() - 2;
  int temp=0;
synchronized (key) {
    for (int i=0; i < size; i++) {
      int temp2=buffer.getByte(offset + i) & 0xFF;
      buffer.setByte(offset + i,(byte)(temp2 ^ key.get(i) ^ temp));
      temp=temp2;
    }
    key.update(size);
  }
  return msg;
}

Fixed version (ground truth):
@Override protected Object encode(ChannelHandlerContext ctx,Channel channel,Object msg) throws Exception {
  if (!(msg instanceof ChannelBuffer))   return msg;
  if (!enabled)   return msg;
  final ChannelBuffer buffer=(ChannelBuffer)msg;
  final int offset=buffer.readerIndex() + 2;
  final int size=buffer.readableBytes() - 2;
  int temp=0, temp2=0;
synchronized (key) {
    for (int i=0; i < size; i++) {
      temp2=buffer.getByte(offset + i) & 0xFF;
      temp=temp2 ^ key.get(i) ^ temp;
      buffer.setByte(offset + i,(byte)temp);
    }
    key.update(size);
  }
  return msg;
}
Program: 178387
Project: 178387
Buggy source:
@Override protected Object encode(ChannelHandlerContext ctx,Channel channel,Object msg) throws Exception {
  if (!(msg instanceof ServerPacket))   return msg;
  final ChannelBuffer buffer=ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN,10);
  final ServerPacket packet=(ServerPacket)msg;
  buffer.writeShort(0x0000);
  buffer.writeByte(packet.getOpcode());
  packet.write(null,buffer);
  log.debug("String_Node_Str",ChannelBuffers.hexDump(buffer));
  return buffer;
}

Fixed version (ground truth):
@Override protected Object encode(ChannelHandlerContext ctx,Channel channel,Object msg) throws Exception {
  if (!(msg instanceof ServerPacket))   return msg;
  final ChannelBuffer buffer=ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN,10);
  final ServerPacket packet=(ServerPacket)msg;
  buffer.writeShort(0);
  buffer.writeByte(packet.getOpcode());
  packet.write(connection,buffer);
  log.debug("String_Node_Str",ChannelBuffers.hexDump(buffer));
  return buffer;
}
Program: 178388
Project: 178388
Buggy source:
@Override public void process(final Lineage2Connection conn){
  final AccountID accountId=accountIdFactory.createID(loginName);
  conn.setSession(new Lineage2Session(accountId,playKey1,playKey2,loginKey1,loginKey2));
  final List<L2Character> chars=characterDao.selectByAccount(accountId);
  conn.setCharacterID(chars.get(0).getID());
  conn.write(new CharacterEnterWorldPacket(chars.get(0),playKey1));
}

Fixed version (ground truth):
@Override public void process(final Lineage2Connection conn){
  final AccountID accountId=accountIdFactory.createID(loginName);
  conn.setSession(new Lineage2Session(accountId,playKey1,playKey2,loginKey1,loginKey2));
  final List<L2Character> chars=characterDao.selectByAccount(accountId);
  conn.write(CharacterSelectionListPacket.fromL2Session(conn.getSession(),chars.get(0)));
}
Program: 178390
Project: 178390
Buggy source:
/** 
 * Writes an unicode string to the buffer
 * @param buffer the buffer
 * @param str the string
 */
public static final void writeString(ChannelBuffer buffer,String str){
  if (str != null && str.length() > 0) {
    final int len=str.length();
    for (int i=0; i < len; i++) {
      buffer.writeChar(str.charAt(i));
    }
  }
  buffer.writeChar('\000');
}

Fixed version (ground truth):
/** 
 * Writes an unicode string to the buffer
 * @param buffer the buffer
 * @param str the string
 */
public static final void writeString(ChannelBuffer buffer,String str){
  if (str != null && str.length() > 0) {
    final int len=str.length();
    for (int i=0; i < len; i++) {
      buffer.writeChar(str.charAt(i));
    }
  }
  buffer.writeShort(0);
}
Program: 178391
Project: 178391
Buggy source:
@Before public void tearUp() throws ServiceStartException {
  Injector injector=Guice.createInjector(new ServiceModule(),new DAOModuleMySQL5(),new IDFactoryModule(),new AbstractModule(){
    @Override protected void configure(){
      bind(WorldService.class).to(WorldServiceImpl.class).in(Scopes.SINGLETON);
      bind(WorldEventDispatcher.class).to(WorldEventDispatcherImpl.class).in(Scopes.SINGLETON);
    }
  }
);
  cidFactory=injector.getInstance(CharacterIDFactory.class);
  iidFactory=injector.getInstance(ItemIDFactory.class);
  world=injector.getInstance(WorldService.class);
  dispatcher=injector.getInstance(WorldEventDispatcher.class);
  Assert.assertNotNull(world);
  Assert.assertNotNull(dispatcher);
  world.start();
}

Fixed version (ground truth):
@Before public void tearUp() throws ServiceStartException {
  Injector injector=Guice.createInjector(new ServiceModule(),new MySQL5DAOModule(),new IDFactoryModule(),new AbstractModule(){
    @Override protected void configure(){
      bind(WorldService.class).to(WorldServiceImpl.class).in(Scopes.SINGLETON);
      bind(WorldEventDispatcher.class).to(WorldEventDispatcherImpl.class).in(Scopes.SINGLETON);
    }
  }
);
  cidFactory=injector.getInstance(CharacterIDFactory.class);
  iidFactory=injector.getInstance(ItemIDFactory.class);
  world=injector.getInstance(WorldService.class);
  dispatcher=injector.getInstance(WorldEventDispatcher.class);
  Assert.assertNotNull(world);
  Assert.assertNotNull(dispatcher);
  world.start();
}
Program: 178392
Project: 178392
Buggy source:
@Override public void run(){
  if (timeout > 0) {
synchronized (timeoutLock) {
      try {
        timeoutLock.wait(timeout);
        exit("String_Node_Str",2);
      }
 catch (      InterruptedException e) {
        Thread.interrupted();
      }
    }
  }
 else {
  }
}

Fixed version (ground truth):
@Override public void run(){
  if (timeout > 0) {
synchronized (timeoutLock) {
      if (!closed) {
        try {
          timeoutLock.wait(timeout);
          exit("String_Node_Str",2);
        }
 catch (        InterruptedException e) {
          Thread.interrupted();
        }
      }
    }
  }
}
Program: 178393
Project: 178393
Buggy source:
private String consumeOptions(Scanner scanner){
  String buffer=null;
  do {
    buffer=scanner.next();
    if (buffer.startsWith("String_Node_Str")) {
      String timeout=buffer.substring("String_Node_Str".length());
      this.timeout=Integer.parseInt(timeout);
      buffer=scanner.next();
    }
 else     if (buffer.startsWith("String_Node_Str")) {
      String evtMask=buffer.substring("String_Node_Str".length());
      eventMask=EnumSet.noneOf(Event.class);
      for (      char c : evtMask.toCharArray()) {
        Event evt=Event.resolveFromChar(c);
        if (evt != null) {
          eventMask.add(evt);
        }
      }
    }
  }
 while (buffer.startsWith("String_Node_Str"));
  return buffer;
}

Fixed version (ground truth):
private String consumeOptions(Scanner scanner){
  String buffer=null;
  do {
    buffer=scanner.next();
    if (buffer.startsWith("String_Node_Str")) {
      String timeoutValue=buffer.substring("String_Node_Str".length());
      this.timeout=Integer.parseInt(timeoutValue);
      buffer=scanner.next();
    }
 else     if (buffer.startsWith("String_Node_Str")) {
      String evtMask=buffer.substring("String_Node_Str".length());
      eventMask=EnumSet.noneOf(Event.class);
      for (      char c : evtMask.toCharArray()) {
        Event evt=Event.resolveFromChar(c);
        if (evt != null) {
          eventMask.add(evt);
        }
      }
    }
  }
 while (buffer.startsWith("String_Node_Str"));
  return buffer;
}
Program: 178394
Project: 178394
Buggy source:
@Override public WaitForCommand command(String command) throws Exception {
  queueService.addCallback(this);
  Scanner scanner=new Scanner(command);
  check(scanner.next(),"String_Node_Str");
  check(scanner.next(),"String_Node_Str");
  check(command,scanner.hasNext());
  String buffer=consumeOptions(scanner);
  String repo=buffer;
  check(command,scanner.hasNext());
  String sha1=scanner.next();
  checkSha1(sha1);
  sha1s.add(sha1);
  while (scanner.hasNext()) {
    sha1=scanner.next();
    checkSha1(sha1);
    sha1s.add(sha1);
  }
  this.repo=createRepository(repo);
  return this;
}

Fixed version (ground truth):
@Override public WaitForCommand command(String command) throws Exception {
  queueService.addCallback(this);
  Scanner scanner=new Scanner(command);
  check(scanner.next(),"String_Node_Str");
  check(scanner.next(),"String_Node_Str");
  check(command,scanner.hasNext());
  String buffer=consumeOptions(scanner);
  String repoValue=buffer;
  check(command,scanner.hasNext());
  String sha1=scanner.next();
  checkSha1(sha1);
  sha1s.add(sha1);
  while (scanner.hasNext()) {
    sha1=scanner.next();
    checkSha1(sha1);
    sha1s.add(sha1);
  }
  this.repo=createRepository(repoValue);
  return this;
}
Program: 178395
Project: 178395
Buggy source:
private void exit(String msg,int exitCode){
  if (closed)   return;
  try {
    out.write(msg.getBytes());
    out.write('\n');
    out.flush();
    sha1s.clear();
    callback.onExit(exitCode);
  }
 catch (  IOException e) {
    callback.onExit(1);
  }
}

Fixed version (ground truth):
private void exit(String msg,int exitCode){
  if (closed) {
    return;
  }
  try {
    out.write(msg.getBytes());
    out.write('\n');
    out.flush();
    sha1s.clear();
    callback.onExit(exitCode);
  }
 catch (  IOException e) {
    callback.onExit(1);
  }
}
Program: 178396
Project: 178396
Buggy source:
public void close(){
synchronized (timeoutLock) {
    closed=true;
    timeoutLock.notify();
  }
}

Fixed version (ground truth):
public void close(){
synchronized (timeoutLock) {
    closed=true;
    timeoutLock.notifyAll();
  }
}
Program: 178397
Project: 178397
Buggy source:
public BuildTask(Context ctx,RepositoryGuard guard,UserIdentity user,TimeService timeService,Repository remote,Pair<Repository,String> target,String command){
  this.gitUtils=ctx.getGitUtils();
  this.guard=guard;
  this.user=user;
  this.timeService=timeService;
  this.remote=remote;
  this.target=target;
  this.repository=target.getT();
  this.command=command;
}

Fixed version (ground truth):
public BuildTask(Context ctx,RepositoryGuard guard,UserIdentity user,TimeService timeService,Repository remote,Pair<Repository,String> target,String commandTreeSha1){
  this.gitUtils=ctx.getGitUtils();
  this.guard=guard;
  this.user=user;
  this.timeService=timeService;
  this.remote=remote;
  this.target=target;
  this.repository=target.getT();
  this.commandTreeSHA1=commandTreeSha1;
}
Program: 178398
Project: 178398
Buggy source:
String findCommand() throws AmbiguousObjectException, IOException {
  return gitUtils.show(this.repository,this.command + "String_Node_Str" + "String_Node_Str");
}

Fixed version (ground truth):
String findCommand() throws IOException {
  return gitUtils.show(this.repository,this.commandTreeSHA1 + "String_Node_Str" + "String_Node_Str");
}
Program: 178399
Project: 178399
Buggy source:
@Override public Date getSubmitDate(){
  return this.submitDate;
}

Fixed version (ground truth):
@Override public Date getSubmitDate(){
  if (submitDate == null) {
    return null;
  }
  return new Date(this.submitDate.getTime());
}
Program: 178400
Project: 178400
Buggy source:
private int build(ByteArrayOutputStream stdout,PrintStream printOut) throws AmbiguousObjectException, IOException, ExecuteException {
  String command=findCommand();
  printOut.println(String.format("String_Node_Str",command));
  CommandLine cmdLine=CommandLine.parse(command);
  DefaultExecutor executable=new DefaultExecutor();
  executable.setWorkingDirectory(repository.getDirectory().getParentFile());
  executable.setStreamHandler(new PumpStreamHandler(stdout));
  int exitCode=executable.execute(cmdLine);
  return exitCode;
}

Fixed version (ground truth):
private int build(ByteArrayOutputStream stdout,PrintStream printOut) throws IOException {
  String command=findCommand();
  printOut.println(String.format("String_Node_Str",command));
  CommandLine cmdLine=CommandLine.parse(command);
  DefaultExecutor executable=new DefaultExecutor();
  executable.setWorkingDirectory(repository.getDirectory().getParentFile());
  executable.setStreamHandler(new PumpStreamHandler(stdout));
  return executable.execute(cmdLine);
}
Program: 178401
Project: 178401
Buggy source:
void endOfTreatment(BuildResult buildResult,int exitCode,boolean success){
  buildResult.setEndDate(new Date());
  buildResult.setSuccess(success);
  buildResult.setExitCode(exitCode);
  try {
    String message="String_Node_Str";
    if (success) {
      message=String.format("String_Node_Str",exitCode);
    }
 else {
      message=String.format("String_Node_Str",exitCode);
    }
    new DefaultExecutor().execute(CommandLine.parse(message));
  }
 catch (  ExecuteException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
void endOfTreatment(BuildResult buildResult,int exitCode,boolean success){
  buildResult.setEndDate(new Date());
  buildResult.setSuccess(success);
  buildResult.setExitCode(exitCode);
  try {
    String message="String_Node_Str";
    if (success) {
      message=String.format("String_Node_Str");
    }
 else {
      message=String.format("String_Node_Str",exitCode);
    }
    new DefaultExecutor().execute(CommandLine.parse(message));
  }
 catch (  ExecuteException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 178402
Project: 178402
Buggy source:
@Override public void setSubmitDate(Date d){
  this.submitDate=d;
}

Fixed version (ground truth):
@Override public void setSubmitDate(Date d){
  if (d == null) {
    this.submitDate=null;
  }
 else {
    this.submitDate=new Date(d.getTime());
  }
}
Program: 178403
Project: 178403
Buggy source:
public ThxEntity(World world){
  super(world);
  preventEntitySpawning=true;
  prevTime=System.nanoTime();
  minecraft=ModLoader.getMinecraftInstance();
  log("String_Node_Str" + world);
  sidedHelper=createEntityHelper();
}

Fixed version (ground truth):
public ThxEntity(World world){
  super(world);
  preventEntitySpawning=true;
  prevTime=System.nanoTime();
  minecraft=ModLoader.getMinecraftInstance();
  log("String_Node_Str" + world.isRemote);
  sidedHelper=createEntityHelper();
}
Program: 178404
Project: 178404
Buggy source:
@Override ThxEntityHelper createEntityHelper(){
  if (worldObj.isRemote) {
    ThxModelHelicopterBase model=ThxConfig.getBoolProperty("String_Node_Str") ? new ThxModelHelicopterAlt() : new ThxModelHelicopter();
    return new ThxEntityHelperClientHelicopter(this,model);
  }
  return new ThxEntityHelperServer(this);
}

Fixed version (ground truth):
@Override ThxEntityHelper createEntityHelper(){
  if (worldObj.isRemote) {
    ThxModelHelicopterBase model=ThxConfig.getBoolProperty("String_Node_Str") ? new ThxModelHelicopterAlt() : new ThxModelHelicopter();
    return new ThxEntityHelperClientHelicopter(this,model);
  }
  return new ThxEntityHelperServerHelicopter(this);
}
Program: 178405
Project: 178405
Buggy source:
@Override void pilotExit(){
  log("String_Node_Str" + (worldObj.isRemote ? "String_Node_Str" : "String_Node_Str"));
  if (riddenByEntity == null)   return;
  Entity pilot=getPilot();
  riddenByEntity.mountEntity(this);
  riddenByEntity=null;
  if (pilot != null) {
    if (pilot.ridingEntity != null)     pilot.ridingEntity.riddenByEntity=null;
    ;
    pilot.ridingEntity=null;
  }
  sidedHelper.pilotExit(pilot);
  targetEntity=null;
}

Fixed version (ground truth):
@Override void pilotExit(){
  log("String_Node_Str" + (worldObj.isRemote ? "String_Node_Str" : "String_Node_Str"));
  if (riddenByEntity == null) {
    log("String_Node_Str");
    return;
  }
  Entity pilot=getPilot();
  riddenByEntity.mountEntity(this);
  riddenByEntity=null;
  if (pilot != null) {
    if (pilot.ridingEntity != null)     pilot.ridingEntity.riddenByEntity=null;
    ;
    pilot.ridingEntity=null;
  }
  sidedHelper.pilotExit(pilot);
  targetEntity=null;
}
Program: 178406
Project: 178406
Buggy source:
@Override void pilotExit(Entity pilot){
  model.visible=true;
  model.rotorSpeed=0f;
  entity.rotationYawSpeed=0f;
  entity.rotationPitchSpeed=0f;
  entity.rotationRollSpeed=0f;
}

Fixed version (ground truth):
@Override void pilotExit(Entity pilot){
  entity.log("String_Node_Str");
  model.visible=true;
  model.rotorSpeed=0f;
  entity.rotationYawSpeed=0f;
  entity.rotationPitchSpeed=0f;
  entity.rotationRollSpeed=0f;
}
Program: 178407
Project: 178407
Buggy source:
void pilotExit(Entity pilot){
  System.out.println("String_Node_Str");
  double exitDist=1.9;
  ((EntityPlayerMP)pilot).playerNetServerHandler.setPlayerLocation(entity.posX + entity.fwd.z * exitDist,entity.posY + pilot.yOffset,entity.posZ - entity.fwd.x * exitDist,entity.rotationYaw,entity.rotationPitch);
}

Fixed version (ground truth):
void pilotExit(Entity pilot){
  entity.log("String_Node_Str");
  System.out.println("String_Node_Str");
  double exitDist=1.9;
  ((EntityPlayerMP)pilot).playerNetServerHandler.setPlayerLocation(entity.posX + entity.fwd.z * exitDist,entity.posY + pilot.yOffset,entity.posZ - entity.fwd.x * exitDist,entity.rotationYaw,entity.rotationPitch);
}
Program: 178408
Project: 178408
Buggy source:
private void applyUpdatePacketFromServer(){
  if (latestUpdatePacket == null)   return;
  Packet230ModLoader packet=latestUpdatePacket;
  latestUpdatePacket=null;
  plog("String_Node_Str" + packet);
  int packetPilotId=packet.dataInt[1];
  int playerId=minecraft.thePlayer.entityId;
  if (packetPilotId > 0 && (riddenByEntity == null || riddenByEntity.entityId != packetPilotId)) {
    Entity pilot=((WorldClient)worldObj).getEntityByID(packetPilotId);
    if (pilot != null && !pilot.isDead) {
      log("String_Node_Str" + pilot + "String_Node_Str");
      pilot.mountEntity(this);
    }
  }
 else   if (packetPilotId == 0 && riddenByEntity != null) {
    log("String_Node_Str" + riddenByEntity.entityId + "String_Node_Str");
    riddenByEntity.mountEntity(this);
  }
  int ownerId=packet.dataInt[4];
  if (ownerId > 0)   owner=(ThxEntityBase)((WorldClient)worldObj).getEntityByID(ownerId);
  log("String_Node_Str" + owner);
  serverPosX=MathHelper.floor_float(packet.dataFloat[0] * 32f);
  serverPosY=MathHelper.floor_float(packet.dataFloat[1] * 32f);
  serverPosZ=MathHelper.floor_float(packet.dataFloat[2] * 32f);
  setPositionAndRotation(packet.dataFloat[0],packet.dataFloat[1],packet.dataFloat[2],packet.dataFloat[3],packet.dataFloat[4]);
  rotationRoll=packet.dataFloat[5] % 360f;
  motionX=packet.dataFloat[6];
  motionY=packet.dataFloat[7];
  motionZ=packet.dataFloat[8];
  damage=packet.dataFloat[9];
  throttle=packet.dataFloat[10];
}

Fixed version (ground truth):
private void applyUpdatePacketFromServer(){
  if (latestUpdatePacket == null)   return;
  Packet230ModLoader packet=latestUpdatePacket;
  latestUpdatePacket=null;
  plog("String_Node_Str" + packet);
  int packetPilotId=packet.dataInt[1];
  int playerId=minecraft.thePlayer.entityId;
  if (packetPilotId > 0 && (riddenByEntity == null || riddenByEntity.entityId != packetPilotId)) {
    Entity pilot=((WorldClient)worldObj).getEntityByID(packetPilotId);
    if (pilot != null && !pilot.isDead) {
      log("String_Node_Str" + pilot + "String_Node_Str");
      pilot.mountEntity(this);
    }
  }
 else   if (packetPilotId == 0 && riddenByEntity != null) {
    log("String_Node_Str" + riddenByEntity.entityId + "String_Node_Str");
    riddenByEntity.mountEntity(this);
  }
  int ownerId=packet.dataInt[4];
  if (ownerId > 0)   owner=((WorldClient)worldObj).getEntityByID(ownerId);
  log("String_Node_Str" + owner);
  serverPosX=MathHelper.floor_float(packet.dataFloat[0] * 32f);
  serverPosY=MathHelper.floor_float(packet.dataFloat[1] * 32f);
  serverPosZ=MathHelper.floor_float(packet.dataFloat[2] * 32f);
  setPositionAndRotation(packet.dataFloat[0],packet.dataFloat[1],packet.dataFloat[2],packet.dataFloat[3],packet.dataFloat[4]);
  rotationRoll=packet.dataFloat[5] % 360f;
  motionX=packet.dataFloat[6];
  motionY=packet.dataFloat[7];
  motionZ=packet.dataFloat[8];
  damage=packet.dataFloat[9];
  throttle=packet.dataFloat[10];
}
Program: 178409
Project: 178409
Buggy source:
@Override public void HandlePacket(Packet230ModLoader packet){
  int entityId=packet.dataInt[0];
  Entity entity=((WorldClient)ModLoader.getMinecraftInstance().theWorld).getEntityByID(entityId);
  ((ThxEntity)entity).handleUpdatePacketFromServer(packet);
}

Fixed version (ground truth):
@Override public void HandlePacket(Packet230ModLoader packet){
  int entityId=packet.dataInt[0];
  if (entityId < 1)   log("String_Node_Str" + packet.packetType + "String_Node_Str"+ packet);
 else {
    Entity entity=((WorldClient)ModLoader.getMinecraftInstance().theWorld).getEntityByID(entityId);
    if (entity != null)     ((ThxEntity)entity).handleUpdatePacketFromServer(packet);
  }
}
Program: 178410
Project: 178410
Buggy source:
private void pilotExit(){
  Entity pilot=getPilot();
  model.visible=true;
  if (ENABLE_DRONE_MODE) {
    pilot.mountEntity(this);
    ((ThxModelHelicopter)model).rotorSpeed=0;
    pilot.setPosition(dronePilotPosX,dronePilotPosY,dronePilotPosZ);
    return;
  }
  ModLoader.getMinecraftInstance().gameSettings.thirdPersonView=prevThirdPersonView;
  pilot.mountEntity(this);
  ((ThxModelHelicopter)model).rotorSpeed=0;
  double exitDist=1.9;
  pilot.setPosition(posX + fwd.z * exitDist,posY + pilot.yOffset,posZ - fwd.x * exitDist);
}

Fixed version (ground truth):
private void pilotExit(){
  Entity pilot=getPilot();
  model.visible=true;
  if (ENABLE_DRONE_MODE) {
    pilot.mountEntity(this);
    ((ThxModelHelicopter)model).rotorSpeed=0;
    pilot.setPosition(dronePilotPosX,dronePilotPosY,dronePilotPosZ);
    return;
  }
  toggleLookBack=false;
  if (lookBack) {
    lookBack=false;
    pilot.prevRotationYaw=pilot.rotationYaw=pilot.rotationYaw - 180;
  }
  ModLoader.getMinecraftInstance().gameSettings.thirdPersonView=prevThirdPersonView;
  pilot.mountEntity(this);
  ((ThxModelHelicopter)model).rotorSpeed=0;
  double exitDist=1.9;
  pilot.setPosition(posX + fwd.z * exitDist,posY + pilot.yOffset,posZ - fwd.x * exitDist);
}
Program: 178411
Project: 178411
Buggy source:
@Override public void updateRiderPosition(){
  EntityPlayer pilot=getPilot();
  if (pilot == null)   return;
  prevRotationYaw=rotationYaw;
  prevRotationPitch=rotationPitch;
  if (ENABLE_DRONE_MODE) {
    pilot.setPosition(dronePilotPosX,dronePilotPosY,dronePilotPosZ);
    return;
  }
  pilot.setPosition(posX,posY + pilot.getYOffset() + getMountedYOffset(),posZ);
  if (toggleLookBack) {
    toggleLookBack=false;
    pilot.prevRotationYaw=pilot.rotationYaw=pilot.rotationYaw - 180;
    if (ENABLE_LOOK_PITCH)     pilot.prevRotationPitch=pilot.rotationPitch=-pilot.rotationPitch;
  }
}

Fixed version (ground truth):
@Override public void updateRiderPosition(){
  EntityPlayer pilot=getPilot();
  if (pilot == null)   return;
  prevRotationYaw=rotationYaw;
  prevRotationPitch=rotationPitch;
  if (ENABLE_DRONE_MODE) {
    pilot.setPosition(dronePilotPosX,dronePilotPosY,dronePilotPosZ);
    return;
  }
  pilot.setPosition(posX,posY + pilot.getYOffset() + getMountedYOffset(),posZ);
  if (toggleLookBack) {
    toggleLookBack=false;
    pilot.prevRotationYaw=pilot.rotationYaw=pilot.rotationYaw - 180;
  }
}
Program: 178413
Project: 178413
Buggy source:
@Override public Range execute(Document document){
  Range caret=document.getSelection().getRangeAt(0);
  TreeCaretPosition startSelection=treeOperationFactory.createCaretPosition(getOperation().getSiteId(),caret,caret.getStartOffset());
  TreeCaretPosition endSelection=treeOperationFactory.createCaretPosition(getOperation().getSiteId(),caret,caret.getEndOffset());
  Iterator<TreeOperation> it=((TreeCompositeOperation)getOperation()).operations.iterator();
  while (it.hasNext()) {
    TreeOperation op=it.next();
    startSelection=(TreeCaretPosition)op.transform(startSelection);
    endSelection=(TreeCaretPosition)op.transform(endSelection);
    DomOperation domOperation=domOperationFactory.createDomOperation(op,this.isRemote);
    domOperation.execute(document);
  }
  Node startContainer=EditorUtils.getChildNodeFromLocator(document.getBody(),startSelection.getPath());
  caret.setStart(startContainer,startSelection.getPosition());
  Node endContainer=EditorUtils.getChildNodeFromLocator(document.getBody(),endSelection.getPath());
  caret.setEnd(endContainer,endSelection.getPosition());
  return caret;
}

Fixed version (ground truth):
@Override public Range execute(Document document){
  Range caret=document.getSelection().getRangeAt(0);
  TreeCaretPosition startSelection=treeOperationFactory.createCaretPosition(getOperation().getSiteId(),caret,caret.getStartOffset());
  TreeCaretPosition endSelection=treeOperationFactory.createCaretPosition(getOperation().getSiteId(),caret,caret.getEndOffset());
  Iterator<TreeOperation> it=((TreeCompositeOperation)getOperation()).getOperations().iterator();
  while (it.hasNext()) {
    TreeOperation op=it.next();
    startSelection=(TreeCaretPosition)op.transform(startSelection);
    endSelection=(TreeCaretPosition)op.transform(endSelection);
    DomOperation domOperation=domOperationFactory.createDomOperation(op,this.isRemote);
    domOperation.execute(document);
  }
  Node startContainer=EditorUtils.getChildNodeFromLocator(document.getBody(),startSelection.getPath());
  caret.setStart(startContainer,startSelection.getPosition());
  Node endContainer=EditorUtils.getChildNodeFromLocator(document.getBody(),endSelection.getPath());
  caret.setEnd(endContainer,endSelection.getPosition());
  return caret;
}