auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public Response getWorkflowLog(String workflowId, ConsonanceUser user) throws NotFoundException { Ga4ghWesWorkflowLog log = new Ga4ghWesWorkflowLog(); log.setWorkflowId(workflowId); final String[] jobUuid = {"-1"}; List<Job> allJobs = orderResource.listWorkflowRuns(user); allJobs.stream().filter((Job t) -> String.valueOf(t.getJobId()).equals(workflowId)).forEach(s -> jobUuid[0] = s.getUuid()); Job parseJob = orderResource.getWorkflowRun(user, jobUuid[0]); Ga4ghWesWorkflowRequest request = new Ga4ghWesWorkflowRequest(); request.setWorkflowDescriptor(parseJob.getContainerImageDescriptor()); request.setWorkflowParams(parseJob.getContainerRuntimeDescriptor()); request.setWorkflowType(parseJob.getContainerImageDescriptorType()); request.setWorkflowTypeVersion("1.0"); log.setRequest(request); JobState workflowState = parseJob.getState(); log.setState(mapState(workflowState)); Ga4ghWesLog workflowLog = new Ga4ghWesLog(); workflowLog.setName("CWL|WDL Job"); workflowLog.addCmdItem("run workflow"); workflowLog.setStartTime(String.valueOf(parseJob.getCreateTimestamp())); workflowLog.setEndTime(String.valueOf(parseJob.getUpdateTimestamp())); workflowLog.setStdout(parseJob.getStdout()); workflowLog.setStderr(parseJob.getStderr()); workflowLog.setExitCode(0); log.addTaskLogsItem(workflowLog); Ga4ghWesParameter outputParameter = new Ga4ghWesParameter(); log.addOutputsItem(outputParameter); return Response.ok().entity(log).build(); }

Target:
public Response getWorkflowLog(String workflowId, ConsonanceUser user) throws NotFoundException { Ga4ghWesWorkflowLog log = new Ga4ghWesWorkflowLog(); log.setWorkflowId(workflowId); final String[] jobUuid = {"-1"}; List<Job> allJobs = orderResource.listWorkflowRuns(user); allJobs.stream().filter((Job t) -> String.valueOf(t.getJobId()).equals(workflowId)).forEach(s -> jobUuid[0] = s.getUuid()); Job parseJob = orderResource.getWorkflowRun(user, jobUuid[0]); Ga4ghWesWorkflowRequest request = new Ga4ghWesWorkflowRequest(); request.setWorkflowDescriptor(parseJob.getContainerImageDescriptor()); request.setWorkflowParams(parseJob.getContainerRuntimeDescriptor()); request.setWorkflowType(parseJob.getContainerImageDescriptorType()); request.setWorkflowTypeVersion("1.0"); log.setRequest(request); JobState workflowState = parseJob.getState(); log.setState(mapState(workflowState)); Ga4ghWesLog workflowLog = new Ga4ghWesLog(); workflowLog.setName(parseJob.getContainerImageDescriptorType()); workflowLog.setStartTime(String.valueOf(parseJob.getCreateTimestamp())); workflowLog.setEndTime(String.valueOf(parseJob.getUpdateTimestamp())); workflowLog.setStdout(parseJob.getStdout()); workflowLog.setStderr(parseJob.getStderr()); log.addTaskLogsItem(workflowLog); Ga4ghWesParameter outputParameter = new Ga4ghWesParameter(); log.addOutputsItem(outputParameter); return Response.ok().entity(log).build(); }
Source:
private void assertFilesAreOpen() { Set<TextEditor> textEditors = getOpenEditorsByType(TextEditor.class); assertEquals(2, textEditors.size()); Set<String> editorTitles = FluentIterable.from(textEditors).transform(new Function<TextEditor, String>() { @Override public String apply(TextEditor editor) { return editor.getTitle(); } }).toSet(); assertTrue(editorTitles.contains(fileA.getName())); assertTrue(editorTitles.contains(fileB.getName())); }

Target:
private void assertFilesAreOpen() { Set<String> editorTitles = getOpenEditorsByType(TextEditor.class, new Function<TextEditor, String>() { @Override public String apply(TextEditor editor) { return editor.getTitle(); } }); assertEquals(ImmutableSet.of(fileA.getName(), fileB.getName()), editorTitles); }
Source:
public void testBool() { final Arbitrary<Boolean> arbBooleanR = arbitrary(arbBoolean.gen); final Property p = property(arbBooleanR, arbBooleanR, (m1, m2) -> bool(m1.equals(m2)) .implies(new BoolTestClass(m1).getBoolean() == new BoolTestClass(m2).getBoolean())); PropertyAssert.assertResult(p); }

Target:
public void testBool() { final Arbitrary<Boolean> arbBooleanR = arbitrary(arbBoolean.gen); final Property p = property(arbBooleanR, arbBooleanR, (m1, m2) -> bool(m1.equals(m2)) .implies(m1 == m2)); PropertyAssert.assertResult(p); }
Source:
public void storeSettings() { prefs.put(JabRefPreferences.EMAIL_SUBJECT, emailSubject.getText()); prefs.putBoolean(JabRefPreferences.OPEN_FOLDERS_OF_ATTACHED_FILES, openFoldersOfAttachedFiles.isSelected()); if (pushToApplicationComboBox.getValue().getApplicationName() != JabRefPreferences.PUSH_TO_APPLICATION) { prefs.put(JabRefPreferences.PUSH_TO_APPLICATION, pushToApplicationComboBox.getValue().getApplicationName()); frame.getPushToApplicationsManager().updateApplicationAction(); } prefs.put(JabRefPreferences.CITE_COMMAND, citeCommand.getText()); prefs.putBoolean(JabRefPreferences.USE_DEFAULT_CONSOLE_APPLICATION, defaultConsole.isSelected()); prefs.put(JabRefPreferences.CONSOLE_COMMAND, consoleCommand.getText()); prefs.put(JabRefPreferences.ADOBE_ACROBAT_COMMAND, adobeAcrobatReaderPath.getText()); prefs.putBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION, defaultFileBrowser.isSelected()); if (StringUtil.isNotBlank(fileBrowserCommand.getText())) { prefs.put(JabRefPreferences.FILE_BROWSER_COMMAND, fileBrowserCommand.getText()); } else { prefs.putBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION, true); } if (OS.WINDOWS) { prefs.put(JabRefPreferences.SUMATRA_PDF_COMMAND, sumatraReaderPath.getText()); } readerSelected(); }

