auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private void indexDown(File dir, String parent, IndexDownArgs args) throws IOException { if (isInterrupted()) { return; } if (!accept(dir)) { return; } File[] files = dir.listFiles(); if (files == null) { LOGGER.log(Level.SEVERE, "Failed to get file listing for: {0}", dir.getPath()); return; } Arrays.sort(files, FILENAME_COMPARATOR); for (File file : files) { if (accept(dir, file)) { String path = parent + '/' + file.getName(); if (file.isDirectory()) { indexDown(file, path, args); } else { args.cur_count++; if (args.count_only) continue; if (uidIter != null) { String uid = Util.path2uid(path, DateTools.timeToString(file.lastModified(), DateTools.Resolution.MILLISECOND)); BytesRef buid = new BytesRef(uid); while (uidIter != null && uidIter.term() != null && uidIter.term().compareTo(emptyBR) != 0 && uidIter.term().compareTo(buid) < 0) { String termPath = Util.uid2url(uidIter.term().utf8ToString()); removeFile(!termPath.equals(path)); BytesRef next = uidIter.next(); if (next == null) { uidIter = null; } } if (uidIter != null && uidIter.term() != null && uidIter.term().bytesEquals(buid)) { boolean chkres = chkFields(file, path); if (!chkres) removeFile(false); BytesRef next = uidIter.next(); if (next == null) uidIter = null; if (chkres) continue; } } args.works.add(new IndexFileWork(file, path)); } } } }

Target:
private void indexDown(File dir, String parent, IndexDownArgs args) throws IOException { if (isInterrupted()) { return; } if (!accept(dir)) { return; } File[] files = dir.listFiles(); if (files == null) { LOGGER.log(Level.SEVERE, "Failed to get file listing for: {0}", dir.getPath()); return; } Arrays.sort(files, FILENAME_COMPARATOR); for (File file : files) { if (accept(dir, file)) { String path = parent + '/' + file.getName(); if (file.isDirectory()) { indexDown(file, path, args); } else { args.cur_count++; if (args.count_only) continue; if (uidIter != null) { String uid = Util.path2uid(path, DateTools.timeToString(file.lastModified(), DateTools.Resolution.MILLISECOND)); BytesRef buid = new BytesRef(uid); while (uidIter != null && uidIter.term() != null && uidIter.term().compareTo(emptyBR) != 0 && uidIter.term().compareTo(buid) < 0) { String termPath = Util.uid2url(uidIter.term().utf8ToString()); removeFile(!termPath.equals(path)); BytesRef next = uidIter.next(); if (next == null) { uidIter = null; } } if (uidIter != null && uidIter.term() != null && uidIter.term().bytesEquals(buid)) { boolean chkres = chkSettings(path); if (!chkres) { removeFile(false); } BytesRef next = uidIter.next(); if (next == null) { uidIter = null; } if (chkres) { continue; } } } args.works.add(new IndexFileWork(file, path)); } } } }
Source:
public List<ActivityDetails> metadataForApiKeys(@RequestParam final Long start, @RequestParam final Long end) throws JsonParseException, IOException, ValidationException { Date startDate = new Date(start); Date endDate = new Date(end); validateActivityDatesAndDateRange(start, end); return activityManager.getApiKeyActivity(startDate, endDate); }

Target:
public List<ActivityMetadata> metadataForApiKeys(@RequestParam final Long start, @RequestParam final Long end) throws JsonParseException, IOException, ValidationException { Date startDate = new Date(start); Date endDate = new Date(end); validateActivityDatesAndDateRange(start, end); return activityMetadataManager.getApiKeyManagementMetadata(startDate, endDate); }
Source:
protected Control createControl(Composite parent) { CTConfiguration config = new CTConfiguration(parent, CTConfiguration.STYLE_TABLE); config.setHorizontalAlignment(SWT.CENTER); config.setCellSelectionEnabled(false); config.setColumnSelectionEnabled(false); config.setRowSelectionEnabled(false); config.setColumnHeaderLayout(CTConfiguration.COLUMN_HEADER_LAYOUT_FILL_EQUAL); config.setRowHeaderLayout(CTConfiguration.ROW_HEADER_LAYOUT_DEFAULT); this.table = new ComponentTable(parent, SWT.FULL_SELECTION, config); return this.table.getControl(); }

Target:
protected Control createControl(Composite parent) { CTConfiguration config = new CTConfiguration(parent, CTConfiguration.STYLE_TABLE); config.setHorizontalAlignment(SWT.CENTER); config.setCellSelectionEnabled(false); config.setColumnSelectionEnabled(false); config.setRowSelectionEnabled(false); config.setColumnHeaderLayout(CTConfiguration.COLUMN_HEADER_LAYOUT_FILL_EQUAL); config.setRowHeaderLayout(CTConfiguration.ROW_HEADER_LAYOUT_DEFAULT); this.table = new ComponentTable(parent, SWT.NONE, config); return this.table.getControl(); }
Source:
private static List<File> listFiles(File dir) { if ((dir != null) && dir.isDirectory()) { File[] files = dir.listFiles(); if (files != null) { return ImmutableList.copyOf(files); } } return ImmutableList.of(); }

Target:
private static List<File> listFiles(File dir) { if (dir != null && dir.isDirectory()) { File[] files = dir.listFiles(); if (files != null) { return ImmutableList.copyOf(files); } } return ImmutableList.of(); }
Source:
public void sessionClosed(IoSession session) throws Exception { TcpipClientChannel channel = (TcpipClientChannel) session.removeAttribute(TcpipClientChannel.class); Throwable cause = (Throwable) session.removeAttribute(TcpipForwardingExceptionMarker.class); if (channel != null) { if (debugEnabled) { log.debug("sessionClosed({}) closing channel={} after messages - cause={}", session, channel, messagesCounter, (cause == null) ? null : cause.getClass().getSimpleName()); } if (cause != null) { channel.close(true); } else { OpenFuture openFuture = channel.getOpenFuture(); if (!openFuture.isDone()) { openFuture.addListener(f -> { channel.close(false); }); } else { channel.close(false); } } } }

