auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void cancelRunningStackConfigUpdates(Environment environment) { try { FlowLog flowLog = flowLogDBService.getLastFlowLogByResourceCrnOrName(environment.getResourceCrn()); if (!flowLog.getFinalized() && flowLog.getFlowType() != null && flowLog.getFlowType().getCanonicalName() .equals(EnvStackConfigUpdatesFlowConfig.class.getCanonicalName())) { LOGGER.info("Canceling running Stack config update flow for environment {}", environment.getResourceCrn()); <START> EnvironmentInMemoryStateStore.put(environment.getId(), PollGroup.CANCELLED); <END> flowCancelService.cancelFlowSilently(flowLog); } else { LOGGER.debug("No running Stack config update flow to cancel"); } } catch (NotFoundException nfe) { LOGGER.info("No flow logs found for environment {}", environment.getResourceCrn()); } }</code><technical_language>I FlowLogDBService#findAllByResourceIdAndFinalizedIsFalseOrderByCreatedDesc spare some resources: - fetch db for environment - loose finalized check in next if - loose try-catch isEmpty instead</technical_language>

Target:
public void cancelRunningStackConfigUpdates(Environment environment) { List<FlowLog> flowLogs = flowLogDBService.findAllByResourceIdAndFinalizedIsFalseOrderByCreatedDesc(environment.getId()); if (!flowLogs.isEmpty() && flowLogs.get(0).getFlowType() != null && EnvStackConfigUpdatesFlowConfig.class.equals(flowLogs.get(0).getFlowType())) { LOGGER.info("Canceling running Stack config update flow for environment {}", environment.getResourceCrn()); EnvironmentInMemoryStateStore.put(environment.getId(), PollGroup.CANCELLED); flowCancelService.cancelFlowSilently(flowLogs.get(0)); } else { LOGGER.debug("No running Stack config update flow to cancel"); } }
Source:
<code>public KStream<K, V> repartition(final Repartitioned<K, V> repartitioned) { Objects.requireNonNull(repartitioned, "repartitioned parameter can't be null"); final RepartitionedInternal<K, V> repartitionedInternal = new RepartitionedInternal<>(repartitioned); final String name = new NamedInternal(repartitionedInternal.name()) <START> .orElseGenerateWithPrefix(builder, REPARTITION_NAME); <END> final Serde<K> keySerde = repartitionedInternal.keySerde() == null ? this.keySerde : repartitionedInternal.keySerde(); final Serde<V> valueSerde = repartitionedInternal.valueSerde() == null ? this.valSerde : repartitionedInternal.valueSerde(); final UnoptimizableRepartitionNodeBuilder<K, V> unoptimizableRepartitionNodeBuilder = UnoptimizableRepartitionNode.repartitionNodeBuilder(); final String repartitionSourceName = createUnoptimizableRepartitionSource( builder, keySerde, valueSerde, name, repartitionedInternal.toInternalTopicProperties(), repartitionedInternal.streamPartitioner(), unoptimizableRepartitionNodeBuilder ); final UnoptimizableRepartitionNode<K, V> unoptimizableRepartitionNode = unoptimizableRepartitionNodeBuilder.build(); builder.addGraphNode(this.streamsGraphNode, unoptimizableRepartitionNode); return new KStreamImpl<>( repartitionSourceName, keySerde, valueSerde, sourceNodes, false, unoptimizableRepartitionNode, builder ); }</code><technical_language>This invocation side effect of incrementing "topology name counter". In other words, this means inserting a "repartition" node a name other processors, stores, repartition topics in topology get renamed anyway. clarify (because confusing) this method increments counter if generating a name. consider instead making Suppression, increment counter if provide a name</technical_language>

Target:
public KStream<K, V> repartition(final Repartitioned<K, V> repartitioned) { return doRepartition(repartitioned); }
Source:
<code>public void testRegexMapper() { <START> Roles roles = createRoles("123-user", "joe", "abc-admin"); <END> RegexRoleMapper roleMapper = new RegexRoleMapper(); roleMapper.initialize(".*-([a-z]*)", "$1",true); Roles mappedRoles = roleMapper.mapRoles(roles); assertTrue(mappedRoles.contains("user")); assertTrue(mappedRoles.contains("admin")); assertFalse(mappedRoles.contains("abc-admin")); assertFalse(mappedRoles.contains("123-user")); assertTrue(mappedRoles.contains("joe")); Iterator<String> iterator = mappedRoles.iterator(); int count = 0; while (iterator.hasNext()) { iterator.next(); count++; } assertEquals(count, 3); }</code><technical_language>Missing copyright header</technical_language>

Target:
public void testRegexMapper() { Roles roles = createRoles("123-user", "joe", "abc-admin"); RegexRoleMapper roleMapper = new RegexRoleMapper.Builder().setPattern(".*-([a-z]*)").setReplacement("$1").setKeepNonMapped(true).build(); Roles mappedRoles = roleMapper.mapRoles(roles); assertTrue(mappedRoles.contains("user")); assertTrue(mappedRoles.contains("admin")); assertFalse(mappedRoles.contains("abc-admin")); assertFalse(mappedRoles.contains("123-user")); assertTrue(mappedRoles.contains("joe")); Iterator<String> iterator = mappedRoles.iterator(); int count = 0; while (iterator.hasNext()) { iterator.next(); count++; } assertEquals(count, 3); }
Source:
<code>public Map<String, String> getCommonLabels() { <START> return KubernetesUtils.getCommonLabels(getClusterId()); <END> }</code><technical_language>this change belong this commit</technical_language>

