nus-yam/ex-repair huggingface dataset:
Program: 11323
Project: 11323
Buggy source:
private JsonDocumentUpdateMarshaller(){
  mapper=new ObjectMapper();
  final SimpleModule jodaDateTimeModule=new SimpleModule();
  jodaDateTimeModule.addSerializer(DateTime.class,new JodaDateTimeSerializer());
  mapper.registerModule(jodaDateTimeModule);
  mapper.setPropertyNamingStrategy(new LowerCasePropertyNamingStrategy());
}

Fixed version (ground truth):
private JsonDocumentUpdateMarshaller(){
  mapper=new ObjectMapper();
  final SimpleModule module=new SimpleModule();
  module.addSerializer(DateTime.class,new JodaDateTimeSerializer());
  module.addSerializer(Boolean.class,new BooleanLiteralSerializer());
  mapper.registerModule(module);
  mapper.setPropertyNamingStrategy(new LowerCasePropertyNamingStrategy());
}
Program: 11325
Project: 11325
Buggy source:
@Override public void filter(final ContainerRequestContext requestContext) throws IOException {
  final MultivaluedMap<String,String> headersMap=requestContext.getHeaders();
  String principal=null;
  String agent=null;
  if (headersMap.containsKey(HttpHeaders.AUTHORIZATION)) {
    for (    final String headerValue : headersMap.get(HttpHeaders.AUTHORIZATION)) {
      final String[] headerValueParts=headerValue.split("String_Node_Str");
      if (headerValueParts.length == 2) {
        if (PRINCIPAL_HEADER_VALUE_PREFIX.equals(headerValueParts[0])) {
          principal=headerValueParts[1];
        }
      }
    }
  }
  if (headersMap.containsKey(PROXY_AUTHORIZATION)) {
    for (    final String headerValue : headersMap.get(PROXY_AUTHORIZATION)) {
      final String[] headerValueParts=headerValue.split("String_Node_Str");
      if (headerValueParts.length == 2) {
        if (AGENT_HEADER_VALUE_PREFIX.equals(headerValueParts[0])) {
          agent=headerValueParts[1];
        }
      }
    }
  }
  if (principal != null && agent != null) {
    SecurityContextHolder.set(new AgentSecurityContext(principal,agent));
  }
 else   if (principal != null) {
    SecurityContextHolder.set(new BasicSecurityContext(principal));
  }
 else {
    SecurityContextHolder.clear();
  }
}

Fixed version (ground truth):
@Override public void filter(final ContainerRequestContext requestContext) throws IOException {
  final MultivaluedMap<String,String> headersMap=requestContext.getHeaders();
  String principal=null;
  String agent=null;
  if (headersMap.containsKey(HttpHeaders.AUTHORIZATION)) {
    for (    final String headerValue : headersMap.get(HttpHeaders.AUTHORIZATION)) {
      final String[] headerValueParts=headerValue.split("String_Node_Str");
      if (headerValueParts.length == 2) {
        if (CLICK_PLATFORM_HEADER_VALUE_PREFIX.equals(headerValueParts[0])) {
          principal=headerValueParts[1];
        }
      }
    }
  }
  if (headersMap.containsKey(PROXY_AUTHORIZATION)) {
    for (    final String headerValue : headersMap.get(PROXY_AUTHORIZATION)) {
      final String[] headerValueParts=headerValue.split("String_Node_Str");
      if (headerValueParts.length == 2) {
        if (CLICK_PLATFORM_HEADER_VALUE_PREFIX.equals(headerValueParts[0])) {
          agent=headerValueParts[1];
        }
      }
    }
  }
  if (principal != null && agent != null) {
    SecurityContextHolder.set(new AgentSecurityContext(principal,agent));
  }
 else   if (principal != null) {
    SecurityContextHolder.set(new BasicSecurityContext(principal));
  }
 else {
    SecurityContextHolder.clear();
  }
}
Program: 11326
Project: 11326
Buggy source:
@Test public void shouldSetPrincipal_withPrincipalHeader() throws Exception {
  mockStatic(SecurityContextHolder.class);
  final String principal=Randoms.randomString();
  final ContainerRequestContext mockContainerRequestContext=mock(ContainerRequestContext.class);
  final MultivaluedMap<String,String> headersMap=new MultivaluedHashMap<>();
  headersMap.add(HttpHeaders.AUTHORIZATION,PRINCIPAL_HEADER_VALUE_PREFIX + "String_Node_Str" + principal);
  when(mockContainerRequestContext.getHeaders()).thenReturn(headersMap);
  final ContainerSecurityRequestFilter containerSecurityRequestFilter=new ContainerSecurityRequestFilter();
  containerSecurityRequestFilter.filter(mockContainerRequestContext);
  final ArgumentCaptor<BasicSecurityContext> securityContextCaptor=ArgumentCaptor.forClass(BasicSecurityContext.class);
  verifyStatic();
  SecurityContextHolder.set(securityContextCaptor.capture());
  assertThat(securityContextCaptor.getValue().principal(),is(principal));
}

Fixed version (ground truth):
@Test public void shouldSetPrincipal_withPrincipalHeader() throws Exception {
  mockStatic(SecurityContextHolder.class);
  final String principal=Randoms.randomString();
  final ContainerRequestContext mockContainerRequestContext=mock(ContainerRequestContext.class);
  final MultivaluedMap<String,String> headersMap=new MultivaluedHashMap<>();
  headersMap.add(HttpHeaders.AUTHORIZATION,CLICK_PLATFORM_HEADER_VALUE_PREFIX + "String_Node_Str" + principal);
  when(mockContainerRequestContext.getHeaders()).thenReturn(headersMap);
  final ContainerSecurityRequestFilter containerSecurityRequestFilter=new ContainerSecurityRequestFilter();
  containerSecurityRequestFilter.filter(mockContainerRequestContext);
  final ArgumentCaptor<BasicSecurityContext> securityContextCaptor=ArgumentCaptor.forClass(BasicSecurityContext.class);
  verifyStatic();
  SecurityContextHolder.set(securityContextCaptor.capture());
  assertThat(securityContextCaptor.getValue().principal(),is(principal));
}
Program: 11327
Project: 11327
Buggy source:
@Test public void shouldSetPrincipal_withPrincipalHeaderAndAgentHeader() throws Exception {
  mockStatic(SecurityContextHolder.class);
  final String principal=Randoms.randomString();
  final String agent=Randoms.randomString();
  final ContainerRequestContext mockContainerRequestContext=mock(ContainerRequestContext.class);
  final MultivaluedMap<String,String> headersMap=new MultivaluedHashMap<>();
  headersMap.add(HttpHeaders.AUTHORIZATION,PRINCIPAL_HEADER_VALUE_PREFIX + "String_Node_Str" + principal);
  headersMap.add("String_Node_Str",AGENT_HEADER_VALUE_PREFIX + "String_Node_Str" + agent);
  when(mockContainerRequestContext.getHeaders()).thenReturn(headersMap);
  final ContainerSecurityRequestFilter containerSecurityRequestFilter=new ContainerSecurityRequestFilter();
  containerSecurityRequestFilter.filter(mockContainerRequestContext);
  final ArgumentCaptor<AgentSecurityContext> securityContextCaptor=ArgumentCaptor.forClass(AgentSecurityContext.class);
  verifyStatic();
  SecurityContextHolder.set(securityContextCaptor.capture());
  assertThat(securityContextCaptor.getValue().principal(),is(principal));
  assertThat(securityContextCaptor.getValue().agent(),is(agent));
}

