nus-yam/ex-repair huggingface dataset:
Program: 46951
Project: 46951
Buggy source:
@Override public Result getBadRequestResult(Context context,Exception exception){
  String messageI18n=messages.getWithDefault(NinjaConstant.I18N_NINJA_SYSTEM_BAD_REQUEST_TEXT_KEY,NinjaConstant.I18N_NINJA_SYSTEM_BAD_REQUEST_TEXT_DEFAULT,context,Optional.<Result>absent());
  Message message=new Message(messageI18n);
  Result result=Results.badRequest().supportedContentTypes(Result.TEXT_HTML,Result.APPLICATON_JSON,Result.APPLICATION_XML).fallbackContentType(Result.TEXT_HTML).render(message).template(NinjaConstant.LOCATION_VIEW_FTL_HTML_BAD_REQUEST);
  return result;
}

Fixed version (ground truth):
@Override public Result getBadRequestResult(Context context,Exception exception){
  String messageI18n=messages.getWithDefault(NinjaConstant.I18N_NINJA_SYSTEM_BAD_REQUEST_TEXT_KEY,NinjaConstant.I18N_NINJA_SYSTEM_BAD_REQUEST_TEXT_DEFAULT,context,Optional.<Result>absent());
  Message message=new Message(messageI18n);
  Result result=Results.badRequest().supportedContentTypes(Result.TEXT_HTML,Result.APPLICATION_JSON,Result.APPLICATION_XML).fallbackContentType(Result.TEXT_HTML).render(message).template(NinjaConstant.LOCATION_VIEW_FTL_HTML_BAD_REQUEST);
  return result;
}
Program: 46952
Project: 46952
Buggy source:
@Override public Result getNotFoundResult(Context context){
  String messageI18n=messages.getWithDefault(NinjaConstant.I18N_NINJA_SYSTEM_NOT_FOUND_TEXT_KEY,NinjaConstant.I18N_NINJA_SYSTEM_NOT_FOUND_TEXT_DEFAULT,context,Optional.<Result>absent());
  Message message=new Message(messageI18n);
  Result result=Results.notFound().supportedContentTypes(Result.TEXT_HTML,Result.APPLICATON_JSON,Result.APPLICATION_XML).fallbackContentType(Result.TEXT_HTML).render(message).template(NinjaConstant.LOCATION_VIEW_FTL_HTML_NOT_FOUND);
  return result;
}

Fixed version (ground truth):
@Override public Result getNotFoundResult(Context context){
  String messageI18n=messages.getWithDefault(NinjaConstant.I18N_NINJA_SYSTEM_NOT_FOUND_TEXT_KEY,NinjaConstant.I18N_NINJA_SYSTEM_NOT_FOUND_TEXT_DEFAULT,context,Optional.<Result>absent());
  Message message=new Message(messageI18n);
  Result result=Results.notFound().supportedContentTypes(Result.TEXT_HTML,Result.APPLICATION_JSON,Result.APPLICATION_XML).fallbackContentType(Result.TEXT_HTML).render(message).template(NinjaConstant.LOCATION_VIEW_FTL_HTML_NOT_FOUND);
  return result;
}
Program: 46953
Project: 46953
Buggy source:
/** 
 * Set the content type of this result to   {@link Result#APPLICATON_JSONP}.
 * @return the same result where you executed this method on. But the content type is now {@link Result#APPLICATON_JSONP}.
 */
public Result jsonp(){
  contentType=APPLICATON_JSONP;
  return this;
}

Fixed version (ground truth):
/** 
 * Set the content type of this result to   {@link Result#APPLICATION_JSONP}.
 * @return the same result where you executed this method on. But the content type is now {@link Result#APPLICATION_JSONP}.
 */
public Result jsonp(){
  contentType=APPLICATION_JSONP;
  return this;
}
Program: 46954
Project: 46954
Buggy source:
/** 
 * Set the content type of this result to   {@link Result#APPLICATON_JSON}.
 * @return the same result where you executed this method on. But the content type is now {@link Result#APPLICATON_JSON}.
 */
public Result json(){
  contentType=APPLICATON_JSON;
  return this;
}

Fixed version (ground truth):
/** 
 * Set the content type of this result to   {@link Result#APPLICATION_JSON}.
 * @return the same result where you executed this method on. But the content type is now {@link Result#APPLICATION_JSON}.
 */
public Result json(){
  contentType=APPLICATION_JSON;
  return this;
}
Program: 46955
Project: 46955
Buggy source:
public static Result TODO(){
  Result result=status(Result.SC_501_NOT_IMPLEMENTED);
  result.contentType(Result.APPLICATON_JSON);
  return result;
}

Fixed version (ground truth):
public static Result TODO(){
  Result result=status(Result.SC_501_NOT_IMPLEMENTED);
  result.contentType(Result.APPLICATION_JSON);
  return result;
}
Program: 46956
Project: 46956
Buggy source:
@Override public String getContentType(){
  return Result.APPLICATON_JSON;
}

Fixed version (ground truth):
@Override public String getContentType(){
  return Result.APPLICATION_JSON;
}
Program: 46957
Project: 46957
Buggy source:
@Override public String getContentType(){
  return Result.APPLICATON_JSONP;
}

Fixed version (ground truth):
@Override public String getContentType(){
  return Result.APPLICATION_JSONP;
}
Program: 46958
Project: 46958
Buggy source:
@Test public void testThatGetBadRequestContentNegotiation() throws Exception {
  Mockito.when(contextImpl.getAcceptContentType()).thenReturn(Result.APPLICATON_JSON);
  Result result=ninjaDefault.getBadRequestResult(contextImpl,new Exception("String_Node_Str"));
  assertThat(result.getContentType(),equalTo(null));
  assertThat(result.supportedContentTypes().size(),equalTo(3));
}

Fixed version (ground truth):
@Test public void testThatGetBadRequestContentNegotiation() throws Exception {
  Mockito.when(contextImpl.getAcceptContentType()).thenReturn(Result.APPLICATION_JSON);
  Result result=ninjaDefault.getBadRequestResult(contextImpl,new Exception("String_Node_Str"));
  assertThat(result.getContentType(),equalTo(null));
  assertThat(result.supportedContentTypes().size(),equalTo(3));
}
Program: 46959
Project: 46959
Buggy source:
@Test public void testThatGetInternalServerErrorContentNegotiation() throws Exception {
  Mockito.when(contextImpl.getAcceptContentType()).thenReturn(Result.APPLICATON_JSON);
  Result result=ninjaDefault.getInternalServerErrorResult(contextImpl,new Exception("String_Node_Str"));
  assertThat(result.getContentType(),equalTo(null));
  assertThat(result.supportedContentTypes().size(),equalTo(3));
}