Target:
public Map<String, String> getCommonLabels() { return Collections.unmodifiableMap(KubernetesUtils.getCommonLabels(getClusterId())); }
Source:
<code>private RecordingCommand <START> sortFiltersIfNeeded(Collection<Notification> <END> notifications) { RecordingCommand recordingCommand = null; for (Notification notification : notifications) { if (notification.getNotifier() instanceof DDiagram && notification.getFeature().equals(DiagramPackage.eINSTANCE.getDDiagram_ActivatedFilters()) && (Notification.ADD == notification.getEventType() || Notification.ADD_MANY == notification.getEventType())) { DDiagram diagram = (DDiagram) notification.getNotifier(); List<FilterDescription> descriptions = new ArrayList<>(diagram.getActivatedFilters()); List<FilterDescription> sortedFilters = FilterService.sortFilters(descriptions); boolean listsAreEqual = sortedFilters.size() == diagram.getActivatedFilters().size(); if (listsAreEqual) { int i = 0; while (listsAreEqual && i < sortedFilters.size()) { listsAreEqual = sortedFilters.get(i).equals(diagram.getActivatedFilters().get(i)); i++; } } if (!listsAreEqual) { recordingCommand = new RecordingCommand(domain) { @Override protected void doExecute() { diagram.getActivatedFilters().clear(); diagram.getActivatedFilters().addAll(sortedFilters); } }; } break; } } return recordingCommand; }</code><technical_language>IMO, missed here: * Existing models need a migration need sort filters in existing commands: * sort filters * * ActivateFiltersCommand.doActivateFilters() * SetDefaultConcernCommand * FilterUpdateTask.handleActivation()</technical_language>

Target:
private RecordingCommand sortFiltersIfNeeded(Collection<Notification> notifications) { RecordingCommand recordingCommand = null; for (Notification notification : notifications) { if (notification.getNotifier() instanceof DDiagram && notification.getFeature().equals(DiagramPackage.eINSTANCE.getDDiagram_ActivatedFilters()) && (Notification.ADD == notification.getEventType() || Notification.ADD_MANY == notification.getEventType())) { DDiagram diagram = (DDiagram) notification.getNotifier(); List<FilterDescription> descriptions = new ArrayList<>(diagram.getActivatedFilters()); List<FilterDescription> sortedFilters = FilterService.sortFilters(descriptions); if (!Iterables.elementsEqual(sortedFilters, diagram.getActivatedFilters())) { recordingCommand = new RecordingCommand(domain) { @Override protected void doExecute() { diagram.getActivatedFilters().clear(); diagram.getActivatedFilters().addAll(sortedFilters); } }; } break; } } return recordingCommand; }
Source:
<code>public boolean isConfigured() { <START> return !CommonUtils.isBlank(getBaseURL()); <END> }</code><technical_language>baseUrl directly</technical_language>

Target:
public boolean isConfigured() { return !CommonUtils.isBlank(baseURL); }
Source:
<code>protected Table constructTable(Class<?> entityClass, EntityDictionary metaDataDictionary) { <START> return new SQLTable(entityClass, metaDataDictionary, defaultConnectionDetails, connectionDetailsMap); <END> }</code><technical_language>SQLTable need default connectionDetails map. handed ConnectionDetail object pertains it</technical_language>

Target:
protected Table constructTable(Class<?> entityClass, EntityDictionary metaDataDictionary) { String dbConnectionName = null; Annotation annotation = EntityDictionary.getFirstAnnotation(entityClass, Arrays.asList(FromTable.class, FromSubquery.class)); if (annotation instanceof FromTable) { dbConnectionName = ((FromTable) annotation).dbConnectionName(); } else if (annotation instanceof FromSubquery) { dbConnectionName = ((FromSubquery) annotation).dbConnectionName(); } ConnectionDetails connectionDetails; if (dbConnectionName == null || dbConnectionName.trim().isEmpty()) { connectionDetails = defaultConnectionDetails; } else { connectionDetails = connectionDetailsMap.get(dbConnectionName); } return new SQLTable(entityClass, metaDataDictionary, connectionDetails); }
Source:
<code>public CommitterPreferencePresenter(CommitterPreferenceView view, GitLocalizationConstant constant, PreferencesManager preferencesManager) { super(constant.committerTitle(), constant.committerPreferenceCategory(), null); this.view = view; this.preferencesManager = preferencesManager; String userName = preferencesManager.getValue(COMMITTER_NAME); String userEmail = preferencesManager.getValue(COMMITTER_EMAIL); <START> name = userName == null ? DEFAULT_COMMITTER_NAME : userName; <END> email = userEmail == null ? DEFAULT_COMMITTER_EMAIL : userEmail; view.setDelegate(this); }</code><technical_language>Objects.firstNonNull guava library</technical_language>

Target:
public CommitterPreferencePresenter(CommitterPreferenceView view, GitLocalizationConstant constant, PreferencesManager preferencesManager) { super(constant.committerTitle(), constant.committerPreferenceCategory(), null); this.view = view; this.preferencesManager = preferencesManager; name = firstNonNull(preferencesManager.getValue(COMMITTER_NAME), DEFAULT_COMMITTER_NAME); email = firstNonNull(preferencesManager.getValue(COMMITTER_EMAIL), DEFAULT_COMMITTER_EMAIL); view.setDelegate(this); }
Source:
<code>public static ByteBuf encode( ByteBufAllocator allocator, int streamId, boolean fragmentFollows, ByteBuf metadata, ByteBuf data) { <START> if (metadata == null) { <END> metadata = Unpooled.EMPTY_BUFFER; } return FLYWEIGHT.encode(allocator, streamId, fragmentFollows, metadata, data); }</code><technical_language>spec metadata is nullable, this case is handled RequestFlyweight.encode</technical_language>

Target:
public static ByteBuf encode( ByteBufAllocator allocator, int streamId, boolean fragmentFollows, ByteBuf metadata, ByteBuf data) { return FLYWEIGHT.encode(allocator, streamId, fragmentFollows, metadata, data); }
Source:
<code>public ListBoxBaseDefinition getDefaultField() { StringListBoxFieldDefinition result = new StringListBoxFieldDefinition(); <START> result.setStandaloneClassName(String.class.getName()); <END> return result; }</code><technical_language>here, on, in case sense</technical_language>