Target:
public void storeSettings() { prefs.put(JabRefPreferences.EMAIL_SUBJECT, emailSubject.getText()); prefs.putBoolean(JabRefPreferences.OPEN_FOLDERS_OF_ATTACHED_FILES, openFoldersOfAttachedFiles.isSelected()); prefs.setActivePushToApplication(pushToApplicationComboBox.getValue(), frame.getPushToApplicationsManager()); prefs.put(JabRefPreferences.CITE_COMMAND, citeCommand.getText()); prefs.putBoolean(JabRefPreferences.USE_DEFAULT_CONSOLE_APPLICATION, defaultConsole.isSelected()); prefs.put(JabRefPreferences.CONSOLE_COMMAND, consoleCommand.getText()); prefs.put(JabRefPreferences.ADOBE_ACROBAT_COMMAND, adobeAcrobatReaderPath.getText()); prefs.putBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION, defaultFileBrowser.isSelected()); if (StringUtil.isNotBlank(fileBrowserCommand.getText())) { prefs.put(JabRefPreferences.FILE_BROWSER_COMMAND, fileBrowserCommand.getText()); } else { prefs.putBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION, true); } if (OS.WINDOWS) { prefs.put(JabRefPreferences.SUMATRA_PDF_COMMAND, sumatraReaderPath.getText()); } readerSelected(); }
Source:
private int createHashCode() { int result = interpolatedMessage != null ? interpolatedMessage.hashCode() : 0; result = 31 * result + ( propertyPath != null ? propertyPath.hashCode() : 0 ); result = 31 * result + ( constraintDescriptor != null ? constraintDescriptor.hashCode() : 0 ); result = 31 * result + ( messageTemplate != null ? messageTemplate.hashCode() : 0 ); result = 31 * result + ( rootBeanClass != null ? rootBeanClass.hashCode() : 0 ); result = 31 * result + ( elementType != null ? elementType.hashCode() : 0 ); return result; }

Target:
private int createHashCode() { int result = interpolatedMessage != null ? interpolatedMessage.hashCode() : 0; result = 31 * result + ( propertyPath != null ? propertyPath.hashCode() : 0 ); result = 31 * result + System.identityHashCode( rootBean ); result = 31 * result + System.identityHashCode( leafBeanInstance ); result = 31 * result + System.identityHashCode( value ); result = 31 * result + ( constraintDescriptor != null ? constraintDescriptor.hashCode() : 0 ); result = 31 * result + ( messageTemplate != null ? messageTemplate.hashCode() : 0 ); result = 31 * result + ( elementType != null ? elementType.hashCode() : 0 ); return result; }
Source:
public static byte getFlagByPartId(final int partId) { return partId == PageIdAllocator.INDEX_PARTITION ? PageStore.TYPE_IDX : PageStore.TYPE_DATA; }

Target:
public static byte getFlagByPartId(final int partId) { return partId == PageIdAllocator.INDEX_PARTITION ? PageIdAllocator.FLAG_IDX : PageIdAllocator.FLAG_DATA; }
Source:
public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity identity) throws InfrastructureException { for (Pod pod : k8sEnv.getPods().values()) { pod.getSpec() .getContainers() .forEach( container -> proxyEnvVars.forEach((k, v) -> container.getEnv().add(new EnvVar(k, v, null)))); } }

Target:
public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity identity) throws InfrastructureException { if (!proxyEnvVars.isEmpty()) { for (Pod pod : k8sEnv.getPods().values()) { pod.getSpec() .getContainers() .forEach( container -> proxyEnvVars.forEach((k, v) -> container.getEnv().add(new EnvVar(k, v, null)))); } } }
Source:
private void sleep() { try { Thread.sleep(30_000); } catch (final InterruptedException ex) { } }

Target:
private void sleep() { try { Thread.sleep(5000); } catch (final InterruptedException ex) { this.isTestThreadInterrupted = true; } }
Source:
public void check() { for (User user : iterateLazily((maxItems, skipCount) -> userManager.getAll(maxItems, skipCount))) { try { String owner = user.getId(); Map<String, String> preferences = preferenceManager.find(owner); String lastTimeAccess = preferences.get(LAST_ACTIVITY_TIME); String namespace = preferences.get(LAST_ACTIVE_INFRASTRUCTURE_NAMESPACE); if (isNullOrEmpty(namespace) || isNullOrEmpty(lastTimeAccess) || isAnyRuntimeInProgress(owner)) { continue; } long lastTimeAccessSec = parseLong(lastTimeAccess); long epochSec = clock.instant().getEpochSecond(); if (epochSec - lastTimeAccessSec >= shutdownTimeoutSec) { PodResource<Pod, DoneablePod> podDoneablePodPodResource = kubernetesClientFactory .create() .pods() .inNamespace(namespace) .withName(ASYNC_STORAGE); if (podDoneablePodPodResource.get() != null) { podDoneablePodPodResource.delete(); } } } catch (InfrastructureException | ServerException e) { LOG.error(e.getMessage(), e); } } }

Target:
public void check() { if (isAsyncStoragePodCanBeRun && shutdownTimeoutSec > 0) { for (User user : iterateLazily((maxItems, skipCount) -> userManager.getAll(maxItems, skipCount))) { try { String owner = user.getId(); Map<String, String> preferences = preferenceManager.find(owner); String lastTimeAccess = preferences.get(LAST_ACTIVITY_TIME); String namespace = preferences.get(LAST_ACTIVE_INFRASTRUCTURE_NAMESPACE); if (isNullOrEmpty(namespace) || isNullOrEmpty(lastTimeAccess) || !runtimes.getInProgress(owner).isEmpty()) { continue; } long lastTimeAccessSec = parseLong(lastTimeAccess); Instant expectedShutdownAfter = ofEpochSecond(lastTimeAccessSec).plusSeconds(shutdownTimeoutSec); if (now().isAfter(expectedShutdownAfter)) { PodResource<Pod, DoneablePod> doneablePodResource = kubernetesClientFactory .create() .pods() .inNamespace(namespace) .withName(ASYNC_STORAGE); if (doneablePodResource.get() != null) { doneablePodResource.delete(); } } } catch (InfrastructureException | ServerException e) { LOG.error(e.getMessage(), e); } } } }
Source:
public static int compare(Float number, long value, OptionalInt treatNanAs) { OptionalInt infinity = InfinityNumberComparatorHelper.infinityCheck( number, treatNanAs ); if ( infinity.isPresent() ) { return infinity.getAsInt(); } return Double.compare( number, value ); }

Target:
public static int compare(Float number, long value, OptionalInt treatNanAs) { OptionalInt infinity = InfinityNumberComparatorHelper.infinityCheck( number, treatNanAs ); if ( infinity.isPresent() ) { return infinity.getAsInt(); } return Float.compare( number, value ); }
Source:
public Navigate toPage(String pageName) { String host = UrlBuilder.getHostForWiki(); String cacheBuster = pageName.equals("") || pageName.equals("/") ? "" : "?cb=" + DateTime.now().getMillis(); String abGroup = pageName.equals("") || pageName.equals("/") ? "" : defaultTestingGroup; driver.get("http://" + host + pageName + cacheBuster + abGroup); return this; }

