auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private static List<Tree> getMutations(Parameter parameter) { Expression defaultValue = parameter.defaultValue(); if (defaultValue == null) { return Collections.emptyList(); } Optional<Symbol> paramSymbol = getSymbolFromTree(parameter.name()); if (!paramSymbol.isPresent() || isUsingMemoization(paramSymbol.get())) { return Collections.emptyList(); } if (!defaultValue.type().canOnlyBe(BuiltinTypes.NONE_TYPE)) { List<Tree> attributeSet = getAttributeSet(paramSymbol.get()); if (!attributeSet.isEmpty()) { return attributeSet; } } String defaultValueType = defaultValueType(defaultValue); Set<String> typeMutatingMethods = MUTATING_METHODS.get(defaultValueType); if (typeMutatingMethods == null) { return Collections.emptyList(); } return paramSymbol.get().usages().stream().filter(usage -> { Tree parent = usage.tree().parent(); if (parent.is(QUALIFIED_EXPR)) { QualifiedExpression qualifiedExpression = (QualifiedExpression) parent; return getSymbolFromTree(qualifiedExpression.qualifier()).equals(paramSymbol) && isMutatingMethod(typeMutatingMethods, qualifiedExpression.name().name()); } return isUsedInDelStatement(usage.tree()) || isUsedInLhsOfAssignment(usage.tree(), exp -> isAccessingExpression(exp, usage.tree())) || isUsedInLhsOfCompoundAssignment(usage.tree()) || isGetItemOnDefaultDict(defaultValueType, usage.tree()) || mightBeReferencedOutsideOfFunction(usage.tree()); }).map(usage -> usage.tree().parent()).collect(Collectors.toList()); }

Target:
private static List<Tree> getMutations(Parameter parameter) { Expression defaultValue = parameter.defaultValue(); if (defaultValue == null) { return Collections.emptyList(); } Optional<Symbol> paramSymbol = getSymbolFromTree(parameter.name()); if (!paramSymbol.isPresent() || isUsingMemoization(paramSymbol.get())) { return Collections.emptyList(); } if (!defaultValue.type().canOnlyBe(BuiltinTypes.NONE_TYPE)) { List<Tree> attributeSet = getAttributeSet(paramSymbol.get()); if (!attributeSet.isEmpty()) { return attributeSet; } } String defaultValueType = defaultValueType(defaultValue); Set<String> typeMutatingMethods = MUTATING_METHODS.get(defaultValueType); if (typeMutatingMethods == null) { return Collections.emptyList(); } return paramSymbol.get().usages().stream() .filter(usage -> isWriteUsage(paramSymbol, defaultValueType, typeMutatingMethods, usage)) .map(usage -> usage.tree().parent()) .collect(Collectors.toList()); }
Source:
public AbstractDiskVmCommand(T parameters) { super(parameters); if (parameters.getDiskInfo() != null && DiskStorageType.IMAGE == parameters.getDiskInfo().getDiskStorageType()) { setQuotaId(((DiskImage) parameters.getDiskInfo()).getQuotaId()); } if (getVm() != null) { setStoragePoolId(getVm().getstorage_pool_id()); } }

Target:
public AbstractDiskVmCommand(T parameters) { super(parameters); if (parameters.getDiskInfo() != null && DiskStorageType.IMAGE == parameters.getDiskInfo().getDiskStorageType()) { setQuotaId(((DiskImage) parameters.getDiskInfo()).getQuotaId()); } }
Source:
public boolean begin() { if ( getStatus() == TransactionManager.STATUS_ROLLEDBACK ) { logger.info("Cleanup of transaction that has been rolled back previously"); rollback(true); } if ( getStatus() == TransactionManager.STATUS_NO_TRANSACTION ) { try { getUt().begin(); return true; } catch ( Exception e ) { if (e.getClass().getName().equals("javax.ejb.EJBException")) { this.ut = findUserTransaction(); this.tm = findTransactionManager(this.ut); this.tsr = findTransactionSynchronizationRegistry(this.ut, this.tm); try { this.ut.begin(); return true; } catch (Exception ex) { logger.warn( "Unable to begin transaction", e); throw new RuntimeException( "Unable to begin transaction", e ); } } else { logger.warn( "Unable to begin transaction", e); throw new RuntimeException( "Unable to begin transaction", e ); } } } return false; }

Target:
public boolean begin() { int status = getStatus(); if ( status == TransactionManager.STATUS_ROLLEDBACK ) { logger.debug("Cleanup of transaction that has been rolled back previously"); rollback(true); status = getStatus(); } if ( status == TransactionManager.STATUS_NO_TRANSACTION ) { try { getUt().begin(); return true; } catch ( Exception e ) { if (e.getClass().getName().equals("javax.ejb.EJBException")) { this.ut = findUserTransaction(); this.tm = findTransactionManager(this.ut); this.tsr = findTransactionSynchronizationRegistry(this.ut, this.tm); try { this.ut.begin(); return true; } catch (Exception ex) { logger.warn( "Unable to begin transaction", e); throw new RuntimeException( "Unable to begin transaction", e ); } } else { logger.warn( "Unable to begin transaction", e); throw new RuntimeException( "Unable to begin transaction", e ); } } } return false; }
Source:
public void load(final InputStream imagePayload) throws DockerException, InterruptedException { load(imagePayload, new LoggingSaveHandler()); }

Target:
public Set<String> load(final InputStream imagePayload) throws DockerException, InterruptedException { return load(imagePayload, new LoggingLoadHandler()); }
Source:
Metrics.MetricFamily.Builder annotateBuilder(final Metrics.MetricFamily.Builder b) { try { skipChild: for (final Map<String, String> labels : children.keySet()) { final Child child = children.get(labels); if (child.isEmpty()) { continue; } final Metrics.Summary.Builder builder = Metrics.Summary.newBuilder(); for (final double q : child.targets.keySet()) { final Double v = child.query(q); if (v == null) { continue skipChild; } final Metrics.Quantile.Builder qs = builder.addQuantileBuilder(); qs.setQuantile(q); qs.setValue(v); } builder.setSampleCount(child.count.get()); builder.setSampleSum(child.sum.get()); final Metrics.Metric.Builder m = b.addMetricBuilder(); for (final String label : labels.keySet()) { final String value = labels.get(label); m.addLabelBuilder().setName(label).setValue(value); } m.setSummary(builder.build()); } return b; } finally { purge(); } }

