nus-yam/ex-repair huggingface dataset:
Program: 130890
Project: 130890
Buggy source:
public static void main(String[] args) throws IOException {
  final List<Class<?>> classes=IntrospectionUtils.publicClassesOfProject();
  final List<Rule> rules=asList(new UpdateActionsInCorrectPackageRule(),new CommandsInCorrectPackageRule(),new QueriesInCorrectPackageRule(),new ImplClassesAreForPackageScopeRule(),new NoOptionalParametersInMethodsRule(),new NoOptionalReturnTypeForGettersRule(),new NoOptionalParametersInPublicConstructorRule(),new PublicConstructorsAreTheExceptionRule(),new BuildersNotForResources());
  final boolean allIsOk=rules.stream().map(rule -> {
    final RulesReport report=rule.check(classes);
    if (!report.isOk()) {
      System.err.println(report);
    }
    return report.isOk();
  }
).noneMatch(res -> res != true);
  if (!allIsOk) {
    System.exit(1);
  }
}

Fixed version (ground truth):
public static void main(String[] args) throws IOException {
  final List<Class<?>> classes=IntrospectionUtils.publicClassesOfProject();
  final List<Rule> rules=asList(new UpdateActionsInCorrectPackageRule(),new CommandsInCorrectPackageRule(),new QueriesInCorrectPackageRule(),new ImplClassesAreForPackageScopeRule(),new NoOptionalParametersInMethodsRule(),new NoOptionalReturnTypeForGettersRule(),new NoOptionalParametersInPublicConstructorRule(),new PublicConstructorsAreTheExceptionRule(),new BuildersNotForResources(),new NeverMixStaticAndInstanceMethodOfSameNameRule());
  final boolean allIsOk=rules.stream().map(rule -> {
    final RulesReport report=rule.check(classes);
    if (!report.isOk()) {
      System.err.println(report);
    }
    return report.isOk();
  }
).noneMatch(res -> res != true);
  if (!allIsOk) {
    System.exit(1);
  }
}
Program: 130891
Project: 130891
Buggy source:
@Test public void execution() throws Exception {
  final ZonedDateTime validFrom=ZonedDateTime.now();
  final ZonedDateTime validUntil=validFrom.plusSeconds(8000);
  final LocalizedStrings name=en("String_Node_Str");
  final LocalizedStrings description=en("String_Node_Str");
  final String predicate="String_Node_Str";
  final AbsoluteCartDiscountValue value=CartDiscountValue.ofAbsolute(MoneyImpl.of(10,EUR));
  final LineItemsTarget target=LineItemsTarget.of("String_Node_Str");
  final String sortOrder="String_Node_Str";
  final boolean requiresDiscountCode=false;
  final CartDiscountDraft discountDraft=CartDiscountDraftBuilder.of(name,CartPredicate.of(predicate),value,target,sortOrder,requiresDiscountCode).validFrom(validFrom).validUntil(validUntil).description(description).isActive(false).build();
  cartDiscount=execute(CartDiscountCreateCommand.of(discountDraft));
  assertThat(cartDiscount.getName()).isEqualTo(name);
  assertThat(cartDiscount.getCartPredicate()).isEqualTo(predicate);
  assertThat(cartDiscount.getValue()).isEqualTo(value);
  assertThat(cartDiscount.getTarget()).isEqualTo(target);
  assertThat(cartDiscount.getSortOrder()).isEqualTo(sortOrder);
  assertThat(cartDiscount.isRequiringDiscountCode()).isEqualTo(requiresDiscountCode);
  assertThat(cartDiscount.getValidFrom()).contains(validFrom);
  assertThat(cartDiscount.getValidUntil()).contains(validUntil);
  assertThat(cartDiscount.getDescription()).contains(description);
  assertThat(cartDiscount.getReferences()).isEqualTo(Collections.emptyList());
}

Fixed version (ground truth):
@Test public void execution() throws Exception {
  final ZonedDateTime validFrom=SphereTestUtils.now();
  final ZonedDateTime validUntil=validFrom.plusSeconds(8000);
  final LocalizedStrings name=en("String_Node_Str");
  final LocalizedStrings description=en("String_Node_Str");
  final String predicate="String_Node_Str";
  final AbsoluteCartDiscountValue value=CartDiscountValue.ofAbsolute(MoneyImpl.of(10,EUR));
  final LineItemsTarget target=LineItemsTarget.of("String_Node_Str");
  final String sortOrder="String_Node_Str";
  final boolean requiresDiscountCode=false;
  final CartDiscountDraft discountDraft=CartDiscountDraftBuilder.of(name,CartPredicate.of(predicate),value,target,sortOrder,requiresDiscountCode).validFrom(validFrom).validUntil(validUntil).description(description).isActive(false).build();
  cartDiscount=execute(CartDiscountCreateCommand.of(discountDraft));
  assertThat(cartDiscount.getName()).isEqualTo(name);
  assertThat(cartDiscount.getCartPredicate()).isEqualTo(predicate);
  assertThat(cartDiscount.getValue()).isEqualTo(value);
  assertThat(cartDiscount.getTarget()).isEqualTo(target);
  assertThat(cartDiscount.getSortOrder()).isEqualTo(sortOrder);
  assertThat(cartDiscount.isRequiringDiscountCode()).isEqualTo(requiresDiscountCode);
  assertThat(cartDiscount.getValidFrom()).contains(validFrom);
  assertThat(cartDiscount.getValidUntil()).contains(validUntil);
  assertThat(cartDiscount.getDescription()).contains(description);
  assertThat(cartDiscount.getReferences()).isEqualTo(Collections.emptyList());
}
Program: 130892
Project: 130892
Buggy source:
@Test public void setValidFrom() throws Exception {
  withPersistentCartDiscount(client(),cartDiscount -> {
    final ZonedDateTime dateTime=ZonedDateTime.now();
    assertThat(cartDiscount.getValidFrom()).isNotEqualTo(Optional.of(dateTime));
    final CartDiscount updatedDiscount=execute(CartDiscountUpdateCommand.of(cartDiscount,SetValidFrom.of(dateTime)));
    assertThat(updatedDiscount.getValidFrom()).contains(dateTime);
  }
);
}