Target:
public Navigate toPage(String pageName) { String host = UrlBuilder.getHostForWiki(); String cacheBuster = pageName.equals("") || pageName.equals("/") ? "" : "?cb=" + DateTime.now().getMillis() + defaultTestingGroup; driver.get("http://" + host + pageName + cacheBuster); return this; }
Source:
public Resource createResource(PerunSession sess, Resource resource, Vo vo, Facility facility) throws InternalErrorException, FacilityNotExistsException, ResourceExistsException { try{ getResourcesManagerImpl().getResourceByName(sess, vo, facility, resource.getName()); throw new ResourceExistsException("Resource with name \"" + resource.getName() + "\" already exists in " + "facility " + facility + " in VO " + vo + "."); } catch (ResourceNotExistsException e) { resource = getResourcesManagerImpl().createResource(sess, vo, resource, facility); getPerunBl().getAuditer().log(sess, "{} created.", resource); } return resource; }

Target:
public Resource createResource(PerunSession sess, Resource resource, Vo vo, Facility facility) throws InternalErrorException, FacilityNotExistsException, ResourceExistsException { try{ Resource existingResource = getResourcesManagerImpl().getResourceByName(sess, vo, facility, resource.getName()); throw new ResourceExistsException(existingResource); } catch (ResourceNotExistsException e) { resource = getResourcesManagerImpl().createResource(sess, vo, resource, facility); getPerunBl().getAuditer().log(sess, "{} created.", resource); } return resource; }
Source:
public Connection createConnection(RuntimeContainer container) throws IOException { Connection conn = null; SnowflakeConnectionProperties connectionProperties = getConnectionProperties(); String refComponentId = connectionProperties.getReferencedComponentId(); if (refComponentId != null) { if (container != null) { conn = (Connection) container.getComponentData(refComponentId, KEY_CONNECTION); try { if (conn != null && !conn.isClosed()) { return conn; } } catch (SQLException ex) { throw new IOException(ex); } throw new IOException(I18N_MESSAGES.getMessage("error.refComponentNotConnected", refComponentId)); } connectionProperties = connectionProperties.getReferencedConnectionProperties(); if (connectionProperties == null) { throw new IOException(I18N_MESSAGES.getMessage("error.refComponentWithoutProperties", refComponentId)); } } if (container != null) { conn = (Connection) container.getComponentData(container.getCurrentComponentId(), KEY_CONNECTION); try { if (conn != null && !conn.isClosed()) { return conn; } } catch (SQLException ex) { throw new IOException(ex); } connectionProperties.talendProductVersion = (String) container.getGlobalData(KEY_TALEND_PRODUCT_VERSION); } conn = DriverManagerUtils.getConnection(connectionProperties); try { conn.setAutoCommit(connectionProperties.autoCommit.getValue()); } catch (SQLException e) { throw new IOException(e); } if (container != null) { container.setComponentData(container.getCurrentComponentId(), KEY_CONNECTION, conn); container.setComponentData(container.getCurrentComponentId(), KEY_CONNECTION_PROPERTIES, connectionProperties); } return conn; }

Target:
public Connection createConnection(RuntimeContainer container) throws IOException { Connection conn = null; SnowflakeConnectionProperties connectionProperties = getConnectionProperties(); String refComponentId = connectionProperties.getReferencedComponentId(); if (refComponentId != null) { if (container != null) { conn = getConnection(container, refComponentId); if (isConnectionValid(conn)) { return conn; } throw new IOException(I18N_MESSAGES.getMessage("error.refComponentNotConnected", refComponentId)); } connectionProperties = connectionProperties.getReferencedConnectionProperties(); if (connectionProperties == null) { throw new IOException(I18N_MESSAGES.getMessage("error.refComponentWithoutProperties", refComponentId)); } } if (container != null) { conn = getConnection(container, container.getCurrentComponentId()); if (isConnectionValid(conn)) { return conn; } connectionProperties.talendProductVersion = (String) container.getGlobalData(KEY_TALEND_PRODUCT_VERSION); } conn = DriverManagerUtils.getConnection(connectionProperties); try { conn.setAutoCommit(connectionProperties.autoCommit.getValue()); } catch (SQLException e) { throw new IOException(e); } if (container != null) { container.setComponentData(container.getCurrentComponentId(), KEY_CONNECTION, conn); container.setComponentData(container.getCurrentComponentId(), KEY_CONNECTION_PROPERTIES, connectionProperties); } return conn; }
Source:
public List<String> emptyCloudBlobDirectory(final String path) throws StorageException, URISyntaxException { List<String> deletedFiles = new ArrayList<>(); CloudBlobDirectory cloudBlobDirectory = cloudBlobContainer.getDirectoryReference(path); for (ListBlobItem blobItem : cloudBlobDirectory.listBlobs()) { if (blobItem instanceof CloudBlob) { CloudBlob cloudBlob = (CloudBlob) blobItem; log.info("Removing file[%s] from Azure.", cloudBlob.getName()); if (cloudBlob.deleteIfExists()) { deletedFiles.add(cloudBlob.getName()); } } } return deletedFiles; }

Target:
public List<String> emptyCloudBlobDirectory(final String path) throws StorageException, URISyntaxException { List<String> deletedFiles = new ArrayList<>(); for (ListBlobItem blobItem : cloudBlobContainer.listBlobs(path, true, null, null, null)) { CloudBlob cloudBlob = (CloudBlob) blobItem; log.info("Removing file[%s] from Azure.", cloudBlob.getName()); if (cloudBlob.deleteIfExists()) { deletedFiles.add(cloudBlob.getName()); } } if (deletedFiles.isEmpty()) { log.warn("No files were deleted on the following Azure path: [%s]", path); } return deletedFiles; }
Source:
public Boolean visitScope(Scope scope) { final Provider<ScopeCleanupMarker> scopedMarkerProvider; if (scope.equals(Scopes.SINGLETON) || scope.equals(LazySingletonScope.get()) || scope.equals(FineGrainedLazySingletonScope.get())) { scopedMarkerProvider = Providers.of(singletonMarker); } else { scopedMarkerProvider = scope.scope(MARKER_KEY, markerProvider); } ScopeCleanupMarker marker = scopedMarkerProvider.get(); UUID markerKey = marker.getId(); synchronized (markerKey) { ManagedInstanceAction instanceAction = new ManagedInstanceAction(injectee, lifecycleActions); if (scopedCleanupActions.containsKey(markerKey)) { scopedCleanupActions.get(markerKey).add(scopedMarkerProvider, instanceAction); } else { scopedCleanupActions.put(markerKey, new ScopeCleanupAction(markerKey, scopedMarkerProvider, marker, markerReferenceQueue, instanceAction)); } } return true; }