Target:
Metrics.MetricFamily.Builder annotateBuilder(final Metrics.MetricFamily.Builder b) { try { for (final Map<String, String> labels : children.keySet()) { final Child child = children.get(labels); final Metrics.Summary.Builder builder = Metrics.Summary.newBuilder(); if (!child.isEmpty()) { for (final double q : child.targets.keySet()) { final Double v = child.query(q); if (v == null) { continue; } final Metrics.Quantile.Builder qs = builder.addQuantileBuilder(); qs.setQuantile(q); qs.setValue(v); } } builder.setSampleCount(child.count.get()); builder.setSampleSum(child.sum.get()); final Metrics.Metric.Builder m = b.addMetricBuilder(); for (final String label : labels.keySet()) { final String value = labels.get(label); m.addLabelBuilder().setName(label).setValue(value); } m.setSummary(builder); } return b; } finally { purge(); } }
Source:
public static byte[] inflate(byte[] bytes, int expectedSize) { try { Inflater decompressor = new Inflater(); decompressor.setInput(bytes, 0, bytes.length); byte[] result = new byte[expectedSize]; decompressor.inflate(result); decompressor.end(); return result; } catch (Exception e) { throw new RuntimeException("Unable to inflate binary data", e); } }

Target:
public static byte[] inflate(byte[] bytes, int expectedSize) throws DataFormatException { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(expectedSize); InflaterOutputStream ios = new InflaterOutputStream(baos); ios.write(bytes, 0, bytes.length); return baos.toByteArray(); } catch (Exception e) { throw new DataFormatException(); } }
Source:
public void startWebSocketServer(String hostname, int webSocketPort) throws IOException { if(webSocketTestServer == null){ webSocketTestServer = new NanoWebSocketTestServer(hostname,webSocketPort); } webSocketTestServer.start(); }

Target:
public void startWebSocketServer(String hostname, int webSocketPort) throws IOException { startWebSocketServer(hostname,webSocketPort,5000); }
Source:
Buffer marshallCall(ReplicableCommand command) { try { return new Buffer(ispnMarshaller.objectToByteBuffer(command)); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException("Failure to marshal argument(s)", e); } }

Target:
Buffer marshallCall(ReplicableCommand command) { try { ByteBuffer bytes = ispnMarshaller.objectToBuffer(command); return new Buffer(bytes.getBuf(), bytes.getOffset(), bytes.getLength()); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException("Failure to marshal argument(s)", e); } }
Source:
public Map<String, Long> getPartitionTimeLag(Map<String, String> currentOffsets) { return partitionResources.entrySet() .stream() .collect( Collectors.toMap(k -> k.getKey().getPartitionId(), k -> k.getValue().getPartitionTimeLag(currentOffsets.get(k.getKey().getPartitionId()))) ); }

Target:
public Map<String, Long> getPartitionTimeLag(Map<String, String> currentOffsets) { Map<String, Long> partitionLag = Maps.newHashMapWithExpectedSize(currentOffsets.size()); for (Map.Entry<StreamPartition<String>, PartitionResource> partition : partitionResources.entrySet()) { final String partitionId = partition.getKey().getPartitionId(); partitionLag.put(partitionId, partition.getValue().getPartitionTimeLag(currentOffsets.get(partitionId))); } return partitionLag; }
Source:
public DynamicSSLContextImpl(AuthenticationContext authenticationContext) throws GeneralSecurityException { this.authenticationContext = authenticationContext; this.configuredSSLContexts = AUTH_CONTEXT_CLIENT.getConfiguredSSLContexts(authenticationContext); this.configuredDefaultSSLContext = AUTH_CONTEXT_CLIENT.getDefaultSSLContext(authenticationContext); }

Target:
public DynamicSSLContextImpl(AuthenticationContext authenticationContext) throws GeneralSecurityException { Assert.assertNotNull("authenticationContext"); this.authenticationContext = authenticationContext; this.configuredSSLContexts = AUTH_CONTEXT_CLIENT.getConfiguredSSLContexts(authenticationContext); this.configuredDefaultSSLContext = AUTH_CONTEXT_CLIENT.getDefaultSSLContext(authenticationContext); }
Source:
public GetUserCallback(final GetUserResponse getUserResponse) { this.getUserResponse = getUserResponse; callback = new GraphRequest.Callback() { @Override public void onCompleted(GraphResponse response) { SocialMember socialMember; try { JSONObject userObj = response.getJSONObject(); if (userObj == null) { logger.warn("Unable to get user json object from facebook graph api."); return; } socialMember = jsonToUser(userObj); } catch (Exception e) { logger.warn("Some exception occurred in fetching user data from facebook graph api."); return; } GetUserCallback.this.getUserResponse.onCompleted(socialMember); } }; }

Target:
public GetUserCallback(final GetUserResponse getUserResponse) { this.getUserResponse = getUserResponse; callback = new GraphRequest.Callback() { @Override public void onCompleted(GraphResponse response) { SocialMember socialMember; try { JSONObject userObj = response.getJSONObject(); if (userObj == null) { logger.warn("Unable to get user json object from facebook graph api."); return; } socialMember = jsonToUser(userObj); } catch (JSONException e) { logger.error(e); return; } GetUserCallback.this.getUserResponse.onCompleted(socialMember); } }; }
Source:
protected ReusableSubprocessTaskExecutionSet createReusableSubprocessTaskExecutionSet(CallActivity activity, CallActivityPropertyReader p) { return new ReusableSubprocessTaskExecutionSet(new CalledElement(activity.getCalledElement()), new IsCase(p.isCase()), new Independent(p.isIndependent()), new WaitForCompletion(p.isWaitForCompletion()), new IsAsync(p.isAsync()), new SLADueDate(p.getSlaDueDate()), new AdHocAutostart(p.isAdHocAutostart()), new IsMultipleInstance(p.isMultipleInstance()), new MultipleInstanceExecutionMode(p.isSequential()), new MultipleInstanceCollectionInput(p.getCollectionInput()), new MultipleInstanceDataInput(p.getDataInput()), new MultipleInstanceCollectionOutput(p.getCollectionOutput()), new MultipleInstanceDataOutput(p.getDataOutput()), new MultipleInstanceCompletionCondition(p.getCompletionCondition()), new OnEntryAction(p.getOnEntryAction()), new OnExitAction(p.getOnExitAction())); }