Fixed version (ground truth):
@Test public void shouldSetPrincipal_withPrincipalHeaderAndAgentHeader() throws Exception {
  mockStatic(SecurityContextHolder.class);
  final String principal=Randoms.randomString();
  final String agent=Randoms.randomString();
  final ContainerRequestContext mockContainerRequestContext=mock(ContainerRequestContext.class);
  final MultivaluedMap<String,String> headersMap=new MultivaluedHashMap<>();
  headersMap.add(HttpHeaders.AUTHORIZATION,CLICK_PLATFORM_HEADER_VALUE_PREFIX + "String_Node_Str" + principal);
  headersMap.add("String_Node_Str",CLICK_PLATFORM_HEADER_VALUE_PREFIX + "String_Node_Str" + agent);
  when(mockContainerRequestContext.getHeaders()).thenReturn(headersMap);
  final ContainerSecurityRequestFilter containerSecurityRequestFilter=new ContainerSecurityRequestFilter();
  containerSecurityRequestFilter.filter(mockContainerRequestContext);
  final ArgumentCaptor<AgentSecurityContext> securityContextCaptor=ArgumentCaptor.forClass(AgentSecurityContext.class);
  verifyStatic();
  SecurityContextHolder.set(securityContextCaptor.capture());
  assertThat(securityContextCaptor.getValue().principal(),is(principal));
  assertThat(securityContextCaptor.getValue().agent(),is(agent));
}
Program: 11329
Project: 11329
Buggy source:
private String createAwsSnsTopic(final String name){
  logger.debug("String_Node_Str" + name);
  return amazonSnsClient.createTopic(new CreateTopicRequest(name)).getTopicArn();
}

Fixed version (ground truth):
private String createAwsSnsTopic(final String name){
  logger.info("String_Node_Str" + name);
  return amazonSnsClient.createTopic(new CreateTopicRequest(name)).getTopicArn();
}
Program: 11330
Project: 11330
Buggy source:
@Override public SnsTopic createSnsTopicForExistingAwsSnsTopic(final String name){
  final String topicArn=pollAndRetryForTopicArnForName(name);
  return new SnsTopic(name,topicArn,amazonSnsClient);
}

Fixed version (ground truth):
@Override public SnsTopicResource createSnsTopicForExistingAwsSnsTopic(final String name){
  final String topicArn=pollAndRetryForTopicArnForName(name);
  logger.info("String_Node_Str" + name);
  return new SnsTopicResource(name,topicArn,amazonSnsClient);
}
Program: 11331
Project: 11331
Buggy source:
@Override public SnsTopic createSnsTopicAndAwsSnsTopicIfAbsent(final String name){
  String topicArn=pollForTopicArnForName(name);
  if (topicArn == null) {
    topicArn=createAwsSnsTopic(name);
    final SnsTopic snsTopic=new SnsTopic(name,topicArn,amazonSnsClient);
    snsTopic.setPolicy(defaultPolicy(snsTopic));
    return snsTopic;
  }
 else {
    return new SnsTopic(name,topicArn,amazonSnsClient);
  }
}

Fixed version (ground truth):
@Override public SnsTopicResource createSnsTopicAndAwsSnsTopicIfAbsent(final String name){
  String topicArn=pollForTopicArnForName(name);
  if (topicArn == null) {
    topicArn=createAwsSnsTopic(name);
    final SnsTopicResource snsTopicResource=new SnsTopicResource(name,topicArn,amazonSnsClient);
    snsTopicResource.setPolicy(allowAllQueuesPolicy(snsTopicResource));
    return snsTopicResource;
  }
 else {
    logger.info("String_Node_Str" + name);
    return new SnsTopicResource(name,topicArn,amazonSnsClient);
  }
}
Program: 11332
Project: 11332
Buggy source:
private Policy acceptMessagesFromTopicsPolicy(final SqsQueue sqsQueue,final SnsTopic... snsTopics){
  final Collection<Statement> statements=new ArrayList<>();
  for (  final SnsTopic snsTopic : snsTopics) {
    statements.add(acceptMessagesFromTopicStatement(sqsQueue,snsTopic));
  }
  final Policy policy=new Policy();
  policy.setStatements(statements);
  return policy;
}

Fixed version (ground truth):
private Policy acceptMessagesFromTopicsPolicy(final SqsQueueResource sqsQueueResource,final SnsTopicResource... snsTopics){
  final Collection<Statement> statements=new ArrayList<>();
  for (  final SnsTopicResource snsTopicResource : snsTopics) {
    statements.add(acceptMessagesFromTopicStatement(sqsQueueResource,snsTopicResource));
  }
  final Policy policy=new Policy();
  policy.setStatements(statements);
  return policy;
}
Program: 11333
Project: 11333
Buggy source:
@Override public SqsQueue createSqsQueue(final String name,final SnsTopic... snsTopics){
  String queueUrl;
  try {
    queueUrl=amazonSqsClient.getQueueUrl(new GetQueueUrlRequest(name)).getQueueUrl();
  }
 catch (  final QueueDoesNotExistException e) {
    queueUrl=createAwsSqsQueue(name);
  }
  final SqsQueue sqsQueue=new SqsQueue(name,queueUrl,amazonSqsClient);
  if (snsTopics.length != 0) {
    sqsQueue.setPolicy(acceptMessagesFromTopicsPolicy(sqsQueue,snsTopics));
    for (    final SnsTopic snsTopic : snsTopics) {
      snsTopic.subscribe(sqsQueue);
    }
  }
  return sqsQueue;
}