Target:
public Boolean visitScope(Scope scope) { final Provider<ScopeCleanupMarker> scopedMarkerProvider; if (scope.equals(Scopes.SINGLETON) || (scope instanceof AbstractScope && ((AbstractScope)scope).isSingletonScope())) { scopedMarkerProvider = Providers.of(singletonMarker); } else { scopedMarkerProvider = scope.scope(MARKER_KEY, markerProvider); } ScopeCleanupMarker marker = scopedMarkerProvider.get(); UUID markerKey = marker.getId(); synchronized (markerKey) { ManagedInstanceAction instanceAction = new ManagedInstanceAction(injectee, lifecycleActions); if (scopedCleanupActions.containsKey(markerKey)) { scopedCleanupActions.get(markerKey).add(scopedMarkerProvider, instanceAction); } else { scopedCleanupActions.put(markerKey, new ScopeCleanupAction(markerKey, scopedMarkerProvider, marker, markerReferenceQueue, instanceAction)); } } return true; }
Source:
public FastIgnoreRule(String pattern) { if (pattern == null) throw new IllegalArgumentException("Pattern must be not null!"); if (pattern.length() == 0) { dirOnly = false; inverse = false; this.matcher = NO_MATCH; return; } inverse = pattern.charAt(0) == '!'; if (inverse) { pattern = pattern.substring(1); if (pattern.length() == 0) { dirOnly = false; this.matcher = NO_MATCH; return; } } if (pattern.charAt(0) == '#') { this.matcher = NO_MATCH; dirOnly = false; } else { dirOnly = pattern.charAt(pattern.length() - 1) == PATH_SEPARATOR; if (dirOnly) { pattern = stripTrailing(pattern, PATH_SEPARATOR); if (pattern.length() == 0) { this.matcher = NO_MATCH; return; } } IMatcher m; try { m = PathMatcher.createPathMatcher(pattern, Character.valueOf(PATH_SEPARATOR), dirOnly); } catch (InvalidPatternException e) { m = NO_MATCH; } this.matcher = m; } }

Target:
public FastIgnoreRule(String pattern) { if (pattern == null) throw new IllegalArgumentException("Pattern must not be null!"); if (pattern.length() == 0) { dirOnly = false; inverse = false; this.matcher = NO_MATCH; return; } inverse = pattern.charAt(0) == '!'; if (inverse) { pattern = pattern.substring(1); if (pattern.length() == 0) { dirOnly = false; this.matcher = NO_MATCH; return; } } if (pattern.charAt(0) == '#') { this.matcher = NO_MATCH; dirOnly = false; } else { dirOnly = pattern.charAt(pattern.length() - 1) == PATH_SEPARATOR; if (dirOnly) { pattern = stripTrailing(pattern, PATH_SEPARATOR); if (pattern.length() == 0) { this.matcher = NO_MATCH; return; } } IMatcher m; try { m = PathMatcher.createPathMatcher(pattern, Character.valueOf(PATH_SEPARATOR), dirOnly); } catch (InvalidPatternException e) { m = NO_MATCH; } this.matcher = m; } }
Source:
public void selectProviderById(Guid providerId) { if (getNetworkProviders().getItems() != null) { Provider provider = getNetworkProviders().getItems().stream() .filter(candidate -> Objects.equals(candidate.getId(), providerId)) .findFirst().orElse(null); getNetworkProviders().setSelectedItem(provider); } }

Target:
public void selectProviderById(Guid providerId) { if (getNetworkProviders().getItems() != null) { Provider provider = getNetworkProviders().getItems().stream() .filter(candidate -> Objects.equals(candidate.getId(), providerId)) .findFirst().orElse(getNoExternalNetworkProvider()); getNetworkProviders().setSelectedItem(provider); } }
Source:
public void registerSonarQubeVersion_publishes_version_on_first_call() { ClusterProperties clusterProperties = new ClusterProperties(newClusterSettings()); try (HazelcastCluster hzCluster = HazelcastCluster.builder(clusterProperties).build()) { hzCluster.registerSonarQubeVersion("1.0.0.0"); HazelcastInstance hzInstance = createHazelcastClient(hzCluster); assertThat(hzInstance.getAtomicReference(SONARQUBE_VERSION).get()) .isNotNull() .isInstanceOf(String.class) .isEqualTo("1.0.0.0"); } }

Target:
public void registerSonarQubeVersion_publishes_version_on_first_call() { ClusterProperties clusterProperties = new ClusterProperties(newClusterSettings()); try (HazelcastCluster hzCluster = HazelcastCluster.create(clusterProperties)) { hzCluster.registerSonarQubeVersion("1.0.0.0"); HazelcastInstance hzInstance = createHazelcastClient(hzCluster); assertThat(hzInstance.getAtomicReference(SONARQUBE_VERSION).get()).isEqualTo("1.0.0.0"); } }
Source:
public synchronized void seek(long pos) throws IOException { checkNotClosed(); if (pos < 0 || pos >= length) { if (pos == 0) { return; } throw new EOFException( "EOF encountered at pos: " + pos + " for key: " + key); } Preconditions.assertTrue(blockIndex >= 0); if (blockIndex >= blockStreams.size()) { blockIndex = Arrays.binarySearch(blockOffsets, pos); } else if (pos < blockOffsets[blockIndex]) { blockIndex = Arrays.binarySearch(blockOffsets, 0, blockIndex, pos); } else if (pos >= blockOffsets[blockIndex] + blockStreams .get(blockIndex).getLength()) { blockIndex = Arrays .binarySearch(blockOffsets, blockIndex + 1, blockStreams.size(), pos); } if (blockIndex < 0) { blockIndex = -blockIndex - 2; } blockStreams.get(blockIndexOfPrevPosition).resetPosition(); blockStreams.get(blockIndex).seek(pos - blockOffsets[blockIndex]); blockIndexOfPrevPosition = blockIndex; }