Target:
protected ReusableSubprocessTaskExecutionSet createReusableSubprocessTaskExecutionSet(CallActivity activity, CallActivityPropertyReader p) { return new ReusableSubprocessTaskExecutionSet(new CalledElement(activity.getCalledElement()), new IsCase(p.isCase()), new Independent(p.isIndependent()), new AbortParent(p.isAbortParent()), new WaitForCompletion(p.isWaitForCompletion()), new IsAsync(p.isAsync()), new AdHocAutostart(p.isAdHocAutostart()), new IsMultipleInstance(p.isMultipleInstance()), new MultipleInstanceExecutionMode(p.isSequential()), new MultipleInstanceCollectionInput(p.getCollectionInput()), new MultipleInstanceDataInput(p.getDataInput()), new MultipleInstanceCollectionOutput(p.getCollectionOutput()), new MultipleInstanceDataOutput(p.getDataOutput()), new MultipleInstanceCompletionCondition(p.getCompletionCondition()), new OnEntryAction(p.getOnEntryAction()), new OnExitAction(p.getOnExitAction()), new SLADueDate(p.getSlaDueDate())); }
Source:
private ImmutableList<String> createCommand() { ImmutableList.Builder<String> command = ImmutableList.builder(); command.addAll(groovyc.getCommandPrefix(resolver)); String classpath = Joiner.on(File.pathSeparator).join(transform(declaredClasspathEntries, Object::toString)); command .add("-cp") .add(classpath.isEmpty() ? "''" : classpath) .add("-d") .add(outputDirectory.toString()); addCrossCompilationOptions(command); command.addAll(extraArguments.orElse(ImmutableList.of())); command.add("@" + pathToSrcsList); ImmutableList<String> built = command.build(); built.forEach(System.out::println); return command.build(); }

Target:
private ImmutableList<String> createCommand() { ImmutableList.Builder<String> command = ImmutableList.builder(); command.addAll(groovyc.getCommandPrefix(resolver)); String classpath = Joiner.on(File.pathSeparator).join(transform(declaredClasspathEntries, Object::toString)); command .add("-cp") .add(classpath.isEmpty() ? "''" : classpath) .add("-d") .add(outputDirectory.toString()); addCrossCompilationOptions(command); command.addAll(extraArguments.orElse(ImmutableList.of())); command.add("@" + pathToSrcsList); return command.build(); }
Source:
public void clickViewActionsButtonOfFirstEntry(){ WebElement table = browser.driver.findElement(By.id("logsTable")); WebElement tableRow; try { tableRow = table.findElements(By.tagName("tr")).get(1); } catch (IndexOutOfBoundsException onlyoneentry) { tableRow = table.findElements(By.tagName("tr")).get(0); } WebElement element = tableRow.findElement(By.tagName("button")); element.click(); }

Target:
public void clickViewActionsButtonOfFirstEntry(){ WebElement table = browser.driver.findElement(By.id("logsTable")); WebElement tableRow = table.findElements(By.tagName("tr")).get(1); WebElement element = tableRow.findElement(By.tagName("button")); element.click(); }
Source:
public int compare(TaskExecution firstTaskExecution, TaskExecution secondTaskExecution) { if (firstTaskExecution.getStartTime().equals(secondTaskExecution.getStartTime())) { return Long.valueOf(firstTaskExecution.getExecutionId()).compareTo(Long.valueOf(secondTaskExecution.getExecutionId())); } else { return secondTaskExecution.getStartTime().compareTo(firstTaskExecution.getStartTime()); } }

Target:
public int compare(TaskExecution firstTaskExecution, TaskExecution secondTaskExecution) { if (firstTaskExecution.getStartTime().equals(secondTaskExecution.getStartTime())) { return Long.compare(firstTaskExecution.getExecutionId(), secondTaskExecution.getExecutionId()); } else { return secondTaskExecution.getStartTime().compareTo(firstTaskExecution.getStartTime()); } }
Source:
public Resource getTotalUsedResources() { return getInstances().stream() .map(PackingPlan.InstancePlan::getResource) .reduce(Resource::plus) .orElse(Resource.EMPTY_RESOURCE) .plus(getPadding()); }

Target:
public Resource getTotalUsedResources() { return getInstances().stream() .map(PackingPlan.InstancePlan::getResource) .reduce(Resource.EMPTY_RESOURCE, Resource::plus) .plus(getPadding()); }
Source:
private final void excludeLinesIfTrue(boolean shouldExclude, Tree tree, Class<? extends JavaCheck> rule) { if (shouldExclude) { excludeLines(tree, rule); } else { acceptLines(tree, rule); } }

Target:
private void excludeLinesIfTrue(boolean shouldExclude, Tree tree, Class<? extends JavaCheck> rule) { if (shouldExclude) { excludeLines(tree, rule); } else { acceptLines(tree, rule); } }
Source:
protected Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { if (tag.getType() == CVSTag.BRANCH) { monitor = Policy.monitorFor(monitor); monitor.beginTask(NLS.bind( CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren, new String[] { root.toString() }), 100); try { ICVSRemoteResource[] children = CVSUIPlugin .getPlugin() .getRepositoryManager() .getFoldersForTag(root, tag, Policy.subMonitorFor(monitor, 50)); if (getWorkingSet() != null) children = CVSUIPlugin.getPlugin().getRepositoryManager() .filterResources(getWorkingSet(), children); return getTopLevelFoldersForChildren(children, Policy.subMonitorFor(monitor, 50)); } finally { monitor.done(); } } ICVSRemoteResource[] children = CVSUIPlugin.getPlugin().getRepositoryManager().getFoldersForTag(root, tag, monitor); if (getWorkingSet() != null) children = CVSUIPlugin.getPlugin().getRepositoryManager().filterResources(getWorkingSet(), children); return children; }

