auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public Collection<IInstallableUnit> resolve() { if (!addedLocationsHaveContent()) { return Collections.emptySet(); } ResolutionDataImpl data = new ResolutionDataImpl(executionEnvironment); data.setRootIUs(rootIUs); data.setAvailableIUsAndFilter(compoundQueriable(availableUnitSources)); AbstractResolutionStrategy strategy = getResolutionStrategy(); strategy.setData(data); Collection<IInstallableUnit> units = strategy.multiPlatformResolve(environments, monitor); if (includeSource) { ArrayList<IRequirement> requirements = new ArrayList<IRequirement>(); for (IInstallableUnit unit : units) { requirements .add(MetadataFactory.createRequirement("osgi.bundle", unit.getId() + ".source", new VersionRange(unit.getVersion(), true, unit.getVersion(), true), null, true, false, true)); } InstallableUnit sourceIU = new InstallableUnit(); sourceIU.setRequiredCapabilities(requirements.toArray(new IRequirement[requirements.size()])); data.setRootIUs(Collections.singleton((IInstallableUnit) sourceIU)); Collection<IInstallableUnit> sourceUnits = strategy.resolve(new TargetEnvironment(), monitor); sourceUnits.remove(sourceIU); units.addAll(sourceUnits); } return units; }

Target:
public Collection<IInstallableUnit> resolve() throws TargetDefinitionResolutionException, ResolverException { if (!addedLocationsHaveContent()) { return Collections.emptySet(); } ResolutionDataImpl data = new ResolutionDataImpl(executionEnvironment); data.setRootIUs(rootIUs); data.setAvailableIUsAndFilter(compoundQueriable(availableUnitSources)); AbstractResolutionStrategy strategy = getResolutionStrategy(); strategy.setData(data); Collection<IInstallableUnit> units = strategy.multiPlatformResolve(environments, monitor); if (includeSource && !units.isEmpty()) { final IRequirement bundleRequirement = MetadataFactory.createRequirement( "org.eclipse.equinox.p2.eclipse.type", "bundle", null, null, false, false, false); ArrayList<IRequirement> requirements = new ArrayList<IRequirement>(); for (IInstallableUnit unit : units) { if (unit.satisfies(bundleRequirement)) { requirements.add(MetadataFactory.createRequirement("osgi.bundle", unit.getId() + ".source", new VersionRange(unit.getVersion(), true, unit.getVersion(), true), null, true, false, true)); } } InstallableUnitDescription sourceDescription = new MetadataFactory.InstallableUnitDescription(); sourceDescription.setSingleton(true); sourceDescription.setId(SOURCE_IU_ID); Version sourceIUVersion = Version.createOSGi(1, 0, 0); sourceDescription.setVersion(sourceIUVersion); sourceDescription.addRequirements(requirements); IProvidedCapability capability = MetadataFactory.createProvidedCapability( IInstallableUnit.NAMESPACE_IU_ID, SOURCE_IU_ID, sourceIUVersion); sourceDescription.setCapabilities(new IProvidedCapability[] { capability }); IInstallableUnit sourceIU = MetadataFactory.createInstallableUnit(sourceDescription); data.setRootIUs(Collections.singleton((IInstallableUnit) sourceIU)); Collection<IInstallableUnit> sourceUnits = strategy.resolve(new TargetEnvironment(), monitor); sourceUnits.remove(sourceIU); units.addAll(sourceUnits); } return units; }
Source:
public JsonElement serialize(Date date, Type typeOfSrc, JsonSerializationContext context) { String dateString = format.format(date); return new JsonPrimitive(dateString); }

Target:
public JsonElement serialize(Date date, Type typeOfSrc, JsonSerializationContext context) { String dateString = getFormat().format(date); return new JsonPrimitive(dateString); }
Source:
public Optional<String> getMetadata(String id) { GetRequestBuilder request = esClient.prepareGet(MetadataIndexDefinition.INDEX_TYPE_METADATA, id) .setStoredFields(MetadataIndexDefinition.FIELD_VALUE); GetResponse response = request.get(); if (response.isExists()) { GetField field = response.getField(MetadataIndexDefinition.FIELD_VALUE); String value = String.valueOf(field.getValue()); return Optional.of(value); } return Optional.empty(); }

Target:
private Optional<String> getMetadata(String id) { GetRequestBuilder request = esClient.prepareGet(MetadataIndexDefinition.INDEX_TYPE_METADATA, id) .setStoredFields(MetadataIndexDefinition.FIELD_VALUE); GetResponse response = request.get(); if (response.isExists()) { GetField field = response.getField(MetadataIndexDefinition.FIELD_VALUE); String value = String.valueOf(field.getValue()); return Optional.of(value); } return Optional.empty(); }
Source:
public void modified(final Map<String, Object> configuration) { logger.debug("modified"); logger.debug("Cardio2e binding will be deactivated and reactivated to apply new configuration..."); purgeCardio2eBinding(); initializeCardio2eBinding(configuration); }

Target:
public void modified(final Map<String, Object> configuration) { logger.info("Configuration was been modified. Cardio2e binding will be deactivated and reactivated to apply new configuration..."); purgeCardio2eBinding(); initializeCardio2eBinding(configuration); }
Source:
public void postsPullComment() throws Exception { final MkStorage storage = new MkStorage.InFile(); final String body = "body"; final String commit = "commit_id"; final String path = "path"; MkPullCommentsTest.repo(storage).pulls() .create("pullrequest1", "head", "base").comments() .post(body, commit, path, 1); final String[] fields = {body, commit, path}; for (final String element : fields) { MkPullCommentsTest.assertFieldContains(storage, element); } final List<String> xpath = storage.xml().xpath( "/github/repos/repo[@coords='test/test']/pulls/pull/comments/comment/position/text()" ); MatcherAssert.assertThat( xpath.get(0), Matchers.notNullValue() ); }