Target:
public void sessionClosed(IoSession session) throws Exception { TcpipClientChannel channel = (TcpipClientChannel) session.removeAttribute(TcpipClientChannel.class); Throwable cause = (Throwable) session.removeAttribute(TcpipForwardingExceptionMarker.class); if (debugEnabled) { log.debug("sessionClosed({}) closing channel={} after messages - cause={}", session, channel, messagesCounter, (cause == null) ? null : cause.getClass().getSimpleName()); } if (channel == null) { return; } if (cause != null) { channel.close(true); } else { OpenFuture f = channel.getOpenFuture(); Throwable err = f.getException(); boolean immediatly = err != null; if (immediatly) { channel.close(immediatly); } else { ClientChannelPendingMessagesQueue queue = channel.getPendingMessagesQueue(); queue.getCompletedFuture().addListener(l -> { channel.close(immediatly); }); } } }
Source:
public void createFromCopy() throws ConflictException, IOException { MutableDocumentRevision update = saved.mutableCopy(); update.body = bodyTwo; update.docId = "copy"; String attachmentName = "bonsai-boston.jpg"; File f = new File("fixture", attachmentName); Attachment att = new UnsavedFileAttachment(f, "image/jpeg"); update.attachments.put(attachmentName, att); DocumentRevision updated = datastore.createDocumentFromRevision(update); Assert.assertNotNull("Updated document is null", updated); DocumentRevision retrieved = datastore.getDocument(update.docId); Assert.assertNotNull("Retrieved document is null", retrieved); Attachment retrievedAtt = datastore.getAttachment(updated, attachmentName); Assert.assertNotNull("Retrieved attachment 1 is null", retrievedAtt); Attachment retrievedAtt2 = datastore.getAttachment(updated, initialAtt1); Assert.assertNotNull("Retrieved attachment 2 is null", retrievedAtt2); Attachment retrievedAtt3 = datastore.getAttachment(updated, initialAtt2); Assert.assertNotNull("Retrieved attachment 3 is null", retrievedAtt3); Assert.assertEquals("Revision should have 2 attachments", 3, saved.getAttachments().size()); Assert.assertNotNull("Document attachment 1 is null", saved.getAttachments().get(initialAtt1)); Assert.assertNotNull("Document attachment 2 is null", saved.getAttachments().get(initialAtt2)); Assert.assertNotNull("Document attachment 2 is null", saved.getAttachments().get(attachmentName)); }

Target:
public void createFromCopy() throws ConflictException, IOException { MutableDocumentRevision update = saved.mutableCopy(); update.body = bodyTwo; update.docId = "copy"; String attachmentName = "bonsai-boston.jpg"; File f = new File("fixture", attachmentName); Attachment att = new UnsavedFileAttachment(f, "image/jpeg"); update.attachments.put(attachmentName, att); BasicDocumentRevision updated = datastore.createDocumentFromRevision(update); Assert.assertNotNull("Updated document is null", updated); BasicDocumentRevision retrieved = datastore.getDocument(update.docId); Assert.assertNotNull("Retrieved document is null", retrieved); Attachment retrievedAtt = datastore.getAttachment(updated, attachmentName); Assert.assertNotNull("Retrieved attachment 1 is null", retrievedAtt); Attachment retrievedAtt2 = datastore.getAttachment(updated, initialAtt1); Assert.assertNotNull("Retrieved attachment 2 is null", retrievedAtt2); Attachment retrievedAtt3 = datastore.getAttachment(updated, initialAtt2); Assert.assertNotNull("Retrieved attachment 3 is null", retrievedAtt3); Assert.assertEquals("Revision should have 2 attachments", 3, saved.getAttachments().size()); Assert.assertNotNull("Document attachment 1 is null", saved.getAttachments().get(initialAtt1)); Assert.assertNotNull("Document attachment 2 is null", saved.getAttachments().get(initialAtt2)); Assert.assertNotNull("Document attachment 2 is null", saved.getAttachments().get(attachmentName)); }
Source:
private Unit(String symbol) { this.symbol = symbol; }

Target:
Unit(String symbol) { this.symbol = symbol; }
Source:
public void addCandidateUsers(CandidateUsersPayload candidateUsersPayload) { Task task; try { task = task(candidateUsersPayload.getTaskId()); } catch (IllegalStateException ex) { throw new IllegalStateException("The authenticated user cannot update the task" + candidateUsersPayload.getTaskId() + " due it is not the current assignee"); } if (candidateUsersPayload.getCandidateUsers() != null && !candidateUsersPayload.getCandidateUsers().isEmpty()) { for (String u : candidateUsersPayload.getCandidateUsers()) { taskService.addCandidateUser(task.getId(), u); } } }

Target:
public void addCandidateUsers(CandidateUsersPayload candidateUsersPayload) { if (candidateUsersPayload.getCandidateUsers() != null && !candidateUsersPayload.getCandidateUsers().isEmpty()) { for (String u : candidateUsersPayload.getCandidateUsers()) { taskService.addCandidateUser(candidateUsersPayload.getTaskId(), u); } } }
Source:
public static void Init() { mUpdateVmTemplate = new ObjectIdentityChecker(VmTemplateHandler.class); BlankVmTemplateId = new Guid("00000000-0000-0000-0000-000000000000"); mUpdateVmTemplate.AddPermittedFields(new String[] { "name", "description", "domain", "os", "osType", "autoSuspend", "interfaces", "memSizeMb", "numOfSockets", "cpuPerSocket", "vdsGroupId", "numOfMonitors", "allowConsoleReconnect", "usbPolicy", "timeZone", "diskMap", "defaultBootSequence", "disabled", "isoPath", "diskImageMap", "defaultDisplayType", "priority", "autoStartup", "stateless", "initrdUrl", "kernelUrl", "kernelParams", "images", "interfaces", "quotaId", "quotaName", "quotaEnforcementType", "migrationSupport", "dedicatedVmForVds", "smartcardEnabled","dbGeneration", "deleteProtected", "quotaDefault", "vncKeyboardLayout", }); }

Target:
public static void Init() { mUpdateVmTemplate = new ObjectIdentityChecker(VmTemplateHandler.class); BlankVmTemplateId = new Guid("00000000-0000-0000-0000-000000000000"); mUpdateVmTemplate.AddPermittedFields(new String[] { "name", "description", "domain", "os", "osType", "autoSuspend", "interfaces", "memSizeMb", "numOfSockets", "cpuPerSocket", "vdsGroupId", "numOfMonitors", "allowConsoleReconnect", "usbPolicy", "timeZone", "diskMap", "defaultBootSequence", "disabled", "isoPath", "diskImageMap", "defaultDisplayType", "priority", "autoStartup", "stateless", "initrdUrl", "kernelUrl", "kernelParams", "images", "interfaces", "quotaId", "quotaName", "quotaEnforcementType", "migrationSupport", "dedicatedVmForVds", "smartcardEnabled","dbGeneration", "deleteProtected", "quotaDefault", "tunnelMigration", "vncKeyboardLayout" }); }
Source:
public String getInstallationID() { return thingIfApi.getInstallationID(); }