Target:
public ListBoxBaseDefinition getDefaultField() { return new StringListBoxFieldDefinition(); }
Source:
<code>public void whenListSubscriptionsLimitAndOffsetAreRespected() throws ServiceUnavailableException { final List<Subscription> testSubscriptions = createRandomSubscriptions(10); testSubscriptions.forEach(this::insertSubscriptionToDB); final List<Subscription> expectedSubscriptions = testSubscriptions.stream() .sorted(SUBSCRIPTION_CREATION_DATE_DESC_COMPARATOR) .collect(toList()); <START> expectedSubscriptions.subList(0, 2).clear(); <END> expectedSubscriptions.subList(3, expectedSubscriptions.size()).clear(); final List<Subscription> subscriptions = repository.listSubscriptions(emptySet(), Optional.empty(), 2, 3); assertThat(subscriptions, equalTo(expectedSubscriptions)); }</code><technical_language>explain a bit</technical_language>

Target:
public void whenListSubscriptionsLimitAndOffsetAreRespected() throws ServiceUnavailableException { final List<Subscription> testSubscriptions = createRandomSubscriptions(10); testSubscriptions.forEach(this::insertSubscriptionToDB); testSubscriptions.sort(SUBSCRIPTION_CREATION_DATE_DESC_COMPARATOR); testSubscriptions.subList(0, 2).clear(); testSubscriptions.subList(3, testSubscriptions.size()).clear(); final List<Subscription> subscriptions = repository.listSubscriptions(emptySet(), Optional.empty(), 2, 3); assertThat(subscriptions, equalTo(testSubscriptions)); }
Source:
<code>private synchronized void startDelayedWrite() { if (OneSignal.appContext == null) return; startThread(); <START> scheduleFlushToDiskJob(); <END> }</code><technical_language>do need this call, depend onLooperPrepared</technical_language>

Target:
private synchronized void startDelayedWrite() { if (OneSignal.appContext == null) return; startThread(); scheduleFlushToDisk(); }
Source:
<code>private static Supplier<ResultSet> getResultSet(Supplier<PreparedStatement> supplier, StatementContext ctx) { return () -> { try { ResultSet rs = supplier.get().getResultSet(); <START> if (rs != null) { <END> ctx.addCleanable(forResultSet(rs)); } return rs; } catch (SQLException e) { throw new ResultSetException("Could not get result set", e, ctx); } }; }</code><technical_language>error call this method if get result set? Feels strongly misuse / coding error</technical_language>

Target:
private static Supplier<ResultSet> getResultSet(Supplier<PreparedStatement> supplier, StatementContext ctx) { return () -> { try { ResultSet rs = supplier.get().getResultSet(); if (rs == null) { throw new NoResultsException("Statement returned no results", ctx); } ctx.addCleanable(forResultSet(rs)); return rs; } catch (SQLException e) { throw new ResultSetException("Could not get result set", e, ctx); } }; }
Source:
<code>public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if ((authentication != null) && authentication.isAuthenticated() && !authentication.getName() .equals(ANONYMOUS_USERNAME) <START> && !httpRequest.getRequestURI().toLowerCase().equals(CHANGE_PASSWORD_URI.toLowerCase())) <END> { User user = userService.getUser(authentication.getName()); if (user == null) { throw new RuntimeException("Unknown username [" + authentication.getName() + "]"); } if (user.isChangePassword() != null && user.isChangePassword()) { redirectStrategy.sendRedirect(httpRequest, httpResponse, CHANGE_PASSWORD_URI); return; } } chain.doFilter(request, response); }</code><technical_language>this is security stuff I a unit test for this code branch</technical_language>

Target:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if ((authentication != null) && authentication.isAuthenticated() && !authentication.getName() .equals(ANONYMOUS_USERNAME) && !httpRequest.getRequestURI().equalsIgnoreCase(CHANGE_PASSWORD_URI)) { User user = userService.getUser(authentication.getName()); if (user == null) { throw new RuntimeException("Unknown username [" + authentication.getName() + "]"); } if (user.isChangePassword() != null && user.isChangePassword()) { redirectStrategy.sendRedirect(httpRequest, httpResponse, CHANGE_PASSWORD_URI); return; } } chain.doFilter(request, response); }
Source:
<code>public <START> BuyOrder(String <END> inputStock, int sizeIn, double priceIn, Trader traderIn) { stockSymbol = inputStock; size = sizeIn; price = priceIn; trader = traderIn; }</code><technical_language>calling super class. add super(params)</technical_language>

Target:
public BuyOrder(String inputStock, int sizeIn, double priceIn, Trader traderIn) { super(); stockSymbol = inputStock; size = sizeIn; price = priceIn; trader = traderIn; }
Source:
<code>private void resolveSetterConflicts(Map<String, List<Method>> conflictingSetters) { for (String propName : conflictingSetters.keySet()) { List<Method> setters = conflictingSetters.get(propName); Class<?> getterType = getTypes.get(propName); Method match = null; for (Method setter : setters) { <START> if (setter.getParameterTypes()[0].equals(getterType)) { <END> match = setter; break; } match = pickBetterSetter(match, setter, propName); } if (match != null) { addSetMethod(propName, match); } } }</code><technical_language>this change, getter methods conflict, I decide method matched parameter type getterType matched method. WDYT</technical_language>

Target:
private void resolveSetterConflicts(Map<String, List<Method>> conflictingSetters) { for (String propName : conflictingSetters.keySet()) { List<Method> setters = conflictingSetters.get(propName); Class<?> getterType = getTypes.get(propName); boolean isGetterAmbiguous = getMethods.get(propName) instanceof AmbiguousMethodInvoker; boolean isSetterAmbiguous = false; Method match = null; for (Method setter : setters) { if (!isGetterAmbiguous && setter.getParameterTypes()[0].equals(getterType)) { match = setter; break; } if (!isSetterAmbiguous) { match = pickBetterSetter(match, setter, propName); isSetterAmbiguous = match == null; } } if (match != null) { addSetMethod(propName, match); } } }
Source:
<code>public void run() { getNodeEngine().getExecutionService().execute(ExecutionService.ASYNC_EXECUTOR, () -> { <START> getNodeEngine().getClusterService().changeClusterState(newState); <END> sendResponse(null); }); }</code><technical_language>need handle exceptions done else</technical_language>