Target:
public void postsPullComment() throws Exception { final MkStorage storage = new MkStorage.InFile(); final String commit = "commit_id"; final String path = "path"; final String bodytext = "some text as a body"; MkPullCommentsTest.repo(storage).pulls() .create("pullrequest1", "head", "base").comments() .post(bodytext, commit, path, 1); final String[] fields = {commit, path}; for (final String element : fields) { MkPullCommentsTest.assertFieldContains(storage, element); } final List<String> position = storage.xml().xpath( "/github/repos/repo[@coords='test/test']/pulls/pull/comments/comment/position/text()" ); MatcherAssert.assertThat( position.get(0), Matchers.notNullValue() ); final List<String> body = storage.xml().xpath( "/github/repos/repo[@coords='test/test']/pulls/pull/comments/comment/body/text()" ); MatcherAssert.assertThat(body.get(0), Matchers.equalTo(bodytext)); }
Source:
private static void computeInterfaceOrder(Class[] interfaces, Collection classes, Set seen) { List newInterfaces = new ArrayList(interfaces.length); for (Class aInterface : interfaces) { if (seen.add(aInterface)) { classes.add(aInterface); newInterfaces.add(aInterface); } } for (Iterator it = newInterfaces.iterator(); it.hasNext();) computeInterfaceOrder(((Class) it.next()).getInterfaces(), classes, seen); }

Target:
private static void computeInterfaceOrder(Class[] interfaces, Collection classes, Set seen) { List newInterfaces = new ArrayList(interfaces.length); for (Class interfaze : interfaces) { if (seen.add(interfaze)) { classes.add(interfaze); newInterfaces.add(interfaze); } } for (Iterator it = newInterfaces.iterator(); it.hasNext();) computeInterfaceOrder(((Class) it.next()).getInterfaces(), classes, seen); }
Source:
public @Nullable ITimeGraphEntry[] getElements(@Nullable Object inputElement) { if (inputElement != null) { try { List<?> list = (List<?>) inputElement; if (list.size() == 0) { return new ITimeGraphEntry[0]; } Object obj = list.get(0); if (!(obj instanceof CriticalPathBaseEntry)) { return new ITimeGraphEntry[0]; } Object worker = ((CriticalPathBaseEntry) obj).getWorker(); fCurrentObject = worker; Map<Object, CriticalPathEntry> entries = workerMaps.get(worker); if (entries != null) { return entries.values().toArray(new ITimeGraphEntry[entries.size()]); } entries = buildEntryList(worker); if (entries == null) { return new ITimeGraphEntry[0]; } workerMaps.put(worker, entries); return entries.values().toArray(new ITimeGraphEntry[entries.size()]); } catch (ClassCastException e) { } } return new ITimeGraphEntry[0]; }

Target:
public @Nullable ITimeGraphEntry[] getElements(@Nullable Object inputElement) { if (inputElement != null) { try { List<?> list = (List<?>) inputElement; if (list.size() == 0) { return new ITimeGraphEntry[0]; } Object obj = list.get(0); if (!(obj instanceof CriticalPathBaseEntry)) { return new ITimeGraphEntry[0]; } IGraphWorker worker = ((CriticalPathBaseEntry) obj).getWorker(); fCurrentObject = worker; List<TimeGraphEntry> entries = workerEntries.get(worker); if (entries == null) { buildEntryList(worker); entries = workerEntries.get(worker); } if (entries == null) { return new ITimeGraphEntry[0]; } return entries.toArray(new ITimeGraphEntry[entries.size()]); } catch (ClassCastException e) { } } return new ITimeGraphEntry[0]; }
Source:
public static void assertHasCodeReviewLabels(ChangeInfo changeInfo) { assertThat(changeInfo, notNullValue()); Map<String, LabelInfo> labels = changeInfo.getLabels(); assertThat(labels, not(empty())); assertThat(labels.size(), is(1)); assertThat(labels, Matchers.<String, LabelInfo> hasKey("Code-Review")); Map<String, String> values = labels.get("Code-Review").getValues(); assertThat(values, not(empty())); assertThat(values.size(), is(5)); assertThat(values, Matchers.<String, String> hasKey("-2")); assertThat(values, Matchers.<String, String> hasKey("-1")); assertThat(values, Matchers.<String, String> hasKey(" 0")); assertThat(values, Matchers.<String, String> hasKey("+1")); assertThat(values, Matchers.<String, String> hasKey("+2")); assertThat(values.get("-2"), equalTo(CRVW.getValue((short) -2).getName())); assertThat(values.get("-1"), equalTo(CRVW.getValue((short) -1).getName())); assertThat(values.get(" 0"), equalTo(CRVW.getValue((short) 0).getName())); assertThat(values.get("+1"), equalTo(CRVW.getValue((short) 1).getName())); assertThat(values.get("+2"), equalTo(CRVW.getValue((short) 2).getName())); }

Target:
public static void assertHasCodeReviewLabels(ChangeInfo changeInfo) { assertHasCodeReviewLabels(changeInfo, false); }
Source:
public File captureWebElement(WebElement element, WebDriver driver) { File screen = capturePage(driver); Point start = element.getLocation(); int width = element.getSize().getWidth(); return cropImage(start, element.getSize(), screen); }

Target:
public File captureWebElement(WebElement element, WebDriver driver) { File screen = capturePage(driver); Point start = element.getLocation(); return cropImage(start, element.getSize(), screen); }
Source:
protected RequestTemplate resolve(Object[] argv, RequestTemplate mutable, Map<String, Object> variables) { if ("POST".equals(metadata.template().method()) && argv == null) { encoder.encode("", String.class, mutable); } return mutable.resolve(variables); }

Target:
protected RequestTemplate resolve(Object[] argv, RequestTemplate mutable, Map<String, Object> variables) { return mutable.resolve(variables); }
Source:
public String toString() { StringBuilder builder = new StringBuilder(StringUtil.simpleClassName(this)).append('['); for (String subscription : topics) { builder.append("topicName = ").append(subscription).append(", "); } if (!topics.isEmpty()) { builder.setLength(builder.length() - 2); } return builder.append("]").toString(); }