Target:
public String getInstallationID() { return this.thingIfApi.getInstallationID(); }
Source:
CacheStorageImpl(){ queryStateMap = new HashMap<>(); }

Target:
CacheStorageImpl(){ queryStateMap = new ConcurrentHashMap<>(); }
Source:
public void intersect_shouldNotContainDuplicatePatientIDs() throws Exception { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date startDate = dateFormat.parse("2017-01-01 00:00:00"); Date startDate2 = dateFormat.parse("20017-02-15 00:00:00"); Cohort cohortA = new Cohort(3); Cohort cohortB = new Cohort (4); CohortMembership membershipAOne = new CohortMembership(7, startDate); CohortMembership membershipATwo = new CohortMembership(7, startDate2); CohortMembership membershipBOne = new CohortMembership(7, startDate); CohortMembership membershipBTwo = new CohortMembership(7, startDate2); cohortA.addMembership(membershipAOne); cohortA.addMembership(membershipATwo); cohortB.addMembership(membershipBOne); cohortB.addMembership(membershipBTwo); Cohort cohortIntersect = Cohort.intersect(cohortA,cohortB); cohortIntersect.getMemberships().forEach(m -> { assertTrue(m.getPatientId().equals(7)); assertNull(m.getStartDate()); }); assertEquals(1, cohortIntersect.getMemberships().size()); }

Target:
public void intersect_shouldNotContainDuplicatePatientIDs() throws Exception { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date startDate = dateFormat.parse("2017-01-01 00:00:00"); Date startDate2 = dateFormat.parse("20017-02-15 00:00:00"); Date endDate = dateFormat.parse("2017-01-15 00:00:00"); Date endDate2 = dateFormat.parse("2017-02-20 00:00:00"); Cohort cohortA = new Cohort(3); Cohort cohortB = new Cohort (4); CohortMembership membershipAOne = new CohortMembership(7, startDate); membershipAOne.setEndDate(endDate); CohortMembership membershipATwo = new CohortMembership(7, startDate2); membershipATwo.setEndDate(endDate2); CohortMembership membershipBOne = new CohortMembership(7, startDate); membershipBOne.setEndDate(endDate); CohortMembership membershipBTwo = new CohortMembership(7, startDate2); membershipBTwo.setEndDate(endDate2); cohortA.addMembership(membershipAOne); cohortA.addMembership(membershipATwo); cohortB.addMembership(membershipBOne); cohortB.addMembership(membershipBTwo); Cohort cohortIntersect = Cohort.intersect(cohortA,cohortB); cohortIntersect.getMemberships().forEach(m -> { assertTrue(m.getPatientId().equals(7)); assertNull(m.getStartDate()); }); assertEquals(1, cohortIntersect.getMemberships().size()); }
Source:
protected void label(Namespace namespace, Map<String, String> ensureLabels) throws InfrastructureException { Map<String, String> currentLabels = namespace.getMetadata().getLabels(); Map<String, String> newLabels = currentLabels != null ? new HashMap<>(currentLabels) : new HashMap<>(); if (newLabels.entrySet().containsAll(ensureLabels.entrySet())) { LOG.debug( "Nothing to do, namespace already has all required labels.", namespace.getMetadata().getName()); return; } newLabels.putAll(ensureLabels); namespace.getMetadata().setLabels(newLabels); try { cheClientFactory.create().namespaces().createOrReplace(namespace); } catch (KubernetesClientException kce) { if (kce.getCode() == 403) { LOG.debug("Can't label the namespace due to lack of permissions ¯\\_(ツ)_/¯"); return; } throw new InfrastructureException(kce); } }

Target:
protected void label(Namespace namespace, Map<String, String> ensureLabels) throws InfrastructureException { Map<String, String> currentLabels = namespace.getMetadata().getLabels(); Map<String, String> newLabels = currentLabels != null ? new HashMap<>(currentLabels) : new HashMap<>(); if (newLabels.entrySet().containsAll(ensureLabels.entrySet())) { LOG.debug( "Nothing to do, namespace already has all required labels.", namespace.getMetadata().getName()); return; } try { cheSAClientFactory .create() .namespaces() .createOrReplace( new NamespaceBuilder(namespace) .editMetadata() .addToLabels(ensureLabels) .endMetadata() .build()); } catch (KubernetesClientException kce) { if (kce.getCode() == 403) { LOG.debug("Can't label the namespace due to lack of permissions ¯\\_(ツ)_/¯"); return; } throw new InfrastructureException(kce); } }
Source:
synchronized TaskStatesPage getTaskPaginated(JobId jobId, int offset, int limit) throws UnknownJobException, NotConnectedException, PermissionException { checkPermissions("getTaskPaginated", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_STATE_OF_THIS_JOB); ClientJobState jobState = jobsMap.get(jobId); synchronized (jobState) { try { final TaskStatesPage tasksPaginated = jobState.getTasksPaginated(offset, limit); final List<TaskState> taskStatesCopy = (List<TaskState>) ProActiveMakeDeepCopy.WithProActiveObjectStream.makeDeepCopy(new ArrayList<>(tasksPaginated.getTaskStates())); return new TaskStatesPage(taskStatesCopy, tasksPaginated.getSize()); } catch (Exception e) { logger.error("Error when copying tasks page", e); throw new IllegalStateException(e); } } }

Target:
synchronized TaskStatesPage getTaskPaginated(JobId jobId, int offset, int limit) throws UnknownJobException, NotConnectedException, PermissionException { checkPermissions("getJobState", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_STATE_OF_THIS_JOB); ClientJobState jobState = jobsMap.get(jobId); synchronized (jobState) { try { final TaskStatesPage tasksPaginated = jobState.getTasksPaginated(offset, limit); final List<TaskState> taskStatesCopy = (List<TaskState>) ProActiveMakeDeepCopy.WithProActiveObjectStream.makeDeepCopy(new ArrayList<>(tasksPaginated.getTaskStates())); return new TaskStatesPage(taskStatesCopy, tasksPaginated.getSize()); } catch (Exception e) { logger.error("Error when copying tasks page", e); throw new IllegalStateException(e); } } }
Source:
public CRAMFileReader(final File cramFile, final File indexFile, final CRAMReferenceSource referenceSource, final ValidationStringency validationStringency) throws IOException { this(new FileInputStream(cramFile), wrapIndexFile(cramFile, indexFile), referenceSource, validationStringency); this.cramFile = cramFile; initIndexFile(indexFile); }