Fixed version (ground truth):
@Test public void setValidFrom() throws Exception {
  withPersistentCartDiscount(client(),cartDiscount -> {
    final ZonedDateTime dateTime=SphereTestUtils.now();
    assertThat(cartDiscount.getValidFrom()).isNotEqualTo(Optional.of(dateTime));
    final CartDiscount updatedDiscount=execute(CartDiscountUpdateCommand.of(cartDiscount,SetValidFrom.of(dateTime)));
    assertThat(updatedDiscount.getValidFrom()).contains(dateTime);
  }
);
}
Program: 130893
Project: 130893
Buggy source:
private ZonedDateTime dateTimeAfterValidFromAndOldValidUntil(final CartDiscount cartDiscount){
  return cartDiscount.getValidUntil().orElse(cartDiscount.getValidFrom().orElse(ZonedDateTime.now()).plusSeconds(1000)).plusSeconds(1);
}

Fixed version (ground truth):
private ZonedDateTime dateTimeAfterValidFromAndOldValidUntil(final CartDiscount cartDiscount){
  return cartDiscount.getValidUntil().orElse(cartDiscount.getValidFrom().orElse(SphereTestUtils.now()).plusSeconds(1000)).plusSeconds(1);
}
Program: 130894
Project: 130894
Buggy source:
@Test public void setExpectedDelivery() throws Exception {
  withUpdateableInventoryEntry(client(),entry -> {
    final ZonedDateTime expectedDelivery=ZonedDateTime.now().plus(7,ChronoUnit.DAYS);
    final UpdateAction<InventoryEntry> action=SetExpectedDelivery.of(expectedDelivery);
    final InventoryEntry updatedEntry=execute(InventoryEntryUpdateCommand.of(entry,action));
    assertThat(updatedEntry.getExpectedDelivery()).contains(expectedDelivery).isNotEqualTo(entry.getExpectedDelivery());
    return updatedEntry;
  }
);
}

Fixed version (ground truth):
@Test public void setExpectedDelivery() throws Exception {
  withUpdateableInventoryEntry(client(),entry -> {
    final ZonedDateTime expectedDelivery=SphereTestUtils.now().plus(7,ChronoUnit.DAYS);
    final UpdateAction<InventoryEntry> action=SetExpectedDelivery.of(expectedDelivery);
    final InventoryEntry updatedEntry=execute(InventoryEntryUpdateCommand.of(entry,action));
    assertThat(updatedEntry.getExpectedDelivery()).contains(expectedDelivery).isNotEqualTo(entry.getExpectedDelivery());
    return updatedEntry;
  }
);
}
Program: 130896
Project: 130896
Buggy source:
@Test public void getCompletedAt() throws Exception {
  final ZonedDateTime completedAt=ZonedDateTime.now().minusSeconds(5555);
  testOrderAspect(builder -> builder.completedAt(completedAt),order -> assertThat(order.getCompletedAt()).contains(completedAt));
}

Fixed version (ground truth):
@Test public void getCompletedAt() throws Exception {
  final ZonedDateTime completedAt=SphereTestUtils.now().minusSeconds(5555);
  testOrderAspect(builder -> builder.completedAt(completedAt),order -> assertThat(order.getCompletedAt()).contains(completedAt));
}
Program: 130897
Project: 130897
Buggy source:
@Test public void addPriceWithValidityPeriod() throws Exception {
  final Price expectedPrice=Price.of(MoneyImpl.of(123,EUR)).withValidFrom(ZonedDateTime.now()).withValidUntil(ZonedDateTime.now().withZoneSameLocal(ZoneId.of("String_Node_Str")).plusHours(2));
  testAddPrice(expectedPrice);
}

Fixed version (ground truth):
@Test public void addPriceWithValidityPeriod() throws Exception {
  final Price expectedPrice=Price.of(MoneyImpl.of(123,EUR)).withValidFrom(SphereTestUtils.now()).withValidUntil(SphereTestUtils.now().withZoneSameLocal(ZoneId.of("String_Node_Str")).plusHours(2));
  testAddPrice(expectedPrice);
}
Program: 130898
Project: 130898
Buggy source:
@Test public void dateTimeAttribute() throws Exception {
  final ZonedDateTime now=ZonedDateTime.now().withZoneSameInstant(ZoneId.of("String_Node_Str"));
  testSingleAndSet(AttributeAccess.ofDateTime(),AttributeAccess.ofDateTimeSet(),asSet(now,now.plus(3,ChronoUnit.DAYS)),DateTimeType.of(),AttributeDefinitionBuilder.of("String_Node_Str",LABEL,DateTimeType.of()).build());
}

Fixed version (ground truth):
@Test public void dateTimeAttribute() throws Exception {
  final ZonedDateTime now=SphereTestUtils.now().withZoneSameInstant(ZoneId.of("String_Node_Str"));
  testSingleAndSet(AttributeAccess.ofDateTime(),AttributeAccess.ofDateTimeSet(),asSet(now,now.plus(3,ChronoUnit.DAYS)),DateTimeType.of(),AttributeDefinitionBuilder.of("String_Node_Str",LABEL,DateTimeType.of()).build());
}
Program: 130899
Project: 130899
Buggy source:
public static final ZonedDateTime tomorrowZonedDateTime(){
  return ZonedDateTime.now().plus(1,ChronoUnit.DAYS);
}

Fixed version (ground truth):
public static final ZonedDateTime tomorrowZonedDateTime(){
  return now().plus(1,ChronoUnit.DAYS);
}
Program: 130900
Project: 130900
Buggy source:
protected ByIdFetchImpl(final String id,final JsonEndpoint<T> endpoint){
  super(endpoint,id);
}

Fixed version (ground truth):
public ByIdFetchImpl(final JsonEndpoint<T> endpoint,final String identifierToSearchFor,final List<HttpQueryParameter> additionalParameters){
  super(endpoint,identifierToSearchFor,additionalParameters);
}
Program: 130901
Project: 130901
Buggy source:
private ProductProjectionByIdFetch(final String id,final ProductProjectionType projectionType){
  super(id,ProductProjectionsEndpoint.ENDPOINT);
  this.projectionType=projectionType;
}

Fixed version (ground truth):
private ProductProjectionByIdFetch(final String id,final ProductProjectionType projectionType){
  super(ProductProjectionsEndpoint.ENDPOINT,id,asList(HttpQueryParameter.of("String_Node_Str",projectionType.isStaged().toString())));
}
Program: 130902
Project: 130902
Buggy source:
@Test public void noSearchHintNoteOnNormalException() throws Exception {
  final SphereClient client=SphereClientFactory.of().createHttpTestDouble(intent -> HttpResponse.of(500));
  assertThatThrownBy(() -> client.execute(CategoryQuery.of())).isInstanceOf(SphereException.class).matches(e -> ((SphereException)e).getAdditionalNotes().stream().allMatch(s -> !s.contains("String_Node_Str")));
}