Target:
public void run() { ILogger logger = getNodeEngine().getLogger(getClass()); ExecutionService executionService = getNodeEngine().getExecutionService(); Future<Void> future = executionService.submit( ExecutionService.ASYNC_EXECUTOR, () -> { getNodeEngine().getClusterService().changeClusterState(newState); return null; }); executionService.asCompletableFuture(future).whenComplete( withTryCatch( logger, (empty, error) -> sendResponse(error != null ? peel(error) : null))); }
Source:
<code>private Provider<OpenStackImageProviderProperties> createOpenStackV2Provider(String name, String url, String tenant) { Provider<OpenStackImageProviderProperties> result = mock(Provider.class); when(result.getName()).thenReturn(name); when(result.getType()).thenReturn(ProviderType.OPENSTACK_IMAGE); <START> when(result.getAuthUrl()).thenReturn("http://localhost:35357/v2.0/"); <END> OpenStackImageProviderProperties props = mock(OpenStackImageProviderProperties.class); when(props.getTenantName()).thenReturn(tenant); when(result.getAdditionalProperties()).thenReturn(props); when(result.getUrl()).thenReturn(url); return result; }</code><technical_language>I more graceful a private final String</technical_language>

Target:
private Provider<OpenStackImageProviderProperties> createOpenStackV2Provider(String name, String url, String tenant) { Provider<OpenStackImageProviderProperties> result = mock(Provider.class); when(result.getName()).thenReturn(name); when(result.getType()).thenReturn(ProviderType.OPENSTACK_IMAGE); when(result.getAuthUrl()).thenReturn(AUTH_URL_LOCALHOST); OpenStackImageProviderProperties props = mock(OpenStackImageProviderProperties.class); when(props.getTenantName()).thenReturn(tenant); when(result.getAdditionalProperties()).thenReturn(props); when(result.getUrl()).thenReturn(url); return result; }
Source:
<code>public void setModified(DateTime date) throws InvalidArgumentException { if (date == null) { throw new InvalidArgumentException("Date cannot be empty"); } <START> copyConditions.put("x-amz-copy-source-if-modified-since", RFC1123_DATE_TIME_FORMATTER.print(date)); <END> }</code><technical_language>Currently format is date.toString(DateFormat.AMZ_DATE_FORMAT). is better</technical_language>

Target:
public void setModified(DateTime date) throws InvalidArgumentException { if (date == null) { throw new InvalidArgumentException("Date cannot be empty"); } copyConditions.put("x-amz-copy-source-if-modified-since", date.toString(DateFormat.HTTP_HEADER_DATE_FORMAT)); }
Source:
<code>public void multipleClientsCanShareGlobalThreads() { List<RemoteLockService> lockServiceList = ImmutableList.of( getLockService(CLIENT_1), getLockService(CLIENT_2), getLockService(CLIENT_3)); <START> assertThat(lockAndUnlockAndCountExceptions(lockServiceList, LOCAL_TC_LIMIT + GLOBAL_TC_LIMIT / 3)) <END> .isEqualTo(0); }</code><technical_language>Wow, some pretty intricate tests. a _seems_ right, a closer merge</technical_language>

Target:
public void multipleClientsCanShareGlobalThreads() throws Exception { List<RemoteLockService> lockServiceList = ImmutableList.of( getLockService(CLIENT_1), getLockService(CLIENT_2), getLockService(CLIENT_3)); assertThat(lockAndUnlockAndCountExceptions(lockServiceList, LOCAL_TC_LIMIT + SHARED_TC_LIMIT / 3)) .isEqualTo(0); }
Source:
<code>protected void configure() { setName(SERVICE_NAME); <START> setDescription("Dictionary ops service."); <END> addHandler(new DictionaryOpsServiceHandler()); }</code><technical_language>"Service get values a Dictionary". more meaningful too</technical_language>

Target:
protected void configure() { setName(SERVICE_NAME); setDescription("Service to retrieve values from a Dictionary."); addHandler(new DictionaryOpsServiceHandler()); }
Source:
<code>public List<VariableDeclarator> localVariablesExposedToChild(Node child) { <START> for (int i=0;i<wrappedNode.getResources().size();i++) { <END> if (child == wrappedNode.getResources().get(i)) { return wrappedNode.getResources().subList(0, i).stream() .map(e -> e instanceof VariableDeclarationExpr ? ((VariableDeclarationExpr) e).getVariables() : Collections.<VariableDeclarator>emptyList()) .flatMap(List::stream) .collect(Collectors.toList()); } } if (child == wrappedNode.getTryBlock()) { List<VariableDeclarator> res = new LinkedList<>(); for (Expression expr : wrappedNode.getResources()) { if (expr instanceof VariableDeclarationExpr) { res.addAll(((VariableDeclarationExpr)expr).getVariables()); } } return res; } return Collections.emptyList(); }</code><technical_language>a bit confused this loop. VariableDeclarationExprs declared _before_ argument child, performing operations get this list excessive. I count 4 iterations list</technical_language>

Target:
public List<VariableDeclarator> localVariablesExposedToChild(Node child) { NodeList<Expression> resources = wrappedNode.getResources(); for (int i=0;i<resources.size();i++) { if (child == resources.get(i)) { return resources.subList(0, i).stream() .map(e -> e instanceof VariableDeclarationExpr ? ((VariableDeclarationExpr) e).getVariables() : Collections.<VariableDeclarator>emptyList()) .flatMap(List::stream) .collect(Collectors.toList()); } } if (child == wrappedNode.getTryBlock()) { List<VariableDeclarator> res = new LinkedList<>(); for (Expression expr : resources) { if (expr instanceof VariableDeclarationExpr) { res.addAll(((VariableDeclarationExpr)expr).getVariables()); } } return res; } return Collections.emptyList(); }
Source:
<code>public void onNetworkCapabilitiesChanged() { <START> synchronized (mNetworkPoliciesSecondLock) { <END> updateNetworkRulesNL(); } }</code><technical_language>a good idea do this ConnectivityService handler thread. slow network switching, possibly lead deadlock. Also, other network change listeners (e.g., mConnReceiver, WifiConfigReceiver) run mHandler, this code takes a lock result in happening in wrong order. run this handler thread instead? like: mHandler.post(() -> { synchronized (mNetworkPoliciesSecondLock) { updateNetworkRulesNL(); } });</technical_language>