Target:
public CRAMFileReader(final File cramFile, final File indexFile, final CRAMReferenceSource referenceSource, final ValidationStringency validationStringency) throws IOException { if (cramFile == null) { throw new IllegalArgumentException("Input file can not be null for CRAM reader"); } if (referenceSource == null) { throw new IllegalArgumentException("A reference is required for CRAM readers"); } this.cramFile = cramFile; this.referenceSource = referenceSource; this.mIndexFile = findIndexForFile(indexFile, cramFile); final SeekableFileStream indexStream = this.mIndexFile == null ? null : new SeekableFileStream(this.mIndexFile); initWithStreams(new FileInputStream(cramFile), indexStream, validationStringency); }
Source:
public List<DCInputSet> getInputsBySubmissionName(String name) throws DCInputsReaderException { SubmissionConfig config; try { config = new SubmissionConfigReader().getSubmissionConfigByName(name); String formName = config.getSubmissionName(); if (formName == null) { throw new DCInputsReaderException("No form designated as default"); } List<DCInputSet> results = new ArrayList<DCInputSet>(); for (int idx = 0; idx < config.getNumberOfSteps(); idx++) { SubmissionStepConfig step = config.getStep(idx); if(SubmissionStepConfig.INPUT_FORM_STEP_NAME.equals(step.getType())) { results.add(getInputsByFormName(step.getId())); } } return results; } catch (ServletException e) { throw new DCInputsReaderException("No form designated as default"); } }

Target:
public List<DCInputSet> getInputsBySubmissionName(String name) throws DCInputsReaderException { SubmissionConfig config; try { config = new SubmissionConfigReader().getSubmissionConfigByName(name); String formName = config.getSubmissionName(); if (formName == null) { throw new DCInputsReaderException("No form designated as default"); } List<DCInputSet> results = new ArrayList<DCInputSet>(); for (int idx = 0; idx < config.getNumberOfSteps(); idx++) { SubmissionStepConfig step = config.getStep(idx); if(SubmissionStepConfig.INPUT_FORM_STEP_NAME.equals(step.getType())) { results.add(getInputsByFormName(step.getId())); } } return results; } catch (SubmissionConfigReaderException e) { throw new DCInputsReaderException("No form designated as default", e); } }
Source:
private static boolean isPrimitiveType(Type type) { return (type instanceof Class) && ((Class)type).isPrimitive(); }

Target:
private static boolean isPrimitiveType(Type type) { return type instanceof Class<?> && ((Class<?>)type).isPrimitive(); }
Source:
public void testAndNameEquals() throws Exception { ReadableBranch branch = setupNameEqualsArtifacts(); QueryBuilder builder = factory.fromBranch(branch); builder.andNameEquals("Folder"); ResultSet<ArtifactReadable> artifacts = builder.getResults(); assertEquals(1, artifacts.size()); assertEquals("Folder", artifacts.getExactlyOne().getName()); }

Target:
public void testAndNameEquals() throws Exception { ReadableBranch branch = setupNameEqualsArtifacts(); try { QueryBuilder builder = factory.fromBranch(branch); builder.andNameEquals("Folder"); ResultSet<ArtifactReadable> artifacts = builder.getResults(); assertEquals(1, artifacts.size()); assertEquals("Folder", artifacts.getExactlyOne().getName()); } finally { branchApi.purgeBranch(branch, true).call(); } }
Source:
private Map<String, String> getNameMap(Node name) { Map<String, String> nameMap = new HashMap<>(); String thisDisplay = null; String thisFirstName = null; String thisSurname = null; String title = null; Node firstNameNode = name .selectSingleNode("eac:part[(@localType=\"forename\") " + "or (@localType=\"givenname\")]"); if (Objects.nonNull(firstNameNode)) { thisFirstName = firstNameNode.getText(); } Node surnameNode = name .selectSingleNode("eac:part[(@localType=\"surname\") " + "or (@localType=\"familyname\")]"); if (Objects.nonNull(surnameNode)) { thisSurname = surnameNode.getText(); } Node titleNode = name.selectSingleNode("eac:part[@localType=\"title\"]"); if (Objects.nonNull(titleNode)) { title = titleNode.getText(); } if (Objects.nonNull(thisSurname)) { thisDisplay = thisSurname; nameMap.put("surname", thisSurname); if (thisFirstName != null) { thisDisplay += ", " + thisFirstName; nameMap.put("firstName", thisFirstName); } if (title != null) { thisDisplay += " (" + title + ")"; } nameMap.put("displayName", thisDisplay); } if (Objects.isNull(thisDisplay)) { @SuppressWarnings("unchecked") List<Node> parts = name.selectNodes("eac:part"); for (Node part : parts) { String value = getValueFromPart((Element) part); if (Objects.isNull(thisDisplay)) { thisDisplay = value; } else { thisDisplay += ", " + value; } } nameMap.put("displayName", thisDisplay); } return nameMap; }

Target:
private Map<String, String> getNameMap(Node name) { Map<String, String> nameMap = new HashMap<>(); String thisDisplay = null; String thisFirstName = null; String thisSurname = null; String title = null; Node firstNameNode = name .selectSingleNode("eac:part[(@localType=\"forename\") " + "or (@localType=\"givenname\")]"); if (Objects.nonNull(firstNameNode)) { thisFirstName = firstNameNode.getText(); } Node surnameNode = name .selectSingleNode("eac:part[(@localType=\"surname\") " + "or (@localType=\"familyname\")]"); if (Objects.nonNull(surnameNode)) { thisSurname = surnameNode.getText(); } Node titleNode = name.selectSingleNode("eac:part[@localType=\"title\"]"); if (Objects.nonNull(titleNode)) { title = titleNode.getText(); } if (Objects.nonNull(thisSurname)) { thisDisplay = thisSurname; nameMap.put("surname", thisSurname); if (Objects.nonNull(thisFirstName)) { thisDisplay += ", " + thisFirstName; nameMap.put("firstName", thisFirstName); } if (Objects.nonNull(title)) { thisDisplay += " (" + title + ")"; } nameMap.put("displayName", thisDisplay); } if (Objects.isNull(thisDisplay)) { @SuppressWarnings("unchecked") List<Node> parts = name.selectNodes("eac:part"); for (Node part : parts) { String value = getValueFromPart((Element) part); if (Objects.isNull(thisDisplay)) { thisDisplay = value; } else { thisDisplay += ", " + value; } } nameMap.put("displayName", thisDisplay); } return nameMap; }
Source:
public void testDisabledRelativeParsingLinksWithName() { parser.setMarkupLanguage(new ConfluenceLanguage(false)); String html = parser.parseToHtml("[abc|Title]"); TestUtil.println("HTML:" + html); assertTrue(Pattern.compile("<body><p>\\[abc|Title\\]</p></body>", Pattern.MULTILINE).matcher(html).find()); }