Fixed version (ground truth):
@Test public void noSearchHintNoteOnNormalException() throws Exception {
  final SphereClient client=SphereClientFactory.of().createHttpTestDouble(intent -> HttpResponse.of(500));
  assertThatThrownBy(() -> client.execute(CategoryQuery.of()).toCompletableFuture().join()).hasCauseInstanceOf(SphereException.class).matches(e -> ((SphereException)e.getCause()).getAdditionalNotes().stream().allMatch(s -> !s.contains("String_Node_Str")));
}
Program: 130903
Project: 130903
Buggy source:
private CurrencyUnit currency(final String currencyCode){
  return CurrencyUnitBuilder.of(currencyCode,CurrencyContext.KEY_PROVIDER).build();
}

Fixed version (ground truth):
private CurrencyUnit currency(final String currencyCode){
  return MonetaryCurrencies.getCurrency(currencyCode);
}
Program: 130904
Project: 130904
Buggy source:
private CurrencyUnit currency(final String currencyCode){
  return CurrencyUnitBuilder.of(currencyCode,CurrencyContext.KEY_PROVIDER).build();
}

Fixed version (ground truth):
private CurrencyUnit currency(final String currencyCode){
  return MonetaryCurrencies.getCurrency(currencyCode);
}
Program: 130905
Project: 130905
Buggy source:
@Test public final void testConnection(){
  final HttpClient client=createClient();
  final HttpResponse response=client.execute(HttpRequest.of(HttpMethod.GET,"String_Node_Str")).join();
  client.close();
  final String body=new String(response.getResponseBody().get());
  assertThat(response.getStatusCode()).isLessThan(400);
  assertThat(body).containsIgnoringCase("String_Node_Str");
}

Fixed version (ground truth):
@Test public final void testConnection(){
  final HttpClient client=createClient();
  final HttpResponse response=client.execute(HttpRequest.of(HttpMethod.GET,"String_Node_Str")).toCompletableFuture().join();
  client.close();
  final String body=new String(response.getResponseBody().get());
  assertThat(response.getStatusCode()).isLessThan(400);
  assertThat(body).containsIgnoringCase("String_Node_Str");
}
Program: 130906
Project: 130906
Buggy source:
public static <T>AsyncAssertions<T> performing(final CompletableFuture<T> stage){
  return new AsyncAssertions<>(stage);
}

Fixed version (ground truth):
public static <T>AsyncAssertions<T> performing(final CompletionStage<T> stage){
  return new AsyncAssertions<>(stage);
}
Program: 130907
Project: 130907
Buggy source:
private CompletionStage<Response> getResponse(){
  return null;
}

Fixed version (ground truth):
private CompletionStage<Response> getResponse(){
  return new CompletableFuture<>();
}
Program: 130909
Project: 130909
Buggy source:
public <T extends SphereError>Optional<T> as(final Class<T> errorClass){
  final ObjectMapper objectMapper=JsonUtils.newObjectMapper();
  final JsonNode jsonNode=objectMapper.createObjectNode().put("String_Node_Str",code).put("String_Node_Str",message).setAll(furtherFields);
  Optional<T> result=Optional.empty();
  try {
    final T object=JsonUtils.readObject(errorClass,jsonNode);
    result=Optional.of(object);
  }
 catch (  final JsonException e) {
    result=Optional.empty();
  }
  return result;
}

Fixed version (ground truth):
public <T extends SphereError>Optional<T> as(final Class<T> errorClass){
  final Optional<String> classErrorCodeOption=codeValueOf(errorClass);
  Optional<T> result=Optional.empty();
  if (classErrorCodeOption.map(classErrCode -> classErrCode.equals(code)).orElse(true)) {
    final ObjectMapper objectMapper=JsonUtils.newObjectMapper();
    final JsonNode jsonNode=objectMapper.createObjectNode().put("String_Node_Str",code).put("String_Node_Str",message).setAll(furtherFields);
    try {
      final T object=JsonUtils.readObject(errorClass,jsonNode);
      result=code.equals(object.getCode()) ? Optional.of(object) : Optional.<T>empty();
    }
 catch (    final JsonException e) {
      result=Optional.empty();
    }
  }
  return result;
}
Program: 130910
Project: 130910
Buggy source:
@Override public String getMessage(){
  StringBuilder builder=new StringBuilder("String_Node_Str").append("String_Node_Str");
  final String httpRequest=getUnderlyingHttpRequest().orElse("String_Node_Str");
  return builder.append("String_Node_Str").append(BuildInfo.version()).append("String_Node_Str").append("String_Node_Str").append(getProjectKey().orElse("String_Node_Str")).append("String_Node_Str").append(httpThing.map(x -> "String_Node_Str" + x + "String_Node_Str").orElse("String_Node_Str")).append("String_Node_Str").append(System.getProperty("String_Node_Str")).append("String_Node_Str").append("String_Node_Str").append(System.getProperty("String_Node_Str")).append("String_Node_Str").append("String_Node_Str").append(new Date()).append("String_Node_Str").append("String_Node_Str").append(getSphereRequest().orElse("String_Node_Str")).append("String_Node_Str").append("String_Node_Str").append(httpRequest).append("String_Node_Str").append("String_Node_Str").append(getUnderlyingHttpResponse().orElse("String_Node_Str")).append("String_Node_Str").append(Optional.ofNullable(super.getMessage()).map(s -> "String_Node_Str" + s + "String_Node_Str").orElse("String_Node_Str")).append("String_Node_Str").append("String_Node_Str").append(BuildInfo.version()).append("String_Node_Str").append(this.getClass().getCanonicalName().replace('.','/')).append("String_Node_Str").append("String_Node_Str").append("String_Node_Str").toString();
}