Target:
public String toString() { StringBuilder builder = new StringBuilder(StringUtil.simpleClassName(this)).append('['); for (int i = 0; i < topics.size(); i++) { builder.append("topicName = ").append(topics.get(i)).append(", "); } if (!topics.isEmpty()) { builder.setLength(builder.length() - 2); } return builder.append("]").toString(); }
Source:
protected void executeQueryCommand() { List<Disk> diskList = DbFacade.getInstance() .getDiskDao() .getAllAttachableDisksByPoolId(getParameters().getStoragePoolId(), getParameters().getVmId(), getUserID(), getParameters().isFiltered()); if (CollectionUtils.isEmpty(diskList)) { setReturnValue(Collections.emptyList()); return; } VM vm = DbFacade.getInstance().getVmDao().get(getParameters().getVmId(), getUserID(), getParameters().isFiltered()); if (vm == null) { setReturnValue(Collections.emptyList()); return; } List<String> supportedDiskInterfaceNames = getOsRepository().getDiskInterfaces(vm.getOs(), vm.getVdsGroupCompatibilityVersion()); Collection<DiskInterface> supportedDiskInterfaces = new HashSet<DiskInterface>(); for (String interfaceName : supportedDiskInterfaceNames) { try { supportedDiskInterfaces.add(DiskInterface.valueOf(interfaceName)); } catch (IllegalArgumentException e) { LOG.errorFormat("Can't find the value {0} in the enum DiskInterface. Error: {1}", ((interfaceName == null) ? "null" : interfaceName), e.toString()); } } List<Disk> filteredDiskList = new ArrayList<Disk>(); for (Disk disk : diskList) { if (supportedDiskInterfaces.contains(disk.getDiskInterface())) { filteredDiskList.add(disk); } } setReturnValue(filteredDiskList); }

Target:
protected void executeQueryCommand() { List<Disk> diskList = DbFacade.getInstance() .getDiskDao() .getAllAttachableDisksByPoolId(getParameters().getStoragePoolId(), getParameters().getVmId(), getUserID(), getParameters().isFiltered()); if (CollectionUtils.isEmpty(diskList)) { setReturnValue(new ArrayList<>()); return; } VM vm = DbFacade.getInstance().getVmDao().get(getParameters().getVmId(), getUserID(), getParameters().isFiltered()); if (vm == null) { setReturnValue(new ArrayList<>()); return; } List<Disk> filteredDiskList = new ArrayList<Disk>(); for (Disk disk : diskList) { if (DiskValidator.isDiskInterfaceSupportedByOs(disk.getDiskInterface(), vm.getOs(), vm.getVdsGroupCompatibilityVersion())) { filteredDiskList.add(disk); } } setReturnValue(filteredDiskList); }
Source:
protected void compareStoreConfiguration(String name, StoreConfiguration beforeStore, StoreConfiguration afterStore) { if (beforeStore instanceof AbstractStoreConfiguration) { AbstractStoreConfiguration beforeASC = (AbstractStoreConfiguration) beforeStore; AbstractStoreConfiguration afterASC = (AbstractStoreConfiguration) afterStore; compareAttributeSets(name, beforeASC.attributes(), afterASC.attributes()); } else { throw new IllegalArgumentException("Cannot compare stores of type: "+beforeStore.getClass().getName()); } }

Target:
protected void compareStoreConfiguration(String name, StoreConfiguration beforeStore, StoreConfiguration afterStore) { if (beforeStore instanceof AbstractStoreConfiguration) { AbstractStoreConfiguration beforeASC = (AbstractStoreConfiguration) beforeStore; AbstractStoreConfiguration afterASC = (AbstractStoreConfiguration) afterStore; compareAttributeSets(name, beforeASC.attributes(), afterASC.attributes()); compareAttributeSets(name, beforeASC.singletonStore().attributes(), afterASC.singletonStore().attributes()); compareAttributeSets(name, beforeASC.async().attributes(), afterASC.async().attributes()); } else { throw new IllegalArgumentException("Cannot compare stores of type: "+beforeStore.getClass().getName()); } }
Source:
public String getTypeImage() { if (isTypeInferred()) { return getImage(); } ASTClassOrInterfaceType refType = getFirstDescendantOfType(ASTClassOrInterfaceType.class); if (refType != null) { return refType.getImage(); } return getFirstDescendantOfType(ASTPrimitiveType.class).getImage(); }

Target:
public String getTypeImage() { ASTClassOrInterfaceType refType = getFirstDescendantOfType(ASTClassOrInterfaceType.class); if (refType != null) { return refType.getImage(); } return getFirstDescendantOfType(ASTPrimitiveType.class).getImage(); }
Source:
public void convertSemVerToAvailableVersion() { Assert.assertEquals("1.10.0", PipHelper.convertSemVerToAvailableVersion(PipHelper.DEV_SEM_VER)); Assert.assertEquals("1.10.0", PipHelper.convertSemVerToAvailableVersion(null)); Assert.assertEquals("1.7.0", PipHelper.convertSemVerToAvailableVersion("1.7.0-snapshot")); Assert.assertEquals("1.7.0", PipHelper.convertSemVerToAvailableVersion("1.7.0")); Assert.assertEquals("1.6.0", PipHelper.convertSemVerToAvailableVersion("1.6.0-snapshot")); Assert.assertEquals("1.6.0", PipHelper.convertSemVerToAvailableVersion("1.6.0")); Assert.assertEquals("1.5.0", PipHelper.convertSemVerToAvailableVersion("1.5.0-snapshot")); Assert.assertEquals("1.5.0", PipHelper.convertSemVerToAvailableVersion("1.5.0")); Assert.assertEquals("1.4.0", PipHelper.convertSemVerToAvailableVersion("1.4.0-snapshot")); Assert.assertEquals("1.4.0", PipHelper.convertSemVerToAvailableVersion("1.4.0")); Assert.assertEquals("1.4.0", PipHelper.convertSemVerToAvailableVersion("1.3.0-snapshot")); Assert.assertEquals("1.4.0", PipHelper.convertSemVerToAvailableVersion("1.3.0")); }