Target:
protected Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { if (tag.getType() == CVSTag.BRANCH) { monitor = Policy.monitorFor(monitor); monitor.beginTask(NLS.bind( CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren, new String[] { root.toString() }), 100); try { ICVSRemoteResource[] children = CVSUIPlugin .getPlugin() .getRepositoryManager() .getFoldersForTag(root, tag, Policy.subMonitorFor(monitor, 50)); if (getWorkingSet() != null) children = CVSUIPlugin.getPlugin().getRepositoryManager() .filterResources(getWorkingSet(), children); return getTopLevelRemoteFolders(children, Policy.subMonitorFor(monitor, 50)); } finally { monitor.done(); } } ICVSRemoteResource[] children = CVSUIPlugin.getPlugin().getRepositoryManager().getFoldersForTag(root, tag, monitor); if (getWorkingSet() != null) children = CVSUIPlugin.getPlugin().getRepositoryManager().filterResources(getWorkingSet(), children); return children; }
Source:
public String render(final GetTapesWithFullDetailsResult obj) throws JsonProcessingException { final NamedDetailedTapeList result = obj.getTapesWithDetails(); if ((result == null) || (null == result.getNamedDetailedTapes()) || (result.getNamedDetailedTapes().size() == 0 ) ){ return "You do not have any tapes"; } return ASCIITable.getInstance().getTable(getHeaders(), formatTapeList(result)); }

Target:
public String render(final GetTapesWithFullDetailsResult obj) throws JsonProcessingException { final NamedDetailedTapeList result = obj.getTapesWithDetails(); if ((result == null) || (Guard.isNullOrEmpty(result.getNamedDetailedTapes())) ){ return "You do not have any tapes"; } return ASCIITable.getInstance().getTable(getHeaders(), formatTapeList(result)); }
Source:
protected boolean isVersionSupportedForShareable() { return Config.<Boolean> GetValue(ConfigValues.ShareableDiskEnabled, getStoragePool().getcompatibility_version().getValue()); }

Target:
protected boolean isVersionSupportedForShareable() { return getStoragePool() != null ?Config.<Boolean> GetValue(ConfigValues.ShareableDiskEnabled, getStoragePool().getcompatibility_version().getValue()) : true; }
Source:
private static IStatus openTraceFromFolder(TmfTraceFolder destinationFolder, String traceName) { final List<ITmfProjectModelElement> elements = destinationFolder.getChildren(); TmfTraceElement traceElement = null; for (ITmfProjectModelElement element : elements) { if (element instanceof TmfTraceElement && element.getName().equals(traceName)) { traceElement = (TmfTraceElement) element; } } if (traceElement == null) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(Messages.TmfOpenTraceHelper_TraceNotFound, traceName)); } IStatus status = openFromElement(traceElement); return status; }

Target:
private static IStatus openTraceFromFolder(TmfTraceFolder destinationFolder, String traceName) { final List<ITmfProjectModelElement> elements = destinationFolder.getChildren(); TmfTraceElement traceElement = null; for (ITmfProjectModelElement element : elements) { if (element instanceof TmfTraceElement && element.getName().equals(traceName)) { traceElement = (TmfTraceElement) element; } } if (traceElement == null) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(Messages.TmfOpenTraceHelper_TraceNotFound, traceName)); } IStatus status = openFromElement(traceElement); if (!status.isOK()) { Activator.getDefault().logError("Error opening trace from folder: " + status.getMessage()); } return status; }
Source:
public void onProduct(final Product product) throws Exception { ProductId id = product.getId(); try { productStorage.storeProduct(product); } catch (ProductAlreadyInStorageException e) { } Date expirationDate = new Date(new Date().getTime() + productStorageMaxAge); URLNotification notification = new URLNotification(id, expirationDate, product.getTrackerURL(), productStorage.getProductURL(id)); Iterator<Notification> existing = getNotificationIndex() .findNotifications(id).iterator(); while (existing.hasNext()) { getNotificationIndex().removeNotification(existing.next()); } getNotificationIndex().addNotification(notification); sendNotification(notification); new ProductTracker(notification.getTrackerURL()).notificationSent( this.getName(), notification); }

Target:
public void onProduct(final Product product) throws Exception { ProductId id = product.getId(); try { productStorage.storeProduct(product); } catch (ProductAlreadyInStorageException e) { } Date expirationDate = new Date(new Date().getTime() + productStorageMaxAge); URLNotification notification = new URLNotification(id, expirationDate, product.getTrackerURL(), productStorage.getProductURL(id)); Iterator<Notification> existing = getNotificationIndex() .findNotifications(id).iterator(); while (existing.hasNext()) { getNotificationIndex().removeNotification(existing.next()); } try { sendNotification(notification); } catch (Exception e) { productStorage.removeProduct(id); throw e; } getNotificationIndex().addNotification(notification); new ProductTracker(notification.getTrackerURL()).notificationSent( this.getName(), notification); }
Source:
public static TaskType fromToken(String token) { return TaskType.valueOf(token.trim().toUpperCase()); }

Target:
public static IndexType fromToken(String token) { return IndexType.valueOf(token.trim().toUpperCase()); }
Source:
public void run(String[] args) { boolean validCommand = false; if (args.length >= 2) { boolean flag = false; if ("enable".equals(args[1])) { flag = true; validCommand = true; } else if ("disable".equals(args[1])) { flag = false; validCommand = true; } if (validCommand) { IWifiManager wifiMgr = IWifiManager.Stub.asInterface(ServiceManager.getService(Context.WIFI_SERVICE)); try { if (wifiMgr == null) { System.err.println("Wi-Fi service is not ready"); return; } wifiMgr.setWifiEnabled("com.android.shell", flag); } catch (RemoteException e) { System.err.println("Wi-Fi operation failed: " + e); } return; } } System.err.println(longHelp()); }