Target:
public synchronized void seek(long pos) throws IOException { checkOpen(); if (pos < 0 || pos >= length) { if (pos == 0) { return; } throw new EOFException( "EOF encountered at pos: " + pos + " for key: " + key); } if (blockIndex >= blockStreams.size()) { blockIndex = Arrays.binarySearch(blockOffsets, pos); } else if (pos < blockOffsets[blockIndex]) { blockIndex = Arrays.binarySearch(blockOffsets, 0, blockIndex, pos); } else if (pos >= blockOffsets[blockIndex] + blockStreams .get(blockIndex).getLength()) { blockIndex = Arrays .binarySearch(blockOffsets, blockIndex + 1, blockStreams.size(), pos); } if (blockIndex < 0) { blockIndex = -blockIndex - 2; } blockStreams.get(blockIndexOfPrevPosition).resetPosition(); blockStreams.get(blockIndex).seek(pos - blockOffsets[blockIndex]); blockIndexOfPrevPosition = blockIndex; }
Source:
public void verifySlotExpanded(String slotName) { By slotById = By.id(slotName); WebElement slot = driver.findElement(slotById); wait.forElementVisible(slotById); scrollToSlotOnMobile(slotName); if (checkIfSlotExpanded(slot)) { Log.log("AdInSlot", "Slot (" + slotName + ") expanded as expecting", true ); } else { throw new NoSuchElementException("Slot (" + slotName + ") is collapsed - should be expanded"); } }

Target:
public void verifySlotExpanded(String slotName) { By slotById = By.id(slotName); WebElement slot = driver.findElement(slotById); scrollToSlotOnMobile(slotName); wait.forElementVisible(slotById); if (checkIfSlotExpanded(slot)) { Log.log("AdInSlot", "Slot (" + slotName + ") expanded as expecting", true ); } else { throw new NoSuchElementException("Slot (" + slotName + ") is collapsed - should be expanded"); } }
Source:
public String addPages() { for (String page : this.allPagesSelection) { int aktuelleID = Integer.parseInt(page.split(":")[0]); boolean schonEnthalten = false; if (this.docStruct.getAllToReferences("logical_physical") != null) { for (ReferenceInterface referenceInterface : this.docStruct.getAllToReferences("logical_physical")) { if (referenceInterface.getTarget() == this.allPagesNew[aktuelleID - 1].getMd().getDocStruct()) { schonEnthalten = true; break; } } } if (!schonEnthalten) { this.docStruct.addReferenceTo(this.allPagesNew[aktuelleID - 1].getMd().getDocStruct(), "logical_physical"); } } determinePagesStructure(this.docStruct); this.allPagesSelection = null; if (!updateBlocked()) { return "SperrungAbgelaufen"; } return null; }

Target:
public String addPages() { for (String page : this.allPagesSelection) { int aktuelleID = Integer.parseInt(page.split(":")[0]); boolean schonEnthalten = false; if (this.docStruct.getAllToReferences("logical_physical") != null) { for (ReferenceInterface reference : this.docStruct.getAllToReferences("logical_physical")) { if (reference.getTarget() == this.allPagesNew[aktuelleID - 1].getMd().getDocStruct()) { schonEnthalten = true; break; } } } if (!schonEnthalten) { this.docStruct.addReferenceTo(this.allPagesNew[aktuelleID - 1].getMd().getDocStruct(), "logical_physical"); } } determinePagesStructure(this.docStruct); this.allPagesSelection = null; if (!updateBlocked()) { return "SperrungAbgelaufen"; } return null; }
Source:
public long getExpectedCompactedFileSize(Iterable<SSTableReader> sstables, OperationType operation) { if (operation != OperationType.CLEANUP || isIndex()) { return SSTableReader.getTotalBytes(sstables); } long expectedFileSize = 0; Collection<Range<Token>> ranges = StorageService.instance.getLocalReplicas(keyspace.getName()).asRangeSet(); for (SSTableReader sstable : sstables) { List<SSTableReader.PartitionPositionBounds> positions = sstable.getPositionsForRanges(ranges); for (SSTableReader.PartitionPositionBounds position : positions) expectedFileSize += position.upperPosition - position.lowerPosition; } double compressionRatio = metric.compressionRatio.getValue(); if (compressionRatio > 0d) expectedFileSize *= compressionRatio; return expectedFileSize; }

Target:
public long getExpectedCompactedFileSize(Iterable<SSTableReader> sstables, OperationType operation) { if (operation != OperationType.CLEANUP || isIndex()) { return SSTableReader.getTotalBytes(sstables); } long expectedFileSize = 0; Collection<Range<Token>> ranges = StorageService.instance.getLocalReplicas(keyspace.getName()).asUnmodifiableRangeCollection(); for (SSTableReader sstable : sstables) { List<SSTableReader.PartitionPositionBounds> positions = sstable.getPositionsForRanges(ranges); for (SSTableReader.PartitionPositionBounds position : positions) expectedFileSize += position.upperPosition - position.lowerPosition; } double compressionRatio = metric.compressionRatio.getValue(); if (compressionRatio > 0d) expectedFileSize *= compressionRatio; return expectedFileSize; }
Source:
public Object visit(ASTFieldDeclaration node, Object data) { if (!node.isStatic()) { return data; } ASTClassOrInterfaceType cit = node.getFirstDescendantOfType(ASTClassOrInterfaceType.class); if (cit == null || !TypeHelper.isA(cit, formatterClassToCheck)) { return data; } ASTVariableDeclaratorId var = node.getFirstDescendantOfType(ASTVariableDeclaratorId.class); for (String formatter: THREAD_SAFE_FORMATTER) { if (TypeHelper.isA(var, formatter)) { return data; } } for (NameOccurrence occ : var.getUsages()) { Node n = occ.getLocation(); if (n.getFirstParentOfType(ASTSynchronizedStatement.class) != null) { continue; } if (!n.getImage().contains(".")) { continue; } ASTMethodDeclaration method = n.getFirstParentOfType(ASTMethodDeclaration.class); if (method != null && (!method.isSynchronized() || !method.isStatic())) { addViolation(data, n); } } return data; }