Target:
public void convertSemVerToAvailableVersion() { Assert.assertEquals("1.10.0", PipHelper.convertSemVerToAvailableVersion(PipHelper.DEV_SEM_VER)); Assert.assertEquals("1.10.0", PipHelper.convertSemVerToAvailableVersion(null)); Assert.assertEquals("1.10.0", PipHelper.convertSemVerToAvailableVersion("9000.9000.9000")); Assert.assertEquals("1.10.0", PipHelper.convertSemVerToAvailableVersion("1.10.0-snapshot")); Assert.assertEquals("1.10.0", PipHelper.convertSemVerToAvailableVersion("1.10.1")); Assert.assertEquals("1.10.0", PipHelper.convertSemVerToAvailableVersion("1.10.0")); Assert.assertEquals("1.7.0", PipHelper.convertSemVerToAvailableVersion("1.7.0-snapshot")); Assert.assertEquals("1.7.0", PipHelper.convertSemVerToAvailableVersion("1.7.0")); Assert.assertEquals("1.6.0", PipHelper.convertSemVerToAvailableVersion("1.6.0-snapshot")); Assert.assertEquals("1.6.0", PipHelper.convertSemVerToAvailableVersion("1.6.0")); Assert.assertEquals("1.5.0", PipHelper.convertSemVerToAvailableVersion("1.5.0-snapshot")); Assert.assertEquals("1.5.0", PipHelper.convertSemVerToAvailableVersion("1.5.0")); Assert.assertEquals("1.4.0", PipHelper.convertSemVerToAvailableVersion("1.4.0-snapshot")); Assert.assertEquals("1.4.0", PipHelper.convertSemVerToAvailableVersion("1.4.0")); Assert.assertEquals("1.4.0", PipHelper.convertSemVerToAvailableVersion("1.3.0-snapshot")); Assert.assertEquals("1.4.0", PipHelper.convertSemVerToAvailableVersion("1.3.0")); }
Source:
static void validateTagUniqueness(String type, List<Value> values) { BitSet tags = new BitSet(); for (Value value : values) { int tag = value.getTag(); if (tags.get(tag)) { throw new IllegalStateException("Duplicate tag " + tag + " in " + type); } tags.set(tag); } }

Target:
static void validateTagUniqueness(String type, List<Value> values) { Set<Integer> tags = new LinkedHashSet<Integer>(); for (Value value : values) { int tag = value.getTag(); if (!tags.add(tag)) { throw new IllegalStateException("Duplicate tag " + tag + " in " + type); } } }
Source:
public Repo<Master> call(long tid, Master master) throws Exception { UniqueNameAllocator namer = master.getContext().getUniqueNameAllocator(); Path exportDir = new Path(tableInfo.exportDir); Set<String> tableDirs = ServerConstants.getTablesDirs(master.getContext()); log.info("Looking for matching filesystem for " + exportDir + " from options " + tableDirs); Path base = master.getFileSystem().matchingFileSystem(exportDir, tableDirs); if (base == null) { throw new IOException(tableInfo.exportDir + " is not in a volume configured for Accumulo"); } log.info("Chose base table directory of " + base); Path directory = new Path(base, tableInfo.tableId.canonical()); Path newBulkDir = new Path(directory, Constants.BULK_PREFIX + namer.getNextName()); tableInfo.importDir = newBulkDir.toString(); log.info("Using import dir: " + tableInfo.importDir); return new MapImportFileNames(tableInfo); }

Target:
public Repo<Master> call(long tid, Master master) throws Exception { UniqueNameAllocator namer = master.getContext().getUniqueNameAllocator(); Path exportDir = new Path(tableInfo.exportDir); Set<String> tableDirs = ServerConstants.getTablesDirs(master.getContext()); log.info("Looking for matching filesystem for from options {}", exportDir, tableDirs); Path base = master.getFileSystem().matchingFileSystem(exportDir, tableDirs); if (base == null) { throw new IOException(tableInfo.exportDir + " is not in a volume configured for Accumulo"); } log.info("Chose base table directory of " + base); Path directory = new Path(base, tableInfo.tableId.canonical()); Path newBulkDir = new Path(directory, Constants.BULK_PREFIX + namer.getNextName()); tableInfo.importDir = newBulkDir.toString(); log.info("Using import dir: " + tableInfo.importDir); return new MapImportFileNames(tableInfo); }
Source:
public String toString() { return "StatusOnlyReturnForXmlRpc [mStatus" + mStatus + "]"; }

Target:
public String toString() { return getClass().getSimpleName() + " [mStatus=" + mStatus + "]"; }
Source:
protected CtfTmfEvent getEvent(int rank) { ITmfContext ctx = fTrace.getTrace().seekEvent(0); for (int i = 0; i < rank; i++) { fTrace.getTrace().getNext(ctx); } final CtfTmfEvent next = fTrace.getTrace().getNext(ctx); ctx.dispose(); return next; }

Target:
protected CtfTmfEvent getEvent(int rank) { ITmfContext ctx = fTrace.getTrace().seekEvent(rank); final CtfTmfEvent next = fTrace.getTrace().getNext(ctx); ctx.dispose(); return next; }
Source:
@Override public void enqueue(final Callback<T> callback) { synchronized (this) { if (executed) throw new IllegalStateException("Already executed"); executed = true; } task = backgroundExecutor.submit(new Runnable() { private void callFailure(final Throwable throwable) { callbackExecutor.execute(new Runnable() { @Override public void run() { try { callback.failure(throwable); } catch (Throwable t) { t.printStackTrace(); } } }); } private void callSuccess(final Response<T> response) { callbackExecutor.execute(new Runnable() { @Override public void run() { try { callback.success(response); } catch (Throwable t) { t.printStackTrace(); } } }); } @Override public void run() { Response<T> response; try { response = getResponse(); } catch (IOException e) { callFailure(e); return; } callSuccess(response); } }); }

Target:
@Override public void enqueue(final Callback<T> callback) { synchronized (this) { if (executed) throw new IllegalStateException("Already executed"); executed = true; } task = backgroundExecutor.submit(new Runnable() { private void callFailure(final Throwable throwable) { callbackExecutor.execute(new Runnable() { @Override public void run() { try { callback.onFailure(throwable); } catch (Throwable t) { Thread thread = Thread.currentThread(); thread.getUncaughtExceptionHandler().uncaughtException(thread, t); } } }); } private void callSuccess(final Response<T> response) { callbackExecutor.execute(new Runnable() { @Override public void run() { try { callback.onResponse(response); } catch (Throwable t) { Thread thread = Thread.currentThread(); thread.getUncaughtExceptionHandler().uncaughtException(thread, t); } } }); } @Override public void run() { Response<T> response; try { response = getResponse(); } catch (IOException e) { callFailure(e); return; } catch (InterruptedException e) { callFailure(new InterruptedIOException("canceled")); return; } callSuccess(response); } }); }
Source:
public void clear() throws StoreAccessException { createBackend(); }