Fixed version (ground truth):
@Test public void testThatGetInternalServerErrorContentNegotiation() throws Exception {
  Mockito.when(contextImpl.getAcceptContentType()).thenReturn(Result.APPLICATION_JSON);
  Result result=ninjaDefault.getInternalServerErrorResult(contextImpl,new Exception("String_Node_Str"));
  assertThat(result.getContentType(),equalTo(null));
  assertThat(result.supportedContentTypes().size(),equalTo(3));
}
Program: 46960
Project: 46960
Buggy source:
@Test public void testThatGetOnNotFoundDoesContentNegotiation() throws Exception {
  Mockito.when(contextImpl.getAcceptContentType()).thenReturn(Result.APPLICATON_JSON);
  Result result=ninjaDefault.getNotFoundResult(contextImpl);
  assertThat(result.getContentType(),equalTo(null));
  assertThat(result.supportedContentTypes().size(),equalTo(3));
}

Fixed version (ground truth):
@Test public void testThatGetOnNotFoundDoesContentNegotiation() throws Exception {
  Mockito.when(contextImpl.getAcceptContentType()).thenReturn(Result.APPLICATION_JSON);
  Result result=ninjaDefault.getNotFoundResult(contextImpl);
  assertThat(result.getContentType(),equalTo(null));
  assertThat(result.supportedContentTypes().size(),equalTo(3));
}
Program: 46961
Project: 46961
Buggy source:
@Test public void testRenderRaw() throws Exception {
  String stringToRender="String_Node_Str";
  Result result=Results.json().renderRaw(stringToRender);
  Writer writer=new StringWriter();
  when(context.finalizeHeaders(result)).thenReturn(responseStreams);
  when(responseStreams.getWriter()).thenReturn(writer);
  Renderable renderable=(Renderable)result.getRenderable();
  renderable.render(context,result);
  verify(context).finalizeHeaders(result);
  assertEquals(writer.toString(),stringToRender);
  assertEquals(Result.APPLICATON_JSON,result.getContentType());
}

Fixed version (ground truth):
@Test public void testRenderRaw() throws Exception {
  String stringToRender="String_Node_Str";
  Result result=Results.json().renderRaw(stringToRender);
  Writer writer=new StringWriter();
  when(context.finalizeHeaders(result)).thenReturn(responseStreams);
  when(responseStreams.getWriter()).thenReturn(writer);
  Renderable renderable=(Renderable)result.getRenderable();
  renderable.render(context,result);
  verify(context).finalizeHeaders(result);
  assertEquals(writer.toString(),stringToRender);
  assertEquals(Result.APPLICATION_JSON,result.getContentType());
}
Program: 46962
Project: 46962
Buggy source:
@Test public void testJson(){
  Result result=new Result(Result.SC_200_OK);
  result.json();
  assertEquals(Result.APPLICATON_JSON,result.getContentType());
}

Fixed version (ground truth):
@Test public void testJson(){
  Result result=new Result(Result.SC_200_OK);
  result.json();
  assertEquals(Result.APPLICATION_JSON,result.getContentType());
}
Program: 46963
Project: 46963
Buggy source:
@Test public void testResultsTODO(){
  Result result=Results.TODO();
  assertEquals(Result.SC_501_NOT_IMPLEMENTED,result.getStatusCode());
  assertEquals(Result.APPLICATON_JSON,result.getContentType());
}

Fixed version (ground truth):
@Test public void testResultsTODO(){
  Result result=Results.TODO();
  assertEquals(Result.SC_501_NOT_IMPLEMENTED,result.getStatusCode());
  assertEquals(Result.APPLICATION_JSON,result.getContentType());
}
Program: 46964
Project: 46964
Buggy source:
@Test public void testResultsJsonWithObjectToRender(){
  TestObject testObject=new TestObject();
  Result result=Results.json().render(testObject);
  assertEquals(Result.SC_200_OK,result.getStatusCode());
  assertEquals(Result.APPLICATON_JSON,result.getContentType());
  assertEquals(testObject,result.getRenderable());
}

Fixed version (ground truth):
@Test public void testResultsJsonWithObjectToRender(){
  TestObject testObject=new TestObject();
  Result result=Results.json().render(testObject);
  assertEquals(Result.SC_200_OK,result.getStatusCode());
  assertEquals(Result.APPLICATION_JSON,result.getContentType());
  assertEquals(testObject,result.getRenderable());
}
Program: 46965
Project: 46965
Buggy source:
@Test public void testResultsJson(){
  Result result=Results.json();
  assertEquals(Result.SC_200_OK,result.getStatusCode());
  assertEquals(Result.APPLICATON_JSON,result.getContentType());
}

Fixed version (ground truth):
@Test public void testResultsJson(){
  Result result=Results.json();
  assertEquals(Result.SC_200_OK,result.getStatusCode());
  assertEquals(Result.APPLICATION_JSON,result.getContentType());
}
Program: 46966
Project: 46966
Buggy source:
@Before public void init() throws Exception {
  resultHandler=new ResultHandler(logger,templateEngineManager);
  when(responseStreams.getOutputStream()).thenReturn(outputStream);
  when(responseStreams.getWriter()).thenReturn(writer);
  when(context.finalizeHeaders(any(Result.class))).thenReturn(responseStreams);
  when(templateEngineManager.getTemplateEngineForContentType(Result.APPLICATON_JSON)).thenReturn(templateEngine);
  when(templateEngineManager.getTemplateEngineForContentType(Result.TEXT_HTML)).thenReturn(templateEngineHtml);
}

Fixed version (ground truth):
@Before public void init() throws Exception {
  resultHandler=new ResultHandler(logger,templateEngineManager);
  when(responseStreams.getOutputStream()).thenReturn(outputStream);
  when(responseStreams.getWriter()).thenReturn(writer);
  when(context.finalizeHeaders(any(Result.class))).thenReturn(responseStreams);
  when(templateEngineManager.getTemplateEngineForContentType(Result.APPLICATION_JSON)).thenReturn(templateEngine);
  when(templateEngineManager.getTemplateEngineForContentType(Result.TEXT_HTML)).thenReturn(templateEngineHtml);
}
Program: 46967
Project: 46967
Buggy source:
public Result getPersonViaContentNegotiationAndFallback(){
  Person person=new Person();
  person.name="String_Node_Str";
  return Results.ok().supportedContentTypes(Result.TEXT_HTML,Result.APPLICATON_JSON).fallbackContentType(Result.TEXT_HTML).template("String_Node_Str").render(person);
}