Target:
public void run(String[] args) { boolean validCommand = false; if (args.length >= 2) { boolean flag = false; if ("enable".equals(args[1])) { flag = true; validCommand = true; } else if ("disable".equals(args[1])) { flag = false; validCommand = true; } if (validCommand) { IWifiManager wifiMgr = IWifiManager.Stub.asInterface(ServiceManager.getService(Context.WIFI_SERVICE)); if (wifiMgr == null) { System.err.println("Wi-Fi service is not ready"); return; } try { wifiMgr.setWifiEnabled("com.android.shell", flag); } catch (RemoteException e) { System.err.println("Wi-Fi operation failed: " + e); } return; } } System.err.println(longHelp()); }
Source:
protected boolean canDoAction() { if (!isVmExist()) { return false; } if (!acquireLockInternal()) { return false; } VM vm = getVm(); if (vm != null) { updateDisksFromDb(); if (!isDiskCanBeAddedToVm(getParameters().getDiskInfo()) || !isDiskPassPciAndIdeLimit(getParameters().getDiskInfo())) { return false; } } if (DiskStorageType.IMAGE == getParameters().getDiskInfo().getDiskStorageType()) { return checkIfImageDiskCanBeAdded(vm); } if (DiskStorageType.LUN == getParameters().getDiskInfo().getDiskStorageType()) { return checkIfLunDiskCanBeAdded(); } return true; }

Target:
protected boolean canDoAction() { if (!isVmExist() || !acquireLockInternal()) { return false; } VM vm = getVm(); if (vm != null) { updateDisksFromDb(); if (!isDiskCanBeAddedToVm(getParameters().getDiskInfo()) || !isDiskPassPciAndIdeLimit(getParameters().getDiskInfo())) { return false; } } if (DiskStorageType.IMAGE == getParameters().getDiskInfo().getDiskStorageType()) { return checkIfImageDiskCanBeAdded(vm); } if (DiskStorageType.LUN == getParameters().getDiskInfo().getDiskStorageType()) { return checkIfLunDiskCanBeAdded(); } return true; }
Source:
public void configure(Type type, Properties params, Dialect dialect) throws MappingException { params.setProperty( SEGMENT_VALUE_PARAM, params.getProperty( IDENTITY_NAME ) ); tableGenerator.configure( type, params, dialect ); }

Target:
public void configure(Type type, Properties params, Dialect dialect) throws MappingException { Properties newParams = new Properties( params ); for ( Map.Entry<Object, Object> param : params.entrySet() ) { newParams.put( param.getKey(), param.getValue() ); } newParams.setProperty( OgmTableGenerator.SEGMENT_VALUE_PARAM, newParams.getProperty( PersistentIdentifierGenerator.TABLE ) ); tableGenerator.configure( type, newParams, dialect ); }
Source:
public void testLogcatOutput_ShouldPrintIfTrayAuthorityIsNotDefault() throws Exception { final MockContext stuff = new MockContext() { @Override public Resources getResources() { final Resources mockResources = mock(Resources.class); when(mockResources.getString(anyInt())).thenReturn(eq("notDefaultTrayAuthority")); return mockResources; } }; TrayContract.generateInternalContentUri(stuff); assertTrue(true); }

Target:
public void testLogcatOutput_ShouldPrintIfTrayAuthorityIsNotDefault() throws Exception { final List<ProviderInfo> mockProviders = new ArrayList<>(); ProviderInfo info = new ProviderInfo(); info.authority = "my.custom.authority"; info.name = TrayContentProvider.class.getName(); mockProviders.add(info); getProviderMockContext().setProviderInfos(mockProviders); final Resources mockResources = mock(Resources.class); when(mockResources.getString(R.string.tray__authority)) .thenReturn("NOTlegacyTrayAuthority"); getProviderMockContext().setResources(mockResources); TrayContract.generateInternalContentUri(getProviderMockContext()); verify(mockResources).getString(R.string.tray__authority); }
Source:
public static void checkConfiguration() { Job job = new Job(UIText.ConfigurationChecker_checkConfiguration) { @Override protected IStatus run(IProgressMonitor monitor) { if (PlatformUI.isWorkbenchRunning()) PlatformUI.getWorkbench().getDisplay() .asyncExec(new Runnable() { public void run() { check(); } }); else schedule(1000L); return Status.OK_STATUS; } }; job.schedule(); }

Target:
public static void checkConfiguration() { Job job = new Job(UIText.ConfigurationChecker_checkConfiguration) { @Override protected IStatus run(IProgressMonitor monitor) { if (PlatformUI.isWorkbenchRunning()) { PlatformUI.getWorkbench().getDisplay() .asyncExec(new Runnable() { public void run() { check(); } }); } else { schedule(1000L); } return Status.OK_STATUS; } }; job.schedule(); }
Source:
private void casePropertiesChange(Object oldValue, Object newValue) { if (oldValue instanceof String[] && newValue instanceof Property) { Property property = (Property) newValue; if (property.getItem() instanceof ProcessItem) { ITestContainerProviderService service = getTestContainerProviderService(); boolean isTestCase = false; if (service != null) { isTestCase = service.isTestContainerItem(property.getItem()); } if (isTestCase) { } else { String[] oldFields = (String[]) oldValue; if (oldFields.length == 0) { return; } String oldName = oldFields[0]; String oldVersion = oldFields[1]; if (!oldName.equals(property.getLabel())) { TalendJavaProjectManager.deleteAllVersionTalendJobProject(property.getId(), oldName, true); TalendJavaProjectManager.createAllVersionTalendJobProject(property.getId()); } else if (!oldVersion.equals(property.getVersion())) { TalendJavaProjectManager.generatePom((ProcessItem) property.getItem(), 0x8); } } } } }