Target:
public void clear() { this.map = map.clear(); }
Source:
public boolean isConstexpr() { ICPPASTDeclSpecifier declSpec = getDeclSpecifier(); if (declSpec == null) { ICPPASTFunctionDeclarator dtor = getPreferredDtor(); return dtor != null ? dtor.isConstexpr() : false; } return declSpec.isConstexpr(); }

Target:
public boolean isConstexpr() { ICPPASTDeclSpecifier declSpec = getDeclSpecifier(); if (declSpec == null) { return false; } return declSpec.isConstexpr(); }
Source:
private static int getAccessibleListenersSize(Accessible accessible) throws Exception { Method m = Accessible.class.getDeclaredMethod("accessibleListenersSize"); m.setAccessible(true); return (Integer) m.invoke(accessible); }

Target:
private static int getAccessibleListenersSize(Accessible accessible) throws Exception { Field f = Accessible.class.getDeclaredField("accessibleListeners"); f.setAccessible(true); Vector accessibleListeners = (Vector) f.get(accessible); return accessibleListeners == null ? 0 : accessibleListeners.size(); }
Source:
protected static String getUniqueFileName(IPath containerFullPath, String fileName, String extension) { if(extension == null) { extension = ""; } if(containerFullPath == null) { containerFullPath = new Path(""); } if(fileName == null || fileName.trim().length() == 0) { fileName = DEFAULT_NAME; } if(fileName.contains(".")) { fileName = fileName.substring(0, fileName.lastIndexOf(".")); } if(fileName.contains(".profile")) { fileName = fileName.substring(0, fileName.lastIndexOf(".profile")); } IPath filePath = containerFullPath.append(fileName); filePath = containerFullPath.append(fileName); filePath = filePath.addFileExtension(extension); int i = 1; while(ResourcesPlugin.getWorkspace().getRoot().exists(filePath)) { i++; filePath = containerFullPath.append(fileName + i); if(extension != null) { filePath = filePath.addFileExtension(extension); } } return filePath.lastSegment(); }

Target:
protected static String getUniqueFileName(IPath containerFullPath, String fileName, String extension) { if(extension == null) { extension = ""; } if(containerFullPath == null) { containerFullPath = new Path(""); } if(fileName == null || fileName.trim().length() == 0) { fileName = DEFAULT_NAME; } if(fileName.contains(".")) { fileName = fileName.substring(0, fileName.lastIndexOf(".")); } List<String> extensionPrefixes = new ArrayList<String>(); for (DiagramCategoryDescriptor diagramCategoryDescriptor : DiagramCategoryRegistry.getInstance().getDiagramCategories()) { String extensionPrefix = diagramCategoryDescriptor.getExtensionPrefix(); if (extensionPrefix == null) continue; extensionPrefixes.add(extensionPrefix); } String[] segments = fileName.split("\\."); for (int i = segments.length-1; i >= 0; i--) { String segment = segments[i]; if (extensionPrefixes.contains(segment)) { fileName = fileName.substring(0, fileName.lastIndexOf("."+segment)); } } IPath filePath = containerFullPath.append(fileName); filePath = filePath.addFileExtension(extension); int i = 1; while(ResourcesPlugin.getWorkspace().getRoot().exists(filePath)) { i++; filePath = containerFullPath.append(fileName + i); if(extension != null) { filePath = filePath.addFileExtension(extension); } } return filePath.lastSegment(); }
Source:
public void testRebalance() throws IOException, HelixRebalanceException { _metadataStore.clearMetadataStore(); WagedRebalancer rebalancer = new WagedRebalancer(_metadataStore, _algorithm, new DelayedAutoRebalancer(), null); ResourceControllerDataProvider clusterData = setupClusterDataCache(); Map<String, Resource> resourceMap = clusterData.getIdealStates().entrySet().stream() .collect(Collectors.toMap(entry -> entry.getKey(), entry -> { Resource resource = new Resource(entry.getKey()); entry.getValue().getPartitionSet().stream() .forEach(partition -> resource.addPartition(partition)); return resource; })); Map<String, IdealState> newIdealStates = rebalancer.computeNewIdealStates(clusterData, resourceMap, new CurrentStateOutput()); Map<String, ResourceAssignment> algorithmResult = _algorithm.getRebalanceResult(); validateRebalanceResult(resourceMap, newIdealStates, algorithmResult); }

Target:
public void testRebalance() throws IOException, HelixRebalanceException { _metadataStore.clearMetadataStore(); WagedRebalancer rebalancer = new WagedRebalancer(_metadataStore, _algorithm, new DelayedAutoRebalancer()); ResourceControllerDataProvider clusterData = setupClusterDataCache(); Map<String, Resource> resourceMap = clusterData.getIdealStates().entrySet().stream() .collect(Collectors.toMap(entry -> entry.getKey(), entry -> { Resource resource = new Resource(entry.getKey()); entry.getValue().getPartitionSet().stream() .forEach(partition -> resource.addPartition(partition)); return resource; })); Map<String, IdealState> newIdealStates = rebalancer.computeNewIdealStates(clusterData, resourceMap, new CurrentStateOutput()); Map<String, ResourceAssignment> algorithmResult = _algorithm.getRebalanceResult(); validateRebalanceResult(resourceMap, newIdealStates, algorithmResult); }
Source:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; if ((req.getHeader("Authorization") != null)) { HttpSession session = req.getSession(false); if (session != null) { session.invalidate(); session = null; } } chain.doFilter(request, response); }

Target:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; if ((req.getHeader(FiltersHelper.Constants.HEADER_AUTHORIZATION) != null)) { HttpSession session = req.getSession(false); if (session != null) { session.invalidate(); session = null; } } chain.doFilter(request, response); }
Source:
private void extractCredentialsFromUrl() { String uriInput = mHostUrlInput.getText().toString().trim(); if(uriInput.length() != 0) { Uri uri = Uri.parse(uriInput); String userInfo = uri.getUserInfo(); if(userInfo != null) { String username = userInfo.split(":", 2)[0]; if(username.length() != 0) { mUsernameInput.setText(username); } String password = userInfo.split(":", 2)[1]; if(password.length() != 0) { mPasswordInput.setText(password); } } } }