Fixed version (ground truth):
@Override public final String getMessage(){
  StringBuilder builder=new StringBuilder("String_Node_Str").append("String_Node_Str");
  final String httpRequest=getUnderlyingHttpRequest().orElse("String_Node_Str");
  return builder.append("String_Node_Str").append(BuildInfo.version()).append("String_Node_Str").append("String_Node_Str").append(getProjectKey().orElse("String_Node_Str")).append("String_Node_Str").append(httpThing.map(x -> "String_Node_Str" + x + "String_Node_Str").orElse("String_Node_Str")).append("String_Node_Str").append(System.getProperty("String_Node_Str")).append("String_Node_Str").append("String_Node_Str").append(System.getProperty("String_Node_Str")).append("String_Node_Str").append("String_Node_Str").append(new Date()).append("String_Node_Str").append("String_Node_Str").append(getSphereRequest().orElse("String_Node_Str")).append("String_Node_Str").append("String_Node_Str").append(httpRequest).append("String_Node_Str").append("String_Node_Str").append(getUnderlyingHttpResponse().orElse("String_Node_Str")).append("String_Node_Str").append(Optional.ofNullable(super.getMessage()).map(s -> "String_Node_Str" + s + "String_Node_Str").orElse("String_Node_Str")).append("String_Node_Str").append("String_Node_Str").append(BuildInfo.version()).append("String_Node_Str").append(this.getClass().getCanonicalName().replace('.','/')).append("String_Node_Str").append("String_Node_Str").append("String_Node_Str").toString();
}
Program: 130911
Project: 130911
Buggy source:
@Test public void localizedStringsAttribute() throws Exception {
  testSingleAndSet(AttributeAccess.ofLocalizedStrings(),AttributeAccess.ofLocalizedStringsSet(),asSet(LocalizedStrings.of(ENGLISH,"String_Node_Str"),LocalizedStrings.of(ENGLISH,"String_Node_Str")),new LocalizedTextType(),AttributeDefinitionBuilder.of("String_Node_Str",LABEL,new LocalizedTextType()).inputHint(TEXT_INPUT_HINT).build());
}

Fixed version (ground truth):
@Test public void localizedStringsAttribute() throws Exception {
  testSingleAndSet(AttributeAccess.ofLocalizedStrings(),AttributeAccess.ofLocalizedStringsSet(),asSet(LocalizedStrings.of(ENGLISH,"String_Node_Str"),LocalizedStrings.of(ENGLISH,"String_Node_Str")),new LocalizedStringsType(),AttributeDefinitionBuilder.of("String_Node_Str",LABEL,new LocalizedStringsType()).inputHint(TEXT_INPUT_HINT).build());
}
Program: 130912
Project: 130912
Buggy source:
@Test public void createLocalizedTextAttribute() throws Exception {
  executeTest(LocalizedTextType.class,AttributeDefinitionBuilder.of("String_Node_Str",LABEL,new LocalizedTextType()).inputHint(TEXT_INPUT_HINT).attributeConstraint(AttributeConstraint.COMBINATION_UNIQUE).searchable(false).required(true).build(),attributeDefinition -> {
    assertThat(attributeDefinition.getIsRequired()).isTrue();
    assertThat(attributeDefinition.getAttributeConstraint()).isEqualTo(AttributeConstraint.COMBINATION_UNIQUE);
    assertThat(attributeDefinition.getIsSearchable()).isFalse();
    assertThat(attributeDefinition.getInputHint()).isEqualTo(TEXT_INPUT_HINT);
  }
);
}

Fixed version (ground truth):
@Test public void createLocalizedTextAttribute() throws Exception {
  executeTest(LocalizedStringsType.class,AttributeDefinitionBuilder.of("String_Node_Str",LABEL,new LocalizedStringsType()).inputHint(TEXT_INPUT_HINT).attributeConstraint(AttributeConstraint.COMBINATION_UNIQUE).searchable(false).required(true).build(),attributeDefinition -> {
    assertThat(attributeDefinition.getIsRequired()).isTrue();
    assertThat(attributeDefinition.getAttributeConstraint()).isEqualTo(AttributeConstraint.COMBINATION_UNIQUE);
    assertThat(attributeDefinition.getIsSearchable()).isFalse();
    assertThat(attributeDefinition.getInputHint()).isEqualTo(TEXT_INPUT_HINT);
  }
);
}
Program: 130913
Project: 130913
Buggy source:
public static AttributeAccess<LocalizedStrings> ofLocalizedStrings(){
  return ofPrimitive(LocalizedStrings.typeReference(),LocalizedTextType.class);
}

Fixed version (ground truth):
public static AttributeAccess<LocalizedStrings> ofLocalizedStrings(){
  return ofPrimitive(LocalizedStrings.typeReference(),LocalizedStringsType.class);
}
Program: 130914
Project: 130914
Buggy source:
@Override public SphereClient createClient(final SphereApiConfig config,final SphereAccessTokenSupplier tokenSupplier){
  return new SphereClientImpl(config,tokenSupplier);
}

Fixed version (ground truth):
@Override public SphereClient createClient(final String projectKey,final String clientId,final String clientSecret){
  return createClient(SphereClientConfig.of(projectKey,clientId,clientSecret));
}
Program: 130915
Project: 130915
Buggy source:
@Override Optional<ProductVariant> getVariant(final int variantId);

Fixed version (ground truth):
@Override default Optional<ProductVariant> getVariant(final int variantId){
  return ProductsPackage.getVariant(variantId,this);
}
Program: 130916
Project: 130916
Buggy source:
@Override ProductVariant getVariantOrMaster(final int variantId);

Fixed version (ground truth):
@Override default ProductVariant getVariantOrMaster(final int variantId){
  return ProductsPackage.getVariantOrMaster(variantId,this);
}
Program: 130917
Project: 130917
Buggy source:
@Override List<ProductVariant> getAllVariants();

Fixed version (ground truth):
@Override default List<ProductVariant> getAllVariants(){
  return ProductsPackage.getAllVariants(this);
}
Program: 130918
Project: 130918
Buggy source:
/** 
 * Finds a product variant by id and returns the master variant if not variant with the id is present.
 * @param variantId the id of the variant to find
 * @return a variant
 * @see #getVariant(int)
 */
default ProductVariant getVariantOrMaster(final int variantId){
  return getVariant(variantId).orElseGet(() -> getMasterVariant());
}

Fixed version (ground truth):
/** 
 * Finds a product variant by id and returns the master variant if not variant with the id is present.
 * @param variantId the id of the variant to find
 * @return a variant
 * @see #getVariant(int)
 */
default ProductVariant getVariantOrMaster(final int variantId){
  return ProductsPackage.getVariantOrMaster(variantId,this);
}
Program: 130919
Project: 130919
Buggy source:
/** 
 * Gets all variants in the product including the master variant as first element in the list.
 * @see #getMasterVariant()
 * @see #getVariants()
 * @return all variants
 */
default List<ProductVariant> getAllVariants(){
  final List<ProductVariant> nonMasterVariants=getVariants();
  final ArrayList<ProductVariant> result=new ArrayList<>(1 + nonMasterVariants.size());
  result.add(getMasterVariant());
  result.addAll(nonMasterVariants);
  return result;
}

