auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public String toString() { return "Body [position=" + position + ", height=" + height + ", width=" + width + ", orientation=" + orientation + ", type=" + type + "]"; }

Target:
public String toString() { return String.format("Body [position=%s, height=%s, width=%s, orientation=%s, type=%s]", position, height, width, orientation, type); }
Source:
public void test() { assertThat(PHPLexicalGrammar.FUNCTION_CALL_PARAMETER_LIST) .matches("()") .matches("($p)") .matches("(& $p)") .matches("(...$p)") .matches("(yield $a)") .matches("($p1, & $p2, ...$p3, yield $p4)") .notMatches("('title', 'body','comments',)") .notMatches("(,)") .notMatches("('function','bar',,)") .notMatches("(,'function','bar')"); }

Target:
public void test() { assertThat(PHPLexicalGrammar.FUNCTION_CALL_PARAMETER_LIST) .matches("()") .matches("($p)") .matches("(& $p)") .matches("(...$p)") .matches("(yield $a)") .matches("($p1, & $p2, ...$p3, yield $p4)") .matches("('title', 'body','comments',)") .notMatches("(,)") .notMatches("('function','bar',,)") .notMatches("(,'function','bar')"); }
Source:
public ABITrace( URL ABIFile ) throws IOException { byte[] bytes = null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); InputStream is = ABIFile.openStream(); BufferedInputStream bis = new BufferedInputStream(is); int b; while ((b = bis.read()) >= 0) { baos.write(b); } bis.close(); is.close(); baos.close(); bytes = baos.toByteArray(); initData(bytes); }

Target:
public ABITrace( URL ABIFile ) throws IOException { InputStream is = ABIFile.openStream(); BufferedInputStream bis = new BufferedInputStream(is); ABITraceInit(bis); is.close(); }
Source:
public void handleRequest(JCoServerContext jCoServerContext, JCoFunction jCoFunction) throws AbapException, AbapClassException { if (log.isDebugEnabled()) { log.debug("New BAPI function call received"); } String xml = jCoFunction.toXML(); ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes()); MessageContext msgContext = null; try { msgContext = endpoint.createMessageContext(); msgContext.setIncomingTransportName(SAPConstants.SAP_BAPI_PROTOCOL_NAME); if (log.isDebugEnabled()) { log.debug("Creating SOAP envelope from the BAPI function call"); } SOAPEnvelope envelope = TransportUtils.createSOAPMessage(msgContext, bais, SAPConstants.SAP_CONTENT_TYPE); msgContext.setEnvelope(envelope); } catch (Exception e) { log.error("Error while processing the BAPI call through the Axis engine", e); } finally { try { bais.close(); } catch (IOException e) { log.error("Error while closing the stream", e); } } workerPool.execute(new BAPIWorker(msgContext)); }

Target:
public void handleRequest(JCoServerContext jCoServerContext, JCoFunction jCoFunction) throws AbapException, AbapClassException { if (log.isDebugEnabled()) { log.debug("New BAPI function call received"); } String xml = jCoFunction.toXML(); workerPool.execute(new BAPIWorker(xml)); }
Source:
protected static String renameDiskAlias(OriginType originType, String alias) { Matcher vmwareMatcher; if (originType == OriginType.VMWARE) { vmwareMatcher = VMWARE_DISK_NAME_PATTERN.matcher(alias); } else { vmwareMatcher = DISK_NAME_PATTERN.matcher(alias); } if (vmwareMatcher.matches()) { return vmwareMatcher.group(1); } return alias; }

Target:
protected static String renameDiskAlias(OriginType originType, String alias) { Matcher matcher; if (originType == OriginType.VMWARE) { matcher = VMWARE_DISK_NAME_PATTERN.matcher(alias); } else { matcher = DISK_NAME_PATTERN.matcher(alias); } if (matcher.matches()) { return matcher.group(1); } return alias; }
Source:
public Map<String, String> getDataForResourceId(final String nodeId, final String resourceIdString) { return m_transactionOperations.execute(new TransactionCallback<Map<String, String>>() { @Override public Map<String, String> doInTransaction(TransactionStatus transactionStatus) { Map<String, String> data = new HashMap<>(); ResourceId resourceId = ResourceId.fromString(resourceIdString); String nodeIdentifier = Optional.ofNullable(nodeId).orElse(determineNodeIdByResourceId(resourceId)); data.put("nodeId", nodeIdentifier); data.put("nodeLabel", m_nodeDao.getLabelForId(Integer.valueOf(nodeIdentifier))); List<OnmsResource> resourceList = m_resourceDao.getResourceById(ResourceId.get("node", nodeIdentifier)).getChildResources(); for (OnmsResource onmsResource : resourceList) { if (resourceId.equals(onmsResource.getId())) { data.put("resourceLabel", onmsResource.getLabel()); data.put("resourceTypeLabel", onmsResource.getResourceType().getLabel()); break; } } return data; } }); }

Target:
public Map<String, String> getDataForResourceId(final String nodeId, final String resourceIdString) { return m_transactionOperations.execute(new TransactionCallback<Map<String, String>>() { @Override public Map<String, String> doInTransaction(TransactionStatus transactionStatus) { Map<String, String> data = new HashMap<>(); ResourceId resourceId = ResourceId.fromString(resourceIdString); OnmsNode node; OnmsResource resource; if(nodeId == null){ resource = determineResourceByResourceId(resourceId); node = ResourceTypeUtils.getNodeFromResource(resource); } else { node = m_nodeDao.get(nodeId); resource = m_resourceDao.getResourceForNode(node); } data.put("nodeId", node.getNodeId()); data.put("nodeLabel", node.getLabel()); for (OnmsResource onmsResource : resource.getChildResources()) { if (resourceId.equals(onmsResource.getId())) { data.put("resourceLabel", onmsResource.getLabel()); data.put("resourceTypeLabel", onmsResource.getResourceType().getLabel()); break; } } return data; } }); }
Source:
private void processError( ContentReviewItem item, Long status, String error, Integer errorCode ) { if( status == null ) { IllegalArgumentException ex = new IllegalArgumentException( "Status is null; you must supply a valid status to update when calling processError()" ); log.warn( ex ); throw ex; } else { item.setStatus( status ); } if( error != null ) { item.setLastError(error); } if( errorCode != null ) { item.setErrorCode( errorCode ); } dao.update( item ); releaseLock( item ); if( status.equals( ContentReviewItem.SUBMISSION_ERROR_NO_RETRY_CODE ) || status.equals( ContentReviewItem.REPORT_ERROR_NO_RETRY_CODE ) || status.equals( ContentReviewItem.SUBMISSION_ERROR_RETRY_EXCEEDED ) ) { try { ContentResource resource = contentHostingService.getResource( item.getContentId() ); boolean itemUpdated = updateItemAccess( resource.getId() ); if (!itemUpdated) { log.error( "Could not update cr item access status" ); } } catch( PermissionException | IdUnusedException | TypeException ex ) { log.error( "Error updating cr item access status; item id = " + item.getContentId(), ex ); } } }

