nus-yam/ex-repair huggingface dataset:
Program: 9068
Project: 9068
Buggy source:
@Test public void shouldSerialiseToJsonCorrectly() throws Exception {
  RedirectCallback redirectCallback=mock(RedirectCallback.class);
  final Map<String,String> redirectData=Collections.singletonMap("String_Node_Str","String_Node_Str");
  given(redirectCallback.getRedirectUrl()).willReturn("String_Node_Str");
  given(redirectCallback.getMethod()).willReturn("String_Node_Str");
  given(redirectCallback.getRedirectData()).willReturn(redirectData);
  String json=JsonValueBuilder.getObjectMapper().writeValueAsString(restAuthRedirectCallbackHandler.convertToJson(redirectCallback,1).getObject());
  JsonValue parsed=JsonValueBuilder.toJsonValue(json);
  assertThat(parsed).stringAt("String_Node_Str").isEqualTo("String_Node_Str");
  assertThat(parsed).hasArray("String_Node_Str").hasSize(3);
  assertThat(parsed).hasObject("String_Node_Str").containsExactly(entry("String_Node_Str","String_Node_Str"),entry("String_Node_Str","String_Node_Str"));
  assertThat(parsed).hasObject("String_Node_Str").containsExactly(entry("String_Node_Str","String_Node_Str"),entry("String_Node_Str","String_Node_Str"));
  assertThat(parsed).hasObject("String_Node_Str").containsExactly(entry("String_Node_Str","String_Node_Str"),entry("String_Node_Str",redirectData));
}

Fixed version (ground truth):
@Test public void shouldSerialiseToJsonCorrectly() throws Exception {
  RedirectCallback redirectCallback=mock(RedirectCallback.class);
  final Map<String,String> redirectData=Collections.singletonMap("String_Node_Str","String_Node_Str");
  given(redirectCallback.getRedirectUrl()).willReturn("String_Node_Str");
  given(redirectCallback.getMethod()).willReturn("String_Node_Str");
  given(redirectCallback.getRedirectData()).willReturn(redirectData);
  String json=JsonValueBuilder.getObjectMapper().writeValueAsString(restAuthRedirectCallbackHandler.convertToJson(redirectCallback,1).getObject());
  JsonValue parsed=JsonValueBuilder.toJsonValue(json);
  assertThat(parsed).stringAt("String_Node_Str").isEqualTo("String_Node_Str");
  assertThat(parsed).hasArray("String_Node_Str").hasSize(4);
  assertThat(parsed).hasObject("String_Node_Str").containsExactly(entry("String_Node_Str","String_Node_Str"),entry("String_Node_Str","String_Node_Str"));
  assertThat(parsed).hasObject("String_Node_Str").containsExactly(entry("String_Node_Str","String_Node_Str"),entry("String_Node_Str","String_Node_Str"));
  assertThat(parsed).hasObject("String_Node_Str").containsExactly(entry("String_Node_Str","String_Node_Str"),entry("String_Node_Str",false));
  assertThat(parsed).hasObject("String_Node_Str").containsExactly(entry("String_Node_Str","String_Node_Str"),entry("String_Node_Str",redirectData));
}
Program: 9069
Project: 9069
Buggy source:
@Test public void shouldFailConvertToJson() throws RestAuthException {
  RedirectCallback redirectCallback=mock(RedirectCallback.class);
  given(redirectCallback.getRedirectUrl()).willReturn("String_Node_Str");
  given(redirectCallback.getMethod()).willReturn("String_Node_Str");
  given(redirectCallback.getRedirectData()).willReturn(Collections.<String,String>emptyMap());
  JsonValue json=restAuthRedirectCallbackHandler.convertToJson(redirectCallback,1);
  assertThat(json.asMap()).hasSize(2);
  assertThat(json.get("String_Node_Str").asString()).isEqualTo("String_Node_Str");
  assertThat(json.get("String_Node_Str").asList()).hasSize(3);
  assertThat(json.get("String_Node_Str").get(0).get("String_Node_Str").asString()).isEqualTo("String_Node_Str");
  assertThat(json.get("String_Node_Str").get(0).get("String_Node_Str").asString()).isEqualTo("String_Node_Str");
  assertThat(json.get("String_Node_Str").get(1).get("String_Node_Str").asString()).isEqualTo("String_Node_Str");
  assertThat(json.get("String_Node_Str").get(1).get("String_Node_Str").asString()).isEqualTo("String_Node_Str");
  assertThat(json.get("String_Node_Str").get(2).get("String_Node_Str").asString()).isEqualTo("String_Node_Str");
  assertThat(json.get("String_Node_Str").get(2).get("String_Node_Str").asMap()).hasSize(0);
}