Target:
private void casePropertiesChange(Object oldValue, Object newValue) { if (oldValue instanceof String[] && newValue instanceof Property) { Property property = (Property) newValue; if (property.getItem() instanceof ProcessItem) { ITestContainerProviderService service = getTestContainerProviderService(); boolean isTestCase = false; if (service != null) { isTestCase = service.isTestContainerItem(property.getItem()); } if (isTestCase) { } else { String[] oldFields = (String[]) oldValue; if (oldFields.length == 0) { return; } String oldName = oldFields[0]; String oldVersion = oldFields[1]; if (!oldName.equals(property.getLabel())) { TalendJavaProjectManager.deleteAllVersionTalendJobProject(property.getId(), oldName, true); TalendJavaProjectManager.createAllVersionTalendJobProject(property.getId()); } else if (!oldVersion.equals(property.getVersion())) { TalendJavaProjectManager.generatePom((ProcessItem) property.getItem(), TalendJavaProjectConstants.GEN_PROPERTIES_CHANGED); } } } } }
Source:
public void run() { Logger.info(this, "Trying to reindex all the content"); try{ conAPI.reindex(); Logger.info(this, "Reindexation is in progress"); }catch (Exception e) { Logger.info(this, "Unable to reindex. Probably because another reindexation is in progress"); }finally{ try { HibernateUtil.closeSession(); } catch (DotHibernateException e) { Logger.error(ContentReindexerThread.class, e.getMessage(), e); } } }

Target:
public void run() { Logger.info(this, "Trying to reindex all the content"); try{ conAPI.reindex(); Logger.info(this, "Reindexation is in progress"); }catch (Exception e) { Logger.info(this, "Unable to reindex. Probably because another reindexation is in progress"); } }
Source:
public void exportRowEnd(final OutputStream outputStream, final int rowPosition) throws IOException { this.currentRow.append("\n"); outputStream.write(this.currentRow.toString().getBytes(this.usedCharset)); }

Target:
public void exportRowEnd(final OutputStream outputStream, final int rowPosition) throws IOException { this.currentRow.append(System.getProperty("line.separator")); outputStream.write(this.currentRow.toString().getBytes(this.usedCharset)); }
Source:
public static DocumentPath from(List<String> elements) { List<String> copy = new ArrayList<>(); copy.add(""); copy.addAll(elements); return new DocumentPath(copy); }

Target:
public static DocumentPath from(List<String> elements) { List<String> copy = new ArrayList<>(); copy.add(ROOT_ELEMENT); copy.addAll(elements); return new DocumentPath(copy); }
Source:
protected void setParentNode(GoloElement parent) { if (!(parent instanceof Union) || parent == null) { throw new IllegalArgumentException("UnionValue can only be defined in a Union"); } super.setParentNode(parent); }

Target:
protected void setParentNode(GoloElement parent) { if (!(parent instanceof Union)) { throw new IllegalArgumentException("UnionValue can only be defined in a Union"); } super.setParentNode(parent); }
Source:
public void setComplete() { this.complete = true; ExchangeObserver obs = this.observer; if (null != obs) { obs.completed(this); } }

Target:
public void setComplete() { this.complete = true; ExchangeObserver obs = this.observer; if (obs != null) { obs.completed(this); } }
Source:
public void update(Observable arg0, Object argN) { final String arg1 = OoyalaNotification.getNameOrUnknown(argN); if (arg1 == OoyalaPlayer.TIME_CHANGED_NOTIFICATION_NAME) { return; } if (arg1 == OoyalaPlayer.ERROR_NOTIFICATION_NAME) { final String msg = "Error Event Received"; if (player != null && player.getError() != null) { Log.e(TAG, msg, player.getError()); } else { Log.e(TAG, msg); } return; } if (arg1 == OoyalaSkinLayoutController.FULLSCREEN_CHANGED_NOTIFICATION_NAME) { Log.d(TAG, "Fullscreen Notification received : " + arg1 + " - fullScreen: " + ((OoyalaNotification)argN).getData()); } String text="Notification Received: " + arg1 + " - state: " + player.getState(); log.writeToSdcardLog(text); Log.d(TAG, "Notification Received: " + arg1 + " - state: " + player.getState()); }

Target:
public void update(Observable arg0, Object argN) { final String arg1 = OoyalaNotification.getNameOrUnknown(argN); if (arg1 == OoyalaPlayer.TIME_CHANGED_NOTIFICATION_NAME) { return; } if (arg1 == OoyalaPlayer.ERROR_NOTIFICATION_NAME) { final String msg = "Error Event Received"; if (null != player && null != player.getError()) { Log.e(TAG, msg, player.getError()); } else { Log.e(TAG, msg); } return; } if (arg1 == OoyalaSkinLayoutController.FULLSCREEN_CHANGED_NOTIFICATION_NAME) { Log.d(TAG, "Fullscreen Notification received : " + arg1 + " - fullScreen: " + ((OoyalaNotification)argN).getData()); } String text = "Notification Received: " + arg1 + " - state: " + player.getState(); log.writeToSdcardLog(text); Log.d(TAG, text); }
Source:
public void setUp() throws Exception { VARIANT.addId("randomID"); VARIANT.setAnnotation(new Annotation(CHROMOSOME, 0, 0, null, null, null, null)); VARIANT.addSourceEntry(new VariantSourceEntryWithSampleNames("fid", "sid", null, null, null, null, null)); List<VariantWithSamplesAndAnnotation> variantEntities = Collections.singletonList(VARIANT); given(variantEntityRepository .findByChromosomeAndStartAndReferenceAndAlternate(eq(CHROMOSOME), anyInt(), any(), any(), any())) .willReturn(variantEntities); }