Target:
public void testDisabledRelativeParsingLinksWithName() { setupLanguageWithRelativeLinksDisabled(); assertMarkup("<p>[abc|Title]</p>", "[abc|Title]"); }
Source:
public void connectServers(final AbstractServerWebSocketHandler serv) { LOG.info("Open Login..,"); LOG.info("Is Connection Local? {}", isConnectionLocal()); LOG.info("Is Secure? {}", isSecure()); try { createAndAddConnection(serv, isConnectionLocal(), "srl02.tamu.edu", LOGIN_PORT, isSecure(), LoginClientWebSocket.class); } catch (ConnectionException e) { LOG.info(LoggingConstants.EXCEPTION_MESSAGE, e); } LOG.info("Open Data..."); try { createAndAddConnection(serv, isConnectionLocal(), "srl04.tamu.edu", DATABASE_PORT, isSecure(), DataClientWebSocket.class); } catch (ConnectionException e) { LOG.info(LoggingConstants.EXCEPTION_MESSAGE, e); } LOG.info("Open Answer..."); try { createAndAddConnection(serv, isConnectionLocal(), "srl04.tamu.edu", ANSWER_PORT, isSecure(), AnswerClientWebSocket.class); } catch (ConnectionException e) { LOG.info(LoggingConstants.EXCEPTION_MESSAGE, e); } }

Target:
public void connectServers(final AbstractServerWebSocketHandler serv) { LOG.info("Open Login..."); LOG.info("Is Connection Local? {}", isConnectionLocal()); LOG.info("Is Secure? {}", isSecure()); try { createAndAddConnection(serv, isConnectionLocal(), "srl02.tamu.edu", LOGIN_PORT, isSecure(), LoginClientWebSocket.class); } catch (ConnectionException e) { LOG.error(LoggingConstants.EXCEPTION_MESSAGE, e); } LOG.info("Open Data..."); try { createAndAddConnection(serv, isConnectionLocal(), "srl04.tamu.edu", DATABASE_PORT, isSecure(), DataClientWebSocket.class); } catch (ConnectionException e) { LOG.error(LoggingConstants.EXCEPTION_MESSAGE, e); } LOG.info("Open Answer..."); try { createAndAddConnection(serv, isConnectionLocal(), "srl04.tamu.edu", ANSWER_PORT, isSecure(), AnswerClientWebSocket.class); } catch (ConnectionException e) { LOG.error(LoggingConstants.EXCEPTION_MESSAGE, e); } }
Source:
public SeleniumWFieldIndicatorWebElement(final WebElement element, final WebDriver driver) { super(element, driver); String tagName = element.getTagName(); if (!(TOP_LEVEL_TAG.equalsIgnoreCase(tagName))) { throw new SystemException("Incorrect element selected for SeleniumWFieldIndicatorWebElement. Found: " + tagName); } loadIndicator(element); }

Target:
public SeleniumWFieldIndicatorWebElement(final WebElement element, final WebDriver driver) { super(element, driver); String tagName = element.getTagName(); String aClass = element.getAttribute("class"); if (!(TOP_LEVEL_TAG.equalsIgnoreCase(tagName))) { throw new SystemException("Incorrect element selected for SeleniumWFieldIndicatorWebElement. Found: " + tagName); } else if (!StringUtils.contains(aClass, CLASS_PREFIX)) { throw new SystemException("Incorrect element selected for SeleniumWFieldIndicatorWebElement. Found: " + aClass); } loadIndicator(element); }
Source:
public void testBadCallback() throws Exception { RequestAndResult req = new RequestAndResult(chunkSize * 5 + random.nextInt(chunkSize - 1) + 1); ReadableStreamChannel putChannel = new ByteBufferReadableStreamChannel(ByteBuffer.wrap(req.putContent)); router = getNonBlockingRouter(); final CountDownLatch callbackCalled = new CountDownLatch(1); router.putBlob(req.putBlobProperties, req.putUserMetadata, putChannel, new Callback<String>() { @Override public void onCompletion(String result, Exception exception) { callbackCalled.countDown(); throw new RuntimeException("Throwing an exception in the user callback"); } }).get(); Assert.assertTrue("Callback not called.", callbackCalled.await(2, TimeUnit.SECONDS)); Assert.assertEquals("All operations should be finished.", 0, router.getOperationsCount()); Assert.assertTrue("Router should not be closed", router.isOpen()); router.close(); }

Target:
public void testBadCallback() throws Exception { RequestAndResult req = new RequestAndResult(chunkSize * 5 + random.nextInt(chunkSize - 1) + 1); router = getNonBlockingRouter(); final CountDownLatch callbackCalled = new CountDownLatch(1); requestAndResultsList.clear(); for (int i = 0; i < 4; i++) { requestAndResultsList.add(new RequestAndResult(chunkSize + random.nextInt(5) * random.nextInt(chunkSize))); } instantiateNewRouterForPuts = false; ReadableStreamChannel putChannel = new ByteBufferReadableStreamChannel(ByteBuffer.wrap(req.putContent)); Future future = router.putBlob(req.putBlobProperties, req.putUserMetadata, putChannel, new Callback<String>() { @Override public void onCompletion(String result, Exception exception) { callbackCalled.countDown(); throw new RuntimeException("Throwing an exception in the user callback"); } }); submitPutsAndAssertSuccess(false); future.get(); Assert.assertTrue("Callback not called.", callbackCalled.await(2, TimeUnit.SECONDS)); Assert.assertEquals("All operations should be finished.", 0, router.getOperationsCount()); Assert.assertTrue("Router should not be closed", router.isOpen()); requestAndResultsList.clear(); requestAndResultsList.add(new RequestAndResult(chunkSize + random.nextInt(5) * random.nextInt(chunkSize))); instantiateNewRouterForPuts = false; submitPutsAndAssertSuccess(true); }
Source:
GreatestSqlAggFunction() { super( NAME, null, SqlKind.GREATEST, ReturnTypes.ARG0_NULLABLE_IF_EMPTY, null, OperandTypes.SAME_VARIADIC, SqlFunctionCategory.SYSTEM, false, false ); }