Target:
private void extractCredentialsFromUrl() { String uriInput = mHostUrlInput.getText().toString().trim(); if(uriInput.length() != 0) { Uri uri = Uri.parse(uriInput); String userInfo = uri.getUserInfo(); if(userInfo != null) { String[] userInfoParts = userInfo.split(":", 2); if(userInfoParts.length > 0 && userInfoParts[0].length() > 0) { mUsernameInput.setText(userInfoParts[0]); } if(userInfoParts.length > 1 && userInfoParts[1].length() > 0) { mPasswordInput.setText(userInfoParts[1]); } } } }
Source:
protected void showIndicatorsForComponent(final List<Diagnostic> diags, final int severity) { FieldIndicatorModel model = getComponentModel(); if (model != null) { model.diagnostics.clear(); } if (diags != null && !diags.isEmpty()) { model = getOrCreateComponentModel(); UIContext uic = UIContextHolder.getCurrent(); for (int i = 0; i < diags.size(); i++) { Diagnostic diagnostic = diags.get(i); if (diagnostic.getSeverity() == severity && uic == diagnostic.getContext() && relatedField == diagnostic.getComponent()) { model.diagnostics.add(diagnostic); } } } }

Target:
protected void showIndicatorsForComponent(final List<Diagnostic> diags, final int severity) { FieldIndicatorModel model = getComponentModel(); if (model != null && !model.diagnostics.isEmpty()) { model = getOrCreateComponentModel(); model.diagnostics.clear(); } if (diags != null && !diags.isEmpty()) { model = getOrCreateComponentModel(); UIContext uic = UIContextHolder.getCurrent(); for (int i = 0; i < diags.size(); i++) { Diagnostic diagnostic = diags.get(i); if (diagnostic.getSeverity() == severity && uic == diagnostic.getContext() && relatedField == diagnostic.getComponent()) { model.diagnostics.add(diagnostic); } } } }
Source:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (getActivity().getActionBar() != null) getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); rootView = inflater.inflate(R.layout.dialog_fragment_disburse_loan, null); ButterKnife.bind(this, rootView); mLoanAccountDisbursementPresenter.attachView(this); safeUIBlockingUtility = new SafeUIBlockingUtility(getActivity()); inflateDisbursementDate(); inflatePaymentTypeSpinner(); disbursement_dates = loanDisbursementDates.getText().toString(); disbursement_dates = DateHelper.getDateAsStringUsedForCollectionSheetPayload (disbursement_dates).replace("-", " "); btDisburseLoan.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { LoanDisbursement loanDisbursement = new LoanDisbursement(); loanDisbursement.setNote(etDisbursedAmount.getEditableText().toString()); loanDisbursement.setActualDisbursementDate(disbursement_dates); loanDisbursement.setTransactionAmount(etDisbursedAmount.getEditableText() .toString()); loanDisbursement.setPaymentId(paymentTypeId); initiateLoanDisbursement(loanDisbursement); } }); return rootView; }

Target:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (getActivity().getActionBar() != null) getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); rootView = inflater.inflate(R.layout.dialog_fragment_disburse_loan, null); ButterKnife.bind(this, rootView); mLoanAccountDisbursementPresenter.attachView(this); safeUIBlockingUtility = new SafeUIBlockingUtility(getActivity()); inflateDisbursementDate(); inflatePaymentTypeSpinner(); disbursement_dates = tvLoanDisbursementDates.getText().toString(); disbursement_dates = DateHelper.getDateAsStringUsedForCollectionSheetPayload (disbursement_dates).replace("-", " "); return rootView; }
Source:
public Double visitLiteral(Literal literal, Stats stats) { Object value = literal.value(); if (value instanceof Boolean) { Boolean val = (Boolean) literal.value(); return (val == null || !val) ? 0.0 : 1.0; } return super.visitLiteral(literal, stats); }

Target:
public Double visitLiteral(Literal literal, Stats stats) { Object value = literal.value(); if (value instanceof Boolean) { Boolean val = (Boolean) value; return (val == null || !val) ? 0.0 : 1.0; } return super.visitLiteral(literal, stats); }
Source:
private boolean validateStoragePropertiesUpdate() { StorageDomainValidator storageDomainValidator = getStorageDomainValidator(); if (!checkStorageDomainStatusNotEqual(StorageDomainStatus.Locked) || !validateStorageNameUpdate() || !validateDiscardAfterDeleteLegal(storageDomainValidator) || !validateDiskOnBackupDomain()) { return false; } List<String> props = ObjectIdentityChecker.getChangedFields(oldDomain, getStorageDomain() .getStorageStaticData()); props.remove("storageName"); props.remove("description"); props.remove("comment"); props.remove("wipeAfterDelete"); props.remove("discardAfterDelete"); props.remove("warningLowSpaceIndicator"); props.remove("criticalSpaceActionBlocker"); props.remove("backup"); if (!props.isEmpty()) { log.warn("There was an attempt to update the following fields although they are not allowed to be updated: {}", StringUtils.join(props, ",")); return failValidation(EngineMessage.ERROR_CANNOT_CHANGE_STORAGE_DOMAIN_FIELDS); } return true; }

Target:
private boolean validateStoragePropertiesUpdate() { StorageDomainValidator storageDomainValidator = getStorageDomainValidator(); if (!checkStorageDomainStatusNotEqual(StorageDomainStatus.Locked) || !validateStorageNameUpdate() || !validateDiscardAfterDeleteLegal(storageDomainValidator) || !validateDiskOnBackupDomain(storageDomainValidator)) { return false; } List<String> props = ObjectIdentityChecker.getChangedFields(oldDomain, getStorageDomain() .getStorageStaticData()); props.remove("storageName"); props.remove("description"); props.remove("comment"); props.remove("wipeAfterDelete"); props.remove("discardAfterDelete"); props.remove("warningLowSpaceIndicator"); props.remove("criticalSpaceActionBlocker"); props.remove("backup"); if (!props.isEmpty()) { log.warn("There was an attempt to update the following fields although they are not allowed to be updated: {}", StringUtils.join(props, ",")); return failValidation(EngineMessage.ERROR_CANNOT_CHANGE_STORAGE_DOMAIN_FIELDS); } return true; }
Source:
public void connect(Action1<? super Subscription> connection) { boolean shouldSubscribe = false; synchronized (guard) { if (subscription != null) { return; } else { shouldSubscribe = true; final Subject<? super T, ? extends R> subject = subjectFactory.call(); subscription = new Subscriber<T>() { @Override public void onCompleted() { subject.onCompleted(); } @Override public void onError(Throwable e) { subject.onError(e); } @Override public void onNext(T args) { subject.onNext(args); } }; for(Subscriber<? super R> s : waitingForConnect) { subject.unsafeSubscribe(s); } waitingForConnect.clear(); connectedSubject.set(subject); } } if (shouldSubscribe) { connection.call(Subscriptions.create(new Action0() { @Override public void call() { Subscription s; synchronized (guard) { s = subscription; subscription = null; connectedSubject.set(null); } if (s != null) { s.unsubscribe(); } } })); if (subscription!=null) source.unsafeSubscribe(subscription); } }