Target:
public void onNetworkCapabilitiesChanged() { mHandler.post(() -> { synchronized (mNetworkPoliciesSecondLock) { updateNetworkRulesNL(); } }); }
Source:
<code>TaskData getTaskData(AbstractRepositoryConnector connector, IProgressMonitor monitor) throws CoreException { if (taskId != null && taskKey != null && connector.supportsSearchByTaskKey(repository)) { try { TaskData data = getTaskDataByKey(connector, monitor); if (data != null) { return data; } } catch (CoreException | RuntimeException e) { } try { return connector.getTaskData(repository, taskId, monitor); } catch (RuntimeException e) { throw new CoreException(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, String.format("Could not find task with ID %s", taskId), e)); } } else if (taskId != null) { <START> return connector.getTaskData(repository, taskId, monitor); <END> } else if (taskKey != null && connector.supportsSearchByTaskKey(repository)) { return getTaskDataByKey(connector, monitor); } return null; }</code><technical_language>this try/catch previous block</technical_language>

Target:
TaskData getTaskData(AbstractRepositoryConnector connector, IProgressMonitor monitor) throws CoreException { if (taskId != null && taskKey != null && connector.supportsSearchByTaskKey(repository)) { try { TaskData data = getTaskDataByKey(connector, monitor); if (data != null) { return data; } } catch (CoreException | RuntimeException e) { } try { return connector.getTaskData(repository, taskId, monitor); } catch (CoreException | RuntimeException e) { throw new CoreException(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, NLS.bind("Could not find task with ID \"{0}\" on repository {1}.", taskId, repository), e)); } } else if (taskId != null) { return connector.getTaskData(repository, taskId, monitor); } else if (taskKey != null && connector.supportsSearchByTaskKey(repository)) { return getTaskDataByKey(connector, monitor); } return null; }
Source:
<code>private List<String> resolveAttributes(MBeanServer mbeanServer, ObjectName on) throws Exception { List<String> resolvedAttributes = new ArrayList<>(); if (attribute == null || attribute.isEmpty()) { for (MBeanAttributeInfo mBeanAttributeInfo : mbeanServer.getMBeanInfo(on).getAttributes()) { resolvedAttributes.add(mBeanAttributeInfo.getName()); } } else { <START> String[] attributes = attribute.split(","); <END> resolvedAttributes.addAll(Arrays.asList(attributes)); } return resolvedAttributes; }</code><technical_language>trim blank spaces</technical_language>

Target:
private List<String> resolveAttributes(MBeanServer mbeanServer, ObjectName on) { if (attributes.isEmpty()) { return findAllAttributes(mbeanServer, on); } return attributes; }
Source:
<code>BlobBatch(String accountUrl, HttpPipeline pipeline) { this.contentId = new AtomicInteger(0); this.batchBoundary = String.format(BATCH_BOUNDARY_TEMPLATE, UUID.randomUUID()); this.contentType = String.format(REQUEST_CONTENT_TYPE_TEMPLATE, batchBoundary); boolean batchHeadersPolicySet = false; HttpPipelineBuilder batchPipelineBuilder = new HttpPipelineBuilder().httpClient(this::setupBatchOperation); for (int i = 0; i < pipeline.getPolicyCount(); i++) { HttpPipelinePolicy policy = pipeline.getPolicy(i); if (policy instanceof SharedKeyCredentialPolicy) { batchHeadersPolicySet = true; batchPipelineBuilder.policies(this::cleanseHeaders); } batchPipelineBuilder.policies(pipeline.getPolicy(i)); } if (!batchHeadersPolicySet) { batchPipelineBuilder.policies(this::cleanseHeaders); } this.batchClient = new BlobClientBuilder() .endpoint(accountUrl) <START> .blobName("") <END> .pipeline(batchPipelineBuilder.build()) .buildAsyncClient(); this.batchOperationQueue = new ConcurrentLinkedDeque<>(); this.batchRequest = new ArrayList<>(); this.batchMapping = new ConcurrentHashMap<>(); }</code><technical_language>blobName empty string</technical_language>

Target:
BlobBatch(String accountUrl, HttpPipeline pipeline) { this.contentId = new AtomicInteger(0); this.batchBoundary = String.format(BATCH_BOUNDARY_TEMPLATE, UUID.randomUUID()); this.contentType = String.format(REQUEST_CONTENT_TYPE_TEMPLATE, batchBoundary); boolean batchHeadersPolicySet = false; HttpPipelineBuilder batchPipelineBuilder = new HttpPipelineBuilder().httpClient(this::setupBatchOperation); for (int i = 0; i < pipeline.getPolicyCount(); i++) { HttpPipelinePolicy policy = pipeline.getPolicy(i); if (policy instanceof SharedKeyCredentialPolicy) { batchHeadersPolicySet = true; batchPipelineBuilder.policies(this::cleanseHeaders, this::setRequestUrl); } batchPipelineBuilder.policies(pipeline.getPolicy(i)); } if (!batchHeadersPolicySet) { batchPipelineBuilder.policies(this::cleanseHeaders, this::setRequestUrl); } this.blobAsyncClient = new BlobClientBuilder() .endpoint(accountUrl) .blobName("") .pipeline(batchPipelineBuilder.build()) .buildAsyncClient(); this.batchOperationQueue = new ConcurrentLinkedDeque<>(); this.batchRequest = new ArrayList<>(); this.batchMapping = new ConcurrentHashMap<>(); }
Source:
<code>public static void tearDownAfterClass() { <START> } <END></code><technical_language>Need WebsocketEchoTestBase.tearDownAfterClass(); clean resources</technical_language>

Target:
public static void tearDownAfterClass() { WebsocketEchoTestBase.cleanupFiles(); }
Source:
<code>public static IntSet make(Set<Integer> x) { int[] vals = new int[x.size()]; Iterator<Integer> vs = x.iterator(); <START> Arrays.setAll(vals, i -> vs.next()); <END> return make(vals); }</code><technical_language>toArray due unboxing</technical_language>