Fixed version (ground truth):
/** 
 * Gets all variants in the product including the master variant as first element in the list.
 * @see #getMasterVariant()
 * @see #getVariants()
 * @return all variants
 */
default List<ProductVariant> getAllVariants(){
  return ProductsPackage.getAllVariants(this);
}
Program: 130920
Project: 130920
Buggy source:
@Override Optional<ProductVariant> getVariant(final int variantId);

Fixed version (ground truth):
@Override default Optional<ProductVariant> getVariant(final int variantId){
  return ProductsPackage.getVariant(variantId,this);
}
Program: 130921
Project: 130921
Buggy source:
@Override ProductVariant getVariantOrMaster(final int variantId);

Fixed version (ground truth):
@Override default ProductVariant getVariantOrMaster(final int variantId){
  return ProductsPackage.getVariantOrMaster(variantId,this);
}
Program: 130922
Project: 130922
Buggy source:
@Override List<ProductVariant> getAllVariants();

Fixed version (ground truth):
@Override default List<ProductVariant> getAllVariants(){
  return ProductsPackage.getAllVariants(this);
}
Program: 130923
Project: 130923
Buggy source:
/** 
 * Takes an http response and maps it into a Java object of type T. Before calling this method, check with   {@link #canHandleResponse(HttpResponse)} if the response can be consumed.
 * @return
 */
Function<HttpResponse,T> resultMapper();

Fixed version (ground truth):
/** 
 * Takes an http response and maps it into a Java object of type T. Before calling this method, check with   {@link #canHandleResponse(HttpResponse)} if the response can be consumed.
 * @return function to map the result of the http request
 */
Function<HttpResponse,T> resultMapper();
Program: 130925
Project: 130925
Buggy source:
@JsonIgnore public static LocalizedString of(final Locale locale,final String value){
  return new LocalizedString(locale,value);
}

Fixed version (ground truth):
@JsonIgnore public static LocalizedString of(final Map<Locale,String> translations){
  requireNonNull(translations);
  return new LocalizedString(translations);
}
Program: 130926
Project: 130926
Buggy source:
/** 
 * Delivers an immutable map of the translation.
 * @return the key-value pairs for the translation
 */
@JsonAnyGetter private Map<Locale,String> getTranslations(){
  return translations;
}

Fixed version (ground truth):
/** 
 * Delivers an immutable map of the translation.
 * @return the key-value pairs for the translation
 */
@JsonAnyGetter private Map<Locale,String> getTranslations(){
  return immutableCopyOf(translations);
}
Program: 130927
Project: 130927
Buggy source:
public static <K,V>Map<K,V> immutableCopyOf(final Map<K,V> map){
  return Collections.unmodifiableMap(copy(map));
}

Fixed version (ground truth):
public static <K,V>Map<K,V> immutableCopyOf(final Map<K,V> map){
  return Collections.unmodifiableMap(copyOf(map));
}
Program: 130928
Project: 130928
Buggy source:
public void queryByAttributeName(){
  Predicate<ProductTypeQueryModel<ProductType>> hasSizeAttribute=ProductTypeQueryModel.get().attributes().name().is("String_Node_Str");
  F.Promise<PagedQueryResult<ProductType>> result=client.execute(new ProductTypeQuery().withPredicate(hasSizeAttribute));
}

Fixed version (ground truth):
public void queryByAttributeName(){
  Predicate<ProductType> hasSizeAttribute=ProductTypeQueryModel.get().attributes().name().is("String_Node_Str");
  F.Promise<PagedQueryResult<ProductType>> result=client.execute(new ProductTypeQuery().withPredicate(hasSizeAttribute));
}
Program: 130929
Project: 130929
Buggy source:
/** 
 * returns a sort expression. Example: dog.age asc
 * @return
 */
String toSphereSort();

Fixed version (ground truth):
/** 
 * returns a sort expression. Example: dog.age asc
 * @return String with unescaped sphere sort expression
 */
String toSphereSort();
Program: 130930
Project: 130930
Buggy source:
/** 
 * @param key The key of the value used as a programmatic identifier, e.g. in facets & filters.
 * @param label A descriptive label of the value.
 */
public static PlainEnumValue of(final String key,final String label){
  return new PlainEnumValue(key,label);
}

Fixed version (ground truth):
/** 
 * @param key The key of the value used as a programmatic identifier, e.g. in facets &amp; filters.
 * @param label A descriptive label of the value.
 * @return PlainEnumValue
 */
public static PlainEnumValue of(final String key,final String label){
  return new PlainEnumValue(key,label);
}
Program: 130931
Project: 130931
Buggy source:
/** 
 * Pretty prints given JSON string, replacing passwords by   {@code 'xxxxx'}.
 * @param json JSON code as String which should be formatted
 * @return <code>json</code> formatted
 * @throws java.io.IOException if <code>json</code> is invalid JSON
 */