Target:
public void connect(Action1<? super Subscription> connection) { boolean shouldSubscribe = false; synchronized (guard) { if (subscription != null) { return; } else { shouldSubscribe = true; final Subject<? super T, ? extends R> subject = subjectFactory.call(); subscription = new Subscriber<T>() { @Override public void onCompleted() { subject.onCompleted(); } @Override public void onError(Throwable e) { subject.onError(e); } @Override public void onNext(T args) { subject.onNext(args); } }; for(Subscriber<? super R> s : waitingForConnect) { subject.unsafeSubscribe(s); } waitingForConnect.clear(); connectedSubject.set(subject); } } if (shouldSubscribe) { connection.call(Subscriptions.create(new Action0() { @Override public void call() { Subscription s; synchronized (guard) { s = subscription; subscription = null; connectedSubject.set(null); } if (s != null) { s.unsubscribe(); } } })); boolean subscriptionIsNull; synchronized(guard) { subscriptionIsNull = subscription == null; } if (!subscriptionIsNull) source.unsafeSubscribe(subscription); } }
Source:
Set<ObjectId> getShallowCommits() throws IOException { final File shallow = shallowFile; if (!shallow.isFile()) return Collections.emptySet(); final BufferedReader reader = new BufferedReader( new FileReader(shallow)); try { final Set<ObjectId> ids = new HashSet<ObjectId>(); String line; while ((line = reader.readLine()) != null) { final ObjectId id = ObjectId.fromString(line); ids.add(id); } return ids; } finally { reader.close(); } }

Target:
Set<ObjectId> getShallowCommits() throws IOException { final File shallow = shallowFile; if (!shallow.isFile()) return Collections.emptySet(); final BufferedReader reader = new BufferedReader( new FileReader(shallow)); try { final Set<ObjectId> ids = new HashSet<ObjectId>(); String line; while ((line = reader.readLine()) != null) ids.add(ObjectId.fromString(line)); return ids; } finally { reader.close(); } }
Source:
public synchronized EmailInfo clone() { EmailInfo info = new EmailInfo(); info.setAttachments(new ArrayList<Attachment>()); info.setEmailTemplate(emailTemplate); info.setEmailType(emailType); info.setFromAddress(fromAddress); info.setMessageBody(messageBody); info.setSendAsyncPriority(sendAsyncPriority); info.setSendEmailReliableAsync(sendEmailReliableAsync); info.setSubject(subject); info.setEncoding(encoding); return info; }

Target:
public synchronized EmailInfo clone() { EmailInfo info = new EmailInfo(); info.setAttachments(new ArrayList<Attachment>(attachments)); info.setEmailTemplate(emailTemplate); info.setEmailType(emailType); info.setFromAddress(fromAddress); info.setMessageBody(messageBody); info.setSendAsyncPriority(sendAsyncPriority); info.setSendEmailReliableAsync(sendEmailReliableAsync); info.setSubject(subject); info.setEncoding(encoding); return info; }
Source:
public GuestIdDTO setAttributes(Map<String, String> attributes) { this.attributes = attributes; return this; }

Target:
public GuestIdDTO setAttributes(Map<String, String> attributes) { if (attributes != null) { if (this.attributes == null) { this.attributes = new HashMap<String, String>(); } else { this.attributes.clear(); } this.attributes.putAll(attributes); } else { this.attributes = null; } return this; }
Source:
private void writeMergedDitaval() throws DITAOTException { XMLStreamWriter export = null; try (OutputStream exportStream = new FileOutputStream(new File(job.tempDir, mergedDitavalFilename))) { export = XMLOutputFactory.newInstance().createXMLStreamWriter(exportStream, "UTF-8"); export.writeStartDocument(); export.writeStartElement("val"); export.writeNamespace(DITA_OT_NS_PREFIX, DITA_OT_NS); if (!ditavalFiles.isEmpty()) { final Iterator<File> dvi = ditavalFiles.iterator(); while (dvi.hasNext()) { final File curDitaVal = dvi.next(); final DocumentBuilder ditavalbuilder = XMLUtils.getDocumentBuilder(); final Document doc = ditavalbuilder.parse(curDitaVal); final Element ditavalRoot = doc.getDocumentElement(); final NodeList rootChildren = ditavalRoot.getChildNodes(); logger.debug("Writing conditions from ditaval: " + curDitaVal); writeConditions(export, rootChildren, curDitaVal.toURI().resolve(".")); } } export.writeEndElement(); export.writeEndDocument(); } catch (final IOException e) { throw new DITAOTException("Failed to merge ditaval files: " + e.getMessage(), e); } catch (final XMLStreamException e) { throw new DITAOTException("Failed to serialize merged ditaval file: " + e.getMessage(), e); } catch (final SAXException e) { throw new DITAOTException("Failed to parse ditaval file: " + e.getMessage(), e); } finally { if (export != null) { try { export.close(); } catch (final XMLStreamException e) { logger.error("Failed to close merged ditaval file: " + e.getMessage(), e); } } } }