Fixed version (ground truth):
public Result getPersonViaContentNegotiationAndFallback(){
  Person person=new Person();
  person.name="String_Node_Str";
  return Results.ok().supportedContentTypes(Result.TEXT_HTML,Result.APPLICATION_JSON).fallbackContentType(Result.TEXT_HTML).template("String_Node_Str").render(person);
}
Program: 46968
Project: 46968
Buggy source:
@Override public String getAcceptContentType(){
  String contentType=httpServletRequest.getHeader("String_Node_Str");
  if (contentType == null) {
    return Result.TEXT_HTML;
  }
  if (contentType.indexOf("String_Node_Str") != -1 || contentType.indexOf("String_Node_Str") != -1 || contentType.startsWith("String_Node_Str")) {
    return Result.TEXT_HTML;
  }
  if (contentType.indexOf("String_Node_Str") != -1 || contentType.indexOf("String_Node_Str") != -1) {
    return Result.APPLICATION_XML;
  }
  if (contentType.indexOf("String_Node_Str") != -1 || contentType.indexOf("String_Node_Str") != -1) {
    return Result.APPLICATON_JSON;
  }
  if (contentType.indexOf("String_Node_Str") != -1) {
    return Result.TEXT_PLAIN;
  }
  if (contentType.indexOf("String_Node_Str") != -1) {
    return Result.APPLICATION_OCTET_STREAM;
  }
  if (contentType.endsWith("String_Node_Str")) {
    return Result.TEXT_HTML;
  }
  return Result.TEXT_HTML;
}

Fixed version (ground truth):
@Override public String getAcceptContentType(){
  String contentType=httpServletRequest.getHeader("String_Node_Str");
  if (contentType == null) {
    return Result.TEXT_HTML;
  }
  if (contentType.indexOf("String_Node_Str") != -1 || contentType.indexOf("String_Node_Str") != -1 || contentType.startsWith("String_Node_Str")) {
    return Result.TEXT_HTML;
  }
  if (contentType.indexOf("String_Node_Str") != -1 || contentType.indexOf("String_Node_Str") != -1) {
    return Result.APPLICATION_XML;
  }
  if (contentType.indexOf("String_Node_Str") != -1 || contentType.indexOf("String_Node_Str") != -1) {
    return Result.APPLICATION_JSON;
  }
  if (contentType.indexOf("String_Node_Str") != -1) {
    return Result.TEXT_PLAIN;
  }
  if (contentType.indexOf("String_Node_Str") != -1) {
    return Result.APPLICATION_OCTET_STREAM;
  }
  if (contentType.endsWith("String_Node_Str")) {
    return Result.TEXT_HTML;
  }
  return Result.TEXT_HTML;
}
Program: 46970
Project: 46970
Buggy source:
@Override public String getWithDefault(String key,String defaultMessage,Optional<String> language,Object... params){
  Optional<String> value=get(key,language,params);
  if (value.isPresent()) {
    MessageFormat messageFormat=getMessageFormatForLocale(value.get(),language);
    return messageFormat.format(params);
  }
 else {
    MessageFormat messageFormat=getMessageFormatForLocale(defaultMessage,language);
    return messageFormat.format(params);
  }
}

Fixed version (ground truth):
@Override public String getWithDefault(String key,String defaultMessage,Optional<String> language,Object... params){
  Optional<String> value=get(key,language,params);
  if (value.isPresent()) {
    return value.get();
  }
 else {
    MessageFormat messageFormat=getMessageFormatForLocale(defaultMessage,language);
    return messageFormat.format(params);
  }
}
Program: 46971
Project: 46971
Buggy source:
/** 
 * Gets a raw uri like "/{name}/id/*" and returns "/([^/]*)/id/*." Also handles regular expressions if defined inside routes: For instance "/users/{username: [a-zA-Z][a-zA-Z_0-9]}" becomes "/users/([a-zA-Z][a-zA-Z_0-9])"
 * @return The converted regex with default matching regex - or the regexspecified by the user.
 */
protected static String convertRawUriToRegex(String rawUri){
  Matcher matcher=PATTERN_FOR_VARIABLE_PARTS_OF_ROUTE.matcher(rawUri);
  StringBuffer stringBuffer=new StringBuffer();
  while (matcher.find()) {
    String namedVariablePartOfRoute=matcher.group(3);
    String namedVariablePartOfORouteReplacedWithRegex;
    if (namedVariablePartOfRoute != null) {
      namedVariablePartOfORouteReplacedWithRegex="String_Node_Str" + namedVariablePartOfRoute + "String_Node_Str";
    }
 else {
      namedVariablePartOfORouteReplacedWithRegex=VARIABLE_ROUTES_DEFAULT_REGEX;
    }
    matcher.appendReplacement(stringBuffer,namedVariablePartOfORouteReplacedWithRegex);
  }
  matcher.appendTail(stringBuffer);
  return stringBuffer.toString();
}

Fixed version (ground truth):
/** 
 * Gets a raw uri like "/{name}/id/*" and returns "/([^/]*)/id/*." Also handles regular expressions if defined inside routes: For instance "/users/{username: [a-zA-Z][a-zA-Z_0-9]}" becomes "/users/([a-zA-Z][a-zA-Z_0-9])"
 * @return The converted regex with default matching regex - or the regexspecified by the user.
 */
protected static String convertRawUriToRegex(String rawUri){
  Matcher matcher=PATTERN_FOR_VARIABLE_PARTS_OF_ROUTE.matcher(rawUri);
  StringBuffer stringBuffer=new StringBuffer();
  while (matcher.find()) {
    String namedVariablePartOfRoute=matcher.group(3);
    String namedVariablePartOfORouteReplacedWithRegex;
    if (namedVariablePartOfRoute != null) {
      namedVariablePartOfORouteReplacedWithRegex="String_Node_Str" + Matcher.quoteReplacement(namedVariablePartOfRoute) + "String_Node_Str";
    }
 else {
      namedVariablePartOfORouteReplacedWithRegex=VARIABLE_ROUTES_DEFAULT_REGEX;
    }
    matcher.appendReplacement(stringBuffer,namedVariablePartOfORouteReplacedWithRegex);
  }
  matcher.appendTail(stringBuffer);
  return stringBuffer.toString();
}
Program: 46972
Project: 46972
Buggy source:
@Override protected void configure(){
  String persistenceUnitName=ninjaProperties.get(NinjaConstant.PERSISTENCE_UNIT_NAME);
  if (persistenceUnitName != null) {
    String connectionUrl=ninjaProperties.get(NinjaConstant.DB_CONNECTION_URL);
    String connectionUsername=ninjaProperties.get(NinjaConstant.DB_CONNECTION_USERNAME);
    String connectionPassword=ninjaProperties.get(NinjaConstant.DB_CONNECTION_PASSWORD);
    Properties jpaProperties=new Properties();
    if (connectionUrl != null) {
      jpaProperties.put("String_Node_Str",connectionUrl);
    }
    if (connectionUsername != null) {
      jpaProperties.put("String_Node_Str",connectionUsername);
    }
    if (connectionPassword != null) {
      jpaProperties.put("String_Node_Str",connectionPassword);
    }
    install(new JpaPersistModule(persistenceUnitName).properties(jpaProperties));
    UnitOfWorkInterceptor unitOfWorkInterceptor=new UnitOfWorkInterceptor(getProvider(com.google.inject.persist.UnitOfWork.class),getProvider(EntityManager.class));
    bindInterceptor(annotatedWith(UnitOfWork.class),any(),unitOfWorkInterceptor);
    bindInterceptor(any(),annotatedWith(UnitOfWork.class),unitOfWorkInterceptor);
    bind(JpaInitializer.class).asEagerSingleton();
  }
}