Target:
public Object visit(ASTFieldDeclaration node, Object data) { if (!node.isStatic()) { return data; } ASTClassOrInterfaceType cit = node.getFirstDescendantOfType(ASTClassOrInterfaceType.class); if (cit == null || !TypeHelper.isA(cit, formatterClassToCheck)) { return data; } ASTVariableDeclaratorId var = node.getFirstDescendantOfType(ASTVariableDeclaratorId.class); for (String formatter: THREAD_SAFE_FORMATTER) { if (TypeHelper.isA(var, formatter)) { return data; } } for (NameOccurrence occ : var.getUsages()) { Node n = occ.getLocation(); if (!n.getImage().contains(".")) { continue; } if (getProperty(ALLOW_METHOD_LEVEL_SYNC)) { ASTMethodDeclaration method = n.getFirstParentOfType(ASTMethodDeclaration.class); if (method != null && (!method.isSynchronized() || !method.isStatic())) { addViolation(data, node); } continue; } ASTSynchronizedStatement syncStatement = n.getFirstParentOfType(ASTSynchronizedStatement.class); if (syncStatement != null) { ASTExpression expression = syncStatement.getFirstChildOfType(ASTExpression.class); if (expression != null) { ASTName name = expression.getFirstDescendantOfType(ASTName.class); if (name != null && name.hasImageEqualTo(var.getVariableName())) { continue; } } } addViolation(data, n); } return data; }
Source:
protected boolean doProcess(Record record) { for (Object value : record.get(inputFieldName)) { InetAddress addr; if (value instanceof InetAddress) { addr = (InetAddress) value; } else { try { addr = InetAddresses.forString(value.toString()); } catch (IllegalArgumentException e) { LOG.debug("Invalid IP string literal: {}", value); return false; } } JsonNode json; try { json = databaseReader.get(addr); } catch (IOException e) { throw new MorphlineRuntimeException("Cannot perform GeoIP lookup for IP: " + addr, e); } if (json != null) { ObjectNode location = (ObjectNode) json.get("location"); if (location != null) { JsonNode jlatitude = location.get("latitude"); JsonNode jlongitude = location.get("longitude"); if (jlatitude != null && jlongitude != null) { String latitude = jlatitude.toString(); String longitude = jlongitude.toString(); location.put("latitude_longitude", latitude + "," + longitude); location.put("longitude_latitude", longitude + "," + latitude); } } } else { json = objectMapper.createObjectNode(); } record.put(Fields.ATTACHMENT_BODY, json); } return super.doProcess(record); }

Target:
protected boolean doProcess(Record record) { final List values = record.get(inputFieldName); if (values.isEmpty()) { LOG.debug("No values found for field {}", inputFieldName); return false; } for (Object value : values) { InetAddress addr; if (value instanceof InetAddress) { addr = (InetAddress) value; } else { try { addr = InetAddresses.forString(value.toString()); } catch (IllegalArgumentException e) { LOG.debug("Invalid IP string literal: {}", value); return false; } } JsonNode json; try { json = databaseReader.get(addr); } catch (IOException e) { throw new MorphlineRuntimeException("Cannot perform GeoIP lookup for IP: " + addr, e); } if (json == null) { LOG.debug("No GeoIP record found for: {}", value); return false; } ObjectNode location = (ObjectNode) json.get("location"); if (location != null) { JsonNode jlatitude = location.get("latitude"); JsonNode jlongitude = location.get("longitude"); if (jlatitude != null && jlongitude != null) { String latitude = jlatitude.toString(); String longitude = jlongitude.toString(); location.put("latitude_longitude", latitude + "," + longitude); location.put("longitude_latitude", longitude + "," + latitude); } } record.put(Fields.ATTACHMENT_BODY, json); } return super.doProcess(record); }
Source:
private boolean ensure(int readSize) throws IOException { requireBuffer(); if(reachedEOF) { return false; } if(position + readSize < buffer.limit()) return true; else { int remaining = buffer.limit() - position; int bufferTotal = remaining; ArrayList<MessageBuffer> bufferList = new ArrayList<MessageBuffer>(); while(bufferTotal < readSize) { MessageBuffer next = in.next(); if(next == null) throw new EOFException(); bufferTotal += next.limit(); bufferList.add(next); } MessageBuffer newBuffer = MessageBuffer.newBuffer(bufferTotal); int p = 0; buffer.copyTo(position, newBuffer, p, remaining); p += remaining; for(MessageBuffer m : bufferList) { m.copyTo(0, newBuffer, p, m.limit()); p += m.limit(); } buffer = newBuffer; position = 0; return true; } }

Target:
private boolean ensure(int readSize) throws IOException { requireBuffer(); if(reachedEOF) { return false; } if(position + readSize < buffer.limit()) return true; else { int remaining = buffer.limit() - position; int bufferTotal = remaining; ArrayList<MessageBuffer> bufferList = new ArrayList<MessageBuffer>(); while(bufferTotal < readSize) { MessageBuffer next = in.next(); if(next == null) { reachedEOF = true; throw new EOFException(); } bufferTotal += next.limit(); bufferList.add(next); } MessageBuffer newBuffer = MessageBuffer.newBuffer(bufferTotal); int p = 0; buffer.copyTo(position, newBuffer, p, remaining); p += remaining; for(MessageBuffer m : bufferList) { m.copyTo(0, newBuffer, p, m.limit()); p += m.limit(); } buffer = newBuffer; position = 0; return true; } }
Source:
private void refillCache() { logger.info("Starting filling Owner Id to Topic Name cache"); long start = System.currentTimeMillis(); Multimap<OwnerId, TopicName> cache = ArrayListMultimap.create(); groupService.listGroupNames().stream() .flatMap(groupName -> topicRepository.listTopics(groupName).stream()) .forEach(topic -> cache.put(topic.getOwner(), topic.getName())); this.cache = Multimaps.synchronizedMultimap(cache); long end = System.currentTimeMillis(); logger.info("Cache filled. Took {}ms", end - start); }

Target:
private void refillCache() { try { logger.info("Starting filling Owner Id to Topic Name cache"); long start = System.currentTimeMillis(); Multimap<OwnerId, TopicName> cache = ArrayListMultimap.create(); groupService.listGroupNames().stream() .flatMap(groupName -> topicRepository.listTopics(groupName).stream()) .forEach(topic -> cache.put(topic.getOwner(), topic.getName())); this.cache = Multimaps.synchronizedMultimap(cache); long end = System.currentTimeMillis(); logger.info("Cache filled. Took {}ms", end - start); } catch (Exception e) { logger.error("Error while filling cache", e); } }
Source:
public FireHydrant getCurrHydrant() { synchronized (hydrantLock) { return currHydrant; } }

Target:
FireHydrant getCurrHydrant() { synchronized (hydrantLock) { return currHydrant; } }
Source:
public void disableAutoSetHostname() { canAutoSetHostname = disableOnHostnameChanged ? canAutoSetHostname : false; }

Target:
public void disableAutoSetHostname() { if (!disableOnHostnameChanged) { canAutoSetHostname = false; } }
Source:
public NinjaFileItemStreamConverter(NinjaProperties properties) { inMemory = properties.getBooleanWithDefault( NinjaConstant.FILE_UPLOADS_IN_MEMORY, false); String dir = properties.getWithDefault( NinjaConstant.FILE_UPLOADS_DIRECTORY, System.getProperty("java.io.tmpdir")); uploadDirectory = new File(dir); if (uploadDirectory.exists()) { if (!uploadDirectory.isDirectory()) { throw new ProvisionException("Specified target for upload files in not a directory"); } } else { uploadDirectory.mkdirs(); } }