Target:
public void setUp() throws Exception { VARIANT.addId("randomID"); VARIANT.setAnnotation(new Annotation(CHROMOSOME, 0, 0, null, null, null, null)); VARIANT.addSourceEntry(new VariantSourceEntryWithSampleNames("fid", "sid", null, null, null, null, null)); List<VariantWithSamplesAndAnnotation> variantEntities = Collections.singletonList(VARIANT); given(service.findByChromosomeAndStartAndReferenceAndAlternate(eq(CHROMOSOME), anyInt(), any(), any(), any())) .willReturn(variantEntities); }
Source:
private static boolean valueEquals(@Nullable Object value1, @Nullable Object value2) { if ((value1 == null) && (value2 == null)) { return true; } if ((value1 == null) || (value2 == null)) { return false; } Class<?> class1 = value1.getClass(); Class<?> class2 = value2.getClass(); if (class1.isArray() && class2.isArray()) { if (class1.equals(int[].class) && class2.equals(int[].class)) { return Arrays.equals((int[]) value1, (int[]) value2); } else if (class1.equals(float[].class) && class2.equals(float[].class)) { return Arrays.equals((float[]) value1, (float[]) value2); } else if (class1.equals(double[].class) && class2.equals(double[].class)) { return Arrays.equals((double[]) value1, (double[]) value2); } else if (class1.equals(boolean[].class) && class2.equals(boolean[].class)) { return Arrays.equals((boolean[]) value1, (boolean[]) value2); } else if (class1.equals(byte[].class) && class2.equals(byte[].class)) { return Arrays.equals((byte[]) value1, (byte[]) value2); } else if (class1.equals(short[].class) && class2.equals(short[].class)) { return Arrays.equals((short[]) value1, (short[]) value2); } else if (class1.equals(long[].class) && class2.equals(long[].class)) { return Arrays.equals((long[]) value1, (long[]) value2); } else if (class1.equals(char[].class) && class2.equals(char[].class)) { return Arrays.equals((char[]) value1, (char[]) value2); } else if (class1.equals(Object[].class) && class2.equals(Object[].class)) { return Arrays.equals((Object[]) value1, (Object[]) value2); } return false; } return (value1.equals(value2)); }

Target:
private static boolean valueEquals(@Nullable Object value1, @Nullable Object value2) { if ((value1 == null) && (value2 == null)) { return true; } if ((value1 == null) || (value2 == null)) { return false; } Class<?> class1 = value1.getClass(); Class<?> class2 = value2.getClass(); if (class1.isArray() && class2.isArray() && class1.equals(class2)) { if (class1.equals(int[].class) && class2.equals(int[].class)) { return Arrays.equals((int[]) value1, (int[]) value2); } else if (class1.equals(float[].class) && class2.equals(float[].class)) { return Arrays.equals((float[]) value1, (float[]) value2); } else if (class1.equals(double[].class) && class2.equals(double[].class)) { return Arrays.equals((double[]) value1, (double[]) value2); } else if (class1.equals(boolean[].class) && class2.equals(boolean[].class)) { return Arrays.equals((boolean[]) value1, (boolean[]) value2); } else if (class1.equals(byte[].class) && class2.equals(byte[].class)) { return Arrays.equals((byte[]) value1, (byte[]) value2); } else if (class1.equals(short[].class) && class2.equals(short[].class)) { return Arrays.equals((short[]) value1, (short[]) value2); } else if (class1.equals(long[].class) && class2.equals(long[].class)) { return Arrays.equals((long[]) value1, (long[]) value2); } else if (class1.equals(char[].class) && class2.equals(char[].class)) { return Arrays.equals((char[]) value1, (char[]) value2); } else if (class1.equals(Object[].class) && class2.equals(Object[].class)) { return Arrays.equals((Object[]) value1, (Object[]) value2); } return false; } return (value1.equals(value2)); }
Source:
public void outputMatchesExpectedForMissingBackupDir() throws UnsupportedEncodingException { String output = runBackup(); String reason = "Missing argument 'backup-dir'\n\n"; assertEquals( reason + BackupHelpOutput.BACKUP_OUTPUT, output ); }

Target:
public void outputMatchesExpectedForMissingBackupDir() throws UnsupportedEncodingException { String output = runBackup(); String reason = "Missing argument 'backup-dir'"; assertThat( output, containsString( reason ) ); for ( String line : BackupHelpOutput.BACKUP_OUTPUT_LINES ) { assertThat( output, containsString( line ) ); } }
Source:
public boolean containsLockOwner(Object lockOwner) { LockPlaceHolder holder = current; if (holder != null && holder.lockOwner.equals(lockOwner)) { return true; } if (pendingRequest.isEmpty()) { return false; } for (LockPlaceHolder pendingHolder : pendingRequest) { if (pendingHolder.lockOwner.equals(lockOwner)) { return true; } } holder = current; return holder != null && holder.lockOwner.equals(lockOwner); }

Target:
public boolean containsLockOwner(Object lockOwner) { return lockOwners.containsKey(lockOwner); }
Source:
public void init() throws IOException { if (fragments == null) { scanIt = new EmptyScanIterator(); } else { Schema projectedFields = getProjectSchema(); initScanner(projectedFields); Schema actualInSchema = scanner.isProjectable() ? projectedFields : inSchema; Target[] realTargets; if (plan.getTargets() == null) { realTargets = PlannerUtil.schemaToTargets(outSchema); } else { realTargets = plan.getTargets(); } if (realTargets.length == inSchema.size()) { for (int i = 0; i < inSchema.size(); i++) { if (realTargets[i].getEvalTree() instanceof FieldEval) { FieldEval f = realTargets[i].getEvalTree(); if(!f.getColumnRef().equals(inSchema.getColumn(i))) { needProjection = true; break; } } else { needProjection = true; break; } } } else { needProjection = true; } if(needProjection) { projector = new Projector(context, actualInSchema, outSchema, plan.getTargets()); } if (plan.hasQual()) { qual.bind(context.getEvalContext(), actualInSchema); } initScanIterator(); } super.init(); }