Fixed version (ground truth):
@Override public SqsQueueResource createSqsQueue(final String name,final SnsTopicResource... snsTopics){
  String queueUrl;
  try {
    queueUrl=amazonSqsClient.getQueueUrl(new GetQueueUrlRequest(name)).getQueueUrl();
    logger.info("String_Node_Str" + name);
  }
 catch (  final QueueDoesNotExistException e) {
    queueUrl=createAwsSqsQueue(name);
  }
  final SqsQueueResource sqsQueueResource=new SqsQueueResource(name,queueUrl,amazonSqsClient);
  if (snsTopics.length != 0) {
    logger.info("String_Node_Str" + name + "String_Node_Str"+ snsTopicNames(snsTopics)+ "String_Node_Str");
    sqsQueueResource.setPolicy(acceptMessagesFromTopicsPolicy(sqsQueueResource,snsTopics));
    for (    final SnsTopicResource snsTopicResource : snsTopics) {
      snsTopicResource.subscribe(sqsQueueResource);
    }
  }
  return sqsQueueResource;
}
Program: 11334
Project: 11334
Buggy source:
private Statement acceptMessagesFromTopicStatement(final SqsQueue sqsQueue,final SnsTopic snsTopic){
  return new Statement(Effect.Allow).withPrincipals(Principal.AllUsers).withActions(SQSActions.SendMessage).withResources(new Resource(sqsQueue.queueArn())).withConditions(new ArnCondition(ArnComparisonType.ArnEquals,ConditionFactory.SOURCE_ARN_CONDITION_KEY,snsTopic.getTopicArn()));
}

Fixed version (ground truth):
private Statement acceptMessagesFromTopicStatement(final SqsQueueResource sqsQueueResource,final SnsTopicResource snsTopicResource){
  return new Statement(Effect.Allow).withPrincipals(Principal.AllUsers).withActions(SQSActions.SendMessage).withResources(new Resource(sqsQueueResource.queueArn())).withConditions(new ArnCondition(ArnComparisonType.ArnEquals,ConditionFactory.SOURCE_ARN_CONDITION_KEY,snsTopicResource.getTopicArn()));
}
Program: 11335
Project: 11335
Buggy source:
private String createAwsSqsQueue(final String name){
  logger.debug("String_Node_Str" + name);
  final Map<String,String> attributes=new HashMap<>();
  attributes.put(SQS_VISIBILITY_TIMEOUT_ATTRIBUTE,SQS_VISIBILITY_TIMEOUT_VALUE);
  final CreateQueueRequest createQueueRequest=new CreateQueueRequest(name).withAttributes(attributes);
  return amazonSqsClient.createQueue(createQueueRequest).getQueueUrl();
}

Fixed version (ground truth):
private String createAwsSqsQueue(final String name){
  logger.info("String_Node_Str" + name);
  final Map<String,String> attributes=new HashMap<>();
  attributes.put(SQS_VISIBILITY_TIMEOUT_ATTRIBUTE,SQS_VISIBILITY_TIMEOUT_VALUE);
  final CreateQueueRequest createQueueRequest=new CreateQueueRequest(name).withAttributes(attributes);
  return amazonSqsClient.createQueue(createQueueRequest).getQueueUrl();
}
Program: 11336
Project: 11336
Buggy source:
public PooledBasicMessageListener(final MessageQueue<BasicMessage> basicMessageQueue,final RateLimiter rateLimiter,final ThreadPoolExecutor threadPoolExecutor,final Semaphore semaphore,final MessageHandler<BasicMessage> messageHandler,final int maxReceivedMessages){
  super(basicMessageQueue,rateLimiter,threadPoolExecutor,semaphore,maxReceivedMessages);
  this.messageHandler=messageHandler;
}

Fixed version (ground truth):
/** 
 * Most general constructor, allows for greatest flexibility
 * @param basicMessageQueue The basic message queue to listen to
 * @param messageHandler The handler used for all messages that are received
 * @param rateLimiter An optional {@link RateLimiter} used to limit the message throughput
 * @param threadPoolExecutor {@link ThreadPoolExecutor} for a fixed-size thread pool for message handler tasks
 * @param semaphore {@link Semaphore} used to regulate number of in-flight messages to keep all worker threads busy
 * @param maxReceivedMessages Maximum number of messages to receive from the queue at a time
 */
public PooledBasicMessageListener(final MessageQueue<BasicMessage> basicMessageQueue,final MessageHandler<BasicMessage> messageHandler,final RateLimiter rateLimiter,final ThreadPoolExecutor threadPoolExecutor,final Semaphore semaphore,final int maxReceivedMessages){
  super(basicMessageQueue,rateLimiter,threadPoolExecutor,semaphore,maxReceivedMessages);
  this.messageHandler=messageHandler;
}
Program: 11337
Project: 11337
Buggy source:
@Override public void run(){
  logger.debug("String_Node_Str" + queueName() + "String_Node_Str");
  try {
    processMessagesUntilShutdownRequested();
  }
 catch (  final InterruptedException e) {
    Thread.currentThread().interrupt();
  }
catch (  final Throwable e) {
    logger.error(e.getMessage(),e);
    throw e;
  }
 finally {
    logger.debug("String_Node_Str" + queueName() + "String_Node_Str");
    threadPoolExecutor.shutdown();
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    listenerStarted();
    final String limiterSummary=rateLimiter != null ? ("String_Node_Str" + rateLimiter.toString()) : "String_Node_Str";
    logger.debug("String_Node_Str" + queueName() + "String_Node_Str"+ threadPoolExecutor.getMaximumPoolSize()+ "String_Node_Str"+ limiterSummary);
    processMessagesUntilShutdownRequested();
  }
 catch (  final InterruptedException e) {
    Thread.currentThread().interrupt();
  }
catch (  final Throwable e) {
    logger.error(e.getMessage(),e);
    throw e;
  }
 finally {
    logger.debug("String_Node_Str" + queueName() + "String_Node_Str");
    threadPoolExecutor.shutdown();
  }
}
Program: 11338
Project: 11338
Buggy source:
@Override public void publishMessage(final T message){
  final SnsSubjectAndMessage snsSubjectAndMessage=snsMessageAdapter.toSnsSubjectAndMessage(message);
  final String subject=snsSubjectAndMessage.getSubject();
  final String snsMessage=snsSubjectAndMessage.getMessage();
  snsTopic.publish(subject,snsMessage);
}