Target:
private void processError( ContentReviewItem item, Long status, String error, Integer errorCode ) { try { if( status == null ) { IllegalArgumentException ex = new IllegalArgumentException( "Status is null; you must supply a valid status to update when calling processError()" ); throw ex; } else { item.setStatus( status ); } if( error != null ) { item.setLastError(error); } if( errorCode != null ) { item.setErrorCode( errorCode ); } dao.update( item ); if( isDeadState( status ) ) { try { ContentResource resource = contentHostingService.getResource( item.getContentId() ); boolean itemUpdated = updateItemAccess( resource.getId() ); if (!itemUpdated) { log.error( "Could not update cr item access status" ); } } catch( PermissionException | IdUnusedException | TypeException ex ) { log.error( "Error updating cr item access status; item id = " + item.getContentId(), ex ); } } } finally { releaseLock( item ); } }
Source:
public void sendEmailToEndorseds() { CronJob cronJob = new CronJob(); cronJob.setName(Constants.CRON_MAIL_ENDORSEMENT_JOB); cronJob.setStartTimestamp(new Date()); Date lastExecutedCronJob = findLastExecutedCronJob(Constants.CRON_MAIL_ENDORSEMENT_JOB); try { List<TechGalleryUser> usersList = techGalleryUserDao.findAll(); for (TechGalleryUser techGalleryUser : usersList) { List<Endorsement> endorsementsList = endorsementDao.findAllEndorsementsStartingFrom(techGalleryUser, lastExecutedCronJob); if (endorsementsList != null) { TechGalleryActivitiesTO activities = new TechGalleryActivitiesTO(Constants.APP_NAME, null, new ArrayList<TechnologyActivitiesTO>()); for (Endorsement endorsement : endorsementsList) { TechnologyActivitiesTO endorsementActivity = new TechnologyActivitiesTO(endorsement.getEndorserEntity(), endorsement.getTechnologyEntity(), null, null, null); activities.getTechnologyActivitiesTo().add(endorsementActivity); } if (!activities.getTechnologyActivitiesTo().isEmpty()) { EmailConfig email = new EmailConfig(EmailTypeEnum.ENDORSED, EmailTypeEnum.ENDORSED.getSubject() + activities.getFormattedTimestamp(), activities, techGalleryUser.getEmail()); emailService.push(email); } } } cronJob.setEndTimestamp(new Date()); cronJob.setCronStatus(CronStatus.SUCCESS); } catch (Exception e) { _LOG.info(e.getMessage()); cronJob.setEndTimestamp(new Date()); cronJob.setCronStatus(CronStatus.FAILURE); cronJob.setDescription(e.getMessage()); } cronJobsDao.add(cronJob); }

Target:
public void sendEmailToEndorseds() { CronJob cronJob = new CronJob(); cronJob.setName(Constants.CRON_MAIL_ENDORSEMENT_JOB); cronJob.setStartTimestamp(new Date()); Date lastExecutedCronJob = findLastExecutedCronJob(Constants.CRON_MAIL_ENDORSEMENT_JOB); try { List<TechGalleryUser> usersList = techGalleryUserDao.findAll(); for (TechGalleryUser techGalleryUser : usersList) { List<Endorsement> endorsementsList = endorsementDao.findAllEndorsementsStartingFrom(techGalleryUser, lastExecutedCronJob); if (endorsementsList != null) { TechGalleryActivitiesEmailTemplateTO activities = new TechGalleryActivitiesEmailTemplateTO(Constants.APP_NAME, null, new ArrayList<TechnologyActivitiesEmailTemplateTO>()); for (Endorsement endorsement : endorsementsList) { TechnologyActivitiesEmailTemplateTO endorsementActivity = new TechnologyActivitiesEmailTemplateTO(endorsement.getEndorserEntity(), endorsement.getTechnologyEntity(), null, null, null); activities.getTechnologyActivitiesTo().add(endorsementActivity); } if (!activities.getTechnologyActivitiesTo().isEmpty()) { EmailConfig email = new EmailConfig(EmailTypeEnum.ENDORSED, EmailTypeEnum.ENDORSED.getSubject() + activities.getFormattedTimestamp(), activities, techGalleryUser.getEmail()); emailService.push(email); } } } cronJob.setEndTimestamp(new Date()); cronJob.setCronStatus(CronStatus.SUCCESS); } catch (Exception e) { _LOG.info(e.getMessage()); cronJob.setEndTimestamp(new Date()); cronJob.setCronStatus(CronStatus.FAILURE); cronJob.setDescription(e.getMessage()); } cronJobsDao.add(cronJob); }
Source:
private void checkAttributeAccessItem(final List<AttributeAccessItem> attributeAccessItemList, final List<AttributeAccessItemDto> attributeAccessItemDtoList) { assertEquals(attributeAccessItemList.size(), attributeAccessItemDtoList.size()); for (final AttributeAccessItem attributeAccessItem : attributeAccessItemList) { assertEquals(attributeAccessItem.getAccessMode(), attributeAccessItem.getAccessMode()); assertEquals(attributeAccessItem.getAccessSelectors(), attributeAccessItem.getAccessSelectors()); assertEquals(attributeAccessItem.getAttributeId(), attributeAccessItem.getAttributeId()); } }

Target:
private void checkAttributeAccessItem(final List<AttributeAccessItem> attributeAccessItemList, final List<AttributeAccessItemDto> attributeAccessItemDtoList) { assertEquals(attributeAccessItemList.size(), attributeAccessItemDtoList.size()); final Iterator<AttributeAccessItem> attributeAccessItemIterator = attributeAccessItemList.iterator(); final Iterator<AttributeAccessItemDto> attributeAccessItemDtoIterator = attributeAccessItemDtoList.iterator(); while (attributeAccessItemIterator.hasNext() && attributeAccessItemDtoIterator.hasNext()) { final AttributeAccessItem attributeAccessItem = attributeAccessItemIterator.next(); final AttributeAccessItemDto attributeAccessItemDto = attributeAccessItemDtoIterator.next(); assertEquals(attributeAccessItem.getAccessMode().name(), attributeAccessItemDto.getAccessMode().name()); assertEquals(attributeAccessItem.getAccessSelectors().getAccessSelector(), attributeAccessItemDto.getAccessSelectors().getAccessSelector()); assertEquals(attributeAccessItem.getAttributeId(), attributeAccessItemDto.getAttributeId()); } }
Source:
public boolean accept(Type type, Class<?> clazz) { if (clazz == null) { return false; } if (GeneratedMessageV3.class.isAssignableFrom(clazz)) { return true; } return false; }