Target:
GreatestSqlAggFunction() { super( NAME, null, SqlKind.GREATEST, ReturnTypes.cascade(ReturnTypes.LEAST_RESTRICTIVE, SqlTypeTransforms.TO_NULLABLE), InferTypes.RETURN_TYPE, OperandTypes.ONE_OR_MORE, SqlFunctionCategory.SYSTEM, false, false, Optionality.FORBIDDEN ); }
Source:
public void update(ActionEvent e) { CurrentProject currentProject = appContext.getCurrentProject(); if (currentProject == null) { e.getPresentation().setVisible(false); } e.getPresentation().setVisible("javac".equals(currentProject.getProjectConfig().getType())); }

Target:
public void update(ActionEvent e) { CurrentProject currentProject = appContext.getCurrentProject(); if (currentProject == null) { e.getPresentation().setVisible(false); } e.getPresentation().setVisible(JAVAC.equals(currentProject.getProjectConfig().getType())); }
Source:
public Resource retrieveResource(URL url) { return cache.get(url.toString(), () -> resourceRetriever.retrieveResource(url)); }

Target:
public Resource retrieveResource(URL url) throws IOException { String jwkSet; try { jwkSet = cache.get(url.toString(), () -> resourceRetriever.retrieveResource(url).getContent()); } catch (Exception ex) { throw new IOException(ex); } return new Resource(jwkSet, "UTF-8"); }
Source:
public int hashCode() { if (hash == 0) { hash = (HashCodeUtil.hash1(x + 1337) ^ HashCodeUtil.hash1(y + 97331)) & 0x7FFFFFFF; } return hash; }

Target:
public int hashCode() { if (hash == 0) { hash = Objects.hash(x, y); } return hash; }
Source:
public void measures_on_project_accessors_handled_as_methods() throws Exception { initAndScan(false); ArgumentCaptor<Measure> captor = ArgumentCaptor.forClass(Measure.class); ArgumentCaptor<org.sonar.api.resources.File> files = ArgumentCaptor.forClass(org.sonar.api.resources.File.class); verify(context, atLeastOnce()).saveMeasure(files.capture(), captor.capture()); Map<String, Double> metrics = new HashMap<String, Double>(); for (Measure measure : captor.getAllValues()) { if (measure.getValue() != null) { if (metrics.get(measure.getMetricKey()) == null) { metrics.put(measure.getMetricKey(), measure.getValue()); } else { metrics.put(measure.getMetricKey(), metrics.get(measure.getMetricKey()) + measure.getValue()); } } } assertThat(metrics.get("classes").intValue()).isEqualTo(412); assertThat(metrics.get("functions").intValue()).isEqualTo(3762); assertThat(metrics.get("lines").intValue()).isEqualTo(64125); assertThat(metrics.get("ncloc").intValue()).isEqualTo(26323); assertThat(metrics.get("statements").intValue()).isEqualTo(12047); assertThat(metrics.get("complexity").intValue()).isEqualTo(8462); assertThat(metrics.get("comment_lines").intValue()).isEqualTo(17908); assertThat(metrics.get("public_api").intValue()).isEqualTo(3221); double density = 1.0; if (metrics.get("public_api").intValue() != 0) { density = (metrics.get("public_api") - metrics.get("public_undocumented_api")) / metrics.get("public_api"); } assertThat(density).isEqualTo(0.64, Delta.delta(0.01)); }

Target:
public void measures_on_project_accessors_handled_as_methods() throws Exception { initAndScan(false); Map<String, Double> metrics = getMetrics(); verifySameResults(metrics); assertThat(metrics.get("functions").intValue()).isEqualTo(3762); assertThat(metrics.get("public_api").intValue()).isEqualTo(3221); assertThat(metrics.get("complexity").intValue()).isEqualTo(8462); }
Source:
public void onLoadFinished(final Loader<SearchResult> arg0, final SearchResult searchIn) { if (searchIn != null) { cacheList.clear(); final Set<Geocache> cachesFromSearchResult = searchIn.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB); cacheList.addAll(cachesFromSearchResult); search = searchIn; updateAdapter(); updateTitle(); showFooterMoreCaches(); } showProgress(false); hideLoading(); invalidateOptionsMenuCompatible(); if( arg0 instanceof AbstractSearchLoader) { AbstractSearchLoader abstractSearchLoader = (AbstractSearchLoader) arg0; switch (abstractSearchLoader.getAfterLoadAction()) { case CHECK_IF_EMPTY: checkIfEmptyAndRemoveAfterConfirm(); break; case NO_ACTION: default: } } }

Target:
public void onLoadFinished(final Loader<SearchResult> arg0, final SearchResult searchIn) { if (searchIn != null) { cacheList.clear(); final Set<Geocache> cachesFromSearchResult = searchIn.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB); cacheList.addAll(cachesFromSearchResult); search = searchIn; updateAdapter(); updateTitle(); showFooterMoreCaches(); } showProgress(false); hideLoading(); invalidateOptionsMenuCompatible(); if (arg0 instanceof AbstractSearchLoader) { switch (((AbstractSearchLoader) arg0).getAfterLoadAction()) { case CHECK_IF_EMPTY: checkIfEmptyAndRemoveAfterConfirm(); break; case NO_ACTION: default: } } }
Source:
protected Command doGetCommand(Request request, EditPart targetEditPart) { boolean canHandle = false; if (targetEditPart instanceof GraphicalEditPart) { dropTarget = (GraphicalEditPart) targetEditPart; if ((targetEditPart instanceof CompartmentEditPart)) { targetEditPart = targetEditPart.getParent(); if (request instanceof DropObjectsRequest && !((DropObjectsRequest) request).getObjects().isEmpty()) { Object droppedObject = ((DropObjectsRequest) request).getObjects().get(0); if (droppedObject instanceof Collaboration) { Collaboration collaboration = (Collaboration) droppedObject; if (!SystemElementsUtils.isBaseProtocol(collaboration)) { canHandle = true; } } } } } return canHandle ? super.doGetCommand(request, targetEditPart) : null; }