Target:
public static IntSet make(Set<Integer> x) { int[] vals = x.stream().mapToInt(Integer::intValue).toArray(); return make(vals); }
Source:
<code>private static ThrottleSetting loadThrottleCommand(Element elem, Warrant w) { long time = 0; try { time = elem.getAttribute("time").getLongValue(); } catch (org.jdom2.DataConversionException dce) { log.warn("error loading throttle command"); } Attribute attr = elem.getAttribute("command"); String command = null; if (attr != null) { command = attr.getValue(); } else { <START> log.error("Command type is null for throttleSetting in warrant {}", command, w.getDisplayName()); <END> return null; } attr = elem.getAttribute("value"); String value = null; if (attr != null) value =attr.getValue(); attr = elem.getAttribute("block"); String block = null; if (attr != null) block =attr.getValue(); float speed = 0.0f; attr = elem.getAttribute("trackSpeed"); if (attr != null) { try { speed = attr.getFloatValue(); } catch (DataConversionException ex) { speed = 0.0f; log.error("Unable to read speed of command.", ex); } } return new ThrottleSetting(time, command, value, block, speed); }</code><technical_language>Spotbugs complains this line. parameter command is null this point. @SuppressFBWarnings needs removed</technical_language>

Target:
private static ThrottleSetting loadThrottleCommand(Element elem, Warrant w) { long time = 0; try { time = elem.getAttribute("time").getLongValue(); } catch (org.jdom2.DataConversionException dce) { log.warn("error loading throttle command"); } Attribute attr = elem.getAttribute("command"); String command = null; if (attr != null) { command = attr.getValue(); } else { log.error("Command type is null. ThrottleSetting not loaded for warrant {}", w.getDisplayName()); return null; } attr = elem.getAttribute("value"); String value = null; if (attr != null) value =attr.getValue(); attr = elem.getAttribute("block"); String block = null; if (attr != null) block =attr.getValue(); float speed = 0.0f; attr = elem.getAttribute("trackSpeed"); if (attr != null) { try { speed = attr.getFloatValue(); } catch (DataConversionException ex) { speed = 0.0f; log.error("Unable to read speed of command.", ex); } } return new ThrottleSetting(time, command, value, block, speed); }
Source:
<code>private synchronized void handleNewCheckpoint(CheckpointBarrier barrier) { long barrierId = barrier.getId(); if (!allBarriersReceivedFuture.isDone()) { LOG.warn("{}: Received checkpoint barrier for checkpoint before completing current checkpoint {}. " + "Skipping current checkpoint.", handler.taskName, barrierId, currentReceivedCheckpointId); long currentCheckpointId = currentReceivedCheckpointId; handler.runInTaskThread(() -> handler.notifyAbort(currentCheckpointId, new CheckpointException( "Barrier id: " + barrierId, CheckpointFailureReason.CHECKPOINT_DECLINED_SUBSUMED)), "notifyAbort"); } currentReceivedCheckpointId = barrierId; Arrays.fill(storeNewBuffers, true); numBarriersReceived = 0; <START> allBarriersReceivedFuture = new CompletableFuture<>(); channelStateWriter.start(barrierId, barrier.getCheckpointOptions()); <END> }</code><technical_language>I understood, channelStateWriter.finishInput is called this allBarriersReceivedFuture is completed. in a entangled manner: StreamTask.prepareInputSnapshot -> InputProcessor -> InputGate -> Unaligner -> ThreadSafeUnaligner (this). set this callback right here</technical_language>

Target:
private synchronized void handleNewCheckpoint(CheckpointBarrier barrier) throws IOException { long barrierId = barrier.getId(); if (!allBarriersReceivedFuture.isDone()) { LOG.warn("{}: Received checkpoint barrier for checkpoint before completing current checkpoint {}. " + "Skipping current checkpoint.", handler.taskName, barrierId, currentReceivedCheckpointId); long currentCheckpointId = currentReceivedCheckpointId; handler.executeInTaskThread(() -> handler.notifyAbort(currentCheckpointId, new CheckpointException( "Barrier id: " + barrierId, CheckpointFailureReason.CHECKPOINT_DECLINED_SUBSUMED)), "notifyAbort"); } currentReceivedCheckpointId = barrierId; Arrays.fill(storeNewBuffers, true); numBarriersReceived = 0; allBarriersReceivedFuture = new CompletableFuture<>(); channelStateWriter.start(barrierId, barrier.getCheckpointOptions()); }
Source:
<code>public Image getImage(AttributeType type) { if (type == AttributeType.IDENTIFYING_ATTRIBUTE) { return getManagedImage("bullet_red.png"); } if (type == AttributeType.INSENSITIVE_ATTRIBUTE) { return getManagedImage("bullet_green.png"); } if (type == AttributeType.SENSITIVE_ATTRIBUTE) { return getManagedImage("bullet_purple.png"); } if (type == AttributeType.QUASI_IDENTIFYING_ATTRIBUTE) { return getManagedImage("bullet_yellow.png"); } <START> return null; <END> }</code><technical_language>Please throw IllegalArgumentException("Unknown attribute type"); here</technical_language>

Target:
public Image getImage(AttributeType type) { if (type == AttributeType.IDENTIFYING_ATTRIBUTE) { return getManagedImage("bullet_red.png"); } else if (type == AttributeType.INSENSITIVE_ATTRIBUTE) { return getManagedImage("bullet_green.png"); } else if (type == AttributeType.SENSITIVE_ATTRIBUTE) { return getManagedImage("bullet_purple.png"); } else if (type == AttributeType.QUASI_IDENTIFYING_ATTRIBUTE) { return getManagedImage("bullet_yellow.png"); } else { throw new IllegalArgumentException("Unknown attribute type '" + type + "'"); } }
Source:
<code>public void testProcessActionSameActionAndResult01() { when(requestDataValueProcessor.processAction( (HttpServletRequest) (anyObject()), anyString())).thenReturn( "action"); when(requestDataValueProcessor.processAction( <START> (HttpServletRequest) (anyObject()), anyString(), Mockito <END> .isNull())).thenReturn("action"); String result = compositeRequestDataValueProcessor.processAction( request, "action"); assertThat(result, is("action")); }</code><technical_language>[x] anyObject() is deprecated method</technical_language>