Target:
public boolean accept(Type type, Class<?> clazz) { if (clazz == null) { return false; } return GeneratedMessageV3.class.isAssignableFrom(clazz); }
Source:
public void testGetRegions() throws IOException { final Kiji mKiji = getKiji(); mKiji.createTable( "user", KijiTableLayouts.getTableLayout(KijiTableLayouts.FULL_FEATURED), 3); final KijiTable mTable = mKiji.openTable("user"); List<KijiRegion> regions = mTable.getRegions(); assertEquals(3, regions.size()); for (KijiRegion region : regions) { assertTrue(region.getLocations().size() > 0); } }

Target:
public void testGetRegions() throws IOException { final int numRegions = 3; final Kiji mKiji = getKiji(); mKiji.createTable( "user", KijiTableLayouts.getTableLayout(KijiTableLayouts.FULL_FEATURED), numRegions); final KijiTable mTable = mKiji.openTable("user"); List<KijiRegion> regions = mTable.getRegions(); assertEquals(numRegions, regions.size()); for (KijiRegion region : regions) { assertTrue(region.getLocations().size() > 0); } }
Source:
DirProperty readPropertyFromPath(Path path, BasicFileAttributes mainAtts) throws IOException { if (Files.exists(path) && Files.isRegularFile(path) && Files.isReadable(path)) { return new DirProperty( new String(Files.readAllBytes(path)), mainAtts.lastModifiedTime(), path.toAbsolutePath(), directory.relativize(path).getNameCount() ); } return null; }

Target:
DirProperty readPropertyFromPath(Path path, BasicFileAttributes mainAtts) throws IOException { if (Files.exists(path) && Files.isRegularFile(path) && Files.isReadable(path)) { return new DirProperty( new String(Files.readAllBytes(path), StandardCharsets.UTF_8), mainAtts.lastModifiedTime(), path.toAbsolutePath(), this.directory ); } throw new IOException("Cannot read property from '"+path.toString()+"'."); }
Source:
public void testSetBaseDirectory() throws IOException { GeoServerResourceLoader loader = new GeoServerResourceLoader(); assertNull(loader.getBaseDirectory()); assertEquals(ResourceStore.EMPTY, loader.getResourceStore()); TemporaryFolder tempFolder = new TemporaryFolder(); tempFolder.create(); File tempDir = tempFolder.getRoot(); loader.setBaseDirectory(tempDir); assertEquals(tempDir, loader.getBaseDirectory()); assertTrue(loader.getResourceStore() instanceof FileSystemResourceStore); ResourceStore mockStore = EasyMock.createMock(ResourceStore.class); loader = new GeoServerResourceLoader(mockStore); assertNull(loader.getBaseDirectory()); assertEquals(mockStore, loader.getResourceStore()); loader.setBaseDirectory(tempDir); assertEquals(tempDir, loader.getBaseDirectory()); assertEquals(mockStore, loader.getResourceStore()); }

Target:
public void testSetBaseDirectory() throws IOException { GeoServerResourceLoader loader = new GeoServerResourceLoader(); assertNull(loader.getBaseDirectory()); assertEquals(ResourceStore.EMPTY, loader.getResourceStore()); tempFolder.create(); File tempDir = tempFolder.getRoot(); loader.setBaseDirectory(tempDir); assertEquals(tempDir, loader.getBaseDirectory()); assertTrue(loader.getResourceStore() instanceof FileSystemResourceStore); ResourceStore mockStore = EasyMock.createMock(ResourceStore.class); loader = new GeoServerResourceLoader(mockStore); assertNull(loader.getBaseDirectory()); assertEquals(mockStore, loader.getResourceStore()); loader.setBaseDirectory(tempDir); assertEquals(tempDir, loader.getBaseDirectory()); assertEquals(mockStore, loader.getResourceStore()); }
Source:
public void close() throws IOException { if (pool != null) { pool.shutdown(); } if (restClient != null) { restClient.close(); } }

Target:
public void close() throws IOException { pool.shutdown(); restClient.close(); }
Source:
public void testGetServicesByName() throws Exception { final String name = "servicesByName"; Ignite g = randomGrid(); g.services().deployMultiple(name, new DummyService(), nodeCount() * 2, 3); AtomicInteger cnt = new AtomicInteger(0); for (int i = 0; i < nodeCount(); i++) { Collection<DummyService> svcs = grid(i).services().services(name); if (svcs != null) cnt.addAndGet(svcs.size()); } assertTrue(GridTestUtils.waitForCondition(() -> cnt.get() == nodeCount() * 2, 10000)); }

Target:
public void testGetServicesByName() { final String name = "servicesByName"; Ignite g = randomGrid(); g.services().deployMultiple(name, new DummyService(), nodeCount() * 2, 3); assertTrue(GridTestUtils.waitUntil(() -> { int cnt = IntStream.range(0, nodeCount()).parallel().map(i -> grid(i).services().services(name).size()).sum(); return cnt == nodeCount() * 2; }, 1000)); }
Source:
public void verifyArticleName(String targetText) { Assertion.assertStringContains(targetText, getArticleName()); PageObjectLogging.log("verifyArticleName", "verifying the article shows " + targetText, true); }