Target:
protected Command doGetCommand(Request request, EditPart targetEditPart) { boolean canHandle = false; if (targetEditPart instanceof GraphicalEditPart) { dropTarget = (GraphicalEditPart) targetEditPart; if ((targetEditPart instanceof CompartmentEditPart)) { targetEditPart = targetEditPart.getParent(); if (request instanceof DropObjectsRequest && !getSourceEObjects(request).isEmpty()) { List<Collaboration> droppedProtocols = getSourceEObjects(request).stream().filter(Collaboration.class::isInstance) .map(Collaboration.class::cast) .collect(Collectors.toList()); if (droppedProtocols != null && !droppedProtocols.isEmpty()) { canHandle = canDrop(droppedProtocols); } } } } return canHandle ? super.doGetCommand(request, targetEditPart) : null; }
Source:
public KafkaSourceEmbeddedKafka(Properties properties) { zookeeper = new KafkaSourceEmbeddedZookeeper(zkPort); dir = new File(System.getProperty("java.io.tmpdir"), "kafka_log-" + UUID.randomUUID()); try { FileUtils.deleteDirectory(dir); } catch (IOException e) { e.printStackTrace(); } Properties props = new Properties(); props.put("zookeeper.connect",zookeeper.getConnectString()); props.put("broker.id","1"); props.put("offsets.topic.replication.factor", "1"); props.put("host.name", "localhost"); props.put("port", String.valueOf(serverPort)); props.put("log.dir", dir.getAbsolutePath()); if (properties != null) { props.putAll(properties); } KafkaConfig config = new KafkaConfig(props); kafkaServer = new KafkaServerStartable(config); kafkaServer.startup(); initProducer(); }

Target:
public KafkaSourceEmbeddedKafka(Properties properties) { zookeeper = new KafkaSourceEmbeddedZookeeper(zkPort); dir = new File(System.getProperty("java.io.tmpdir"), "kafka_log-" + UUID.randomUUID()); try { FileUtils.deleteDirectory(dir); } catch (IOException e) { e.printStackTrace(); } Properties props = new Properties(); props.put("zookeeper.connect",zookeeper.getConnectString()); props.put("broker.id","-1"); props.put("offsets.topic.replication.factor", "1"); props.put("host.name", "localhost"); props.put("port", String.valueOf(serverPort)); props.put("log.dir", dir.getAbsolutePath()); if (properties != null) { props.putAll(properties); } KafkaConfig config = new KafkaConfig(props); kafkaServer = new KafkaServerStartable(config); kafkaServer.startup(); initProducer(); }
Source:
public Map<String, String> getIdAttrsMap() { return ImmutableMap.of("fileSystemPath", this.getFileSystemPath()); }

Target:
public Map<String, String> getIdAttrsMap() { return ImmutableMap.of(FILE_SYSTEM_PATH, this.getFileSystemPath()); }
Source:
public void channelRead0(ChannelHandlerContext ctx, Object msg) { if (msg instanceof FullHttpRequest) { handleHttpRequest(ctx, (FullHttpRequest) msg); } else if (msg instanceof WebSocketFrame) { handleWebSocketFrame(ctx, (WebSocketFrame) msg); } globalStats.mark(Command.WEB_SOCKETS); }

Target:
public void channelRead0(ChannelHandlerContext ctx, Object msg) { if (msg instanceof FullHttpRequest) { handleHttpRequest(ctx, (FullHttpRequest) msg); } else if (msg instanceof WebSocketFrame) { handleWebSocketFrame(ctx, (WebSocketFrame) msg); } }
Source:
private ObjCClass(long handle, Class<? extends ObjCObject> type, String name, boolean custom) { super(handle, false); this.type = type; this.name = name; this.custom = custom; if (custom) { ObjCObject.ObjectOwnershipHelper.registerClass(this); } }

Target:
private ObjCClass(long handle, Class<? extends ObjCObject> type, String name, boolean custom) { super(handle, false); this.type = type; this.name = name; this.custom = custom; }
Source:
public boolean undo() { if (s3Client.doesObjectExist(bucket, previousVersionFilePath)) { try { s3Client.copyObject(bucket, previousVersionFilePath, bucket, remoteFilePath); } catch (SdkClientException e) { LOG.log(Level.SEVERE, "Error undoing deploying", e); return false; } } return true; }

Target:
public boolean undo() { if (s3Client.doesObjectExist(bucket, previousVersionFilePath)) { try { s3Client.copyObject(bucket, previousVersionFilePath, bucket, remoteFilePath); } catch (SdkClientException e) { LOG.log(Level.SEVERE, "Reverting to previous topology version failed", e); return false; } } return true; }
Source:
public CassandraYesNoType() { super( CharacterStringGridTypeDescriptor.INSTANCE, org.hibernate.type.YesNoType.INSTANCE.getJavaTypeDescriptor() ); }

Target:
public CassandraYesNoType() { super( StringMappedGridTypeDescriptor.INSTANCE, org.hibernate.type.YesNoType.INSTANCE.getJavaTypeDescriptor() ); }
Source:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); NotificationUtil.subscribeToTopics(environment, this); NotificationUtil.logFirebaseToken(); initWhatsNew(); addClickListenerOnProfileButton(); }

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initWhatsNew(); addClickListenerOnProfileButton(); }
Source:
protected I prepareInteractor(String actionName) { if (_customInteractorListener != null) { I customResult = (I) _customInteractorListener.createInteractor(actionName); if (customResult != null) { customResult.onScreenletAttached(this); _interactors.put(actionName, customResult); return customResult; } } I result = createInteractor(actionName); if (result != null) { result.onScreenletAttached(this); _interactors.put(actionName, result); } return result; }

Target:
protected I prepareInteractor(String actionName) { I result = _customInteractorListener == null ? createInteractor(actionName) : (I) _customInteractorListener.createInteractor(actionName); if (result != null) { result.onScreenletAttached(this); _interactors.put(actionName, result); } return result; }
Source:
public void createFile(JDBCSequentialFile file) throws SQLException { try (Connection connection = connectionProvider.getConnection()) { try (PreparedStatement createFile = connection.prepareStatement(this.createFile)) { connection.setAutoCommit(false); Long oid = largeObjectManager.createLO(connection); createFile.setString(1, file.getFileName()); createFile.setString(2, file.getExtension()); createFile.setLong(3, oid); createFile.executeUpdate(); try (ResultSet keys = createFile.getGeneratedKeys()) { keys.next(); file.setId(keys.getLong(1)); } connection.commit(); } catch (SQLException e) { connection.rollback(); throw e; } } }