Fixed version (ground truth):
@Override public void publishMessage(final T message){
  final SnsSubjectAndMessage snsSubjectAndMessage=snsMessageAdapter.toSnsSubjectAndMessage(message);
  final String subject=snsSubjectAndMessage.getSubject();
  final String snsMessage=snsSubjectAndMessage.getMessage();
  snsTopicResource.publish(subject,snsMessage);
}
Program: 11339
Project: 11339
Buggy source:
@Override public String exchangeName(){
  return snsTopic.getTopicName();
}

Fixed version (ground truth):
@Override public String exchangeName(){
  return snsTopicResource.getTopicName();
}
Program: 11340
Project: 11340
Buggy source:
public SnsExchange(final SnsTopic snsTopic,final SnsMessageAdapter<T> snsMessageAdapter){
  this.snsTopic=snsTopic;
  this.snsMessageAdapter=snsMessageAdapter;
}

Fixed version (ground truth):
public SnsExchange(final SnsTopicResource snsTopicResource,final SnsMessageAdapter<T> snsMessageAdapter){
  this.snsTopicResource=snsTopicResource;
  this.snsMessageAdapter=snsMessageAdapter;
}
Program: 11341
Project: 11341
Buggy source:
/** 
 * Creates a   {@link SnsTopic} representing an existing actual AWS SNS topic.
 * @param name Topic name
 * @return {@link SnsTopic} with the given name
 */
SnsTopic createSnsTopicForExistingAwsSnsTopic(String name);

Fixed version (ground truth):
/** 
 * Creates a   {@link SnsTopicResource} representing an existing actual AWS SNS topic.
 * @param name Topic name
 * @return {@link SnsTopicResource} with the given name
 */
SnsTopicResource createSnsTopicForExistingAwsSnsTopic(String name);
Program: 11342
Project: 11342
Buggy source:
/** 
 * Creates a   {@link SnsTopic} and the actual AWS SNS topic if it does not already exist with the given name.
 * @param name Topic name
 * @return {@link SnsTopic} with the given name
 */
SnsTopic createSnsTopicAndAwsSnsTopicIfAbsent(String name);

Fixed version (ground truth):
/** 
 * Creates a   {@link SnsTopicResource} and the actual AWS SNS topic if it does not already exist with the given name.
 * @param name Topic name
 * @return {@link SnsTopicResource} with the given name
 */
SnsTopicResource createSnsTopicAndAwsSnsTopicIfAbsent(String name);
Program: 11343
Project: 11343
Buggy source:
@Autowired public DeferrableProcessingStatusHolder(final Collection<MessageListener> messageListeners,final MessageListener eventMessageListener,final MessageListener highPriorityEventMessageListener,final MessageListener systemEventMessageListener){
  messageListenersForDeferrableProcessing=new HashSet<>(messageListeners);
  messageListeners.remove(eventMessageListener);
  messageListeners.remove(highPriorityEventMessageListener);
  messageListeners.remove(systemEventMessageListener);
}

Fixed version (ground truth):
@Autowired public DeferrableProcessingStatusHolder(final Collection<MessageListener> messageListeners,final MessageListener eventMessageListener,final MessageListener highPriorityEventMessageListener,final MessageListener systemEventMessageListener){
  messageListenersForDeferrableProcessing=new HashSet<>(messageListeners);
  messageListenersForDeferrableProcessing.remove(eventMessageListener);
  messageListenersForDeferrableProcessing.remove(highPriorityEventMessageListener);
  messageListenersForDeferrableProcessing.remove(systemEventMessageListener);
}
Program: 11344
Project: 11344
Buggy source:
@Override public void update(final Document document){
  final DocumentConfiguration documentConfiguration=getDocumentConfiguration(document.getClass());
  final String searchDomain=documentConfigurationHolder.schemaName() + "String_Node_Str" + documentConfiguration.namespace();
  final BatchDocumentUpdateRequest batchDocumentUpdateRequest=new BatchDocumentUpdateRequest(searchDomain);
  final DocumentUpdate csDocument=new DocumentUpdate(Type.ADD,document.getId());
  final Collection<Field> fields=new ArrayList<>();
  for (  final IndexDefinition indexDefinition : documentConfiguration.indexDefinitions()) {
    final String indexName=indexDefinition.getName();
    final PropertyDescriptor propertyDescriptor=documentConfiguration.properties().get(indexName);
    final Field field=new Field(indexName,getPropertyValue(document,propertyDescriptor));
    fields.add(field);
  }
  csDocument.withFields(fields);
  batchDocumentUpdateRequest.withDocument(csDocument);
  getDocumentServiceClient(searchDomain).uploadDocuments(uploadDocumentsRequest(batchDocumentUpdateRequest));
}