Target:
public void verifyArticleName(String targetText) { Assertion.assertStringContains(targetText, getArticleName()); PageObjectLogging.log( "verifyArticleName", "The article shows " + targetText, true ); }
Source:
public void run(final String... args) throws Exception { BugsnagAppender.getInstance().addCallback((report) -> { report.addToTab("diagnostics", "timestamp", new Date()); report.addToTab("customer", "name", "acme-inc"); report.addToTab("customer", "paying", true); report.addToTab("customer", "spent", 1234); report.setUserName("User Name"); report.setUserEmail("user@example.com"); report.setUserId("12345"); }); BugsnagAppender.addThreadMetaData("report", "application", "has started on this thread"); LOGGER.info("Sending a handled exception to Bugsnag"); try { throw new RuntimeException("Handled exception - default severity"); } catch (RuntimeException e) { LOGGER.warn(e.getMessage(), e); } LOGGER.info("Sending a handled exception to Bugsnag with INFO severity"); try { throw new RuntimeException("Handled exception - INFO severity"); } catch (RuntimeException e) { LOGGER.info(e.getMessage(), e); } LOGGER.info("Sending a handled exception to Bugsnag with custom MetaData"); try { throw new RuntimeException("Handled exception - custom metadata"); } catch (RuntimeException e) { BugsnagAppender.addReportMetaData("report", "something", "that happened"); BugsnagAppender.addReportMetaData("report", "something else", "that happened"); LOGGER.warn(e.getMessage(), e); } LOGGER.info("Sending an unhandled exception to Bugsnag"); Thread thread = new Thread() { @Override public void run() { throw new RuntimeException("Unhandled exception"); } }; thread.start(); thread.join(); BugsnagAppender.clearThreadMetaData(); SpringApplication.exit(applicationContext); }

Target:
public void run(final String... args) throws Exception { BugsnagAppender.getInstance().addCallback((report) -> { report.addToTab("diagnostics", "timestamp", new Date()); report.addToTab("customer", "name", "acme-inc"); report.addToTab("customer", "paying", true); report.addToTab("customer", "spent", 1234); report.setUserName("User Name"); report.setUserEmail("user@example.com"); report.setUserId("12345"); }); BugsnagAppender.addThreadMetaData("thread tab", "thread key 1", "thread value 1"); LOGGER.info("Sending a handled exception to Bugsnag"); try { throw new RuntimeException("Handled exception - default severity"); } catch (RuntimeException e) { LOGGER.warn(e.getMessage(), e); } LOGGER.info("Sending a handled exception to Bugsnag with INFO severity"); try { throw new RuntimeException("Handled exception - INFO severity"); } catch (RuntimeException e) { LOGGER.info(e.getMessage(), e); } LOGGER.info("Sending a handled exception to Bugsnag with custom MetaData"); try { throw new RuntimeException("Handled exception - custom metadata"); } catch (RuntimeException e) { LOGGER.warn("Something bad happened", new ExceptionWithCallback(e, report -> { report.addToTab("report tab", "data key 1", "data value 1"); report.addToTab("report tab", "data key 2", "data value 2"); })); } LOGGER.info("Sending an unhandled exception to Bugsnag"); Thread thread = new Thread() { @Override public void run() { throw new RuntimeException("Unhandled exception"); } }; thread.start(); thread.join(); BugsnagAppender.clearThreadMetaData(); SpringApplication.exit(applicationContext); }
Source:
public void checkFindReferencesFeature() { projectExplorer.openItemByPath(PROJECT_NAME + "/towers.go"); editor.waitActive(); editor.goToPosition(12, 1); menu.runCommand(ASSISTANT, FIND_REFERENCES); findReferencesConsoleTab.waitExpectedTextInLsPanel(REFERENCES_NOTJHING_TO_SHOW_TEXT); editor.goToPosition(19, 5); menu.runCommand(ASSISTANT, FIND_REFERENCES); try { findReferencesConsoleTab.waitAllReferencesWithText( "/desktop-go-simple/towers.go\n" + "From:23:71 To:23:76"); findReferencesConsoleTab.doubleClickOnReference("From:23:71 To:23:76"); } catch (TimeoutException ex) { fail( "Need to delete 'try/catch' and change values of the parameters, because the known issue <LINK_0> is resolved"); } editor.typeTextIntoEditor(ARROW_LEFT.toString()); editor.waitSpecifiedValueForLineAndChar(24, 72); editor.waitTextElementsActiveLine("count"); editor.goToPosition(19, 5); menu.runCommand(ASSISTANT, FIND_REFERENCES); try { findReferencesConsoleTab.waitAllReferencesWithText(REFERENCES_EXPECTED_TEXT); } catch (TimeoutException ex) { fail("Known permanent failure <LINK_0>", ex); } }

Target:
public void checkFindReferencesFeature() { projectExplorer.openItemByPath(PROJECT_NAME + "/towers.go"); editor.waitActive(); editor.goToPosition(12, 1); menu.runCommand(ASSISTANT, FIND_REFERENCES); findReferencesConsoleTab.waitExpectedTextInLsPanel(REFERENCES_NOTJHING_TO_SHOW_TEXT); editor.goToPosition(19, 5); menu.runCommand(ASSISTANT, FIND_REFERENCES); try { findReferencesConsoleTab.waitAllReferencesWithText( "/desktop-go-simple/towers.go\nFrom:23:71 To:23:76"); findReferencesConsoleTab.doubleClickOnReference("From:23:71 To:23:76"); } catch (TimeoutException ex) { fail( "Need to delete 'try/catch' and change values of the parameters, because the known issue <LINK_0> is resolved"); } editor.typeTextIntoEditor(ARROW_LEFT.toString()); editor.waitSpecifiedValueForLineAndChar(24, 72); editor.waitTextElementsActiveLine("count"); editor.goToPosition(19, 5); menu.runCommand(ASSISTANT, FIND_REFERENCES); try { findReferencesConsoleTab.waitAllReferencesWithText(REFERENCES_EXPECTED_TEXT); } catch (TimeoutException ex) { fail("Known permanent failure <LINK_0>", ex); } }
Source:
public void validate(Object target, Errors errors) { log.debug("{}.validate...", this.getClass().getName()); if (target == null) { return; } Person person = (Person) target; int index = 0; boolean atLeastOneNonVoidPersonNameLeft = false; for (PersonName personName : person.getNames()) { errors.pushNestedPath("names[" + index + "]"); personNameValidator.validate(personName, errors); if (!personName.getVoided()) { atLeastOneNonVoidPersonNameLeft = true; } errors.popNestedPath(); index++; } if (!person.getVoided() && !atLeastOneNonVoidPersonNameLeft) { errors.rejectValue("names", "Person.shouldHaveAtleastOneNonVoidedName"); } index = 0; for (PersonAddress address : person.getAddresses()) { try { errors.pushNestedPath("addresses[" + index + "]"); ValidationUtils.invokeValidator(personAddressValidator, address, errors); } finally { errors.popNestedPath(); index++; } } validateBirthDate(errors, person.getBirthdate()); validateDeathDate(errors, person.getDeathDate(), person.getBirthdate()); if (person.getVoided()) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "voidReason", "error.null"); } if (person.getDead()) { if(person.getCauseOfDeath() != null && person.getCauseOfDeathNonCoded() != null) { errors.rejectValue("causeOfDeath", "Person.shouldHaveOnlyOneCauseOfDeathOrCauseOfDeathNonCodedSet"); } else if(person.getCauseOfDeath() == null && person.getCauseOfDeathNonCoded() == null) { errors.rejectValue("causeOfDeath", "Person.dead.causeOfDeathNull"); } } ValidateUtil.validateFieldLengths(errors, Person.class, "gender", "personVoidReason"); }