Target:
public void testProcessActionSameActionAndResult01() { when(requestDataValueProcessor.processAction(any( HttpServletRequest.class), anyString())).thenReturn("action"); when(requestDataValueProcessor.processAction(any( HttpServletRequest.class), anyString(), nullable(String.class))) .thenReturn("action"); String result = compositeRequestDataValueProcessor.processAction( request, "action"); assertThat(result, is("action")); }
Source:
<code>public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DateStatistics that = (DateStatistics) o; return hasMinMax == that.hasMinMax && <START> minimum == that.minimum && <END> maximum == that.maximum; }</code><technical_language>problem !has*</technical_language>

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DateStatistics that = (DateStatistics) o; return Objects.equals(getMin(), that.getMin()) && Objects.equals(getMax(), that.getMax()); }
Source:
<code>public static ErrorMessageFactory shouldBePackagePrivate(Class<?> actual) { <START> return new ClassModifierShouldBe(actual, true, "Package-Private"); <END> }</code><technical_language>parameter case style Modifier.toString(), i.e., "package-private"</technical_language>

Target:
public static ErrorMessageFactory shouldBePackagePrivate(Class<?> actual) { return new ClassModifierShouldBe(actual, true, "package-private"); }
Source:
<code>public String buildJVMArgumentWithoutMemory() { StringBuilder jvmArguments = new StringBuilder(); if (securityEnabled) { jvmArguments = addSecurityManager(jvmArguments); jvmArguments = addCurrentAgentPath(jvmArguments); jvmArguments = addConsoleIP(jvmArguments); jvmArguments = addDnsIP(jvmArguments); } else { jvmArguments.append(properties.getProperty("grinder.jvm.arguments", "")); jvmArguments = addNativeLibraryPath(jvmArguments); } jvmArguments = addParam(jvmArguments, properties.getProperty("grinder.param", "")); jvmArguments = addPythonPathJvmArgument(jvmArguments); jvmArguments = addCustomDns(jvmArguments); <START> jvmArguments = addBasePath(jvmArguments); <END> if (server) { jvmArguments = addServerMode(jvmArguments); } if (StringUtils.isNotBlank(additionalJavaOpt)) { jvmArguments = addAdditionalJavaOpt(jvmArguments); } return jvmArguments.toString(); }</code><technical_language>I this located in line 171 activated in security mode. I more method name is... addUserDir</technical_language>

Target:
public String buildJVMArgumentWithoutMemory() { StringBuilder jvmArguments = new StringBuilder(); if (securityEnabled) { jvmArguments = addSecurityManager(jvmArguments); jvmArguments = addCurrentAgentPath(jvmArguments); jvmArguments = addConsoleIP(jvmArguments); jvmArguments = addDnsIP(jvmArguments); } else { jvmArguments.append(properties.getProperty("grinder.jvm.arguments", "")); jvmArguments = addNativeLibraryPath(jvmArguments); } jvmArguments = addParam(jvmArguments, properties.getProperty("grinder.param", "")); jvmArguments = addPythonPathJvmArgument(jvmArguments); jvmArguments = addCustomDns(jvmArguments); jvmArguments = addUserDir(jvmArguments); if (server) { jvmArguments = addServerMode(jvmArguments); } if (StringUtils.isNotBlank(additionalJavaOpt)) { jvmArguments = addAdditionalJavaOpt(jvmArguments); } return jvmArguments.toString(); }
Source:
<code>private static AbstractVexAction[] computeQuickFixActions(final VexWidget widget) { final ElementName[] names = widget.getValidMorphElements(); final AbstractVexAction[] actions = new AbstractVexAction[names.length]; final int caretOffset = widget.getCaretOffset(); final IElement element = widget.getDocument().getElementForInsertionAt(caretOffset); final String sourceName = element.getPrefixedName(); for (int i = 0; i < names.length; i++) { final QualifiedName qualifiedName = names[i].getQualifiedName(); <START> if (!widget.canMorph(qualifiedName)) { <END> continue; } final String message = Messages.getString("command.convertElement.dynamicCommandName"); final String text = MessageFormat.format(message, sourceName, names[i]); final Icon icon = Icon.CONVERT; actions[i] = new AbstractVexAction(widget, names[i], text, icon) { @Override public void execute(final VexWidget vexWidget) { getWidget().morph(qualifiedName); } }; } return actions; }</code><technical_language>getValidMorphElements some of checks. check delete canMorph check here? canMorph do like: getValidMorphElements.contains(qualifiedName)</technical_language>

Target:
private static AbstractVexAction[] computeQuickFixActions(final VexWidget widget) { final ElementName[] names = widget.getValidMorphElements(); final AbstractVexAction[] actions = new AbstractVexAction[names.length]; final int caretOffset = widget.getCaretOffset(); final IElement element = widget.getDocument().getElementForInsertionAt(caretOffset); final String sourceName = element.getPrefixedName(); for (int i = 0; i < names.length; i++) { final QualifiedName qualifiedName = names[i].getQualifiedName(); final String message = Messages.getString("command.convertElement.dynamicCommandName"); final String text = MessageFormat.format(message, sourceName, names[i]); final Icon icon = Icon.CONVERT; actions[i] = new AbstractVexAction(widget, names[i], text, icon) { @Override public void execute(final VexWidget vexWidget) { getWidget().morph(qualifiedName); } }; } return actions; }
Source:
<code>static ColumnStatus columnStatusWithValue(long value) { <START> return ImmutableColumnStatus.builder().exists(true).value(value).build(); <END> }</code><technical_language>suggest OptionalLong for here, users Optional<ColumnStatus> null object pattern</technical_language>