Fixed version (ground truth):
@Test public void shouldFailConvertToJson() throws RestAuthException {
  RedirectCallback redirectCallback=mock(RedirectCallback.class);
  given(redirectCallback.getRedirectUrl()).willReturn("String_Node_Str");
  given(redirectCallback.getMethod()).willReturn("String_Node_Str");
  given(redirectCallback.getRedirectData()).willReturn(Collections.<String,String>emptyMap());
  JsonValue json=restAuthRedirectCallbackHandler.convertToJson(redirectCallback,1);
  assertThat(json.asMap()).hasSize(2);
  assertThat(json.get("String_Node_Str").asString()).isEqualTo("String_Node_Str");
  assertThat(json.get("String_Node_Str").asList()).hasSize(4);
  assertThat(json.get("String_Node_Str").get(0).get("String_Node_Str").asString()).isEqualTo("String_Node_Str");
  assertThat(json.get("String_Node_Str").get(0).get("String_Node_Str").asString()).isEqualTo("String_Node_Str");
  assertThat(json.get("String_Node_Str").get(1).get("String_Node_Str").asString()).isEqualTo("String_Node_Str");
  assertThat(json.get("String_Node_Str").get(1).get("String_Node_Str").asString()).isEqualTo("String_Node_Str");
  assertThat(json.get("String_Node_Str").get(2).get("String_Node_Str").asString()).isEqualTo("String_Node_Str");
  assertThat(json.get("String_Node_Str").get(2).get("String_Node_Str").asBoolean()).isEqualTo(false);
  assertThat(json.get("String_Node_Str").get(3).get("String_Node_Str").asString()).isEqualTo("String_Node_Str");
  assertThat(json.get("String_Node_Str").get(3).get("String_Node_Str").asMap()).hasSize(0);
}
Program: 9070
Project: 9070
Buggy source:
public void handleRedirectCallback(HttpServletRequest request,HttpServletResponse response,RedirectCallback redirectCallback,String loginURL) throws IOException {
  setRedirectCallbackCookie(request,response,redirectCallback,loginURL);
  String qString=AuthClientUtils.getQueryStrFromParameters(redirectCallback.getRedirectData());
  StringBuilder redirectUrl=new StringBuilder(redirectCallback.getRedirectUrl());
  if (qString != null && qString.length() != 0) {
    redirectUrl.append(qString);
  }
  String rUrl=redirectUrl.toString();
  if (rUrl.startsWith("String_Node_Str")) {
    if (debug.messageEnabled()) {
      debug.message("String_Node_Str" + "String_Node_Str" + rUrl + "String_Node_Str"+ AuthClientUtils.getServiceURI());
    }
    response.sendRedirect(AuthClientUtils.getServiceURI() + rUrl);
  }
 else {
    if (redirectCallback.getMethod().equalsIgnoreCase("String_Node_Str")) {
      request.setAttribute("String_Node_Str",redirectCallback.getRedirectData());
      request.setAttribute("String_Node_Str",redirectCallback.getRedirectUrl());
      try {
        request.getRequestDispatcher(FORWARDING_PLACE).forward(request,response);
      }
 catch (      ServletException e) {
        if (debug.warningEnabled()) {
          debug.warning("String_Node_Str" + e.toString());
        }
        throw new RedirectException("String_Node_Str",e);
      }
    }
 else {
      response.sendRedirect(rUrl);
    }
  }
}

Fixed version (ground truth):
public void handleRedirectCallback(HttpServletRequest request,HttpServletResponse response,RedirectCallback redirectCallback,String loginURL) throws IOException {
  setRedirectCallbackCookie(request,response,redirectCallback,loginURL);
  String qString=AuthClientUtils.getQueryStrFromParameters(redirectCallback.getRedirectData());
  StringBuilder redirectUrl=new StringBuilder(redirectCallback.getRedirectUrl());
  if (qString != null && qString.length() != 0) {
    redirectUrl.append(qString);
  }
  String rUrl=redirectUrl.toString();
  if (rUrl.startsWith("String_Node_Str")) {
    if (debug.messageEnabled()) {
      debug.message("String_Node_Str" + "String_Node_Str" + rUrl + "String_Node_Str"+ AuthClientUtils.getServiceURI());
    }
    response.sendRedirect(AuthClientUtils.getServiceURI() + rUrl);
  }
 else {
    if (redirectCallback.getMethod().equalsIgnoreCase("String_Node_Str")) {
      Map<String,String> dataMap=redirectCallback.getRedirectData();
      if (dataMap == null) {
        dataMap=new HashMap<>();
      }
      request.setAttribute("String_Node_Str",dataMap);
      request.setAttribute("String_Node_Str",redirectCallback.getRedirectUrl());
      try {
        request.getRequestDispatcher(FORWARDING_PLACE).forward(request,response);
      }
 catch (      ServletException e) {
        if (debug.warningEnabled()) {
          debug.warning("String_Node_Str" + e.toString());
        }
        throw new RedirectException("String_Node_Str",e);
      }
    }
 else {
      response.sendRedirect(rUrl);
    }
  }
}
Program: 9071
Project: 9071
Buggy source:
/** 
 * Create a body auditor for JSON bodies.
 * @param fields The fields that should be captured if they exist.
 * @return The auditor object.
 */