Target:
public void validate(Object target, Errors errors) { log.debug("{}.validate...", this.getClass().getName()); if (target == null) { return; } Person person = (Person) target; int index = 0; boolean atLeastOneNonVoidPersonNameLeft = false; for (PersonName personName : person.getNames()) { errors.pushNestedPath("names[" + index + "]"); personNameValidator.validate(personName, errors); if (!personName.getVoided()) { atLeastOneNonVoidPersonNameLeft = true; } errors.popNestedPath(); index++; } if (!person.getVoided() && !atLeastOneNonVoidPersonNameLeft) { errors.rejectValue("names", "Person.shouldHaveAtleastOneNonVoidedName"); } index = 0; for (PersonAddress address : person.getAddresses()) { try { errors.pushNestedPath("addresses[" + index + "]"); ValidationUtils.invokeValidator(personAddressValidator, address, errors); } finally { errors.popNestedPath(); index++; } } validateBirthDate(errors, person.getBirthdate()); validateDeathDate(errors, person.getDeathDate(), person.getBirthdate()); if (person.getVoided()) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "voidReason", "error.null"); } if (person.getDead()) { if(person.getCauseOfDeath() != null && person.getCauseOfDeathNonCoded() != null) { errors.rejectValue("causeOfDeath", "Person.dead.shouldHaveOnlyOneCauseOfDeathOrCauseOfDeathNonCodedSet"); } else if(person.getCauseOfDeath() == null && person.getCauseOfDeathNonCoded() == null) { errors.rejectValue("causeOfDeath", "Person.dead.causeOfDeathAndCauseOfDeathNonCodedNull"); } } ValidateUtil.validateFieldLengths(errors, Person.class, "gender", "personVoidReason"); }
Source:
public AdvertisedSocketAddress[] resolveSrvRecord( String url ) throws NamingException { Attributes attrs = (_idc == null ? getIdc() : _idc).getAttributes( url, SRV_RECORDS ); NamingEnumeration<?> records = attrs.get( SRV_ATTR ).getAll(); List<AdvertisedSocketAddress> addresses = new ArrayList<>(); while ( records.hasMore() ) { SrvRecord record = SrvRecord.parse( (String) records.next() ); addresses.add( new AdvertisedSocketAddress( record.host, record.port ) ); } return addresses.toArray( new AdvertisedSocketAddress[addresses.size()] ); }

Target:
public Stream<SrvRecord> resolveSrvRecord( String url ) throws NamingException { Attributes attrs = _idc.orElseGet( this::setIdc ).getAttributes( url, SRV_RECORDS ); return enumerationAsStream( (NamingEnumeration<String>) attrs.get( SRV_ATTR ).getAll() ).map( SrvRecord::parse ); }
Source:
private void generateDoGetMethod(Parameter mainParameter, JavaTypeReference mainTypeReference) { String parameterName = javaNames.getJavaMemberStyleName(mainParameter.getName()); javaBuffer.addLine("default public %s doGet() {", mainTypeReference.getText()); javaBuffer.addLine(mainTypeReference.getText() + " " + parameterName + " = get();"); javaBuffer.addLine("follow(%s);", parameterName); javaBuffer.addLine("return %s;", parameterName); javaBuffer.addLine("}"); }

Target:
private void generateDoGetMethod(Parameter mainParameter, JavaTypeReference mainTypeReference) { String parameterName = javaNames.getJavaMemberStyleName(mainParameter.getName()); javaBuffer.addLine("default public %s doGet() {", mainTypeReference.getText()); javaBuffer.addLine("%s %s = get();", mainTypeReference.getText(), parameterName); javaBuffer.addLine("follow(%s);", parameterName); javaBuffer.addLine("return %s;", parameterName); javaBuffer.addLine("}"); }
Source:
public ValidationResult isVirtIoScsiValid(VM vm) { if (diskVmElement != null && DiskInterface.VirtIO_SCSI != diskVmElement.getDiskInterface()) { return ValidationResult.VALID; } if (disk.getSgio() != null && DiskStorageType.IMAGE == disk.getDiskStorageType()) { return new ValidationResult(EngineMessage.SCSI_GENERIC_IO_IS_NOT_SUPPORTED_FOR_IMAGE_DISK); } if (vm == null) { return ValidationResult.VALID; } if (!isVirtioScsiControllerAttached(vm)) { return new ValidationResult(EngineMessage.CANNOT_PERFORM_ACTION_VIRTIO_SCSI_IS_DISABLED); } return isDiskInterfaceSupported(vm); }

Target:
public ValidationResult isVirtIoScsiValid(VM vm) { if (vm == null) { return ValidationResult.VALID; } if (diskVmElement != null && DiskInterface.VirtIO_SCSI != diskVmElement.getDiskInterface()) { return ValidationResult.VALID; } if (disk.getSgio() != null && DiskStorageType.IMAGE == disk.getDiskStorageType()) { return new ValidationResult(EngineMessage.SCSI_GENERIC_IO_IS_NOT_SUPPORTED_FOR_IMAGE_DISK); } if (!isVirtioScsiControllerAttached(vm)) { return new ValidationResult(EngineMessage.CANNOT_PERFORM_ACTION_VIRTIO_SCSI_IS_DISABLED); } return isDiskInterfaceSupported(vm); }
Source:
public BigDecimal getBuyPrice(IEssentials ess, ItemStack itemStack) { BigDecimal result; String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); result = config.getBigDecimal("buy." + itemname + "." + itemStack.getDurability(), BigDecimal.ONE.negate()); if (result.signum() < 0) { final ConfigurationSection itemNameMatch = config.getConfigurationSection("buy." + itemname); if (itemNameMatch != null && itemNameMatch.getKeys(false).size() == 1) { result = config.getBigDecimal("buy." + itemname + ".0", BigDecimal.ONE.negate()); } } if (result.signum() < 0) { result = config.getBigDecimal("buy." + itemname + ".*", BigDecimal.ONE.negate()); } if (result.signum() < 0) { result = config.getBigDecimal("buy." + itemname, BigDecimal.ONE.negate()); } if (result.signum() < 0) { return getPrice(ess, itemStack); } return result; }