Fixed version (ground truth):
@Override protected void configure(){
  String persistenceUnitName=ninjaProperties.get(NinjaConstant.PERSISTENCE_UNIT_NAME);
  if (persistenceUnitName != null) {
    String connectionUrl=ninjaProperties.get(NinjaConstant.DB_CONNECTION_URL);
    String connectionUsername=ninjaProperties.get(NinjaConstant.DB_CONNECTION_USERNAME);
    String connectionPassword=ninjaProperties.get(NinjaConstant.DB_CONNECTION_PASSWORD);
    Properties jpaProperties=new Properties();
    if (connectionUrl != null) {
      jpaProperties.put("String_Node_Str",connectionUrl);
    }
    if (connectionUsername != null) {
      jpaProperties.put("String_Node_Str",connectionUsername);
    }
    if (connectionPassword != null) {
      jpaProperties.put("String_Node_Str",connectionPassword);
    }
    install(new JpaPersistModule(persistenceUnitName).properties(jpaProperties));
    UnitOfWorkInterceptor unitOfWorkInterceptor=new UnitOfWorkInterceptor();
    requestInjection(unitOfWorkInterceptor);
    bindInterceptor(annotatedWith(UnitOfWork.class),any(),unitOfWorkInterceptor);
    bindInterceptor(any(),annotatedWith(UnitOfWork.class),unitOfWorkInterceptor);
    bind(JpaInitializer.class).asEagerSingleton();
  }
}
Program: 46973
Project: 46973
Buggy source:
@Override public Object invoke(MethodInvocation invocation) throws Throwable {
  final UnitOfWork unitOfWork;
  if (entityManagerProvider.get() == null) {
    unitOfWork=unitOfWorkProvider.get();
    unitOfWork.begin();
    didWeStartWork.set(Boolean.TRUE);
  }
 else {
    return invocation.proceed();
  }
  try {
    return invocation.proceed();
  }
  finally {
    if (null != didWeStartWork.get()) {
      didWeStartWork.remove();
      unitOfWork.end();
    }
  }
}

Fixed version (ground truth):
@Override public Object invoke(MethodInvocation invocation) throws Throwable {
  if (null == didWeStartWork.get()) {
    unitOfWork.begin();
    didWeStartWork.set(Boolean.TRUE);
  }
 else {
    return invocation.proceed();
  }
  try {
    return invocation.proceed();
  }
  finally {
    if (null != didWeStartWork.get()) {
      didWeStartWork.remove();
      unitOfWork.end();
    }
  }
}
Program: 46974
Project: 46974
Buggy source:
@Override protected void configure(){
  String persistenceUnitName=ninjaProperties.get(NinjaConstant.PERSISTENCE_UNIT_NAME);
  if (persistenceUnitName != null) {
    String connectionUrl=ninjaProperties.get(NinjaConstant.DB_CONNECTION_URL);
    String connectionUsername=ninjaProperties.get(NinjaConstant.DB_CONNECTION_USERNAME);
    String connectionPassword=ninjaProperties.get(NinjaConstant.DB_CONNECTION_PASSWORD);
    Properties jpaProperties=new Properties();
    if (connectionUrl != null) {
      jpaProperties.put("String_Node_Str",connectionUrl);
    }
    if (connectionUsername != null) {
      jpaProperties.put("String_Node_Str",connectionUsername);
    }
    if (connectionPassword != null) {
      jpaProperties.put("String_Node_Str",connectionPassword);
    }
    install(new JpaPersistModule(persistenceUnitName).properties(jpaProperties));
    UnitOfWorkInterceptor unitOfWorkInterceptor=new UnitOfWorkInterceptor(getProvider(com.google.inject.persist.UnitOfWork.class),getProvider(EntityManager.class));
    bindInterceptor(annotatedWith(UnitOfWork.class),any(),unitOfWorkInterceptor);
    bindInterceptor(any(),annotatedWith(UnitOfWork.class),unitOfWorkInterceptor);
    bind(JpaInitializer.class).asEagerSingleton();
  }
}

Fixed version (ground truth):
@Override protected void configure(){
  String persistenceUnitName=ninjaProperties.get(NinjaConstant.PERSISTENCE_UNIT_NAME);
  if (persistenceUnitName != null) {
    String connectionUrl=ninjaProperties.get(NinjaConstant.DB_CONNECTION_URL);
    String connectionUsername=ninjaProperties.get(NinjaConstant.DB_CONNECTION_USERNAME);
    String connectionPassword=ninjaProperties.get(NinjaConstant.DB_CONNECTION_PASSWORD);
    Properties jpaProperties=new Properties();
    if (connectionUrl != null) {
      jpaProperties.put("String_Node_Str",connectionUrl);
    }
    if (connectionUsername != null) {
      jpaProperties.put("String_Node_Str",connectionUsername);
    }
    if (connectionPassword != null) {
      jpaProperties.put("String_Node_Str",connectionPassword);
    }
    install(new JpaPersistModule(persistenceUnitName).properties(jpaProperties));
    UnitOfWorkInterceptor unitOfWorkInterceptor=new UnitOfWorkInterceptor();
    requestInjection(unitOfWorkInterceptor);
    bindInterceptor(annotatedWith(UnitOfWork.class),any(),unitOfWorkInterceptor);
    bindInterceptor(any(),annotatedWith(UnitOfWork.class),unitOfWorkInterceptor);
    bind(JpaInitializer.class).asEagerSingleton();
  }
}
Program: 46975
Project: 46975
Buggy source:
@Override public Object invoke(MethodInvocation invocation) throws Throwable {
  final UnitOfWork unitOfWork;
  if (entityManagerProvider.get() == null) {
    unitOfWork=unitOfWorkProvider.get();
    unitOfWork.begin();
    didWeStartWork.set(Boolean.TRUE);
  }
 else {
    return invocation.proceed();
  }
  try {
    return invocation.proceed();
  }
  finally {
    if (null != didWeStartWork.get()) {
      didWeStartWork.remove();
      unitOfWork.end();
    }
  }
}