Target:
NinjaFileItemStreamConverter(NinjaProperties properties) { Boolean b = properties.getBoolean(NinjaConstant.FILE_UPLOADS_IN_MEMORY); inMemory = b != null ? b.booleanValue() : false; }
Source:
public static EmbeddedDatastreamCluster initializeTestDatastreamServer(Properties override) throws Exception { DatastreamServer.INSTANCE.shutdown(); Map<String, Properties> connectorProperties = new HashMap<>(); connectorProperties.put(DUMMY_CONNECTOR, getDummyConnectorProperties(false)); EmbeddedDatastreamCluster datastreamKafkaCluster = EmbeddedDatastreamCluster.newTestDatastreamKafkaCluster(connectorProperties, -1); return datastreamKafkaCluster; }

Target:
public static EmbeddedDatastreamCluster initializeTestDatastreamServer(Properties override) throws Exception { DatastreamServer.INSTANCE.shutdown(); Map<String, Properties> connectorProperties = new HashMap<>(); connectorProperties.put(DUMMY_CONNECTOR, getDummyConnectorProperties(false)); EmbeddedDatastreamCluster datastreamKafkaCluster = EmbeddedDatastreamCluster.newTestDatastreamKafkaCluster(connectorProperties, override, -1); return datastreamKafkaCluster; }
Source:
private void checkSizeEstimatesTableExist() { try { session.getTable(new SchemaTableName(SYSTEM, SIZE_ESTIMATES)); } catch (NotFoundException e) { throw new PrestoException(NOT_SUPPORTED, "Cassandra versions prior to 2.1.5 are not supported"); } }

Target:
private void checkSizeEstimatesTableExist() { try { session.getTable(new SchemaTableName(SYSTEM, SIZE_ESTIMATES)); } catch (TableNotFoundException e) { throw new PrestoException(NOT_SUPPORTED, "Cassandra versions prior to 2.1.5 are not supported"); } }
Source:
private void downgradeToVersion5(SQLiteDatabase db) { Cursor cursor = db.query(INSTANCES_TABLE_NAME, null, null, null, null, null, null); if (cursor != null && cursor.moveToFirst()) { List<Instance> instances = new InstancesDao().getInstancesFromCursor(cursor); for (Instance instance : instances) { if (instance.getInstanceFilePath().startsWith("../")) { String where = INSTANCE_FILE_PATH + "=?"; String[] whereArgs = {instance.getInstanceFilePath()}; ContentValues values = new ContentValues(); values.put(INSTANCE_FILE_PATH, Collect.ODK_ROOT + instance.getInstanceFilePath().substring(2)); db.update(INSTANCES_TABLE_NAME, values, where, whereArgs); } } } if (cursor != null) { cursor.close(); } }

Target:
private void downgradeToVersion5(SQLiteDatabase db) { Cursor cursor = db.query(INSTANCES_TABLE_NAME, null, null, null, null, null, null); if (cursor != null && cursor.moveToFirst()) { List<Instance> instances = new InstancesDao().getInstancesFromCursor(cursor); for (Instance instance : instances) { File instanceFile = new File(instance.getInstanceFilePath()); if (!instanceFile.isAbsolute()) { String where = _ID + "=?"; String[] whereArgs = {String.valueOf(instance.getDatabaseId())}; ContentValues values = new ContentValues(); values.put(INSTANCE_FILE_PATH, Collect.ODK_ROOT + FileUtils.getCanonicalPath(instanceFile)); db.update(INSTANCES_TABLE_NAME, values, where, whereArgs); } } } if (cursor != null) { cursor.close(); } }
Source:
public void truncFailTest() throws Exception { final boolean[] exitProcCalled = {false}; ServiceUtils.setSystemExitProcedure(new Consumer<Integer>() { @Override public void accept(Integer exitCode) { exitProcCalled[0] = true; assertThat(exitCode, equalTo(ExitCode.QUORUM_PACKET_ERROR.getValue())); } }); File tmpFile = File.createTempFile("test", ".dir", testData); tmpFile.delete(); try { FileTxnSnapLog txnSnapLog = new FileTxnSnapLog(tmpFile, tmpFile); SimpleLearner sl = new SimpleLearner(txnSnapLog); long startZxid = sl.zk.getLastProcessedZxid(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); BinaryOutputArchive oa = BinaryOutputArchive.getArchive(baos); sl.leaderOs = BinaryOutputArchive.getArchive(new ByteArrayOutputStream()); sl.bufferedOutput = new BufferedOutputStream(System.out); sl.sock = new Socket(); QuorumPacket qp = new QuorumPacket(Leader.TRUNC, 0, null, null); oa.writeRecord(qp, null); sl.leaderIs = BinaryInputArchive.getArchive(new ByteArrayInputStream(baos.toByteArray())); try { sl.syncWithLeader(3); } catch (EOFException e) { } sl.zk.shutdown(); assertThat(startZxid, equalTo(0L)); assertThat(exitProcCalled[0], is(true)); } finally { TestUtils.deleteFileRecursively(tmpFile); } }

Target:
public void truncFailTest() throws Exception { final boolean[] exitProcCalled = {false}; ServiceUtils.setSystemExitProcedure(new Consumer<Integer>() { @Override public void accept(Integer exitCode) { exitProcCalled[0] = true; assertThat("System.exit() was called with invalid exit code", exitCode, equalTo(ExitCode.QUORUM_PACKET_ERROR.getValue())); } }); File tmpFile = File.createTempFile("test", ".dir", testData); tmpFile.delete(); try { FileTxnSnapLog txnSnapLog = new FileTxnSnapLog(tmpFile, tmpFile); SimpleLearner sl = new SimpleLearner(txnSnapLog); long startZxid = sl.zk.getLastProcessedZxid(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); BinaryOutputArchive oa = BinaryOutputArchive.getArchive(baos); sl.leaderOs = BinaryOutputArchive.getArchive(new ByteArrayOutputStream()); sl.bufferedOutput = new BufferedOutputStream(System.out); sl.sock = new Socket(); QuorumPacket qp = new QuorumPacket(Leader.TRUNC, 0, null, null); oa.writeRecord(qp, null); sl.leaderIs = BinaryInputArchive.getArchive(new ByteArrayInputStream(baos.toByteArray())); try { sl.syncWithLeader(3); } catch (EOFException e) { } sl.zk.shutdown(); assertThat("System.exit() should have been called", exitProcCalled[0], is(true)); } finally { TestUtils.deleteFileRecursively(tmpFile); } }
Source:
private void refreshRating() { if (getCampaign().getCampaignOptions().useDragoonRating()) { getCampaign().getUnitRating().reInitialize(); String text = "<html><b>Dragoons Rating:</b> " + getCampaign().getUnitRatingText() + "</html>"; lblRating.setText(text); } else { lblRating.setText(""); } }