public static String prettyPrintJsonStringSecure(String json){
  try {
    ObjectMapper jsonParser=new ObjectMapper();
    JsonNode jsonTree=jsonParser.readValue(json,JsonNode.class);
    secure(jsonTree);
    ObjectWriter writer=jsonParser.writerWithDefaultPrettyPrinter();
    return writer.writeValueAsString(jsonTree);
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * Pretty prints given JSON string, replacing passwords by   {@code 'xxxxx'}.
 * @param json JSON code as String which should be formatted
 * @return <code>json</code> formatted
 */
public static String prettyPrintJsonStringSecure(String json){
  try {
    ObjectMapper jsonParser=new ObjectMapper();
    JsonNode jsonTree=jsonParser.readValue(json,JsonNode.class);
    secure(jsonTree);
    ObjectWriter writer=jsonParser.writerWithDefaultPrettyPrinter();
    return writer.writeValueAsString(jsonTree);
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 130932
Project: 130932
Buggy source:
/** 
 * Sphere web service endpoint where the request was sent. 
 */
public String getRequestUrl(){
  return requestUrl;
}

Fixed version (ground truth):
public String getRequestUrl(){
  return requestUrl;
}
Program: 130933
Project: 130933
Buggy source:
/** 
 * The HTTP status code of the response. 
 */
public int getStatusCode(){
  return errorResponse.getStatusCode();
}

Fixed version (ground truth):
public int getStatusCode(){
  return errorResponse.getStatusCode();
}
Program: 130934
Project: 130934
Buggy source:
/** 
 * The message of the first error, for convenience. 
 */
public String getMessage(){
  return errorResponse.getMessage();
}

Fixed version (ground truth):
public String getMessage(){
  return errorResponse.getMessage();
}
Program: 130935
Project: 130935
Buggy source:
/** 
 * The individual errors. 
 */
@Nonnull public List<SphereError> getErrors(){
  return errorResponse.getErrors();
}

Fixed version (ground truth):
@Nonnull public List<SphereError> getErrors(){
  return errorResponse.getErrors();
}
Program: 130936
Project: 130936
Buggy source:
/** 
 * The HTTP status code. 
 */
public int getStatusCode(){
  return statusCode;
}

Fixed version (ground truth):
public int getStatusCode(){
  return statusCode;
}
Program: 130937
Project: 130937
Buggy source:
/** 
 * The message of the first error, for convenience. 
 */
public String getMessage(){
  return message;
}

Fixed version (ground truth):
/** 
 * The message of the first error, for convenience.
 * @return the first error message
 */
public String getMessage(){
  return message;
}
Program: 130938
Project: 130938
Buggy source:
/** 
 * The individual errors. 
 */
public List<SphereError> getErrors(){
  return errors;
}

Fixed version (ground truth):
public List<SphereError> getErrors(){
  return errors;
}
Program: 130939
Project: 130939
Buggy source:
/** 
 * Creates an executor that only allows execution of a single task at a time. 
 */
public static ThreadPoolExecutor singleTaskExecutor(String poolName){
  return new ThreadPoolExecutor(1,1,30,TimeUnit.SECONDS,new SynchronousQueue<Runnable>(),namedThreadFactory(poolName));
}

Fixed version (ground truth):
/** 
 * Creates an executor that only allows execution of a single task at a time.
 * @param poolName the name of the pool
 * @return a new ThreadPoolExecutor
 */
public static ThreadPoolExecutor singleTaskExecutor(final String poolName){
  return new ThreadPoolExecutor(1,1,30,TimeUnit.SECONDS,new SynchronousQueue<Runnable>(),namedThreadFactory(poolName));
}
Program: 130940
Project: 130940
Buggy source:
/** 
 * Creates a thread factory.
 * @param poolName Name of created threads (an auto-incrementing suffix is appended). 
 */
public static ThreadFactory namedThreadFactory(final String poolName){
  return new ThreadFactory(){
    final AtomicInteger count=new AtomicInteger(0);
    @Override public Thread newThread(    Runnable r){
      Thread newThread=new Thread(r,poolName + "String_Node_Str" + count.incrementAndGet());
      return newThread;
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Creates a thread factory.
 * @param poolName Name of created threads (an auto-incrementing suffix is appended).
 * @return a new ThreadFactory
 */
public static ThreadFactory namedThreadFactory(final String poolName){
  return new ThreadFactory(){
    final AtomicInteger count=new AtomicInteger(0);
    @Override public Thread newThread(    Runnable r){
      Thread newThread=new Thread(r,poolName + "String_Node_Str" + count.incrementAndGet());
      return newThread;
    }
  }
;
}
Program: 130941
Project: 130941
Buggy source:
/** 
 * Returns all available locales.
 */
@JsonIgnore public Set<Locale> getLocales(){
  return translations.keySet();
}

Fixed version (ground truth):
@JsonIgnore public Set<Locale> getLocales(){
  return translations.keySet();
}
Program: 130942
Project: 130942
Buggy source:
/** 
 * LocalizedString containing the given entries, in order.
 * @throws IllegalArgumentException if duplicate locales are provided
 */
public LocalizedString(final Locale locale1,final String value1,final Locale locale2,final String value2){
  this(ImmutableMap.of(locale1,value1,locale2,value2));
}

Fixed version (ground truth):
/** 
 * LocalizedString containing the 2 entries.
 * @param locale1 the locale for the first entry
 * @param value1 the value for the first entry
 * @param locale2 the locale for the second entry
 * @param value2 the value for the second entry
 * @throws IllegalArgumentException if duplicate locales are provided
 */
public LocalizedString(final Locale locale1,final String value1,final Locale locale2,final String value2){
  this(ImmutableMap.of(locale1,value1,locale2,value2));
}
Program: 130943
Project: 130943
Buggy source:
/** 
 * LocalizedString containing the given entries, in order.
 * @throws IllegalArgumentException if duplicate locales are provided
 */
public LocalizedString plus(final Locale locale,final String value){
  final Map<Locale,String> newMap=new ImmutableMap.Builder<Locale,String>().putAll(translations).put(locale,value).build();
  return new LocalizedString(newMap);
}

Fixed version (ground truth):
/** 
 * LocalizedString containing the given entries.
 * @param locale the additional locale of the new entry
 * @param value the value for the <code>locale</code>
 * @return a LocalizedString containing this data and the from the parameters.
 * @throws IllegalArgumentException if duplicate locales are provided
 */
public LocalizedString plus(final Locale locale,final String value){
  final Map<Locale,String> newMap=new ImmutableMap.Builder<Locale,String>().putAll(translations).put(locale,value).build();
  return new LocalizedString(newMap);
}
Program: 130944
Project: 130944
Buggy source:
/** 
 * The ISO 4217 currency code, for example "EUR" or "USD".
 */
public String getCurrencyCode(){
  return currencyCode;
}

Fixed version (ground truth):
/** 
 * @return The ISO 4217 currency code, for example "EUR" or "USD".
 */
public String getCurrencyCode(){
  return currencyCode;
}
Program: 130945
Project: 130945
Buggy source:
/** 
 * Formats the amount to given number of decimal places. <p/> Example:  {@code price.format(2) => "3.50"}
 */
public String format(final int decimalPlaces){
  return getAmount().setScale(decimalPlaces).toPlainString();
}

Fixed version (ground truth):
/** 
 * Formats the amount to given number of decimal places. <br> Example:  {@code price.format(2) => "3.50"}
 * @param decimalPlaces number of the decimal places to display
 * @return formatted money output without the currency
 */
public String format(final int decimalPlaces){
  return getAmount().setScale(decimalPlaces).toPlainString();
}
Program: 130946
Project: 130946
Buggy source:
/** 
 * The cent amount.
 */
public long getCentAmount(){
  return centAmount;
}

Fixed version (ground truth):
public long getCentAmount(){
  return centAmount;
}
Program: 130947
Project: 130947
Buggy source:
/** 
 * Returns a new Money instance that is a sum of this instance and given instance.
 */
public Money plus(final Money amount){
  if (!amount.currencyCode.equals(this.currencyCode)) {
    throw new IllegalArgumentException(String.format("String_Node_Str",this,amount));
  }
  return new Money(centAmount + amount.centAmount,currencyCode);
}

Fixed version (ground truth):
/** 
 * Returns a new Money instance that is a sum of this instance and given instance.
 * @param amount the amount which should be added to this amount
 * @return a new money instance
 */
public Money plus(final Money amount){
  if (!amount.currencyCode.equals(this.currencyCode)) {
    throw new IllegalArgumentException(String.format("String_Node_Str",this,amount));
  }
  return new Money(centAmount + amount.centAmount,currencyCode);
}
Program: 130948
Project: 130948
Buggy source:
/** 
 * Creates a new Money instance. Money can't represent cent fractions. The value will be rounded to nearest cent value using RoundingMode.HALF_EVEN.
 * @param amount the money value as fraction, e.g. 43.21 will be 4321 cents.
 */
public Money(final BigDecimal amount,final String currencyCode){
  this(amountToCents(amount),requireValidCurrencyCode(currencyCode));
}

Fixed version (ground truth):
/** 
 * Creates a new Money instance. Money can't represent cent fractions. The value will be rounded to nearest cent value using RoundingMode.HALF_EVEN.
 * @param amount the money value as fraction, e.g. 43.21 will be 4321 cents.
 * @param currencyCode the ISO 4217 currency code
 */
public Money(final BigDecimal amount,final String currencyCode){
  this(amountToCents(amount),requireValidCurrencyCode(currencyCode));
}
Program: 130949
Project: 130949
Buggy source:
/** 
 * Returns a new Money instance that has the amount multiplied by given factor. Fractional cents will be rounded to the nearest cent value using Banker's rounding algorithm (RoundingMode.HALF_EVEN).
 */
public Money multiply(final double multiplier){
  return multiply(multiplier,RoundingMode.HALF_EVEN);
}

Fixed version (ground truth):
/** 
 * Returns a new Money instance that has the amount multiplied by given factor. Fractional cents will be rounded to the nearest cent value using Banker's rounding algorithm (RoundingMode.HALF_EVEN).
 * @param multiplier the factor to multiply with
 * @return the new money instance
 */
public Money multiply(final double multiplier){
  return multiply(multiplier,RoundingMode.HALF_EVEN);
}
Program: 130950
Project: 130950
Buggy source:
/** 
 * The exact amount as BigDecimal, useful for implementing e.g. custom rounding / formatting methods.
 */
@JsonIgnore public BigDecimal getAmount(){
  return centsToAmount(centAmount);
}

Fixed version (ground truth):
/** 
 * The exact amount as BigDecimal, useful for implementing e.g. custom rounding / formatting methods.
 * @return the amount as decimal number
 */
@JsonIgnore public BigDecimal getAmount(){
  return centsToAmount(centAmount);
}
Program: 130951
Project: 130951
Buggy source:
/** 
 * Id of the object this reference represents.
 */
public String getId(){
  return id;
}

Fixed version (ground truth):
/** 
 * Id of the object this reference represents.
 * @return the id
 */
public String getId(){
  return id;
}
Program: 130952
Project: 130952
Buggy source:
/** 
 * Type id of the object this reference represents, e.g. "customer".
 */
public String getTypeId(){
  return typeId;
}

Fixed version (ground truth):
/** 
 * Type id of the object this reference represents, e.g. "customer".
 * @return the type id
 */
public String getTypeId(){
  return typeId;
}
Program: 130953
Project: 130953
Buggy source:
/** 
 * Pretty prints given JSON string, replacing passwords by   {@code 'xxxxx'}. 
 */
public static String prettyPrintJsonStringSecure(String json) throws IOException {
  ObjectMapper jsonParser=new ObjectMapper();
  JsonNode jsonTree=jsonParser.readValue(json,JsonNode.class);
  secure(jsonTree);
  ObjectWriter writer=jsonParser.writerWithDefaultPrettyPrinter();
  return writer.writeValueAsString(jsonTree);
}

Fixed version (ground truth):
/** 
 * Pretty prints given JSON string, replacing passwords by   {@code 'xxxxx'}.
 * @param json JSON code as String which should be formatted
 * @return <code>json</code> formatted
 * @throws java.io.IOException if <code>json</code> is invalid JSON
 */
public static String prettyPrintJsonStringSecure(String json) throws IOException {
  ObjectMapper jsonParser=new ObjectMapper();
  JsonNode jsonTree=jsonParser.readValue(json,JsonNode.class);
  secure(jsonTree);
  ObjectWriter writer=jsonParser.writerWithDefaultPrettyPrinter();
  return writer.writeValueAsString(jsonTree);
}
Program: 130954
Project: 130954
Buggy source:
/** 
 * Partitions <code>list</code> in two lists according to <code>predicate</code>.
 * @param list
 * @param predicate
 * @param < T >
 * @return the first list satisfies <code>predicate</code>, the second one not.
 */
public static <T>Pair<List<T>,List<T>> partition(final List<T> list,final Predicate<T> predicate){
  final List<T> matchingPredicate=newArrayList();
  final List<T> notMatchingPredicate=newArrayList();
  for (  final T element : list) {
    if (predicate.apply(element)) {
      matchingPredicate.add(element);
    }
 else {
      notMatchingPredicate.add(element);
    }
  }
  return new Pair<>(matchingPredicate,notMatchingPredicate);
}

Fixed version (ground truth):
/** 
 * Partitions <code>list</code> in two lists according to <code>predicate</code>.
 * @param list the list which should be divided
 * @param predicate returns true if the element of <code>list</code> should belong to the first result list
 * @param < T > generic type of the list
 * @return the first list satisfies <code>predicate</code>, the second one not.
 */
public static <T>Pair<List<T>,List<T>> partition(final List<T> list,final Predicate<T> predicate){
  final List<T> matchingPredicate=newArrayList();
  final List<T> notMatchingPredicate=newArrayList();
  for (  final T element : list) {
    if (predicate.apply(element)) {
      matchingPredicate.add(element);
    }
 else {
      notMatchingPredicate.add(element);
    }
  }
  return new Pair<>(matchingPredicate,notMatchingPredicate);
}
Program: 130955
Project: 130955
Buggy source:
/** 
 * Encodes urls with US-ASCII. 
 */
public static String urlEncode(String s){
  try {
    return URLEncoder.encode(s,"String_Node_Str");
  }
 catch (  UnsupportedEncodingException e) {
    throw new IllegalArgumentException("String_Node_Str" + s);
  }
}

Fixed version (ground truth):
/** 
 * Encodes urls with US-ASCII.
 * @param s String which should be URL encoded
 * @return url encoded s
 */
public static String urlEncode(final String s){
  try {
    return URLEncoder.encode(s,"String_Node_Str");
  }
 catch (  UnsupportedEncodingException e) {
    throw new IllegalArgumentException("String_Node_Str" + s);
  }
}
Program: 130956
Project: 130956
Buggy source:
/** 
 * If this is a successful result, returns the value. You should always check for   {@link #isSuccess() isSuccess} before calling this method. 
 */
public E getError(){
  if (!isError())   throw new IllegalStateException("String_Node_Str");
  return error;
}

Fixed version (ground truth):
/** 
 * If this is a successful result, returns the value. You should always check for   {@link #isSuccess() isSuccess} before calling this method.
 * @return error value if defined
 */
public E getError(){
  if (!isError())   throw new IllegalStateException("String_Node_Str");
  return error;
}
Program: 130957
Project: 130957
Buggy source:
/** 
 * If this is a successful result, returns the value. You should always check for   {@link #isSuccess() isSuccess} before calling this method. 
 */
public T getValue(){
  if (!isSuccess())   throw new IllegalStateException("String_Node_Str");
  return value;
}

Fixed version (ground truth):
/** 
 * If this is a successful result, returns the value. You should always check for   {@link #isSuccess() isSuccess} before calling this method.
 * @return the value if present
 */
public T getValue(){
  if (!isSuccess())   throw new IllegalStateException("String_Node_Str");
  return value;
}
Program: 130958
Project: 130958
Buggy source:
/** 
 * Returns true if this is an erroneous result. 
 */
public boolean isError(){
  return !isSuccess();
}

Fixed version (ground truth):
public boolean isError(){
  return !isSuccess();
}
Program: 130959
Project: 130959
Buggy source:
/** 
 * Returns true if this is a successful result. 
 */
public boolean isSuccess(){
  return error == null;
}

Fixed version (ground truth):
public boolean isSuccess(){
  return error == null;
}
Program: 130960
Project: 130960
Buggy source:
/** 
 * Creates an instance of ClientCredentials based on config. 
 */
public static ShopClientCredentials createAndBeginRefreshInBackground(ShopClientConfig config,OAuthClient oauthClient){
  String authEndpoint=Endpoints.tokenEndpoint(config.getAuthHttpServiceUrl());
  ShopClientCredentials credentials=new ShopClientCredentials(oauthClient,authEndpoint,config.getProjectKey(),config.getClientId(),config.getClientSecret());
  credentials.beginRefresh(false);
  return credentials;
}

Fixed version (ground truth):
/** 
 * Creates an instance of ClientCredentials based on config. 
 */
public static ShopClientCredentials createAndBeginRefreshInBackground(ShopClientConfig config,OAuthClient oauthClient){
  String authEndpoint=Endpoints.tokenEndpoint(config.getAuthHttpServiceUrl());
  ShopClientCredentials credentials=new ShopClientCredentials(oauthClient,authEndpoint,config.getProjectKey(),config.getClientId(),config.getClientSecret());
  credentials.beginRefresh();
  return credentials;
}
Program: 130961
Project: 130961
Buggy source:
/** 
 * Asynchronously refreshes the tokens contained in this instance. 
 */
private void beginRefresh(final boolean isAboutToExpire){
  try {
    refreshExecutor.execute(new Runnable(){
      @Override public void run(){
        Log.debug(isAboutToExpire ? "String_Node_Str" : "String_Node_Str");
        Tokens tokens=null;
        try {
          tokens=oauthClient.getTokensForClient(tokenEndpoint,clientID,clientSecret,"String_Node_Str" + projectID).get();
        }
 catch (        Exception e) {
          update(null,e);
          return;
        }
        update(tokens,null);
      }
    }
);
  }
 catch (  RejectedExecutionException e) {
  }
}

Fixed version (ground truth):
/** 
 * Asynchronously refreshes the tokens contained in this instance. 
 */
private void beginRefresh(){
  try {
    refreshExecutor.execute(new Runnable(){
      @Override public void run(){
        Log.debug("String_Node_Str");
        Tokens tokens=null;
        try {
          tokens=oauthClient.getTokensForClient(tokenEndpoint,clientID,clientSecret,"String_Node_Str" + projectID).get();
        }
 catch (        Exception e) {
          update(null,e);
          return;
        }
        update(tokens,null);
      }
    }
);
  }
 catch (  RejectedExecutionException e) {
  }
}
Program: 130962
Project: 130962
Buggy source:
private void update(Tokens tokens,Exception e){
  if (e != null) {
    Log.error("String_Node_Str",e);
  }
synchronized (accessTokenLock) {
    if (e == null) {
      this.accessToken=Optional.of(Validation.success(new AccessToken(tokens.getAccessToken(),tokens.getExpiresIn(),System.currentTimeMillis())));
      Log.debug("String_Node_Str");
    }
 else {
      this.accessToken=Optional.of(Validation.<AccessToken>error(new SphereException(e)));
      Log.error("String_Node_Str",e);
    }
    accessTokenLock.notifyAll();
  }
}

Fixed version (ground truth):
private void update(Tokens tokens,Exception e){
synchronized (accessTokenLock) {
    if (e == null) {
      AccessToken newToken=new AccessToken(tokens.getAccessToken(),tokens.getExpiresIn(),System.currentTimeMillis());
      this.accessToken=Optional.of(Validation.success(newToken));
      Log.debug("String_Node_Str");
      if (tokens.getExpiresIn().isPresent()) {
        if (tokens.getExpiresIn().get() * 1000 > Defaults.tokenAboutToExpireMs) {
          long refreshTimeout=tokens.getExpiresIn().get() * 1000 - Defaults.tokenAboutToExpireMs;
          Log.debug("String_Node_Str" + refreshTimeout / 1000 + "String_Node_Str");
          refreshTimer.schedule(new TimerTask(){
            @Override public void run(){
              beginRefresh();
            }
          }
,refreshTimeout);
        }
 else {
          Log.warn("String_Node_Str" + tokens.getExpiresIn().get() + "String_Node_Str");
        }
      }
 else {
        Log.warn("String_Node_Str");
      }
    }
 else {
      this.accessToken=Optional.of(Validation.<AccessToken>error(new SphereException(e)));
      Log.error("String_Node_Str",e);
    }
    accessTokenLock.notifyAll();
  }
}