Fixed version (ground truth):
@Override public Object invoke(MethodInvocation invocation) throws Throwable {
  if (null == didWeStartWork.get()) {
    unitOfWork.begin();
    didWeStartWork.set(Boolean.TRUE);
  }
 else {
    return invocation.proceed();
  }
  try {
    return invocation.proceed();
  }
  finally {
    if (null != didWeStartWork.get()) {
      didWeStartWork.remove();
      unitOfWork.end();
    }
  }
}
Program: 46976
Project: 46976
Buggy source:
@Override public void renderErrorResultAndCatchAndLogExceptions(Result result,Context context){
  try {
    if (context.isAsync()) {
      context.returnResultAsync(result);
    }
 else {
      resultHandler.handleResult(result,context);
    }
  }
 catch (  Exception exceptionCausingRenderError) {
    logger.error("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str",exceptionCausingRenderError);
  }
}

Fixed version (ground truth):
@Override public void renderErrorResultAndCatchAndLogExceptions(Result result,Context context){
  try {
    if (context.isAsync()) {
      context.returnResultAsync(result);
    }
 else {
      resultHandler.handleResult(result,context);
    }
  }
 catch (  Exception exceptionCausingRenderError) {
    logger.error("String_Node_Str" + "String_Node_Str",exceptionCausingRenderError);
  }
}
Program: 46977
Project: 46977
Buggy source:
@Override protected void configure(){
  String persistenceUnitName=ninjaProperties.get(NinjaConstant.PERSISTENCE_UNIT_NAME);
  if (persistenceUnitName != null) {
    String connectionUrl=ninjaProperties.get(NinjaConstant.DB_CONNECTION_URL);
    String connectionUsername=ninjaProperties.get(NinjaConstant.DB_CONNECTION_USERNAME);
    String connectionPassword=ninjaProperties.get(NinjaConstant.DB_CONNECTION_PASSWORD);
    Properties jpaProperties=new Properties();
    if (connectionUrl != null) {
      jpaProperties.put("String_Node_Str",connectionUrl);
    }
    if (connectionUsername != null) {
      jpaProperties.put("String_Node_Str",connectionUsername);
    }
    if (connectionPassword != null) {
      jpaProperties.put("String_Node_Str",connectionPassword);
    }
    install(new JpaPersistModule(persistenceUnitName).properties(jpaProperties));
    UnitOfWorkInterceptor unitOfWorkInterceptor=new UnitOfWorkInterceptor();
    requestInjection(unitOfWorkInterceptor);
    bindInterceptor(annotatedWith(UnitOfWork.class),any(),unitOfWorkInterceptor);
    bindInterceptor(any(),annotatedWith(UnitOfWork.class),unitOfWorkInterceptor);
    bind(JpaInitializer.class).asEagerSingleton();
  }
}

Fixed version (ground truth):
@Override protected void configure(){
  String persistenceUnitName=ninjaProperties.get(NinjaConstant.PERSISTENCE_UNIT_NAME);
  if (persistenceUnitName != null) {
    String connectionUrl=ninjaProperties.get(NinjaConstant.DB_CONNECTION_URL);
    String connectionUsername=ninjaProperties.get(NinjaConstant.DB_CONNECTION_USERNAME);
    String connectionPassword=ninjaProperties.get(NinjaConstant.DB_CONNECTION_PASSWORD);
    Properties jpaProperties=new Properties();
    if (connectionUrl != null) {
      jpaProperties.put("String_Node_Str",connectionUrl);
    }
    if (connectionUsername != null) {
      jpaProperties.put("String_Node_Str",connectionUsername);
    }
    if (connectionPassword != null) {
      jpaProperties.put("String_Node_Str",connectionPassword);
    }
    install(new JpaPersistModule(persistenceUnitName).properties(jpaProperties));
    UnitOfWorkInterceptor unitOfWorkInterceptor=new UnitOfWorkInterceptor(getProvider(com.google.inject.persist.UnitOfWork.class),getProvider(EntityManager.class));
    bindInterceptor(annotatedWith(UnitOfWork.class),any(),unitOfWorkInterceptor);
    bindInterceptor(any(),annotatedWith(UnitOfWork.class),unitOfWorkInterceptor);
    bind(JpaInitializer.class).asEagerSingleton();
  }
}
Program: 46978
Project: 46978
Buggy source:
@Override public Object invoke(MethodInvocation invocation) throws Throwable {
  if (null == didWeStartWork.get()) {
    unitOfWork.begin();
    didWeStartWork.set(Boolean.TRUE);
  }
 else {
    return invocation.proceed();
  }
  try {
    return invocation.proceed();
  }
  finally {
    if (null != didWeStartWork.get()) {
      didWeStartWork.remove();
      unitOfWork.end();
    }
  }
}

Fixed version (ground truth):
@Override public Object invoke(MethodInvocation invocation) throws Throwable {
  final UnitOfWork unitOfWork;
  if (entityManagerProvider.get() == null) {
    unitOfWork=unitOfWorkProvider.get();
    unitOfWork.begin();
    didWeStartWork.set(Boolean.TRUE);
  }
 else {
    return invocation.proceed();
  }
  try {
    return invocation.proceed();
  }
  finally {
    if (null != didWeStartWork.get()) {
      didWeStartWork.remove();
      unitOfWork.end();
    }
  }
}
Program: 46979
Project: 46979
Buggy source:
@Override protected void configure(){
  String persistenceUnitName=ninjaProperties.get(NinjaConstant.PERSISTENCE_UNIT_NAME);
  if (persistenceUnitName != null) {
    String connectionUrl=ninjaProperties.get(NinjaConstant.DB_CONNECTION_URL);
    String connectionUsername=ninjaProperties.get(NinjaConstant.DB_CONNECTION_USERNAME);
    String connectionPassword=ninjaProperties.get(NinjaConstant.DB_CONNECTION_PASSWORD);
    Properties jpaProperties=new Properties();
    if (connectionUrl != null) {
      jpaProperties.put("String_Node_Str",connectionUrl);
    }
    if (connectionUsername != null) {
      jpaProperties.put("String_Node_Str",connectionUsername);
    }
    if (connectionPassword != null) {
      jpaProperties.put("String_Node_Str",connectionPassword);
    }
    install(new JpaPersistModule(persistenceUnitName).properties(jpaProperties));
    UnitOfWorkInterceptor unitOfWorkInterceptor=new UnitOfWorkInterceptor();
    requestInjection(unitOfWorkInterceptor);
    bindInterceptor(annotatedWith(UnitOfWork.class),any(),unitOfWorkInterceptor);
    bindInterceptor(any(),annotatedWith(UnitOfWork.class),unitOfWorkInterceptor);
    bind(JpaInitializer.class).asEagerSingleton();
  }
}