Target:
public void createFile(JDBCSequentialFile file) throws SQLException { try (Connection connection = connectionProvider.getConnection()) { try (PreparedStatement createFile = connection.prepareStatement(this.createFile, this.createFileAutogeneratedKeys)) { connection.setAutoCommit(false); Long oid = largeObjectManager.createLO(connection); createFile.setString(1, file.getFileName()); createFile.setString(2, file.getExtension()); createFile.setLong(3, oid); createFile.executeUpdate(); try (ResultSet keys = createFile.getGeneratedKeys()) { keys.next(); file.setId(keys.getLong(1)); } connection.commit(); } catch (SQLException e) { connection.rollback(); throw e; } } }
Source:
public void updateMessage() throws Exception { assertThat(modifier.createEdit(change, getCurrentPatchSet(changeId))) .isEqualTo(RefUpdate.Result.NEW); Optional<ChangeEdit> edit = editUtil.byChange(change); try { modifier.modifyMessage( edit.get(), edit.get().getEditCommit().getFullMessage()); fail("InvalidChangeOperationException expected"); } catch (UnchangedCommitMessage ex) { assertThat(ex.getMessage()).isEqualTo( "New commit message cannot be same as existing commit message"); } String msg = String.format("New commit message\n\nChange-Id: %s", change.getKey()); assertThat(modifier.modifyMessage(edit.get(), msg)).isEqualTo( RefUpdate.Result.FORCED); edit = editUtil.byChange(change); assertThat(edit.get().getEditCommit().getFullMessage()).isEqualTo(msg); editUtil.publish(edit.get()); assertThat(editUtil.byChange(change).isPresent()).isFalse(); ChangeInfo info = get(changeId, ListChangesOption.CURRENT_COMMIT, ListChangesOption.CURRENT_REVISION); assertThat(info.revisions.get(info.currentRevision).commit.message) .isEqualTo(msg); }

Target:
public void updateMessage() throws Exception { assertThat(modifier.createEdit(change, getCurrentPatchSet(changeId))) .isEqualTo(RefUpdate.Result.NEW); Optional<ChangeEdit> edit = editUtil.byChange(change); try { modifier.modifyMessage( edit.get(), edit.get().getEditCommit().getFullMessage()); fail("UnchangedCommitMessage expected"); } catch (UnchangedCommitMessageException ex) { assertThat(ex.getMessage()).isEqualTo( "New commit message cannot be same as existing commit message"); } String msg = String.format("New commit message\n\nChange-Id: %s", change.getKey()); assertThat(modifier.modifyMessage(edit.get(), msg)).isEqualTo( RefUpdate.Result.FORCED); edit = editUtil.byChange(change); assertThat(edit.get().getEditCommit().getFullMessage()).isEqualTo(msg); editUtil.publish(edit.get()); assertThat(editUtil.byChange(change).isPresent()).isFalse(); ChangeInfo info = get(changeId, ListChangesOption.CURRENT_COMMIT, ListChangesOption.CURRENT_REVISION); assertThat(info.revisions.get(info.currentRevision).commit.message) .isEqualTo(msg); }
Source:
private void testGuts(FileTailingMessageProducerSupport adapter, String field) throws Exception { final List<FileTailingEvent> events = new ArrayList<FileTailingEvent>(); adapter.setApplicationEventPublisher(new ApplicationEventPublisher() { @Override public void publishEvent(ApplicationEvent event) { FileTailingEvent tailEvent = (FileTailingEvent) event; logger.warn(event); events.add(tailEvent); } }); adapter.setFile(new File(testDir, "foo")); QueueChannel outputChannel = new QueueChannel(); adapter.setOutputChannel(outputChannel); adapter.afterPropertiesSet(); File file = new File(testDir, "foo"); File renamed = new File(testDir, "bar"); file.delete(); renamed.delete(); adapter.start(); waitForField(adapter, field); FileOutputStream foo = new FileOutputStream(file); for (int i = 0; i < 50; i++) { foo.write(("hello" + i + "\n").getBytes()); } foo.flush(); for (int i = 0; i < 50; i++) { Message<?> message = outputChannel.receive(5000); assertNotNull(message); assertEquals("hello" + i, message.getPayload()); } file.renameTo(renamed); foo.close(); foo = new FileOutputStream(file); if (adapter instanceof ApacheCommonsFileTailingMessageProducer) { Thread.sleep(1000); } for (int i = 50; i < 100; i++) { foo.write(("hello" + i + "\n").getBytes()); } foo.flush(); for (int i = 50; i < 100; i++) { Message<?> message = outputChannel.receive(3000); assertNotNull(message); assertEquals("hello" + i, message.getPayload()); } foo.close(); adapter.stop(); }

Target:
private void testGuts(FileTailingMessageProducerSupport adapter, String field) throws Exception { this.adapter = adapter; final List<FileTailingEvent> events = new ArrayList<FileTailingEvent>(); adapter.setApplicationEventPublisher(new ApplicationEventPublisher() { @Override public void publishEvent(ApplicationEvent event) { FileTailingEvent tailEvent = (FileTailingEvent) event; logger.warn(event); events.add(tailEvent); } }); adapter.setFile(new File(testDir, "foo")); QueueChannel outputChannel = new QueueChannel(); adapter.setOutputChannel(outputChannel); adapter.setTailAttemptsDelay(500); adapter.afterPropertiesSet(); File file = new File(testDir, "foo"); File renamed = new File(testDir, "bar"); file.delete(); renamed.delete(); adapter.start(); waitForField(adapter, field); FileOutputStream foo = new FileOutputStream(file); for (int i = 0; i < 50; i++) { foo.write(("hello" + i + "\n").getBytes()); } foo.flush(); for (int i = 0; i < 50; i++) { Message<?> message = outputChannel.receive(5000); assertNotNull("expected a non-null message", message); assertEquals("hello" + i, message.getPayload()); } file.renameTo(renamed); foo.close(); foo = new FileOutputStream(file); if (adapter instanceof ApacheCommonsFileTailingMessageProducer) { Thread.sleep(1000); } for (int i = 50; i < 100; i++) { foo.write(("hello" + i + "\n").getBytes()); } foo.flush(); for (int i = 50; i < 100; i++) { Message<?> message = outputChannel.receive(3000); assertNotNull("expected a non-null message", message); assertEquals("hello" + i, message.getPayload()); } foo.close(); }
Source:
public String getDirectoryUrl() { return azureFileStorageClient.url(); }

Target:
public URL getDirectoryUrl() { try { return new URL(azureFileStorageClient.url()); } catch (MalformedURLException e) { throw new RuntimeException(String.format("Invalid URL on %s: %s" + getClass().getSimpleName(), azureFileStorageClient.url()), e); } }