public static RestletBodyAuditor jacksonAuditor(String... fields){
  return new RestletBodyAuditor<Map<String,Object>>(fields){
    @Override public JsonValue apply(    Representation representation) throws AuditException {
      try {
        if (((JacksonRepresentation)representation).getObject() instanceof Map) {
          return extractValues((Map<String,Object>)((JacksonRepresentation)representation).getObject());
        }
        return json(object());
      }
 catch (      IOException e) {
        throw new AuditException("String_Node_Str",e);
      }
    }
    @Override Object getValue(    String field,    Map<String,Object> object) throws AuditException {
      return object.get(field);
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Create a body auditor for JSON bodies.
 * @param fields The fields that should be captured if they exist.
 * @return The auditor object.
 */
public static RestletBodyAuditor jacksonAuditor(String... fields){
  return new RestletBodyAuditor<Map<String,Object>>(fields){
    @Override public JsonValue apply(    Representation representation) throws AuditException {
      try {
        if (!representation.isEmpty() && ((JacksonRepresentation)representation).getObject() instanceof Map) {
          return extractValues((Map<String,Object>)((JacksonRepresentation)representation).getObject());
        }
        return json(object());
      }
 catch (      IOException e) {
        throw new AuditException("String_Node_Str",e);
      }
    }
    @Override Object getValue(    String field,    Map<String,Object> object) throws AuditException {
      return object.get(field);
    }
  }
;
}
Program: 9072
Project: 9072
Buggy source:
@Override protected void configure(){
  bind(ResourceTypeConfiguration.class).to(ResourceTypeConfigurationImpl.class);
  bind(ResourceTypeService.class).to(ResourceTypeServiceImpl.class);
  bind(ConstraintValidator.class).to(ConstraintValidatorImpl.class);
  install(new FactoryModuleBuilder().implement(ApplicationService.class,ApplicationServiceImpl.class).build(ApplicationServiceFactory.class));
}

Fixed version (ground truth):
@Override protected void configure(){
  bind(ResourceTypeConfiguration.class).to(ResourceTypeConfigurationImpl.class);
  bind(ResourceTypeService.class).to(ResourceTypeServiceImpl.class);
  bind(ConstraintValidator.class).to(ConstraintValidatorImpl.class);
  install(new FactoryModuleBuilder().implement(ApplicationService.class,ApplicationServiceImpl.class).build(ApplicationServiceFactory.class));
  bind(SessionCache.class).toInstance(SessionCache.getInstance());
}
Program: 9074
Project: 9074
Buggy source:
/** 
 * Handles POST requests to the OpenId Connect client registration endpoint for creating OpenId Connect client registrations.
 * @param entity The representation of the client registration details.
 * @return The representation of the client registration details as created in the store.
 * @throws OAuth2RestletException If an error occurs whilst processing the client registration.
 */
@Post public Representation createClient(Representation entity) throws OAuth2RestletException {
  final OAuth2Request request=requestFactory.create(getRequest());
  final ChallengeResponse authHeader=getRequest().getChallengeResponse();
  final String accessToken=authHeader != null ? authHeader.getRawValue() : null;
  try {
    final String deploymentUrl=getRequest().getHostRef().toString() + "String_Node_Str" + getRequest().getResourceRef().getSegments().get(0);
    final JsonValue registration=clientRegistrationService.createRegistration(accessToken,deploymentUrl,request);
    setStatus(Status.SUCCESS_CREATED);
    return new JsonRepresentation(registration.asMap());
  }
 catch (  OAuth2Exception e) {
    throw new OAuth2RestletException(e.getStatusCode(),e.getError(),e.getMessage(),null);
  }
}

Fixed version (ground truth):
/** 
 * Handles POST requests to the OpenId Connect client registration endpoint for creating OpenId Connect client registrations.
 * @param entity The representation of the client registration details.
 * @return The representation of the client registration details as created in the store.
 * @throws OAuth2RestletException If an error occurs whilst processing the client registration.
 */
@Post public Representation createClient(Representation entity) throws OAuth2RestletException {
  final OAuth2Request request=requestFactory.create(getRequest());
  final ChallengeResponse authHeader=getRequest().getChallengeResponse();
  final String accessToken=authHeader != null ? authHeader.getRawValue() : null;
  try {
    final String deploymentUrl=getRequest().getHostRef().toString() + "String_Node_Str" + getRequest().getResourceRef().getSegments().get(0);
    final JsonValue registration=clientRegistrationService.createRegistration(accessToken,deploymentUrl,request);
    setStatus(Status.SUCCESS_CREATED);
    return new JacksonRepresentation(registration.asMap());
  }
 catch (  OAuth2Exception e) {
    throw new OAuth2RestletException(e.getStatusCode(),e.getError(),e.getMessage(),null);
  }
}
Program: 9075
Project: 9075
Buggy source:
/** 
 * Handles GET requests to the OpenId Connect client registration endpoint for retrieving OpenId Connect client registrations.
 * @return The representation of the client registration details.
 * @throws OAuth2RestletException If an error occurs whilst retrieving the client registration.
 */
@Get public Representation getClient() throws OAuth2RestletException {
  final OAuth2Request request=requestFactory.create(getRequest());
  final String clientId=request.getParameter(OAuth2Constants.OAuth2Client.CLIENT_ID);
  final String accessToken=getRequest().getChallengeResponse().getRawValue();
  try {
    final JsonValue registration=clientRegistrationService.getRegistration(clientId,accessToken,request);
    return new JsonRepresentation(registration.asMap());
  }
 catch (  OAuth2Exception e) {
    throw new OAuth2RestletException(e.getStatusCode(),e.getError(),e.getMessage(),null);
  }
}

Fixed version (ground truth):
/** 
 * Handles GET requests to the OpenId Connect client registration endpoint for retrieving OpenId Connect client registrations.
 * @return The representation of the client registration details.
 * @throws OAuth2RestletException If an error occurs whilst retrieving the client registration.
 */
@Get public Representation getClient() throws OAuth2RestletException {
  final OAuth2Request request=requestFactory.create(getRequest());
  final String clientId=request.getParameter(OAuth2Constants.OAuth2Client.CLIENT_ID);
  final String accessToken=getRequest().getChallengeResponse().getRawValue();
  try {
    final JsonValue registration=clientRegistrationService.getRegistration(clientId,accessToken,request);
    return new JacksonRepresentation(registration.asMap());
  }
 catch (  OAuth2Exception e) {
    throw new OAuth2RestletException(e.getStatusCode(),e.getError(),e.getMessage(),null);
  }
}
Program: 9076
Project: 9076
Buggy source:
/** 
 * Create a body auditor for JSON bodies.
 * @param fields The fields that should be captured if they exist.
 * @return The auditor object.
 */
public static RestletBodyAuditor jacksonAuditor(String... fields){
  return new RestletBodyAuditor<Map<String,Object>>(fields){
    @Override public JsonValue apply(    Representation representation) throws AuditException {
      try {
        return extractValues((Map<String,Object>)(new JacksonRepresentation(representation).getObject()));
      }
 catch (      IOException e) {
        throw new AuditException("String_Node_Str",e);
      }
    }
    @Override Object getValue(    String field,    Map<String,Object> object) throws AuditException {
      return object.get(field);
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Create a body auditor for JSON bodies.
 * @param fields The fields that should be captured if they exist.
 * @return The auditor object.
 */
public static RestletBodyAuditor jacksonAuditor(String... fields){
  return new RestletBodyAuditor<Map<String,Object>>(fields){
    @Override public JsonValue apply(    Representation representation) throws AuditException {
      try {
        if (((JacksonRepresentation)representation).getObject() instanceof Map) {
          return extractValues((Map<String,Object>)((JacksonRepresentation)representation).getObject());
        }
        return json(object());
      }
 catch (      IOException e) {
        throw new AuditException("String_Node_Str",e);
      }
    }
    @Override Object getValue(    String field,    Map<String,Object> object) throws AuditException {
      return object.get(field);
    }
  }
;
}
Program: 9077
Project: 9077
Buggy source:
/** 
 * Create a body auditor for JSON bodies.
 * @param fields The fields that should be captured if they exist.
 * @return The auditor object.
 */
public static RestletBodyAuditor jsonAuditor(String... fields){
  return new RestletBodyAuditor<JSONObject>(fields){
    @Override public JsonValue apply(    Representation representation) throws AuditException {
      try {
        return extractValues(new JsonRepresentation(representation).getJsonObject());
      }
 catch (      IOException|JSONException e) {
        throw new AuditException("String_Node_Str",e);
      }
    }
    @Override Object getValue(    String field,    JSONObject object) throws AuditException {
      return object.opt(field);
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Create a body auditor for JSON bodies.
 * @param fields The fields that should be captured if they exist.
 * @return The auditor object.
 */
public static RestletBodyAuditor jsonAuditor(String... fields){
  return new RestletBodyAuditor<JSONObject>(fields){
    @Override public JsonValue apply(    Representation representation) throws AuditException {
      try {
        boolean isBufferingRepresentation=(representation instanceof BufferingRepresentation);
        boolean isEmptyBufferingRepresentation=isBufferingRepresentation && ((BufferingRepresentation)representation).getWrappedRepresentation().isEmpty();
        if (isEmptyBufferingRepresentation || (!isBufferingRepresentation && representation.isEmpty())) {
          return json(object());
        }
        return extractValues(new JsonRepresentation(representation).getJsonObject());
      }
 catch (      IOException|JSONException e) {
        throw new AuditException("String_Node_Str",e);
      }
    }
    @Override Object getValue(    String field,    JSONObject object) throws AuditException {
      return object.opt(field);
    }
  }
;
}
Program: 9078
Project: 9078
Buggy source:
/** 
 * Create a body auditor for JSON bodies.
 * @param fields The fields that should be captured if they exist.
 * @return The auditor object.
 */
public static RestletBodyAuditor jacksonAuditor(String... fields){
  return new RestletBodyAuditor<Map<String,Object>>(fields){
    @Override public JsonValue apply(    Representation representation) throws AuditException {
      try {
        return extractValues((Map<String,Object>)((JacksonRepresentation)representation).getObject());
      }
 catch (      IOException e) {
        throw new AuditException("String_Node_Str",e);
      }
    }
    @Override Object getValue(    String field,    Map<String,Object> object) throws AuditException {
      return object.get(field);
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Create a body auditor for JSON bodies.
 * @param fields The fields that should be captured if they exist.
 * @return The auditor object.
 */
public static RestletBodyAuditor jacksonAuditor(String... fields){
  return new RestletBodyAuditor<Map<String,Object>>(fields){
    @Override public JsonValue apply(    Representation representation) throws AuditException {
      try {
        return extractValues((Map<String,Object>)(new JacksonRepresentation(representation).getObject()));
      }
 catch (      IOException e) {
        throw new AuditException("String_Node_Str",e);
      }
    }
    @Override Object getValue(    String field,    Map<String,Object> object) throws AuditException {
      return object.get(field);
    }
  }
;
}
Program: 9079
Project: 9079
Buggy source:
/** 
 * Create a body auditor for JSON bodies.
 * @param fields The fields that should be captured if they exist.
 * @return The auditor object.
 */
public static RestletBodyAuditor jsonAuditor(String... fields){
  return new RestletBodyAuditor<JSONObject>(fields){
    @Override public JsonValue apply(    Representation representation) throws AuditException {
      try {
        return extractValues(((JsonRepresentation)representation).getJsonObject());
      }
 catch (      JSONException e) {
        throw new AuditException("String_Node_Str",e);
      }
    }
    @Override Object getValue(    String field,    JSONObject object) throws AuditException {
      return object.opt(field);
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Create a body auditor for JSON bodies.
 * @param fields The fields that should be captured if they exist.
 * @return The auditor object.
 */
public static RestletBodyAuditor jsonAuditor(String... fields){
  return new RestletBodyAuditor<JSONObject>(fields){
    @Override public JsonValue apply(    Representation representation) throws AuditException {
      try {
        return extractValues(new JsonRepresentation(representation).getJsonObject());
      }
 catch (      IOException|JSONException e) {
        throw new AuditException("String_Node_Str",e);
      }
    }
    @Override Object getValue(    String field,    JSONObject object) throws AuditException {
      return object.opt(field);
    }
  }
;
}
Program: 9080
Project: 9080
Buggy source:
/** 
 * Adds and removes labels on the updated resource set, creating the label if required and deleting labels which are no longer used.
 * @param resourceSet The updated resource set.
 */
void updateLabelsForExistingResourceSet(ResourceSetDescription resourceSet){
  JsonValue newLabels=resourceSet.getDescription().get(OAuth2Constants.ResourceSets.LABELS);
  if (newLabels.isNull()) {
    newLabels=json(array());
  }
  Collection<String> addedLabels=newLabels.asSet(String.class);
  try {
    Set<ResourceSetLabel> labels=labelsStore.forResourceSet(resourceSet.getRealm(),resourceSet.getResourceOwnerId(),resourceSet.getId(),true);
    Collection<String> removedLabels=new HashSet<>();
    for (    ResourceSetLabel label : labels) {
      String labelName=label.getName().substring(label.getName().lastIndexOf("String_Node_Str") + 1);
      if (!addedLabels.remove(labelName)) {
        removedLabels.add(labelName);
      }
    }
    updateLabels(resourceSet,addedLabels,removedLabels);
  }
 catch (  ResourceException e) {
    logger.error("String_Node_Str",resourceSet.getId(),e);
  }
}

Fixed version (ground truth):
/** 
 * Adds and removes labels on the updated resource set, creating the label if required and deleting labels which are no longer used.
 * @param resourceSet The updated resource set.
 */
void updateLabelsForExistingResourceSet(ResourceSetDescription resourceSet){
  JsonValue newLabels=resourceSet.getDescription().get(OAuth2Constants.ResourceSets.LABELS);
  if (newLabels.isNull()) {
    newLabels=json(array());
  }
  Collection<String> addedLabels=new HashSet<>(newLabels.asSet(String.class));
  try {
    Set<ResourceSetLabel> labels=labelsStore.forResourceSet(resourceSet.getRealm(),resourceSet.getResourceOwnerId(),resourceSet.getId(),true);
    Collection<String> removedLabels=new HashSet<>();
    for (    ResourceSetLabel label : labels) {
      String labelName=label.getName().substring(label.getName().lastIndexOf("String_Node_Str") + 1);
      if (!addedLabels.remove(labelName)) {
        removedLabels.add(labelName);
      }
    }
    updateLabels(resourceSet,addedLabels,removedLabels);
  }
 catch (  ResourceException e) {
    logger.error("String_Node_Str",resourceSet.getId(),e);
  }
}
Program: 9081
Project: 9081
Buggy source:
private Representation readResourceSet(String resourceSetId) throws NotFoundException, ServerException {
  ResourceSetStore store=providerSettingsFactory.get(requestFactory.create(getRequest())).getResourceSetStore();
  return createJsonResponse(store.read(resourceSetId),true,true);
}

Fixed version (ground truth):
private Representation readResourceSet(String resourceSetId) throws NotFoundException, ServerException {
  ResourceSetStore store=providerSettingsFactory.get(requestFactory.create(getRequest())).getResourceSetStore();
  ResourceSetDescription resourceSetDescription=store.read(resourceSetId);
  Set<String> labels=new HashSet<String>();
  try {
    Set<ResourceSetLabel> labelSet=umaLabelsStore.forResourceSet(resourceSetDescription.getRealm(),resourceSetDescription.getResourceOwnerId(),resourceSetDescription.getId(),false);
    for (    ResourceSetLabel label : labelSet) {
      labels.add(label.getName());
    }
  }
 catch (  org.forgerock.json.resource.ResourceException e) {
    throw new ServerException(e);
  }
  resourceSetDescription.getDescription().put("String_Node_Str",labels);
  return createJsonResponse(resourceSetDescription,true,true);
}
Program: 9083
Project: 9083
Buggy source:
private Tag generateETag(ResourceSetDescription resourceSetDescription){
  return new Tag(Integer.toString(resourceSetDescription.hashCode()),true);
}

Fixed version (ground truth):
private Tag generateETag(ResourceSetDescription resourceSetDescription){
  int hashCode=resourceSetDescription.hashCode();
  JsonValue description=resourceSetDescription.getDescription();
  if (!description.isDefined(OAuth2Constants.ResourceSets.LABELS)) {
    description.put(OAuth2Constants.ResourceSets.LABELS,null);
    hashCode=resourceSetDescription.hashCode();
    description.remove(OAuth2Constants.ResourceSets.LABELS);
  }
  return new Tag(Integer.toString(hashCode),true);
}
Program: 9084
Project: 9084
Buggy source:
@Put public Representation updateResourceSet(JsonRepresentation entity) throws NotFoundException, ServerException, BadRequestException {
  if (!isConditionalRequest()) {
    throw new ResourceException(512,"String_Node_Str","String_Node_Str",null);
  }
  final Map<String,Object> resourceSetDescriptionAttributes=validator.validate(toMap(entity));
  final String resourceSetId=getResourceSetId();
  ResourceSetStore store=providerSettingsFactory.get(requestFactory.create(getRequest())).getResourceSetStore();
  ResourceSetDescription resourceSetDescription=store.read(resourceSetId).update(resourceSetDescriptionAttributes);
  JsonValue labels=resourceSetDescription.getDescription().get(OAuth2Constants.ResourceSets.LABELS);
  resourceSetDescription.getDescription().remove(OAuth2Constants.ResourceSets.LABELS);
  store.update(resourceSetDescription);
  resourceSetDescription.getDescription().add(OAuth2Constants.ResourceSets.LABELS,labels);
  labelRegistration.updateLabelsForExistingResourceSet(resourceSetDescription);
  return createJsonResponse(resourceSetDescription,false,true);
}

Fixed version (ground truth):
@Put public Representation updateResourceSet(JsonRepresentation entity) throws NotFoundException, ServerException, BadRequestException {
  if (!isConditionalRequest()) {
    throw new ResourceException(512,"String_Node_Str","String_Node_Str",null);
  }
  final Map<String,Object> resourceSetDescriptionAttributes=validator.validate(toMap(entity));
  final String resourceSetId=getResourceSetId();
  ResourceSetStore store=providerSettingsFactory.get(requestFactory.create(getRequest())).getResourceSetStore();
  ResourceSetDescription resourceSetDescription=store.read(resourceSetId).update(resourceSetDescriptionAttributes);
  JsonValue labels=resourceSetDescription.getDescription().get(OAuth2Constants.ResourceSets.LABELS);
  resourceSetDescription.getDescription().remove(OAuth2Constants.ResourceSets.LABELS);
  store.update(resourceSetDescription);
  if (labels.isNotNull()) {
    resourceSetDescription.getDescription().add(OAuth2Constants.ResourceSets.LABELS,labels.asSet());
  }
 else {
    resourceSetDescription.getDescription().add(OAuth2Constants.ResourceSets.LABELS,new HashSet<String>());
  }
  labelRegistration.updateLabelsForExistingResourceSet(resourceSetDescription);
  return createJsonResponse(resourceSetDescription,false,true);
}
Program: 9085
Project: 9085
Buggy source:
/** 
 * Construct a new ResourceSetRegistrationEndpoint instance.
 * @param providerSettingsFactory An instance of the {@link OAuth2ProviderSettingsFactory}.
 * @param validator An instance of the {@link ResourceSetDescriptionValidator}.
 * @param requestFactory An instance of the OAuth2RequestFactory.
 * @param listeners A {@code Set} of {@code ResourceSetRegistrationListener}s.
 * @param labelRegistration An instance of the {@code ResourceSetLabelRegistration}.
 * @param extensionFilterManager An instance of the {@code ExtensionFilterManager}.
 * @param exceptionHandler An instance of the {@code ExceptionHandler}.
 */
@Inject public ResourceSetRegistrationEndpoint(OAuth2ProviderSettingsFactory providerSettingsFactory,ResourceSetDescriptionValidator validator,OAuth2RequestFactory<Request> requestFactory,Set<ResourceSetRegistrationListener> listeners,ResourceSetLabelRegistration labelRegistration,ExtensionFilterManager extensionFilterManager,ExceptionHandler exceptionHandler){
  this.providerSettingsFactory=providerSettingsFactory;
  this.validator=validator;
  this.requestFactory=requestFactory;
  this.listeners=listeners;
  this.labelRegistration=labelRegistration;
  this.extensionFilterManager=extensionFilterManager;
  this.exceptionHandler=exceptionHandler;
}

Fixed version (ground truth):
/** 
 * Construct a new ResourceSetRegistrationEndpoint instance.
 * @param providerSettingsFactory An instance of the {@link OAuth2ProviderSettingsFactory}.
 * @param validator An instance of the {@link ResourceSetDescriptionValidator}.
 * @param requestFactory An instance of the OAuth2RequestFactory.
 * @param listeners A {@code Set} of {@code ResourceSetRegistrationListener}s.
 * @param labelRegistration An instance of the {@code ResourceSetLabelRegistration}.
 * @param extensionFilterManager An instance of the {@code ExtensionFilterManager}.
 * @param exceptionHandler An instance of the {@code ExceptionHandler}.
 * @param umaLabelsStore An instance of the Uma Label Store
 */
@Inject public ResourceSetRegistrationEndpoint(OAuth2ProviderSettingsFactory providerSettingsFactory,ResourceSetDescriptionValidator validator,OAuth2RequestFactory<Request> requestFactory,Set<ResourceSetRegistrationListener> listeners,ResourceSetLabelRegistration labelRegistration,ExtensionFilterManager extensionFilterManager,ExceptionHandler exceptionHandler,UmaLabelsStore umaLabelsStore){
  this.providerSettingsFactory=providerSettingsFactory;
  this.validator=validator;
  this.requestFactory=requestFactory;
  this.listeners=listeners;
  this.labelRegistration=labelRegistration;
  this.extensionFilterManager=extensionFilterManager;
  this.exceptionHandler=exceptionHandler;
  this.umaLabelsStore=umaLabelsStore;
}
Program: 9088
Project: 9088
Buggy source:
/** 
 * Lets through any request which is coming from a verifiable administrator.
 */
protected Promise<AuthorizationResult,ResourceException> authorize(Context context){
  try {
    String userId=getUserId(context);
    if (isSuperUser(userId)) {
      if (debug.messageEnabled()) {
        debug.message("String_Node_Str" + userId + "String_Node_Str");
      }
      return Promises.newResultPromise(AuthorizationResult.accessPermitted());
    }
 else {
      if (debug.messageEnabled()) {
        debug.message("String_Node_Str" + userId);
      }
      return Promises.newResultPromise(AuthorizationResult.accessDenied("String_Node_Str"));
    }
  }
 catch (  ResourceException e) {
    return e.asPromise();
  }
}

Fixed version (ground truth):
/** 
 * Lets through any request which is coming from a verifiable administrator.
 */
protected Promise<AuthorizationResult,ResourceException> authorize(Context context){
  try {
    String userId=getUserId(context);
    if (isSuperUser(userId)) {
      if (debug.messageEnabled()) {
        debug.message("String_Node_Str" + userId + "String_Node_Str");
      }
      return Promises.newResultPromise(AuthorizationResult.accessPermitted());
    }
 else {
      if (debug.messageEnabled()) {
        debug.message("String_Node_Str" + userId);
      }
      return Promises.newResultPromise(AuthorizationResult.accessDenied("String_Node_Str"));
    }
  }
 catch (  ForbiddenException e) {
    return Promises.newResultPromise(AuthorizationResult.accessDenied("String_Node_Str"));
  }
catch (  ResourceException re) {
    return re.asPromise();
  }
}
Program: 9089
Project: 9089
Buggy source:
/** 
 * Given the calling context and the privilege definition attempts to authorise the calling subject.
 * @param context the server context
 * @param definition the privilege definition
 * @return the authorisation result
 */
private Promise<AuthorizationResult,ResourceException> evaluate(final Context context,final PrivilegeDefinition definition){
  final String realm=(context.containsContext(RealmContext.class)) ? context.asContext(RealmContext.class).getResolvedRealm() : "String_Node_Str";
  final SubjectContext subjectContext=context.asContext(SubjectContext.class);
  final UriRouterContext routerContext=context.asContext(UriRouterContext.class);
  final Set<String> actions=transformSet(definition.getActions(),ACTION_TO_STRING_MAPPER);
  try {
    final DelegationPermission permissionRequest=permissionFactory.newInstance(realm,REST,VERSION,routerContext.getMatchedUri(),definition.getCommonVerb(),actions,Collections.<String,String>emptyMap());
    if (evaluator.isAllowed(subjectContext.getCallerSSOToken(),permissionRequest,Collections.<String,Set<String>>emptyMap())) {
      return Promises.newResultPromise(AuthorizationResult.accessPermitted());
    }
  }
 catch (  DelegationException dE) {
    return new InternalServerErrorException("String_Node_Str",dE).asPromise();
  }
catch (  SSOException ssoE) {
    return new InternalServerErrorException("String_Node_Str",ssoE).asPromise();
  }
  return Promises.newResultPromise(AuthorizationResult.accessDenied("String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Given the calling context and the privilege definition attempts to authorise the calling subject.
 * @param context the server context
 * @param definition the privilege definition
 * @return the authorisation result
 */
private Promise<AuthorizationResult,ResourceException> evaluate(final Context context,final PrivilegeDefinition definition){
  final String realm=(context.containsContext(RealmContext.class)) ? context.asContext(RealmContext.class).getResolvedRealm() : "String_Node_Str";
  final SubjectContext subjectContext=context.asContext(SubjectContext.class);
  final UriRouterContext routerContext=context.asContext(UriRouterContext.class);
  final Set<String> actions=transformSet(definition.getActions(),ACTION_TO_STRING_MAPPER);
  try {
    final DelegationPermission permissionRequest=permissionFactory.newInstance(realm,REST,VERSION,routerContext.getMatchedUri(),definition.getCommonVerb(),actions,Collections.<String,String>emptyMap());
    if (evaluator.isAllowed(subjectContext.getCallerSSOToken(),permissionRequest,Collections.<String,Set<String>>emptyMap())) {
      return Promises.newResultPromise(AuthorizationResult.accessPermitted());
    }
  }
 catch (  DelegationException dE) {
    return new InternalServerErrorException("String_Node_Str",dE).asPromise();
  }
catch (  SSOException ssoE) {
    return Promises.newResultPromise(AuthorizationResult.accessDenied("String_Node_Str"));
  }
  return Promises.newResultPromise(AuthorizationResult.accessDenied("String_Node_Str"));
}
Program: 9090
Project: 9090
Buggy source:
@Test(expectedExceptions=ResourceException.class) public void shouldErrorInvalidContext() throws SSOException, ResourceException, InterruptedException {
  SSOTokenContext mockSSOTokenContext=mock(SSOTokenContext.class);
  SSOToken mockSSOToken=mock(SSOToken.class);
  given(mockSSOTokenContext.getCallerSSOToken()).willReturn(mockSSOToken);
  given(mockSSOToken.getProperty(Constants.UNIVERSAL_IDENTIFIER)).willThrow(new SSOException("String_Node_Str"));
  Promise<AuthorizationResult,ResourceException> result=testModule.authorize(mockSSOTokenContext);
  result.getOrThrow();
}

Fixed version (ground truth):
@Test public void shouldErrorInvalidContext() throws SSOException, ResourceException, InterruptedException, ExecutionException {
  SSOTokenContext mockSSOTokenContext=mock(SSOTokenContext.class);
  SSOToken mockSSOToken=mock(SSOToken.class);
  given(mockSSOTokenContext.getCallerSSOToken()).willReturn(mockSSOToken);
  given(mockSSOToken.getProperty(Constants.UNIVERSAL_IDENTIFIER)).willThrow(new SSOException("String_Node_Str"));
  Promise<AuthorizationResult,ResourceException> result=testModule.authorize(mockSSOTokenContext);
  assertFalse(result.get().isAuthorized());
}
Program: 9091
Project: 9091
Buggy source:
/** 
 * Set the result.
 * @param result The result.
 */
public void setResult(EventOutcome result){
  this.entry.put(RESULT_KEY,result);
}

Fixed version (ground truth):
/** 
 * Set the result.
 * @param result The result.
 */
public void setResult(AuthenticationAuditEventBuilder.Status result){
  this.entry.put(RESULT_KEY,result);
}
Program: 9092
Project: 9092
Buggy source:
/** 
 * Get the result.
 * @return The result.
 */
public EventOutcome getResult(){
  return (EventOutcome)this.entry.get(RESULT_KEY);
}

Fixed version (ground truth):
/** 
 * Get the result.
 * @return The result.
 */
public AuthenticationAuditEventBuilder.Status getResult(){
  return (AuthenticationAuditEventBuilder.Status)this.entry.get(RESULT_KEY);
}
Program: 9094
Project: 9094
Buggy source:
private boolean auditAuthenticationEvent(String description,String transactionId,String authentication,String realmName,long time,Map<String,String> contexts,List<?> entries){
  boolean couldHandleEvent=true;
  AMAuthenticationAuditEventBuilder builder=authenticationAuditor.authenticationEvent();
  builder.transactionId(transactionId).authentication(authentication).timestamp(time).component(AuditConstants.Component.AUTHENTICATION);
  if (StringUtils.isNotEmpty(description)) {
    builder.eventName(description);
  }
  if (StringUtils.isNotEmpty(realmName)) {
    builder.realm(realmName);
  }
  if (contexts != null && !contexts.isEmpty()) {
    builder.contexts(contexts);
  }
  if (entries != null && !entries.isEmpty()) {
    builder.entries(entries);
  }
  try {
    authenticationAuditor.publish(builder.toEvent());
  }
 catch (  AuditException e) {
    couldHandleEvent=false;
  }
  return couldHandleEvent;
}

Fixed version (ground truth):
private boolean auditAuthenticationEvent(String description,String transactionId,String authentication,String realmName,long time,Map<String,String> contexts,List<Entry> entries){
  boolean couldHandleEvent=true;
  AMAuthenticationAuditEventBuilder builder=authenticationAuditor.authenticationEvent();
  builder.transactionId(transactionId).authentication(authentication).timestamp(time).component(AuditConstants.Component.AUTHENTICATION);
  if (StringUtils.isNotEmpty(description)) {
    builder.eventName(description);
  }
  if (StringUtils.isNotEmpty(realmName)) {
    builder.realm(realmName);
  }
  if (contexts != null && !contexts.isEmpty()) {
    builder.contexts(contexts);
  }
  if (entries != null && !entries.isEmpty()) {
    List<Map<String,Object>> list=new ArrayList<>();
    for (    Entry entry : entries) {
      Map<String,Object> map=new HashMap<>();
      map.put("String_Node_Str",entry.getModuleId());
      map.put("String_Node_Str",entry.getResult());
      map.put("String_Node_Str",entry.getInfo());
      list.add(map);
    }
    builder.entries(list);
  }
  try {
    authenticationAuditor.publish(builder.toEvent());
  }
 catch (  AuditException e) {
    couldHandleEvent=false;
  }
  return couldHandleEvent;
}
Program: 9101
Project: 9101
Buggy source:
private String getCodeVerifier(String codeChallengeMethod) throws LoginException {
  String codeVerifier=Base64url.encode(RandomStringUtils.randomAlphanumeric(96).getBytes());
  if (SHA_256_DISPLAY_NAME.equals(codeChallengeMethod)) {
    try {
      return Base64url.encode(MessageDigest.getInstance("String_Node_Str").digest(codeVerifier.getBytes(StandardCharsets.US_ASCII)));
    }
 catch (    NoSuchAlgorithmException e) {
      throw new LoginException("String_Node_Str");
    }
  }
 else {
    return codeVerifier;
  }
}

Fixed version (ground truth):
private String getCodeVerifier(String codeChallengeMethod) throws LoginException {
  String codeVerifier=Base64url.encode(RandomStringUtils.randomAlphanumeric(96).getBytes());
  if (OAuth2Constants.Custom.CODE_CHALLENGE_METHOD_S_256.equals(codeChallengeMethod)) {
    try {
      return Base64url.encode(MessageDigest.getInstance("String_Node_Str").digest(codeVerifier.getBytes(StandardCharsets.US_ASCII)));
    }
 catch (    NoSuchAlgorithmException e) {
      throw new LoginException("String_Node_Str");
    }
  }
 else {
    return codeVerifier;
  }
}
Program: 9102
Project: 9102
Buggy source:
@Override protected String getContextIdForAccessAttempt(Request request){
  try {
    String jsonString=request.getEntity().getString();
    if (isNotEmpty(jsonString)) {
      JsonValue jsonValue=toJsonValue(jsonString);
      if (jsonValue.isDefined(AUTH_ID)) {
        populateContextFromAuthId(jsonValue.get(AUTH_ID).asString());
      }
    }
    return super.getContextIdForAccessAttempt(request);
  }
 catch (  IOException e) {
    return "String_Node_Str";
  }
}

Fixed version (ground truth):
protected String getContextIdForAccessAttempt(Request request){
  try {
    String jsonString=request.getEntity().getString();
    if (isNotEmpty(jsonString)) {
      JsonValue jsonValue=toJsonValue(jsonString);
      if (jsonValue.isDefined(AUTH_ID)) {
        populateContextFromAuthId(jsonValue.get(AUTH_ID).asString());
      }
    }
  }
 catch (  IOException e) {
    return "String_Node_Str";
  }
  return null;
}
Program: 9103
Project: 9103
Buggy source:
@Override protected String getContextIdForAccessOutcome(Response response){
  String contextId=super.getContextIdForAccessOutcome(response);
  if (isNotEmpty(contextId)) {
    return contextId;
  }
  String tokenId=AuditRequestContext.getProperty(TOKEN_ID);
  String sessionId=AuditRequestContext.getProperty(SESSION_ID);
  String authId=AuditRequestContext.getProperty(AUTH_ID);
  if (isNotEmpty(tokenId)) {
    populateContextFromTokenId(tokenId);
  }
 else   if (isNotEmpty(sessionId)) {
    AuditRequestContext.putProperty(CONTEXT_ID,getContextIdFromSessionId(sessionId));
  }
 else   if (isNotEmpty(authId)) {
    populateContextFromAuthId(authId);
  }
  return super.getContextIdForAccessOutcome(response);
}

Fixed version (ground truth):
protected String getContextIdForAccessOutcome(Response response){
  String tokenId=AuditRequestContext.getProperty(TOKEN_ID);
  String sessionId=AuditRequestContext.getProperty(SESSION_ID);
  String authId=AuditRequestContext.getProperty(AUTH_ID);
  if (isNotEmpty(tokenId)) {
    populateContextFromTokenId(tokenId);
  }
 else   if (isNotEmpty(sessionId)) {
  }
 else   if (isNotEmpty(authId)) {
    populateContextFromAuthId(authId);
  }
  return null;
}
Program: 9104
Project: 9104
Buggy source:
private void populateContextFromAuthId(String authId){
  try {
    String sessionId=authIdHelper.reconstructAuthId(authId).getClaimsSet().getClaim(SESSION_ID,String.class);
    if (isEmpty(sessionId)) {
      return;
    }
    String contextId=getContextIdFromSessionId(sessionId);
    if (isNotEmpty(contextId)) {
      AuditRequestContext.putProperty(CONTEXT_ID,contextId);
    }
  }
 catch (  RestAuthException e) {
    debug.warning("String_Node_Str");
  }
}

Fixed version (ground truth):
private void populateContextFromAuthId(String authId){
  try {
    String sessionId=authIdHelper.reconstructAuthId(authId).getClaimsSet().getClaim(SESSION_ID,String.class);
    if (isEmpty(sessionId)) {
      return;
    }
    String contextId=getContextIdFromSessionId(sessionId);
    if (isNotEmpty(contextId)) {
    }
  }
 catch (  RestAuthException e) {
    debug.warning("String_Node_Str");
  }
}
Program: 9105
Project: 9105
Buggy source:
private void populateContextFromTokenId(String tokenId){
  try {
    SSOToken token=SSOTokenManager.getInstance().createSSOToken(tokenId);
    AuditRequestContext.putProperty(USER_ID,getUserId(token));
    AuditRequestContext.putProperty(CONTEXT_ID,getContextIdFromSSOToken(token));
  }
 catch (  SSOException e) {
    debug.warning("String_Node_Str");
  }
}

Fixed version (ground truth):
private void populateContextFromTokenId(String tokenId){
  try {
    SSOToken token=SSOTokenManager.getInstance().createSSOToken(tokenId);
    AuditRequestContext.putProperty(USER_ID,getUserId(token));
  }
 catch (  SSOException e) {
    debug.warning("String_Node_Str");
  }
}
Program: 9106
Project: 9106
Buggy source:
private void auditAccessSuccess(Request request,Response response){
  if (auditEventPublisher.isAuditing(ACCESS_TOPIC)) {
    long endTime=System.currentTimeMillis();
    AMAccessAuditEventBuilder builder=auditEventFactory.accessEvent().timestamp(endTime).transactionId(AuditRequestContext.getTransactionIdValue()).eventName(EventName.AM_ACCESS_OUTCOME).component(component).authentication(getUserIdForAccessOutcome(response)).contextId(getContextIdForAccessOutcome(response)).response("String_Node_Str",endTime - request.getDate().getTime());
    addHttpData(request,builder);
    auditEventPublisher.tryPublish(ACCESS_TOPIC,builder.toEvent());
  }
}

Fixed version (ground truth):
private void auditAccessSuccess(Request request,Response response){
}
Program: 9107
Project: 9107
Buggy source:
private void addHttpData(Request request,AMAccessAuditEventBuilder builder){
  HttpServletRequest servletRequest=getRequest(request);
  if (servletRequest != null) {
    builder.forHttpServletRequest(servletRequest);
  }
}

Fixed version (ground truth):
private void addHttpData(Request request,AMAccessAuditEventBuilder builder){
}
Program: 9108
Project: 9108
Buggy source:
/** 
 * Retrieve the context ID for an access attempt.
 * @param request the restlet request
 * @return the context ID
 */
protected String getContextIdForAccessAttempt(Request request){
  return AuditRequestContext.getProperty(CONTEXT_ID);
}

Fixed version (ground truth):
/** 
 * Retrieve the context ID for an access attempt.
 * @param request the restlet request
 * @return the context ID
 */
protected String getContextIdForAccessAttempt(Request request){
  return null;
}
Program: 9109
Project: 9109
Buggy source:
/** 
 * Retrieve the user ID for an access outcome.
 * @param response the restlet response
 * @return the user ID
 */
protected String getUserIdForAccessOutcome(Response response){
  String userId=AuditRequestContext.getProperty(USER_ID);
  return userId == null ? "String_Node_Str" : userId;
}

Fixed version (ground truth):
/** 
 * Retrieve the user ID for an access outcome.
 * @param response the restlet response
 * @return the user ID
 */
protected String getUserIdForAccessOutcome(Response response){
  return null;
}
Program: 9110
Project: 9110
Buggy source:
@Override protected void afterHandle(Request request,Response response){
  super.afterHandle(request,response);
  if (response.getStatus().isError()) {
    auditAccessFailure(request,response);
  }
 else {
    auditAccessSuccess(request,response);
  }
}

Fixed version (ground truth):
@Override protected void afterHandle(Request request,Response response){
}
Program: 9111
Project: 9111
Buggy source:
/** 
 * Retrieve the Context ID for an access outcome.
 * @param response the restlet response
 * @return the context ID
 */
protected String getContextIdForAccessOutcome(Response response){
  return AuditRequestContext.getProperty(CONTEXT_ID);
}

Fixed version (ground truth):
/** 
 * Retrieve the Context ID for an access outcome.
 * @param response the restlet response
 * @return the context ID
 */
protected String getContextIdForAccessOutcome(Response response){
  return null;
}