Target:
public void init() throws IOException { if (fragments == null) { scanIt = new EmptyScanIterator(); } else { Schema projectedFields = getProjectSchema(); initScanner(projectedFields); Schema actualInSchema = scanner.isProjectable() ? projectedFields : inSchema; initializeProjector(actualInSchema); if (plan.hasQual()) { qual.bind(context.getEvalContext(), actualInSchema); } initScanIterator(); } super.init(); }
Source:
private void initKeyStore() throws CertificateManagerException { LOG.debug("SamlCallbackHandler.initKeyStore() -- Begin"); final HashMap<String, String> keyStoreProperties = getKeyStoreSystemProperties(); String storeType = keyStoreProperties.get(KEY_STORE_TYPE_KEY); final String password = keyStoreProperties.get(KEY_STORE_SECRET_KEY); final String storeLoc = keyStoreProperties.get(KEY_STORE_KEY); if (storeType == null) { LOG.warn("javax.net.ssl.keyStoreType is not defined. Switch to use JKS by default"); storeType = JKS_TYPE; } if (password !=null){ if (JKS_TYPE.equals(storeType) && storeLoc == null) { LOG.error("javax.net.ssl.keyStore is not defined"); } else { keyStore = loadKeyStore(storeType, password, storeLoc); } }else{ LOG.error("Please define javax.net.ssl.keyStorePassword"); } LOG.debug("SamlCallbackHandler.initKeyStore() -- End"); }

Target:
private void initKeyStore() throws CertificateManagerException { LOG.debug("SamlCallbackHandler.initKeyStore() -- Begin"); final HashMap<String, String> keyStoreProperties = getKeyStoreSystemProperties(); String storeType = keyStoreProperties.get(KEY_STORE_TYPE_KEY); final String password = keyStoreProperties.get(KEY_STORE_PASSWORD_KEY); final String storeLoc = keyStoreProperties.get(KEY_STORE_KEY); if (storeType == null) { LOG.warn("{} is not defined. Switch to use JKS by default", KEY_STORE_TYPE_KEY); storeType = JKS_TYPE; } if (password !=null){ if (JKS_TYPE.equals(storeType) && storeLoc == null) { LOG.error("{} is not defined", KEY_STORE_TYPE_KEY); } else { keyStore = loadKeyStore(storeType, password, storeLoc); } }else{ LOG.error("Please define {}", KEY_STORE_PASSWORD_KEY); } LOG.debug("SamlCallbackHandler.initKeyStore() -- End"); }
Source:
public List<SnmpAgentConfig> getListOfAgentConfigs(DetectRequest request) { List<SnmpAgentConfig> agentConfigList = new ArrayList<>(); Map<String, String> runTimeAttributes = request.getRuntimeAttributes(); if (hasMultipleAgentConfigs(runTimeAttributes)) { runTimeAttributes.remove(HAS_MULTIPLE_AGENT_CONFIGS); runTimeAttributes.forEach((label, configAsString) -> { agentConfigList.add(SnmpAgentConfig.parseProtocolConfigurationString(configAsString)); }); } return agentConfigList; }

Target:
public List<SnmpAgentConfig> getListOfAgentConfigs(DetectRequest request) { List<SnmpAgentConfig> agentConfigList = new ArrayList<>(); Map<String, String> runTimeAttributes = request.getRuntimeAttributes(); if (useSnmpProfiles() && hasMultipleAgentConfigs(runTimeAttributes)) { runTimeAttributes.forEach((label, configAsString) -> { if (label.contains(AGENT_CONFIG_PREFIX)) { agentConfigList.add(SnmpAgentConfig.parseProtocolConfigurationString(configAsString)); } }); } else if (hasMultipleAgentConfigs(runTimeAttributes)) { runTimeAttributes.forEach((label, configAsString) -> { if (label.contains(AGENT_CONFIG_PREFIX) && label.contains(PROFILE_LABEL_FOR_DEFAULT_CONFIG)) { agentConfigList.add(SnmpAgentConfig.parseProtocolConfigurationString(configAsString)); } }); } return agentConfigList; }
Source:
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { context.acquireControllerLock(); context.readResource(PathAddress.EMPTY_ADDRESS, false); final String group = getServerGroupName(operation); final boolean blocking = operation.get(BLOCKING).asBoolean(false); final int timeout = operation.get(TIMEOUT).asInt(0); context.addStep(new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { context.getServiceRegistry(true); if (group != null) { final Set<String> waitForServers = new HashSet<String>(); final ModelNode model = Resource.Tools.readModel(context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, true)); for (String server : getServersForGroup(model, group)) { serverInventory.stopServer(server, timeout > 0 ? timeout * 1000 : timeout); waitForServers.add(server); } if (blocking) { serverInventory.awaitServersState(waitForServers, false); } } else { serverInventory.stopServers( timeout > 0 ? timeout * 1000 : timeout, blocking); } context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }, Stage.RUNTIME); context.stepCompleted(); }

Target:
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { context.acquireControllerLock(); context.readResource(PathAddress.EMPTY_ADDRESS, false); final String group = getServerGroupName(operation); final boolean blocking = BLOCKING.resolveModelAttribute(context, operation).asBoolean(); final int timeout = TIMEOUT.resolveModelAttribute(context, operation).asInt(); context.addStep(new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { context.getServiceRegistry(true); if (group != null) { final Set<String> waitForServers = new HashSet<String>(); final ModelNode model = Resource.Tools.readModel(context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, true)); for (String server : getServersForGroup(model, group)) { serverInventory.stopServer(server, timeout > 0 ? timeout * 1000 : timeout); waitForServers.add(server); } if (blocking) { serverInventory.awaitServersState(waitForServers, false); } } else { serverInventory.stopServers( timeout > 0 ? timeout * 1000 : timeout, blocking); } context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }, Stage.RUNTIME); context.stepCompleted(); }
Source:
public static StringBuffer statusToString(IStatus status, int severities, StringBuffer b) { IStatus[] nestedStatus = status.getChildren(); if (b == null) b = new StringBuffer(); if (severities == -1 || (status.getSeverity() & severities) != 0) { if (b.length() > 0) b.append('\n'); b.append(status.getMessage()); } for (IStatus nestedStatu : nestedStatus) { statusToString(nestedStatu, severities, b); } return b; }

Target:
public static StringBuffer statusToString(IStatus status, int severities, StringBuffer b) { IStatus[] nestedStatus = status.getChildren(); if (b == null) b = new StringBuffer(); if (severities == -1 || (status.getSeverity() & severities) != 0) { if (b.length() > 0) b.append('\n'); b.append(status.getMessage()); } for (IStatus s : nestedStatus) { statusToString(s, severities, b); } return b; }