Target:
static Optional<ColumnStatus> columnStatusWithValue(long value) { return Optional.of(ImmutableColumnStatus.builder().value(value).build()); }
Source:
<code>private Function<AuthorisationGatewayRequest, GatewayOrder> buildAuthoriseOrderFor(String frontendUrl) { return request -> { EpdqOrderRequestBuilder epdqOrderRequestBuilder = anEpdqAuthoriseOrderRequestBuilder(); if (request.getGatewayAccount().isRequires3ds()) { <START> epdqOrderRequestBuilder = anEpdq3DsAuthoriseOrderRequestBuilder(frontendUrl); <END> } return epdqOrderRequestBuilder .withOrderId(request.getChargeExternalId()) .withPassword(request.getGatewayAccount().getCredentials().get(CREDENTIALS_PASSWORD)) .withShaInPassphrase(request.getGatewayAccount().getCredentials().get( CREDENTIALS_SHA_IN_PASSPHRASE)) .withUserId(request.getGatewayAccount().getCredentials().get(CREDENTIALS_USERNAME)) .withMerchantCode(request.getGatewayAccount().getCredentials().get(CREDENTIALS_MERCHANT_ID)) .withDescription(request.getDescription()) .withAmount(request.getAmount()) .withAuthorisationDetails(request.getAuthCardDetails()) .build(); }; }</code><technical_language>Ternary operator maybe</technical_language>

Target:
private Function<AuthorisationGatewayRequest, GatewayOrder> buildAuthoriseOrderFor(String frontendUrl) { return request -> { EpdqOrderRequestBuilder epdqOrderRequestBuilder = request.getGatewayAccount().requires3ds() ? anEpdq3DsAuthoriseOrderRequestBuilder(frontendUrl) : anEpdqAuthoriseOrderRequestBuilder(); return epdqOrderRequestBuilder .withOrderId(request.getChargeExternalId()) .withPassword(request.getGatewayAccount().getCredentials().get(CREDENTIALS_PASSWORD)) .withShaInPassphrase(request.getGatewayAccount().getCredentials().get( CREDENTIALS_SHA_IN_PASSPHRASE)) .withUserId(request.getGatewayAccount().getCredentials().get(CREDENTIALS_USERNAME)) .withMerchantCode(request.getGatewayAccount().getCredentials().get(CREDENTIALS_MERCHANT_ID)) .withDescription(request.getDescription()) .withAmount(request.getAmount()) .withAuthorisationDetails(request.getAuthCardDetails()) .build(); }; }
Source:
<code>private DataPointAssignment marshallToDomain(DataPointAssignmentDto dto) { final DataPointAssignment dpa = new DataPointAssignment(); BeanUtils.copyProperties(dto, dpa); if (dto.getKeyId() != null) { dpa.setKey(KeyFactory.createKey("DataPointAssignment", dto.getKeyId())); } <START> dpa.setDataPointIds(dto.getDataPointIds()); <END> return dpa; }</code><technical_language>BeanUtils.copyProperties() handle this</technical_language>

Target:
private DataPointAssignment marshallToDomain(DataPointAssignmentDto dto) { final DataPointAssignment dpa = new DataPointAssignment(); BeanUtils.copyProperties(dto, dpa); if (dto.getKeyId() != null) { dpa.setKey(KeyFactory.createKey("DataPointAssignment", dto.getKeyId())); } return dpa; }
Source:
<code>public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(REQUIRES_TENANT, "true"); <START> properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.API_ACCESS_KEY_CREDENTIALS); <END> return properties; }</code><technical_language>@ccustine this line, I service type for provider: properties.setProperty(SERVICE_TYPE, ServiceType.BLOCK_STORAGE);</technical_language>

Target:
public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(REQUIRES_TENANT, "true"); properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.API_ACCESS_KEY_CREDENTIALS); properties.setProperty(SERVICE_TYPE, ServiceType.BLOCK_STORAGE); return properties; }
Source:
<code>public void sendsMessageToBout() throws Exception { final MkBase base = new MkBase(); final String urn = "urn:test:1"; final User user = base.user(new URN(urn)); user.aliases().add("jeff"); final Alias alias = user.aliases().iterate().iterator().next(); final long number = alias.inbox().start(); final Bout bout = alias.inbox().bout(number); bout.friends().invite(alias.name()); final RqWithAuth req = new RqWithAuth( urn, new RqMultipart.Fake( new RqFake( "POST", String.format("/b/%d/attach", number) ), new RqWithHeaders( new RqLive( new ByteArrayInputStream("content".getBytes()) ), String.format("POST /b/%d/attach HTTP/1.1", number), "Content-Disposition: form-data; name=\"file\"; filename=\"some.xml\"", "Content-Type: application/xml" ) ) ); try { new FkBout(".*", new TkAttach(base)).route(req); } catch (final RsForward rsf) { MatcherAssert.assertThat( bout.messages().iterate().iterator().next().text(), <START> Matchers.containsString("some.xml") <END> ); throw rsf; } }</code><technical_language>@bdragan match attachment some.xml</technical_language>

Target:
public void sendsMessageToBout() throws Exception { final MkBase base = new MkBase(); final String urn = "urn:test:1"; final User user = base.user(new URN(urn)); user.aliases().add("jeff1"); final Alias alias = user.aliases().iterate().iterator().next(); final long number = alias.inbox().start(); final Bout bout = alias.inbox().bout(number); bout.friends().invite(alias.name()); final RqWithAuth request = new RqWithAuth( urn, new RqMultipart.Fake( TkAttachTest.fake(number), new RqWithHeaders( new RqLive( new ByteArrayInputStream("content1".getBytes()) ), String.format(TkAttachTest.POST_URL, number), "Content-Disposition: form-data; name=\"file\"; filename=\"some.xml\"", "Content-Type: application/xml" ) ) ); try { new FkBout(".+", new TkAttach(base)).route(request); } catch (final RsForward response) { MatcherAssert.assertThat( response, new HmRsStatus(HttpURLConnection.HTTP_SEE_OTHER) ); } MatcherAssert.assertThat( bout.messages().iterate().iterator().next().text(), Matchers.containsString("attachment \"some.xml\"") ); }