Target:
public BigDecimal getBuyPrice(IEssentials ess, ItemStack itemStack) { BigDecimal result = getPrice(ess, itemStack, "buy"); if (result.signum() < 0) { return getWorthPrice(ess, itemStack); } return result; }
Source:
public String toString() { StringBuilder sb = new StringBuilder("AwareNetworkRequestInformation: "); sb.append("state=").append(state).append(", role=").append(role).append( ", uid=").append(uid).append(", interfaceName=").append(interfaceName).append( ", pubSubId=").append(pubSubId).append(", peerDiscoveryMac=").append( peerDiscoveryMac == null ? "" : String.valueOf(HexEncoding.encode(peerDiscoveryMac))).append( ", pmk=").append(pmk).append(", ndpId=").append(ndpId).append( ", peerDataMac=").append( peerDataMac == null ? "" : String.valueOf(HexEncoding.encode(peerDataMac))); return sb.toString(); }

Target:
public String toString() { StringBuilder sb = new StringBuilder("AwareNetworkRequestInformation: "); sb.append("state=").append(state).append(", role=").append(role).append( ", uid=").append(uid).append(", interfaceName=").append(interfaceName).append( ", pubSubId=").append(pubSubId).append(", peerDiscoveryMac=").append( peerDiscoveryMac == null ? "" : String.valueOf(HexEncoding.encode(peerDiscoveryMac))).append( ", ndpId=").append(ndpId).append(", peerDataMac=").append( peerDataMac == null ? "" : String.valueOf(HexEncoding.encode(peerDataMac))); return sb.toString(); }
Source:
public void canCreateLock() { String rgName = generateRandomResourceName("rgloc", 15); String lockName = generateRandomResourceName("lock", 15); ResourceGroup resourceGroup = resourceClient.resourceGroups().define(rgName) .withRegion(Region.US_WEST) .create(); ManagementLock lock = resourceClient.managementLocks().define(lockName) .withLockedResourceGroup(resourceGroup) .withLevel(LockLevel.CAN_NOT_DELETE) .create(); Assertions.assertNotNull(lock); Assertions.assertEquals(resourceGroup.id(), lock.lockedResourceId()); try { resourceClient.resourceGroups().deleteByName(rgName); } catch (ManagementException ex) { Assertions.assertEquals("ScopeLocked", ex.getValue().getCode()); } resourceClient.managementLocks().deleteById(lock.id()); resourceClient.resourceGroups().deleteByName(rgName); }

Target:
public void canCreateLock() { String rgName = generateRandomResourceName("rgloc", 15); String lockName = generateRandomResourceName("lock", 15); ResourceGroup resourceGroup = resourceClient.resourceGroups().define(rgName) .withRegion(Region.US_WEST) .create(); ManagementLock lock = resourceClient.managementLocks().define(lockName) .withLockedResourceGroup(resourceGroup) .withLevel(LockLevel.CAN_NOT_DELETE) .create(); Assertions.assertNotNull(lock); Assertions.assertEquals(resourceGroup.id(), lock.lockedResourceId()); boolean failed = false; try { resourceClient.resourceGroups().deleteByName(rgName); } catch (ManagementException ex) { failed = true; Assertions.assertEquals("ScopeLocked", ex.getValue().getCode()); } Assertions.assertTrue(failed); resourceClient.managementLocks().deleteById(lock.id()); resourceClient.resourceGroups().deleteByName(rgName); }
Source:
public boolean matchesSafely(final Response item) { try { final String head = item.head().iterator().next(); final String[] parts = head.split(" "); return this.expected.matches(Integer.parseInt(parts[1])); } catch (final IOException exception) { throw new IllegalStateException(exception); } }

Target:
public boolean matchesSafely(final Response item) { try { final String head = item.head().iterator().next(); final String[] parts = head.split(" "); return this.matcher.matches(Integer.parseInt(parts[1])); } catch (final IOException ex) { throw new IllegalStateException(ex); } }
Source:
public void checkLaunchingCodeServer() throws Exception { ide.open(testWorkspace); String expectedTextOnCodeServerPage = "GWT Code Server\n" + "Drag these two bookmarklets to your browser's bookmark bar:\n" + "Dev Mode On Dev Mode Off\n" + "Visit a web page that uses one of these modules:\n" + "GWT\n" + "Click \"Dev Mode On\" to start development mode."; projectExplorer.waitItem(projectName); toastLoader.waitAppeareanceAndClosing(); projectExplorer.selectItem(projectName); projectExplorer.invokeCommandWithContextMenu(COMMON, projectName, BUILD_COMMAND); consoles.waitExpectedTextIntoConsole(BUILD_SUCCESS, 600); projectExplorer.invokeCommandWithContextMenu(COMMON, projectName, RUN_GWT_COMMAND); consoles.waitExpectedTextIntoConsole("The code server is ready", APPLICATION_START_TIMEOUT_SEC); String url = workspaceServiceClient .getServerFromDevMachineBySymbolicName(testWorkspace.getId(), "9876/tcp") .getUrl(); ide.driver().get(url); new WebDriverWait(ide.driver(), REDRAW_UI_ELEMENTS_TIMEOUT_SEC) .until( ExpectedConditions.textToBePresentInElementLocated( By.tagName("body"), expectedTextOnCodeServerPage)); }