Fixed version (ground truth):
@Override protected void configure(){
  String persistenceUnitName=ninjaProperties.get(NinjaConstant.PERSISTENCE_UNIT_NAME);
  if (persistenceUnitName != null) {
    String connectionUrl=ninjaProperties.get(NinjaConstant.DB_CONNECTION_URL);
    String connectionUsername=ninjaProperties.get(NinjaConstant.DB_CONNECTION_USERNAME);
    String connectionPassword=ninjaProperties.get(NinjaConstant.DB_CONNECTION_PASSWORD);
    Properties jpaProperties=new Properties();
    if (connectionUrl != null) {
      jpaProperties.put("String_Node_Str",connectionUrl);
    }
    if (connectionUsername != null) {
      jpaProperties.put("String_Node_Str",connectionUsername);
    }
    if (connectionPassword != null) {
      jpaProperties.put("String_Node_Str",connectionPassword);
    }
    install(new JpaPersistModule(persistenceUnitName).properties(jpaProperties));
    UnitOfWorkInterceptor unitOfWorkInterceptor=new UnitOfWorkInterceptor(getProvider(com.google.inject.persist.UnitOfWork.class),getProvider(EntityManager.class));
    bindInterceptor(annotatedWith(UnitOfWork.class),any(),unitOfWorkInterceptor);
    bindInterceptor(any(),annotatedWith(UnitOfWork.class),unitOfWorkInterceptor);
    bind(JpaInitializer.class).asEagerSingleton();
  }
}
Program: 46980
Project: 46980
Buggy source:
@Override public Object invoke(MethodInvocation invocation) throws Throwable {
  if (null == didWeStartWork.get()) {
    unitOfWork.begin();
    didWeStartWork.set(Boolean.TRUE);
  }
 else {
    return invocation.proceed();
  }
  try {
    return invocation.proceed();
  }
  finally {
    if (null != didWeStartWork.get()) {
      didWeStartWork.remove();
      unitOfWork.end();
    }
  }
}

Fixed version (ground truth):
@Override public Object invoke(MethodInvocation invocation) throws Throwable {
  final UnitOfWork unitOfWork;
  if (entityManagerProvider.get() == null) {
    unitOfWork=unitOfWorkProvider.get();
    unitOfWork.begin();
    didWeStartWork.set(Boolean.TRUE);
  }
 else {
    return invocation.proceed();
  }
  try {
    return invocation.proceed();
  }
  finally {
    if (null != didWeStartWork.get()) {
      didWeStartWork.remove();
      unitOfWork.end();
    }
  }
}
Program: 46981
Project: 46981
Buggy source:
@Override public void contextInitialized(ServletContextEvent servletContextEvent){
  super.contextInitialized(servletContextEvent);
  contextPath=servletContextEvent.getServletContext().getContextPath();
}

Fixed version (ground truth):
@Override public void contextInitialized(ServletContextEvent servletContextEvent){
  contextPath=servletContextEvent.getServletContext().getContextPath();
  super.contextInitialized(servletContextEvent);
}
Program: 46985
Project: 46985
Buggy source:
/** 
 * @return id of a session.
 */
@Override public String getId(){
  if (!data.containsKey(ID_KEY)) {
    data.put(ID_KEY,UUID.randomUUID().toString());
  }
  return data.get(ID_KEY);
}

Fixed version (ground truth):
/** 
 * @return id of a session.
 */
@Override public String getId(){
  if (!data.containsKey(ID_KEY)) {
    put(ID_KEY,UUID.randomUUID().toString());
  }
  return get(ID_KEY);
}
Program: 46986
Project: 46986
Buggy source:
/** 
 * @return an authenticity token or generates a new one.
 */
@Override public String getAuthenticityToken(){
  if (!data.containsKey(AUTHENTICITY_KEY)) {
    data.put(AUTHENTICITY_KEY,UUID.randomUUID().toString());
  }
  return data.get(AUTHENTICITY_KEY);
}

Fixed version (ground truth):
/** 
 * @return an authenticity token or generates a new one.
 */
@Override public String getAuthenticityToken(){
  if (!data.containsKey(AUTHENTICITY_KEY)) {
    put(AUTHENTICITY_KEY,UUID.randomUUID().toString());
  }
  return get(AUTHENTICITY_KEY);
}
Program: 46987
Project: 46987
Buggy source:
public void handleResult(Result result,Context context){
  if (result == null || result instanceof AsyncResult) {
    return;
  }
  Object objectToBeRendered=result.getRenderable();
  if (objectToBeRendered instanceof Renderable) {
    handleRenderable((Renderable)objectToBeRendered,context,result);
  }
 else {
    if (result.getContentType() == null) {
      result.contentType(context.getAcceptContentType());
    }
    if (!result.getHeaders().containsKey(Result.CACHE_CONTROL)) {
      result.doNotCacheContent();
    }
    if (objectToBeRendered instanceof NoHttpBody) {
      context.finalizeHeaders(result);
    }
 else {
      renderWithTemplateEngine(context,result);
    }
  }
}

Fixed version (ground truth):
public void handleResult(Result result,Context context){
  if (result == null || result instanceof AsyncResult) {
    return;
  }
  Object objectToBeRendered=result.getRenderable();
  if (objectToBeRendered instanceof Renderable) {
    handleRenderable((Renderable)objectToBeRendered,context,result);
  }
 else {
    if (result.getContentType() == null) {
      result.contentType(context.getAcceptContentType());
    }
    if (!result.getHeaders().containsKey(Result.CACHE_CONTROL)) {
      result.doNotCacheContent();
    }
    if (objectToBeRendered instanceof NoHttpBody) {
      context.finalizeHeaders(result);
    }
 else {
      renderWithTemplateEngineOrRaw(context,result);
    }
  }
}
Program: 46988
Project: 46988
Buggy source:
/** 
 * This method directly renders the String to the output. It completely bypasses any rendering engine. Thus you can render anything you want. Chaining of resultRaw is NOT supported. Mixing with render() is NOT supported. It is always recommended to implement your own RenderingEngine OR use existing rendering engines. Example: <code> public Result controllerMethod() { String customJson = "{\"user\" : \"john@woo.com\"}"; return Results.json().renderRaw(customJson); } </code>
 * @param string The string to render.
 * @return A result that will render the string directly to the output stream.
 */