Fixed version (ground truth):
@Override public void update(final Document document){
  final DocumentConfiguration documentConfiguration=getDocumentConfiguration(document.getClass());
  final String searchDomain=documentConfigurationHolder.schemaName() + "String_Node_Str" + documentConfiguration.namespace();
  final BatchDocumentUpdateRequest batchDocumentUpdateRequest=new BatchDocumentUpdateRequest(searchDomain);
  final DocumentUpdate csDocument=new DocumentUpdate(Type.ADD,document.getId());
  final Collection<Field> fields=new ArrayList<>();
  for (  final IndexDefinition indexDefinition : documentConfiguration.indexDefinitions()) {
    final String indexName=indexDefinition.getName();
    final PropertyDescriptor propertyDescriptor=documentConfiguration.properties().get(indexName);
    if (propertyDescriptor == null) {
      throw new IllegalStateException("String_Node_Str" + indexName);
    }
    final Field field=new Field(indexName,getPropertyValue(document,propertyDescriptor));
    fields.add(field);
  }
  csDocument.withFields(fields);
  batchDocumentUpdateRequest.withDocument(csDocument);
  getDocumentServiceClient(searchDomain).uploadDocuments(uploadDocumentsRequest(batchDocumentUpdateRequest));
}
Program: 11345
Project: 11345
Buggy source:
public DatabaseSchemaHolder(final String schemaName,final Collection<ItemConfiguration> itemConfigurations,final Collection<SequenceConfiguration> sequenceConfigurations){
  if (schemaName == null || schemaName.isEmpty()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (itemConfigurations == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.schemaName=schemaName;
  this.itemConfigurations=new HashSet<>(itemConfigurations);
  this.sequenceConfigurations=new HashSet<>(sequenceConfigurations);
}

Fixed version (ground truth):
public DatabaseSchemaHolder(final String schemaName,final Collection<ItemConfiguration> itemConfigurations,final Collection<SequenceConfiguration> sequenceConfigurations){
  if (schemaName == null || schemaName.isEmpty()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (itemConfigurations == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.schemaName=schemaName;
  this.itemConfigurations=Collections.unmodifiableSet(new HashSet<>(itemConfigurations));
  this.sequenceConfigurations=Collections.unmodifiableSet(new HashSet<>(sequenceConfigurations));
}
Program: 11346
Project: 11346
Buggy source:
public Collection<IndexDefinition> indexDefinitions(){
  return indexDefinitions.values();
}

Fixed version (ground truth):
public Collection<IndexDefinition> indexDefinitions(){
  return Collections.unmodifiableCollection(indexDefinitions.values());
}
Program: 11347
Project: 11347
Buggy source:
public Collection<UniqueConstraint> uniqueConstraints(){
  return uniqueConstraints.values();
}

Fixed version (ground truth):
public Collection<UniqueConstraint> uniqueConstraints(){
  return Collections.unmodifiableCollection(uniqueConstraints.values());
}
Program: 11348
Project: 11348
Buggy source:
public Collection<PropertyDescriptor> propertyDescriptors(){
  return properties.values();
}

Fixed version (ground truth):
public Collection<PropertyDescriptor> propertyDescriptors(){
  return Collections.unmodifiableCollection(properties.values());
}
Program: 11349
Project: 11349
Buggy source:
public Collection<IndexDefinition> indexDefinitions(){
  return indexDefinitions;
}

Fixed version (ground truth):
public Collection<IndexDefinition> indexDefinitions(){
  return Collections.unmodifiableCollection(indexDefinitions);
}
Program: 11350
Project: 11350
Buggy source:
public Map<String,PropertyDescriptor> properties(){
  return properties;
}

Fixed version (ground truth):
public Map<String,PropertyDescriptor> properties(){
  return Collections.unmodifiableMap(properties);
}
Program: 11351
Project: 11351
Buggy source:
@Test public void shouldRegisterIndexes_withIndexDefinitions() throws Exception {
  final Collection<IndexDefinition> indexDefinitions=Arrays.asList(new IndexDefinition("String_Node_Str",IndexFieldType.LITERAL));
  final String namespace=randomString(10);
  final Class<? extends Document> documentClass=StubDocument.class;
  final DocumentConfiguration documentConfiguration=new DocumentConfiguration(documentClass,namespace);
  documentConfiguration.registerIndexes(indexDefinitions);
  assertEquals(indexDefinitions,documentConfiguration.indexDefinitions());
}

Fixed version (ground truth):
@Test public void shouldRegisterIndexes_withIndexDefinitions() throws Exception {
  final Collection<IndexDefinition> indexDefinitions=Arrays.asList(new IndexDefinition("String_Node_Str",IndexFieldType.LITERAL));
  final String namespace=randomString(10);
  final Class<? extends Document> documentClass=StubDocument.class;
  final DocumentConfiguration documentConfiguration=new DocumentConfiguration(documentClass,namespace);
  documentConfiguration.registerIndexes(indexDefinitions);
  assertEquals(new ArrayList<>(indexDefinitions),new ArrayList<>(documentConfiguration.indexDefinitions()));
}
Program: 11352
Project: 11352
Buggy source:
@Deprecated public boolean isProcessedRecentDeferrableEvent(){
  return deferrableProcessing;
}

Fixed version (ground truth):
public boolean isProcessedRecentDeferrableEvent(){
  return deferrableProcessing;
}
Program: 11353
Project: 11353
Buggy source:
protected void handlePersistenceException(final PersistenceException persistenceException) throws Throwable {
  for (  final PersistenceExceptionHandler<?> persistenceExceptionHandler : persistenceExceptionHandlers) {
    Method method;
    try {
      method=getPersistenceHandlerMethod(persistenceExceptionHandler,persistenceException);
    }
 catch (    final NoSuchMethodException e) {
      continue;
    }
    try {
      method.setAccessible(true);
      method.invoke(persistenceExceptionHandler,persistenceException);
    }
 catch (    IllegalAccessException|IllegalArgumentException e) {
      continue;
    }
catch (    final InvocationTargetException handlerException) {
      throw handlerException.getCause();
    }
  }
}

Fixed version (ground truth):
protected void handlePersistenceException(final PersistenceException persistenceException) throws Throwable {
  if (persistenceExceptionHandlers.isEmpty()) {
    throw persistenceException;
  }
  for (  final PersistenceExceptionHandler<?> persistenceExceptionHandler : persistenceExceptionHandlers) {
    Method method;
    try {
      method=getPersistenceHandlerMethod(persistenceExceptionHandler,persistenceException);
    }
 catch (    final NoSuchMethodException e) {
      continue;
    }
    try {
      method.setAccessible(true);
      method.invoke(persistenceExceptionHandler,persistenceException);
    }
 catch (    IllegalAccessException|IllegalArgumentException e) {
      continue;
    }
catch (    final InvocationTargetException handlerException) {
      throw handlerException.getCause();
    }
  }
}
Program: 11354
Project: 11354
Buggy source:
public void updateLocation(Collection<IBeacon> iBeacons){
  if (mLastChanged.plusSeconds(THROTTLE).isAfterNow()) {
    return;
  }
  if (iBeacons.size() == 0) {
    setLocation(null);
    return;
  }
  IBeacon[] iBeaconsArray=iBeacons.toArray(new IBeacon[iBeacons.size()]);
  Arrays.sort(iBeaconsArray,new Comparator<IBeacon>(){
    @Override public int compare(    IBeacon a,    IBeacon b){
      return a.getAccuracy() - b.getAccuracy() < 0 ? 1 : -1;
    }
  }
);
  for (  IBeacon iBeacon : iBeaconsArray) {
    if (iBeacon.getProximity() == IBeacon.PROXIMITY_IMMEDIATE) {
      setLocation(iBeacon);
      return;
    }
  }
  for (  IBeacon iBeacon : iBeaconsArray) {
    if (iBeacon.getProximity() == IBeacon.PROXIMITY_NEAR) {
      setLocation(iBeacon);
      return;
    }
  }
}

Fixed version (ground truth):
public void updateLocation(Collection<IBeacon> iBeacons){
  if (mLastChanged.plusSeconds(THROTTLE).isAfterNow()) {
    return;
  }
  if (iBeacons.size() == 0) {
    setLocation(null);
    return;
  }
  IBeacon[] iBeaconsArray=iBeacons.toArray(new IBeacon[iBeacons.size()]);
  Arrays.sort(iBeaconsArray,new Comparator<IBeacon>(){
    @Override public int compare(    IBeacon a,    IBeacon b){
      return a.getAccuracy() - b.getAccuracy() < 0 ? 1 : -1;
    }
  }
);
  for (  IBeacon iBeacon : iBeaconsArray) {
    if (iBeacon.getProximity() == IBeacon.PROXIMITY_IMMEDIATE) {
      setLocation(iBeacon);
      return;
    }
  }
  for (  IBeacon iBeacon : iBeaconsArray) {
    if (iBeacon.getProximity() == IBeacon.PROXIMITY_NEAR) {
      setLocation(iBeacon);
      return;
    }
  }
  setLocation(null);
}
Program: 11355
Project: 11355
Buggy source:
public static byte[] stringNumberToByteArray(String number,int radix,int size){
  byte[] array=new BigInteger(number,radix).toByteArray();
  byte[] sizedArray=new byte[size];
  System.arraycopy(array,0,sizedArray,0,Math.min(size,array.length));
  return sizedArray;
}

Fixed version (ground truth):
public static byte[] stringNumberToByteArray(String number,int radix,int size){
  byte[] array=new BigInteger(number,radix).toByteArray();
  byte[] sizedArray=new byte[size];
  int signOffset=array[0] == 0 ? 1 : 0;
  System.arraycopy(array,signOffset,sizedArray,0,Math.min(size,array.length));
  return sizedArray;
}
Program: 11356
Project: 11356
Buggy source:
/** 
 * @param location
 * @param secretKey
 * @param identifier
 */
public MacaroonsBuilder(String location,String secretKey,String identifier){
  this.location=location;
  this.secretKey=secretKey;
  this.identifier=identifier;
}

Fixed version (ground truth):
/** 
 * @param location   location
 * @param secretKey  secretKey
 * @param identifier identifier
 */
public MacaroonsBuilder(String location,String secretKey,String identifier){
  this.location=location;
  this.secretKey=secretKey;
  this.identifier=identifier;
}
Program: 11357
Project: 11357
Buggy source:
/** 
 * @param macaroon
 * @param secretKey
 * @return
 */
public static MacaroonsBuilder modify(Macaroon macaroon,String secretKey){
  return new MacaroonsBuilder(macaroon.location,secretKey,macaroon.identifier);
}

Fixed version (ground truth):
/** 
 * @param macaroon  macaroon
 * @param secretKey secretKey
 * @return {@link com.github.nitram509.jmacaroons.MacaroonsBuilder}
 */
public static MacaroonsBuilder modify(Macaroon macaroon,String secretKey){
  return new MacaroonsBuilder(macaroon.location,secretKey,macaroon.identifier);
}
Program: 11358
Project: 11358
Buggy source:
/** 
 * throws java.security.InvalidKeyException      (wrapped within a RuntimeException) throws java.security.NoSuchAlgorithmException (wrapped within a RuntimeException)
 * @return
 */
public Macaroon getMacaroon(){
}

Fixed version (ground truth):
/** 
 * throws java.security.InvalidKeyException      (wrapped within a RuntimeException) throws java.security.NoSuchAlgorithmException (wrapped within a RuntimeException)
 * @return {@link com.github.nitram509.jmacaroons.Macaroon}
 */
public Macaroon getMacaroon(){
}
Program: 11359
Project: 11359
Buggy source:
/** 
 * @param caveat
 * @return
 */
public MacaroonsBuilder add_first_party_caveat(String caveat){
}

Fixed version (ground truth):
/** 
 * @param caveat caveat
 * @return this {@link com.github.nitram509.jmacaroons.MacaroonsBuilder}
 */
public MacaroonsBuilder add_first_party_caveat(String caveat){
}
Program: 11360
Project: 11360
Buggy source:
/** 
 * @param caveat
 * @return
 */
private MacaroonsBuilder add_third_party_caveat(String caveat){
  if (caveat != null) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  return this;
}

Fixed version (ground truth):
/** 
 * @param caveat caveat
 * @return this {@link com.github.nitram509.jmacaroons.MacaroonsBuilder}
 */
private MacaroonsBuilder add_third_party_caveat(String caveat){
  if (caveat != null) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  return this;
}
Program: 11361
Project: 11361
Buggy source:
/** 
 * @param location
 * @param secretKey
 * @param identifier
 * @return
 */
public static Macaroon create(String location,String secretKey,String identifier){
  return new MacaroonsBuilder(location,secretKey,identifier).getMacaroon();
}

Fixed version (ground truth):
/** 
 * @param location   location
 * @param secretKey  secretKey
 * @param identifier identifier
 * @return {@link com.github.nitram509.jmacaroons.Macaroon}
 */
public static Macaroon create(String location,String secretKey,String identifier){
  return new MacaroonsBuilder(location,secretKey,identifier).getMacaroon();
}
Program: 11362
Project: 11362
Buggy source:
/** 
 * @param serializedMacaroon
 * @return
 * @throws com.github.nitram509.jmacaroons.NotDeSerializableException when serialized macaroon is not valid base64, length is to short or contains invalid packet data
 */
public static Macaroon deserialize(String serializedMacaroon) throws IllegalArgumentException {
  return MacaroonsDeSerializer.deserialize(serializedMacaroon);
}

Fixed version (ground truth):
/** 
 * @param serializedMacaroon serializedMacaroon
 * @return {@link com.github.nitram509.jmacaroons.Macaroon}
 * @throws com.github.nitram509.jmacaroons.NotDeSerializableException when serialized macaroon is not valid base64, length is to short or contains invalid packet data
 */
public static Macaroon deserialize(String serializedMacaroon) throws IllegalArgumentException {
  return MacaroonsDeSerializer.deserialize(serializedMacaroon);
}
Program: 11363
Project: 11363
Buggy source:
/** 
 * @param secret
 * @return
 * @throws com.github.nitram509.jmacaroons.MacaroonValidationException     when the macaroon isn't valid
 * @throws com.github.nitram509.jmacaroons.GeneralSecurityRuntimeException
 */
public void assertIsValid(String secret) throws MacaroonValidationException, GeneralSecurityRuntimeException {
  if (!isValid(secret)) {
    throw new MacaroonValidationException("String_Node_Str",macaroon);
  }
}

Fixed version (ground truth):
/** 
 * @param secret secret
 * @throws com.github.nitram509.jmacaroons.MacaroonValidationException     when the macaroon isn't valid
 * @throws com.github.nitram509.jmacaroons.GeneralSecurityRuntimeException
 */
public void assertIsValid(String secret) throws MacaroonValidationException, GeneralSecurityRuntimeException {
  if (!isValid(secret)) {
    throw new MacaroonValidationException("String_Node_Str",macaroon);
  }
}
Program: 11364
Project: 11364
Buggy source:
/** 
 * @param secret
 * @return
 * @throws com.github.nitram509.jmacaroons.GeneralSecurityRuntimeException
 */
public boolean isValid(String secret) throws GeneralSecurityRuntimeException {
  try {
    byte[] key=generate_derived_key(secret);
    byte[] hmac=macaroon_hmac(key,macaroon.identifier);
    for (    String caveat : exactCaveats) {
      if (containsElement(macaroon.caveats,caveat)) {
        hmac=macaroon_hmac(hmac,caveat);
      }
    }
    return Arrays.equals(hmac,macaroon.signatureBytes);
  }
 catch (  InvalidKeyException|NoSuchAlgorithmException e) {
    throw new GeneralSecurityRuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * @param secret secret
 * @return true/false if the macaroon is valid
 * @throws com.github.nitram509.jmacaroons.GeneralSecurityRuntimeException
 */
public boolean isValid(String secret) throws GeneralSecurityRuntimeException {
  try {
    byte[] key=generate_derived_key(secret);
    byte[] hmac=macaroon_hmac(key,macaroon.identifier);
    for (    String caveat : exactCaveats) {
      if (containsElement(macaroon.caveats,caveat)) {
        hmac=macaroon_hmac(hmac,caveat);
      }
    }
    return Arrays.equals(hmac,macaroon.signatureBytes);
  }
 catch (  InvalidKeyException|NoSuchAlgorithmException e) {
    throw new GeneralSecurityRuntimeException(e);
  }
}
Program: 11365
Project: 11365
Buggy source:
/** 
 * Caveats like these are called "exact caveats" because there is exactly one way to satisfy them.  Either the given caveat matches, or it doesn't.  At verification time, the verifier will check each caveat in the macaroon against the list of satisfied caveats provided to   {@link #satisfyExcact(String)}. When it finds a match, it knows that the caveat holds and it can move onto the next caveat in the macaroon.
 * @param caveat
 * @return
 */
public MacaroonsVerifier satisfyExcact(String caveat){
  if (caveat != null) {
    this.exactCaveats=appendToArray(this.exactCaveats,caveat);
  }
  return this;
}

Fixed version (ground truth):
/** 
 * Caveats like these are called "exact caveats" because there is exactly one way to satisfy them.  Either the given caveat matches, or it doesn't.  At verification time, the verifier will check each caveat in the macaroon against the list of satisfied caveats provided to satisfyExcact(String). When it finds a match, it knows that the caveat holds and it can move onto the next caveat in the macaroon.
 * @param caveat caveat
 * @return this {@link com.github.nitram509.jmacaroons.MacaroonsVerifier}
 */
public MacaroonsVerifier satisfyExcact(String caveat){
  if (caveat != null) {
    this.exactCaveats=appendToArray(this.exactCaveats,caveat);
  }
  return this;
}
Program: 11366
Project: 11366
Buggy source:
/** 
 * @return
 * @throws java.security.InvalidKeyException      (wrapped within a RuntimeException)
 * @throws java.security.NoSuchAlgorithmException (wrapped within a RuntimeException)
 */
public Macaroon getMacaroon(){
}

Fixed version (ground truth):
/** 
 * throws java.security.InvalidKeyException      (wrapped within a RuntimeException) throws java.security.NoSuchAlgorithmException (wrapped within a RuntimeException)
 * @return
 */
public Macaroon getMacaroon(){
}
Program: 11367
Project: 11367
Buggy source:
/** 
 * @param macaroon
 * @param secret
 * @return
 * @throws java.security.InvalidKeyException (wrapped within a RuntimeException)
 * @throws java.security.NoSuchAlgorithmException (wrapped within a RuntimeException)
 */
public boolean verify(Macaroon macaroon,String secret){
  try {
    byte[] key=generate_derived_key(secret);
    byte[] hmac=macaroon_hmac(key,macaroon.identifier);
    for (    String caveat : macaroon.caveats) {
      hmac=macaroon_hmac(hmac,caveat);
    }
    return Arrays.equals(hmac,macaroon.signatureBytes);
  }
 catch (  InvalidKeyException|NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * throws java.security.InvalidKeyException (wrapped within a RuntimeException) throws java.security.NoSuchAlgorithmException (wrapped within a RuntimeException)
 * @param macaroon
 * @param secret
 * @return
 */
public boolean verify(Macaroon macaroon,String secret){
  try {
    byte[] key=generate_derived_key(secret);
    byte[] hmac=macaroon_hmac(key,macaroon.identifier);
    for (    String caveat : macaroon.caveats) {
      hmac=macaroon_hmac(hmac,caveat);
    }
    return Arrays.equals(hmac,macaroon.signatureBytes);
  }
 catch (  InvalidKeyException|NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
  }
}
Program: 11368
Project: 11368
Buggy source:
@Override public void run(){
  while (isRunning) {
    dequeuedEvents.clear();
    long currentTime=System.currentTimeMillis();
synchronized (queuedEventList) {
      for (      MidiEventWithTiming event : queuedEventList) {
        if (event.timing <= currentTime) {
          dequeuedEvents.add(event);
        }
      }
      queuedEventList.removeAll(dequeuedEvents);
    }
    if (dequeuedEvents.size() > 0) {
      Collections.sort(dequeuedEvents,midiTimerTaskComparator);
      if (midiInputEventListener != null) {
        for (        MidiEventWithTiming event : dequeuedEvents) {
          while (event.timing < System.currentTimeMillis()) {
            try {
              Thread.sleep(1);
            }
 catch (            InterruptedException ignored) {
            }
          }
          event.run();
        }
      }
    }
    try {
      Thread.sleep(BUFFER_LENGTH_MILLIS);
    }
 catch (    InterruptedException ignored) {
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  while (isRunning) {
    dequeuedEvents.clear();
    long currentTime=System.currentTimeMillis();
synchronized (queuedEventList) {
      for (      MidiEventWithTiming event : queuedEventList) {
        if (event.timing <= currentTime) {
          dequeuedEvents.add(event);
        }
      }
      queuedEventList.removeAll(dequeuedEvents);
    }
    if (dequeuedEvents.size() > 0) {
      Collections.sort(dequeuedEvents,midiTimerTaskComparator);
      if (midiInputEventListener != null) {
        for (        MidiEventWithTiming event : dequeuedEvents) {
          while (event.timing > System.currentTimeMillis()) {
            try {
              Thread.sleep(1);
            }
 catch (            InterruptedException ignored) {
            }
          }
          event.run();
        }
      }
    }
    try {
      Thread.sleep(BUFFER_LENGTH_MILLIS);
    }
 catch (    InterruptedException ignored) {
    }
  }
}
Program: 11369
Project: 11369
Buggy source:
/** 
 * SysEx
 * @param systemExclusive : start with 'F0', and end with 'F7'
 */
public final void sendMidiSystemExclusive(@NonNull byte[] systemExclusive){
  byte[] timestampAddedSystemExclusive=new byte[systemExclusive.length + 2];
  System.arraycopy(systemExclusive,0,timestampAddedSystemExclusive,1,systemExclusive.length);
  byte[] writeBuffer=new byte[20];
  long timestamp=System.currentTimeMillis() % MAX_TIMESTAMP;
  timestampAddedSystemExclusive[0]=(byte)(0x80 | ((timestamp >> 7) & 0x3f));
  for (int i=0; i < timestampAddedSystemExclusive.length; i+=19) {
    writeBuffer[0]=(byte)(0x80 | ((timestamp >> 7) & 0x3f));
    timestampAddedSystemExclusive[systemExclusive.length]=(byte)(0x80 | (timestamp & 0x7f));
    if (i + 20 <= timestampAddedSystemExclusive.length) {
      System.arraycopy(timestampAddedSystemExclusive,i,writeBuffer,1,19);
    }
 else {
      writeBuffer=new byte[timestampAddedSystemExclusive.length - i + 1];
      System.arraycopy(timestampAddedSystemExclusive,i,writeBuffer,1,timestampAddedSystemExclusive.length - i);
    }
    transferData(writeBuffer);
    timestamp=System.currentTimeMillis() % MAX_TIMESTAMP;
  }
}

Fixed version (ground truth):
/** 
 * SysEx
 * @param systemExclusive : start with 'F0', and end with 'F7'
 */
public final void sendMidiSystemExclusive(@NonNull byte[] systemExclusive){
  byte[] timestampAddedSystemExclusive=new byte[systemExclusive.length + 2];
  System.arraycopy(systemExclusive,0,timestampAddedSystemExclusive,1,systemExclusive.length);
  byte[] writeBuffer=new byte[20];
  long timestamp=System.currentTimeMillis() % MAX_TIMESTAMP;
  timestampAddedSystemExclusive[0]=(byte)(0x80 | ((timestamp >> 7) & 0x3f));
  for (int i=0; i < timestampAddedSystemExclusive.length; i+=19) {
    writeBuffer[0]=(byte)(0x80 | ((timestamp >> 7) & 0x3f));
    timestampAddedSystemExclusive[systemExclusive.length]=(byte)(0x80 | (timestamp & 0x7e));
    if (i + 20 <= timestampAddedSystemExclusive.length) {
      System.arraycopy(timestampAddedSystemExclusive,i,writeBuffer,1,19);
    }
 else {
      writeBuffer=new byte[timestampAddedSystemExclusive.length - i + 1];
      System.arraycopy(timestampAddedSystemExclusive,i,writeBuffer,1,timestampAddedSystemExclusive.length - i);
    }
    transferData(writeBuffer);
    timestamp=System.currentTimeMillis() % MAX_TIMESTAMP;
  }
}
Program: 11371
Project: 11371
Buggy source:
/** 
 * SysEx
 * @param systemExclusive : start with 'F0', and end with 'F7'
 */
public final void sendMidiSystemExclusive(@NonNull byte[] systemExclusive){
  byte[] timestampAddedSystemExclusive=new byte[systemExclusive.length + 2];
  System.arraycopy(systemExclusive,0,timestampAddedSystemExclusive,1,systemExclusive.length);
  byte[] writeBuffer=new byte[20];
  long timestamp=System.currentTimeMillis() % MAX_TIMESTAMP;
  timestampAddedSystemExclusive[0]=(byte)(0x80 | ((timestamp >> 7) & 0x3f));
  for (int i=0; i < timestampAddedSystemExclusive.length; i+=19) {
    writeBuffer[0]=(byte)(0x80 | ((timestamp >> 7) & 0x3f));
    timestampAddedSystemExclusive[systemExclusive.length]=(byte)(0x80 | (timestamp & 0x7f));
    if (i + 20 <= timestampAddedSystemExclusive.length) {
      System.arraycopy(timestampAddedSystemExclusive,i,writeBuffer,1,19);
    }
 else {
      writeBuffer=new byte[timestampAddedSystemExclusive.length - i + 1];
      System.arraycopy(timestampAddedSystemExclusive,i,writeBuffer,1,timestampAddedSystemExclusive.length - i);
    }
    transferData(writeBuffer);
    timestamp=System.currentTimeMillis() % MAX_TIMESTAMP;
  }
}

Fixed version (ground truth):
/** 
 * SysEx
 * @param systemExclusive : start with 'F0', and end with 'F7'
 */
public final void sendMidiSystemExclusive(@NonNull byte[] systemExclusive){
  byte[] timestampAddedSystemExclusive=new byte[systemExclusive.length + 2];
  System.arraycopy(systemExclusive,0,timestampAddedSystemExclusive,1,systemExclusive.length);
  long timestamp=System.currentTimeMillis() % MAX_TIMESTAMP;
  timestampAddedSystemExclusive[systemExclusive.length + 1]=systemExclusive[systemExclusive.length - 1];
  timestampAddedSystemExclusive[0]=(byte)(0x80 | (timestamp & 0x7f));
  byte[] writeBuffer=new byte[20];
  for (int i=0; i < timestampAddedSystemExclusive.length; i+=19) {
    timestampAddedSystemExclusive[systemExclusive.length]=(byte)(0x80 | (timestamp & 0x7e));
    if (i + 19 <= timestampAddedSystemExclusive.length) {
      System.arraycopy(timestampAddedSystemExclusive,i,writeBuffer,1,19);
    }
 else {
      writeBuffer=new byte[timestampAddedSystemExclusive.length - i + 1];
      System.arraycopy(timestampAddedSystemExclusive,i,writeBuffer,1,timestampAddedSystemExclusive.length - i);
    }
    writeBuffer[0]=(byte)(0x80 | ((timestamp >> 7) & 0x3f));
    transferData(writeBuffer);
    timestamp=System.currentTimeMillis() % MAX_TIMESTAMP;
  }
}