Target:
private void refreshRating() { if (getCampaign().getCampaignOptions().useDragoonRating()) { getCampaign().getUnitRating().reInitialize(); String text; if (UnitRatingMethod.FLD_MAN_MERCS_REV.equals(getCampaign().getCampaignOptions().getUnitRatingMethod())) { text = String.format(resourceMap.getString("bottomRating.DragoonsRating"), getCampaign().getUnitRatingText()); } else { text = String.format(resourceMap.getString("bottomRating.CampaignOpsRating"), getCampaign().getUnitRatingText()); } lblRating.setText(text); } else { lblRating.setText(""); } }
Source:
public PatchSetAttribute asPatchSetAttribute(final PatchSet patchSet) { PatchSetAttribute p = new PatchSetAttribute(); p.revision = patchSet.getRevision().get(); p.number = Integer.toString(patchSet.getPatchSetId()); p.ref = patchSet.getRefName(); p.uploader = asAccountAttribute(patchSet.getUploader()); p.createdOn = patchSet.getCreatedOn().getTime() / 1000L; try { final ReviewDb db = schema.open(); try { p.parentsRevision = patchSetInfoFactory.get(db, patchSet.getId()).getParentRevisons(); } finally { db.close(); } } catch (PatchSetInfoNotAvailableException e) { log.error(e); e.printStackTrace(); } catch (OrmException e) { log.error(e); e.printStackTrace(); } return p; }

Target:
public PatchSetAttribute asPatchSetAttribute(final PatchSet patchSet) { PatchSetAttribute p = new PatchSetAttribute(); p.revision = patchSet.getRevision().get(); p.number = Integer.toString(patchSet.getPatchSetId()); p.ref = patchSet.getRefName(); p.uploader = asAccountAttribute(patchSet.getUploader()); p.createdOn = patchSet.getCreatedOn().getTime() / 1000L; try { final ReviewDb db = schema.open(); try { p.parentsRevision = new ArrayList<String>(); for (PatchSetAncestor a : db.patchSetAncestors().ancestorsOf( patchSet.getId())) { p.parentsRevision.add(a.getAncestorRevision().get()); } } finally { db.close(); } } catch (OrmException e) { log.error("Cannot load patch set data for " + patchSet.getId(), e); } return p; }
Source:
private Optional<JavaFileScannerContext.Location> flowFromThrownException(ExplodedGraph.Edge edge) { if (isMethodInvocationNode(edge.parent)) { SymbolicValue peekValue = edge.child.programState.peekValue(); if (peekValue instanceof SymbolicValue.ExceptionalSymbolicValue) { Type type = ((SymbolicValue.ExceptionalSymbolicValue) peekValue).exceptionType(); String msg = type == null ? "Exception is thrown." : ("'" + type.name() + "' is thrown."); return Optional.of(location(edge.parent, msg)); } } return Optional.empty(); }

Target:
private Optional<JavaFileScannerContext.Location> flowFromThrownException(ExplodedGraph.Edge edge) { if (isMethodInvocationNode(edge.parent)) { SymbolicValue peekValue = edge.child.programState.peekValue(); if (peekValue instanceof SymbolicValue.ExceptionalSymbolicValue) { Type type = ((SymbolicValue.ExceptionalSymbolicValue) peekValue).exceptionType(); String msg = String.format("%s is thrown.", type == null ? "Exception" : ("'" + type.name() + "'")); return Optional.of(location(edge.parent, msg)); } } return Optional.empty(); }
Source:
public int indexOf(Object o) { for (Entry<Integer, E> entry : fInnerElements.entrySet()) { if (Objects.equals(entry.getValue(), o)) { return entry.getKey(); } } return -1; }

Target:
public int indexOf(Object o) { if (o == null && contains(null)) { for (int i = 0; i < size(); i++) { if (!fInnerElements.containsKey(i)) { return i; } } } for (Entry<Integer, E> entry : fInnerElements.entrySet()) { if (Objects.equals(entry.getValue(), o)) { return entry.getKey(); } } return -1; }
Source:
public void loseQuorum() { LeadershipToken token = state.gainLeadership(0); for (int i = 1; i < NUM_POTENTIAL_LEADERS - QUORUM_SIZE + 2; i++) { state.goDown(i); } assertNotSame("leader cannot maintain leadership withou quorum", state.leader(0).isStillLeading(token), StillLeadingStatus.LEADING); state.comeUp(1); state.gainLeadership(0); assertNotSame("leader can confirm leadership with quorum", state.leader(0).isStillLeading(token), StillLeadingStatus.NOT_LEADING); }

Target:
public void loseQuorum() { LeadershipToken token = state.gainLeadership(0); for (int i = 1; i < NUM_POTENTIAL_LEADERS - QUORUM_SIZE + 2; i++) { state.goDown(i); } assertNotSame("leader cannot maintain leadership without quorum", state.leader(0).isStillLeading(token), StillLeadingStatus.LEADING); state.comeUp(1); state.gainLeadership(0); assertNotSame("leader can confirm leadership with quorum", state.leader(0).isStillLeading(token), StillLeadingStatus.NOT_LEADING); }
Source:
public void fetchesRawRepresentation() throws Exception { final Contents contents = MkContentTest.repo().contents(); final String raw = "raw test"; final InputStream stream = contents.create( jsonContent("raw.txt", "for raw", raw) ).raw(); try { MatcherAssert.assertThat( IOUtils.toString(stream), Matchers.is(raw) ); } finally { stream.close(); } }

Target:
public void fetchesRawRepresentation() throws Exception { final Contents contents = MkContentTest.repo().contents(); final String raw = "raw test \u20ac\u0000"; final InputStream stream = contents.create( jsonContent("raw.txt", "for raw", raw) ).raw(); try { MatcherAssert.assertThat( IOUtils.toString(stream), Matchers.is(raw) ); } finally { stream.close(); } }
Source:
protected boolean validateResource(ScriptRequest request, BinaryResource responseCandidate) { String requestedFingerprint = request.fingerprint(); if (!StringUtility.hasText(requestedFingerprint)) { return true; } String responseFingerprint = HtmlDocumentParser.createFingerprintFor(responseCandidate); if (requestedFingerprint.equals(responseFingerprint)) { return true; } LOG.debug("Resource '{}' having fingerprint '{}' could not be found. A resource was found but would have different fingerprint '{}'.", request, requestedFingerprint, responseFingerprint); return false; }

Target:
protected boolean validateResource(ScriptRequest request, BinaryResource responseCandidate) { String requestedFingerprint = request.fingerprint(); if (!StringUtility.hasText(requestedFingerprint)) { return true; } String responseFingerprint = responseCandidate.getFingerprintAsHexString(); if (requestedFingerprint.equals(responseFingerprint)) { return true; } LOG.debug("Resource '{}' having fingerprint '{}' could not be found. A resource was found but would have a different fingerprint '{}'.", request, requestedFingerprint, responseFingerprint); return false; }