Target:
public void checkLaunchingCodeServer() throws Exception { ide.open(testWorkspace); String expectedTextOnCodeServerPage = "GWT Code Server\n" + "Drag these two bookmarklets to your browser's bookmark bar:\n" + "Dev Mode On Dev Mode Off\n" + "Visit a web page that uses one of these modules:\n" + "GWT\n" + "Click \"Dev Mode On\" to start development mode."; projectExplorer.waitItem(projectName); toastLoader.waitAppeareanceAndClosing(); projectExplorer.selectItem(projectName); projectExplorer.invokeCommandWithContextMenu(COMMON, projectName, BUILD_COMMAND); consoles.waitExpectedTextIntoConsole(BUILD_SUCCESS, 600); projectExplorer.invokeCommandWithContextMenu(COMMON, projectName, RUN_GWT_COMMAND); consoles.waitExpectedTextIntoConsole("The code server is ready", APPLICATION_START_TIMEOUT_SEC); String url = workspaceServiceClient .getServerFromDevMachineBySymbolicName(testWorkspace.getId(), GWT_CODESERVER_NAME) .getUrl(); ide.driver().get(url); new WebDriverWait(ide.driver(), REDRAW_UI_ELEMENTS_TIMEOUT_SEC) .until( ExpectedConditions.textToBePresentInElementLocated( By.tagName("body"), expectedTextOnCodeServerPage)); }
Source:
public JComponent render(AnalyzerResultFuture<? extends AnalyzerResult> renderable) { final JXBusyLabel busyLabel = new JXBusyLabel(); busyLabel.setBusy(true); final DCPanel resultPanel = new DCPanel(); resultPanel.add(busyLabel); resultPanel.updateUI(); renderable.addListener(new AnalyzerResultFuture.Listener<AnalyzerResult>() { @Override public void onSuccess(AnalyzerResult result) { Renderer<? super AnalyzerResult, ? extends JComponent> renderer = _rendererFactory.getRenderer(result, SwingRenderingFormat.class); if (renderer != null) { JComponent jComponent = renderer.render(result); resultPanel.add(jComponent); } else { logger.error("No renderer found for: " + result); } resultPanel.remove(busyLabel); resultPanel.updateUI(); } @Override public void onError(RuntimeException error) { logger.error("Error occured while retrieving AnalyzerResult from AnalyzerResultFuture" + error); } }); return resultPanel; }

Target:
public JComponent render(AnalyzerResultFuture<? extends AnalyzerResult> renderable) { final LoadingIcon loadingIcon = new LoadingIcon(); final DCPanel resultPanel = new DCPanel(); resultPanel.add(loadingIcon); resultPanel.updateUI(); renderable.addListener(new AnalyzerResultFuture.Listener<AnalyzerResult>() { @Override public void onSuccess(AnalyzerResult result) { try { Renderer<? super AnalyzerResult, ? extends JComponent> renderer = _rendererFactory.getRenderer(result, SwingRenderingFormat.class); if (renderer != null) { logger.debug("renderer.render({})", result); final JComponent component = renderer.render(result); resultPanel.add(component); } else { final String message = "No renderer found for result type " + result.getClass().getName(); logger.error(message); throw new IllegalStateException(message); } } finally { resultPanel.remove(loadingIcon); resultPanel.updateUI(); } } @Override public void onError(RuntimeException error) { WidgetUtils.showErrorMessage("Unable to fetch result", error); } }); return resultPanel; }
Source:
private void discardWithTableHints() { if (readIf("WITH")) { read(OPEN_PAREN); if (!readIf(CLOSE_PAREN)) { do { discardTableHint(); } while (readIfMore(true)); } } }

Target:
private void discardWithTableHints() { if (readIf(WITH)) { read(OPEN_PAREN); do { discardTableHint(); } while (readIfMore(true)); } }
Source:
private final SuggestionMenu setupSuggestion() { SuggestionMenu suggestion = new SuggestionMenu(MAX_SUGGESTIONS).setActionHandler(this::menuItemHandler); suggestion.loadSuggestions(keywords); return suggestion; }

Target:
private SuggestionsMenu setupSuggestion() { SuggestionsMenu suggestion = new SuggestionsMenu(MAX_SUGGESTIONS).setActionHandler(this::menuItemHandler); suggestion.loadSuggestions(keywords); return suggestion; }
Source:
public Entity getMouseOverEntity() { return Minecraft.getMinecraft().objectMouseOver.entityHit; }

Target:
public Entity getMouseOverEntity() { RayTraceResult r = Minecraft.getMinecraft().objectMouseOver; if (r == null) return null; return r.entityHit; }
Source:
public void setSaveOffline(boolean saved) { if (pages.size() == 0) { emptyListSavePagesState = saved; return; } for (ReadingListPage page : pages) { page.savedOrSaving(saved); ReadingListPageDao.instance().upsert(page); } }

Target:
public void setSaveOffline(boolean saved) { if (pages.isEmpty()) { emptyListSavePagesState = saved; return; } for (ReadingListPage page : pages) { page.savedOrSaving(saved); ReadingListPageDao.instance().upsert(page); } }
Source:
private boolean isActionFilter(FilterSet filterSet) { boolean result = true; if (filterSet.getActionFilterOrder() == null) { result = false; } return result; }

Target:
private boolean isActionFilter(FilterSet filterSet) { return filterSet.getActionFilterOrder() != null; }
Source:
private Entity getDataPointAssignment(DatastoreService ds, long deviceId, long surveyAssignmentId, long surveyId) { try { Query.Filter f1 = new FilterPredicate("deviceId", FilterOperator.EQUAL, deviceId); Query.Filter f2 = new FilterPredicate("surveyAssignmentId", FilterOperator.EQUAL, surveyAssignmentId); Query.Filter f3 = new FilterPredicate("surveyId", FilterOperator.EQUAL, surveyId); Query q = new Query("DataPointAssignment"); q.setFilter(Query.CompositeFilterOperator.and(f1, f2, f3)); PreparedQuery pq = ds.prepare(q); return pq.asSingleEntity(); } catch (Exception e) { throw new Error("Error DataPointAssignment duplicated! deviceId: " + deviceId + " surveyAssignmentId: " + surveyAssignmentId + " surveyId: " + surveyId); } }

Target:
private Entity getDataPointAssignment(DatastoreService ds, long deviceId, long surveyAssignmentId, long surveyId) { Query.Filter f1 = new FilterPredicate("deviceId", FilterOperator.EQUAL, deviceId); Query.Filter f2 = new FilterPredicate("surveyAssignmentId", FilterOperator.EQUAL, surveyAssignmentId); Query.Filter f3 = new FilterPredicate("surveyId", FilterOperator.EQUAL, surveyId); Query q = new Query("DataPointAssignment"); q.setFilter(Query.CompositeFilterOperator.and(f1, f2, f3)); PreparedQuery pq = ds.prepare(q); return pq.asSingleEntity(); }
Source:
public CommandResult execute(CommandInvocation commandInvocation) throws IOException { if (help || arguments == null || arguments.isEmpty()) { commandInvocation.getShell().out().println(commandInvocation.getHelpInfo("rm")); return CommandResult.SUCCESS; } for (Resource r : arguments) { Resource currentWorkingDirectory = commandInvocation.getAeshContext().getCurrentWorkingDirectory(); Shell shell = commandInvocation.getShell(); Resource resource = r.resolve(currentWorkingDirectory).get(0); if (dir) { rmDir(resource, commandInvocation); } else { rmFile(resource, commandInvocation); } } return CommandResult.SUCCESS; }