public Result renderRaw(final String string){
  Renderable renderable=new Renderable(){
    @Override public void render(    Context context,    Result result) throws Exception {
      ResponseStreams resultJsonCustom=context.finalizeHeaders(result);
      OutputStream outputStream=resultJsonCustom.getOutputStream();
      outputStream.write(string.getBytes());
      outputStream.close();
    }
  }
;
  render(renderable);
  return this;
}

Fixed version (ground truth):
/** 
 * This method directly renders the String to the output. It completely bypasses any rendering engine. Thus you can render anything you want. Chaining of resultRaw is NOT supported. Mixing with render() is NOT supported. It is always recommended to implement your own RenderingEngine OR use existing rendering engines. Example: <code> public Result controllerMethod() { String customJson = "{\"user\" : \"john@woo.com\"}"; return Results.json().renderRaw(customJson); } </code>
 * @param string The string to render.
 * @return A result that will render the string directly to the output stream.
 */
public Result renderRaw(final String string){
  Renderable renderable=new Renderable(){
    @Override public void render(    Context context,    Result result) throws Exception {
      ResponseStreams resultJsonCustom=context.finalizeHeaders(result);
      try (Writer writer=resultJsonCustom.getWriter()){
        writer.write(string);
      }
 catch (      IOException ioException) {
        logger.error("String_Node_Str",ioException);
      }
    }
  }
;
  render(renderable);
  return this;
}
Program: 46989
Project: 46989
Buggy source:
@Override public void render(Context context,Result result) throws Exception {
  ResponseStreams resultJsonCustom=context.finalizeHeaders(result);
  OutputStream outputStream=resultJsonCustom.getOutputStream();
  outputStream.write(string.getBytes());
  outputStream.close();
}

Fixed version (ground truth):
@Override public void render(Context context,Result result) throws Exception {
  ResponseStreams resultJsonCustom=context.finalizeHeaders(result);
  try (Writer writer=resultJsonCustom.getWriter()){
    writer.write(string);
  }
 catch (  IOException ioException) {
    logger.error("String_Node_Str",ioException);
  }
}
Program: 46990
Project: 46990
Buggy source:
private void renderWithTemplateEngineOrRaw(Context context,Result result){
  TemplateEngine templateEngine=templateEngineManager.getTemplateEngineForContentType(result.getContentType());
  if (templateEngine != null) {
    templateEngine.invoke(context,result);
  }
 else {
    if (result.getRenderable() instanceof String) {
      if (result.getContentType() == null) {
        result.contentType(Result.TEXT_PLAIN);
      }
      ResponseStreams responseStreams=context.finalizeHeaders(result);
      try (Writer writer=responseStreams.getWriter()){
        writer.append((String)result.getRenderable());
      }
 catch (      IOException e) {
        throw new RuntimeException(e);
      }
    }
 else     if (result.getRenderable() instanceof byte[]) {
      if (result.getContentType() == null) {
        result.contentType(Result.APPLICATION_OCTET_STREAM);
      }
      ResponseStreams responseStreams=context.finalizeHeaders(result);
      try (OutputStream outputStream=responseStreams.getOutputStream()){
        outputStream.write((byte[])result.getRenderable());
      }
 catch (      IOException e) {
        throw new RuntimeException(e);
      }
    }
 else {
      context.finalizeHeaders(result);
      throw new IllegalArgumentException("String_Node_Str" + result.getContentType());
    }
  }
}

Fixed version (ground truth):
private void renderWithTemplateEngineOrRaw(Context context,Result result){
  TemplateEngine templateEngine=templateEngineManager.getTemplateEngineForContentType(result.getContentType());
  if (templateEngine != null) {
    templateEngine.invoke(context,result);
  }
 else {
    if (result.getRenderable() instanceof String) {
      if (result.getContentType() == null) {
        result.contentType(Result.TEXT_PLAIN);
      }
      ResponseStreams responseStreams=context.finalizeHeaders(result);
      try (Writer writer=responseStreams.getWriter()){
        writer.write((String)result.getRenderable());
      }
 catch (      IOException e) {
        throw new RuntimeException(e);
      }
    }
 else     if (result.getRenderable() instanceof byte[]) {
      if (result.getContentType() == null) {
        result.contentType(Result.APPLICATION_OCTET_STREAM);
      }
      ResponseStreams responseStreams=context.finalizeHeaders(result);
      try (OutputStream outputStream=responseStreams.getOutputStream()){
        outputStream.write((byte[])result.getRenderable());
      }
 catch (      IOException e) {
        throw new RuntimeException(e);
      }
    }
 else {
      context.finalizeHeaders(result);
      throw new IllegalArgumentException("String_Node_Str" + result.getContentType());
    }
  }
}
Program: 46993
Project: 46993
Buggy source:
/** 
 * Finalizing the headers copies all stuff into the headers. After finalizing the headers you can access the responseStreams.
 */
ResponseStreams finalizeHeaders(Result result);

Fixed version (ground truth):
/** 
 * Finalizing the headers copies all stuff into the headers. It of course also handles Ninja session and Flash information. After finalizing the headers you can access the responseStreams.
 */
ResponseStreams finalizeHeaders(Result result);
Program: 46994
Project: 46994
Buggy source:
@Test public void testAssetsController404() throws Exception {
  AssetsController assetsController=new AssetsController(httpCacheToolkit,mimeTypes,ninjaProperties);
  when(contextRenerable.getRequestPath()).thenReturn("String_Node_Str");
  Result result2=assetsController.serve(null);
  Renderable renderable=(Renderable)result2.getRenderable();
  Result result=Results.ok();
  renderable.render(contextRenerable,result);
  verify(contextRenerable).finalizeHeaders(resultCaptor.capture());
  assertTrue(resultCaptor.getValue().getStatusCode() == Result.SC_404_NOT_FOUND);
}