Target:
private void writeMergedDitaval() throws DITAOTException { final DocumentBuilder ditavalbuilder = XMLUtils.getDocumentBuilder(); XMLStreamWriter export = null; try (OutputStream exportStream = new FileOutputStream(new File(job.tempDir, FILE_NAME_MERGED_DITAVAL))) { export = XMLOutputFactory.newInstance().createXMLStreamWriter(exportStream, "UTF-8"); export.writeStartDocument(); export.writeStartElement("val"); export.writeNamespace(DITA_OT_NS_PREFIX, DITA_OT_NS); for (File curDitaVal : ditavalFiles) { final Document doc = ditavalbuilder.parse(curDitaVal); final Element ditavalRoot = doc.getDocumentElement(); final NodeList rootChildren = ditavalRoot.getChildNodes(); logger.debug("Writing conditions from ditaval: " + curDitaVal); writeConditions(export, rootChildren, curDitaVal.toURI().resolve(".")); } export.writeEndElement(); export.writeEndDocument(); } catch (final IOException e) { throw new DITAOTException("Failed to merge ditaval files: " + e.getMessage(), e); } catch (final XMLStreamException e) { throw new DITAOTException("Failed to serialize merged ditaval file: " + e.getMessage(), e); } catch (final SAXException e) { throw new DITAOTException("Failed to parse ditaval file: " + e.getMessage(), e); } finally { if (export != null) { try { export.close(); } catch (final XMLStreamException e) { logger.error("Failed to close merged ditaval file: " + e.getMessage(), e); } } } }
Source:
private void initPool(HostAndPort master) { synchronized(initPoolLock){ if (!master.equals(currentHostMaster)) { currentHostMaster = master; if (factory == null) { factory = new JedisFactory(master.getHost(), master.getPort(), connectionTimeout, soTimeout, password, database, clientName); factory = new JedisFactory(master.getHost(), master.getPort(), connectionTimeout, soTimeout, password, database, clientName, isRedisSslEnabled); initPool(poolConfig, factory); } else { factory.setHostAndPort(currentHostMaster); internalPool.clear(); } log.info("Created JedisPool to master at " + master); } } }

Target:
private void initPool(HostAndPort master) { synchronized(initPoolLock){ if (!master.equals(currentHostMaster)) { currentHostMaster = master; if (factory == null) { factory = new JedisFactory(master.getHost(), master.getPort(), connectionTimeout, soTimeout, password, database, clientName, isRedisSslEnabled, sslSocketFactory, sslParameters, hostnameVerifier); initPool(poolConfig, factory); } else { factory.setHostAndPort(currentHostMaster); internalPool.clear(); } log.info("Created JedisPool to master at " + master); } } }
Source:
private S getService(String url) { S service = services.get(url); if (service == null) { service = initService(url); services.putIfAbsent(url, service); } return service; }

Target:
private S getService(String url) { S service = services.get(url); if (service == null) { service = initService(url); services.putIfAbsent(url, service); service = services.get(url); } return service; }
Source:
public void receiveSignature(PacketLineIn pckIn) throws IOException { try { StringBuilder sig = new StringBuilder(); String line = pckIn.readStringRaw(); while (!line.equals("-----END PGP SIGNATURE-----")) sig.append(line); signature = sig.toString(); commandList = commandlistBuilder.toString(); } catch (EOFException eof) { throw new IOException(MessageFormat.format( JGitText.get().errorInvalidPushCert, "broken push certificate signature")); } writePushCertificate(); verifySignedPushCommands(signature); }

Target:
public void receiveSignature(PacketLineIn pckIn) throws IOException { try { StringBuilder sig = new StringBuilder(); String line = pckIn.readStringRaw(); while (!line.equals("-----END PGP SIGNATURE-----\n")) sig.append(line); signature = sig.toString(); commandList = commandlistBuilder.toString(); } catch (EOFException eof) { throw new IOException(MessageFormat.format( JGitText.get().errorInvalidPushCert, "broken push certificate signature")); } writePushCertificate(); verifySignedPushCommands(signature); }
Source:
private void updateTree(List<ControlFlowEntry> entryList, ITmfTrace parentTrace) { List<TimeGraphEntry> rootListToAdd = new ArrayList<>(); List<TimeGraphEntry> rootListToRemove = new ArrayList<>(); List<TimeGraphEntry> rootList = getEntryList(parentTrace); for (ControlFlowEntry entry : entryList) { boolean root = (entry.getParent() == null); if (root && entry.getParentThreadId() > 0) { for (ControlFlowEntry parent : entryList) { if (parent.getThreadId() == entry.getParentThreadId() && !((entry.getStartTime() >= parent.getEndTime()) && entry.getEndTime() <= parent.getStartTime())) { parent.addChild(entry); root = false; if (rootList != null && rootList.contains(entry)) { rootListToRemove.add(entry); } break; } } } if (root && (rootList == null || !rootList.contains(entry))) { rootListToAdd.add(entry); } } addToEntryList(parentTrace, rootListToAdd); removeFromEntryList(parentTrace, rootListToRemove); }

Target:
private void updateTree(List<ControlFlowEntry> entryList, ITmfTrace parentTrace) { List<TimeGraphEntry> rootListToAdd = new ArrayList<>(); List<TimeGraphEntry> rootListToRemove = new ArrayList<>(); List<TimeGraphEntry> rootList = getEntryList(parentTrace); for (ControlFlowEntry entry : entryList) { boolean root = (entry.getParent() == null); if (root && entry.getParentThreadId() > 0) { for (ControlFlowEntry parent : entryList) { if (parent.getThreadId() == entry.getParentThreadId() && !(entry.getStartTime() > parent.getEndTime() || entry.getEndTime() < parent.getStartTime())) { parent.addChild(entry); root = false; if (rootList != null && rootList.contains(entry)) { rootListToRemove.add(entry); } break; } } } if (root && (rootList == null || !rootList.contains(entry))) { rootListToAdd.add(entry); } } addToEntryList(parentTrace, rootListToAdd); removeFromEntryList(parentTrace, rootListToRemove); }
Source:
public void emitTuples() { if (flag) { super.emitTuples(); } else { try { Thread.sleep(spinMillis); } catch (InterruptedException e) { throw Throwables.propagate(e); } } }

Target:
public void emitTuples() { if (flag) { super.emitTuples(); } }
Source:
private Limiter<Void> newLimiter() { Limiter<Void> limiter = new InstrumentedLimiter(SimpleLimiter.newBuilder() .limit(new RemotingWindowedLimit(VegasLimit.newDefault())) .build(), slowAcquire); return RemotingBlockingLimiter.wrap(limiter, timeout); }

Target:
private Limiter<Void> newLimiter() { Limiter<Void> limiter = new InstrumentedLimiter(SimpleLimiter.newBuilder() .limit(new ConjureWindowedLimit(VegasLimit.newDefault())) .build(), slowAcquire); return ConjureBlockingLimiter.wrap(limiter, timeout); }