Target:
public CommandResult execute(CommandInvocation commandInvocation) throws IOException, InterruptedException { if (help || arguments == null || arguments.isEmpty()) { commandInvocation.getShell().out().println(commandInvocation.getHelpInfo("rm")); return CommandResult.SUCCESS; } Resource currentWorkingDirectory = commandInvocation.getAeshContext().getCurrentWorkingDirectory(); for (Resource r : arguments) { Shell shell = commandInvocation.getShell(); Resource resource = r.resolve(currentWorkingDirectory).get(0); if (dir) { rmDir(resource, commandInvocation); } else { rmFile(resource, commandInvocation); } } return CommandResult.SUCCESS; }
Source:
public boolean accept(String dimVal) { if (dimVal == null) { return false; } final String input = caseSensitive ? dimVal : dimVal.toLowerCase(); return input.contains(target); }

Target:
public boolean accept(String dimVal) { if (dimVal == null || value == null) { return false; } if (caseSensitive) { return dimVal.contains(value); } return org.apache.commons.lang.StringUtils.containsIgnoreCase(dimVal, value); }
Source:
public void testMoreOptionsDiscardImage() { onDrawingSurfaceView() .perform(touchAt(DrawingSurfaceLocationProvider.MIDDLE)); onDrawingSurfaceView() .checkPixelColor(Color.BLACK, BitmapLocationProvider.MIDDLE); onTopBarView() .onMoreOptionsClicked(); onView(withText(R.string.menu_discard_image)) .perform(click()); onDrawingSurfaceView() .checkPixelColor(Color.TRANSPARENT, BitmapLocationProvider.MIDDLE); }

Target:
public void testMoreOptionsDiscardImage() { onDrawingSurfaceView() .perform(touchAt(DrawingSurfaceLocationProvider.MIDDLE)); onDrawingSurfaceView() .checkPixelColor(Color.BLACK, BitmapLocationProvider.MIDDLE); onTopBarView() .performOpenMoreOptions(); onView(withText(R.string.menu_discard_image)) .perform(click()); onDrawingSurfaceView() .checkPixelColor(Color.TRANSPARENT, BitmapLocationProvider.MIDDLE); }
Source:
protected void initVm() { if (!isInitVmRequired()) { return; } fetchVmDisksFromDb(); updateVmDevicesOnRun(); updateGraphicsAndDisplayInfos(); getVm().setRunAndPause(getParameters().getRunAndPause() == null ? getVm().isRunAndPause() : getParameters().getRunAndPause()); getVm().setConsoleUserId(null); updateVmInit(); if (!StringUtils.isEmpty(getParameters().getFloppyPath()) && isPayloadExists(VmDeviceType.FLOPPY)) { vmPayload = null; } updateVmGuestAgentVersion(); if (!getVm().isUsingCpuPassthrough() && getVm().getCpuName() == null) { if (getVm().getCustomCpuName() != null) { getVm().setCpuName(getVm().getCustomCpuName()); } else { getVm().setCpuName(getCluster().getCpuVerb()); } } if (getVm().getEmulatedMachine() == null) { getVm().setEmulatedMachine(getEffectiveEmulatedMachine()); } }

Target:
protected void initVm() { if (!isInitVmRequired()) { return; } fetchVmDisksFromDb(); updateVmDevicesOnRun(); updateGraphicsAndDisplayInfos(); getVm().setRunAndPause(getParameters().getRunAndPause() == null ? getVm().isRunAndPause() : getParameters().getRunAndPause()); getVm().setConsoleUserId(null); updateVmInit(); if (!StringUtils.isEmpty(getParameters().getFloppyPath()) && isPayloadExists(VmDeviceType.FLOPPY)) { vmPayload = null; } updateVmGuestAgentVersion(); if (!getVm().isUsingCpuPassthrough() && getVm().getCpuName() == null) { if (getVm().getCustomCpuName() != null) { getVm().setCpuName(getVm().getCustomCpuName()); } else { if (getCluster().getCompatibilityVersion().equals(getVm().getCompatibilityVersion())) { getVm().setCpuName(getCluster().getCpuVerb()); } else { getVm().setCpuName(getCpuFlagsManagerHandler().getCpuId( getVm().getClusterCpuName(), getVm().getCompatibilityVersion())); } } } if (getVm().getEmulatedMachine() == null) { getVm().setEmulatedMachine(getEffectiveEmulatedMachine()); } }
Source:
public static Algorithm getAlgorithmNamed(BasicFBType basicFBType, String name) { for(Algorithm alg : basicFBType.getAlgorithm()) { if(alg.getName().equals(name)) { return alg; } } return null; }

Target:
public static Algorithm getAlgorithmNamed(BasicFBType basicFBType, String name) { return basicFBType.getAlgorithm().stream().filter(alg -> alg.getName().equals(name)).findFirst().orElse(null); }
Source:
public EventHubMessage receive() { logger.debug("Retrieving messages for partition: " + partitionId); int countToRetrieve = pending.size() - config.getMaxPendingMsgsPerPartition(); if (countToRetrieve >= 0) { Log.debug("Pending queue has more than " + config.getMaxPendingMsgsPerPartition() + " messages. No new events will be retrieved from EventHub."); return null; } EventHubMessage ehm = null; if (!toResend.isEmpty()) { ehm = toResend.pollFirst(); } else { if (waitingToEmit.isEmpty()) { fill(); } ehm = waitingToEmit.pollFirst(); } if (ehm == null) { logger.debug("No messages pending or waiting for reprocessing."); return null; } lastOffset = ehm.getOffset(); pending.put(lastOffset, ehm); return ehm; }

Target:
public EventHubMessage receive() { logger.debug("Retrieving messages for partition: " + this.partitionPath); if (pendingAcks.size() >= config.getMaxPendingMsgsPerPartition()) { logger.debug(String.format( "Pending queue full(%s) - no new events will be received from EventHub Partition: %s.", config.getMaxPendingMsgsPerPartition(), this.partitionPath)); return null; } final EventHubMessage ehm; if (!failed.isEmpty()) { ehm = failed.pollFirst(); } else { final Iterable<EventData> events = this.receiver.receive(1); ehm = (events == null || !events.iterator().hasNext()) ? null : new EventHubMessage(events.iterator().next(), this.partitionId); } if (ehm == null) { logger.debug( String.format("No messages available from EventHubPartition: %s, or waiting for reprocessing.", this.partitionPath)); return null; } this.firstEventTracker.set(ehm); pendingAcks.put(ehm.getOffset(), ehm); return ehm; }