Fixed version (ground truth):
@Test public void testAssetsController404() throws Exception {
  AssetsController assetsController=new AssetsController(httpCacheToolkit,mimeTypes,ninjaProperties);
  when(contextRenerable.getRequestPath()).thenReturn("String_Node_Str");
  Result result2=assetsController.serve(null);
  Renderable renderable=(Renderable)result2.getRenderable();
  Result result=Results.ok();
  renderable.render(contextRenerable,result);
  verify(contextRenerable).finalizeHeadersWithoutFlashAndSessionCookie(resultCaptor.capture());
  assertTrue(resultCaptor.getValue().getStatusCode() == Result.SC_404_NOT_FOUND);
}
Program: 46995
Project: 46995
Buggy source:
@Test public void testAssetsController304NotModified() throws Exception {
  AssetsController assetsController=new AssetsController(httpCacheToolkit,mimeTypes,ninjaProperties);
  when(contextRenerable.getRequestPath()).thenReturn("String_Node_Str");
  Result result2=assetsController.serve(null);
  Renderable renderable=(Renderable)result2.getRenderable();
  Result result=Results.ok();
  result.status(Result.SC_304_NOT_MODIFIED);
  renderable.render(contextRenerable,result);
  verify(httpCacheToolkit).addEtag(Mockito.eq(contextRenerable),Mockito.eq(result),Mockito.anyLong());
  verify(contextRenerable).finalizeHeaders(resultCaptor.capture());
  assertEquals(Result.SC_304_NOT_MODIFIED,resultCaptor.getValue().getStatusCode());
}

Fixed version (ground truth):
@Test public void testAssetsController304NotModified() throws Exception {
  AssetsController assetsController=new AssetsController(httpCacheToolkit,mimeTypes,ninjaProperties);
  when(contextRenerable.getRequestPath()).thenReturn("String_Node_Str");
  Result result2=assetsController.serve(null);
  Renderable renderable=(Renderable)result2.getRenderable();
  Result result=Results.ok();
  result.status(Result.SC_304_NOT_MODIFIED);
  renderable.render(contextRenerable,result);
  verify(httpCacheToolkit).addEtag(Mockito.eq(contextRenerable),Mockito.eq(result),Mockito.anyLong());
  verify(contextRenerable).finalizeHeadersWithoutFlashAndSessionCookie(resultCaptor.capture());
  assertEquals(Result.SC_304_NOT_MODIFIED,resultCaptor.getValue().getStatusCode());
}
Program: 46996
Project: 46996
Buggy source:
@Test public void testAssetsControllerNormalOperationModifiedNoCaching() throws Exception {
  AssetsController assetsController=new AssetsController(httpCacheToolkit,mimeTypes,ninjaProperties);
  Result result=Results.ok();
  when(contextRenerable.getRequestPath()).thenReturn("String_Node_Str");
  when(mimeTypes.getContentType(Mockito.eq(contextRenerable),Mockito.anyString())).thenReturn("String_Node_Str");
  when(contextRenerable.finalizeHeaders(Mockito.eq(result))).thenReturn(responseStreams);
  ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();
  when(responseStreams.getOutputStream()).thenReturn(byteArrayOutputStream);
  Result result2=assetsController.serve(null);
  Renderable renderable=(Renderable)result2.getRenderable();
  renderable.render(contextRenerable,result);
  verify(httpCacheToolkit).addEtag(Mockito.eq(contextRenerable),Mockito.eq(result),Mockito.anyLong());
  verify(contextRenerable).finalizeHeaders(resultCaptor.capture());
  assertEquals(Result.SC_200_OK,resultCaptor.getValue().getStatusCode());
  assertEquals("String_Node_Str",result.getContentType());
  assertEquals("String_Node_Str",byteArrayOutputStream.toString());
}

Fixed version (ground truth):
@Test public void testAssetsControllerNormalOperationModifiedNoCaching() throws Exception {
  AssetsController assetsController=new AssetsController(httpCacheToolkit,mimeTypes,ninjaProperties);
  Result result=Results.ok();
  when(contextRenerable.getRequestPath()).thenReturn("String_Node_Str");
  when(mimeTypes.getContentType(Mockito.eq(contextRenerable),Mockito.anyString())).thenReturn("String_Node_Str");
  when(contextRenerable.finalizeHeadersWithoutFlashAndSessionCookie(Mockito.eq(result))).thenReturn(responseStreams);
  ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();
  when(responseStreams.getOutputStream()).thenReturn(byteArrayOutputStream);
  Result result2=assetsController.serve(null);
  Renderable renderable=(Renderable)result2.getRenderable();
  renderable.render(contextRenerable,result);
  verify(httpCacheToolkit).addEtag(Mockito.eq(contextRenerable),Mockito.eq(result),Mockito.anyLong());
  verify(contextRenerable).finalizeHeadersWithoutFlashAndSessionCookie(resultCaptor.capture());
  assertEquals(Result.SC_200_OK,resultCaptor.getValue().getStatusCode());
  assertEquals("String_Node_Str",result.getContentType());
  assertEquals("String_Node_Str",byteArrayOutputStream.toString());
}
Program: 46997
Project: 46997
Buggy source:
@Override public ResponseStreams finalizeHeaders(Result result){
  httpServletResponse.setStatus(result.getStatusCode());
  for (  Entry<String,String> header : result.getHeaders().entrySet()) {
    httpServletResponse.addHeader(header.getKey(),header.getValue());
  }
  flashCookie.save(this,result);
  sessionCookie.save(this,result);
  for (  ninja.Cookie cookie : result.getCookies()) {
    httpServletResponse.addCookie(CookieHelper.convertNinjaCookieToServletCookie(cookie));
  }
  if (result.getContentType() != null) {
    httpServletResponse.setContentType(result.getContentType());
  }
  if (result.getCharset() != null) {
    httpServletResponse.setCharacterEncoding(result.getCharset());
  }
 else {
    httpServletResponse.setCharacterEncoding(NinjaConstant.UTF_8);
  }
  ResponseStreamsServlet responseStreamsServlet=new ResponseStreamsServlet();
  responseStreamsServlet.init(httpServletResponse);
  return (ResponseStreams)responseStreamsServlet;
}

Fixed version (ground truth):
@Override public ResponseStreams finalizeHeaders(Result result){
  return finalizeHeaders(result,true);
}
Program: 46998
Project: 46998
Buggy source:
@Override public RouteBuilder OPTIONS(){
  RouteBuilderImpl routeBuilder=new RouteBuilderImpl().OPTION();
  allRouteBuilders.add(routeBuilder);
  return routeBuilder;
}

Fixed version (ground truth):
@Override public RouteBuilder OPTIONS(){
  RouteBuilderImpl routeBuilder=new RouteBuilderImpl().OPTIONS();
  allRouteBuilders.add(routeBuilder);
  return routeBuilder;
}
Program: 47001
Project: 47001
Buggy source:
/** 
 * Finalizing the headers copies all stuff into the headers. After finalizing the headers you can access the responseStreams.
 */
ResponseStreams finalizeHeaders(Result result);

Fixed version (ground truth):
/** 
 * Finalizing the headers copies all stuff into the headers. It of course also handles Ninja session and Flash information. After finalizing the headers you can access the responseStreams.
 */
ResponseStreams finalizeHeaders(Result result);