auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testRollBackAfterOperationfailure() throws Exception { container.start(); try { try (ModelControllerClient client = TestSuiteEnvironment.getModelControllerClient()) { final File deploymentOne = new File(deployDir, "deployment-one.jar"); createDeployment(deploymentOne, "org.jboss.modules"); addDeploymentScanner(client); prepareRollback(client); try { assertThat(exists(client, DEPLOYMENT_ONE), is(false)); runFailingScan(client); long timeout = System.currentTimeMillis() + TimeoutUtil.adjust(30000); while (!exists(client, DEPLOYMENT_ONE) && System.currentTimeMillis() < timeout) { Thread.sleep(100); <START> } <END> assertThat(exists(client, DEPLOYMENT_ONE), is(false)); String[] files = deployDir.list(); assertThat(files.length, is(1)); assertThat(files[0], is("deployment-one.jar")); deploymentOne.delete(); } finally { removeDeploymentScanner(client); cleanRollback(client); } } } finally { container.stop(); } }</code><technical_language>This 30 secs prove a scan happen. I clever ideas for proving a negative, 2 3 secs</technical_language>

Target:
public void testRollBackAfterOperationfailure() throws Exception { container.start(); try { try (ModelControllerClient client = TestSuiteEnvironment.getModelControllerClient()) { final File deploymentOne = new File(deployDir, "deployment-one.jar"); createDeployment(deploymentOne, "org.jboss.modules"); addDeploymentScanner(client); prepareRollback(client); try { assertThat(exists(client, DEPLOYMENT_ONE), is(false)); runFailingScan(client); long timeout = System.currentTimeMillis() + TimeoutUtil.adjust(FAILING_TIMEOUT); while (!exists(client, DEPLOYMENT_ONE) && System.currentTimeMillis() < timeout) { Thread.sleep(DELAY); } assertThat(exists(client, DEPLOYMENT_ONE), is(false)); String[] files = deployDir.list(); assertThat(files.length, is(1)); assertThat(files[0], is("deployment-one.jar")); deploymentOne.delete(); } finally { removeDeploymentScanner(client); cleanRollback(client); } } } finally { container.stop(); } }
Source:
<code>public boolean isRepeatedProperty(String entityType, List<String> propertyPath) { Descriptor messageDescriptor; try { messageDescriptor = serializationContext.getMessageDescriptor(entityType); } catch (Exception e) { throw new IllegalStateException("Unknown entity name " + entityType); } int i = 0; for (String p : propertyPath) { FieldDescriptor field = messageDescriptor.findFieldByName(p); if (field == null) { break; } if (field.isRepeated()) { return true; } <START> if (++i == propertyPath.size() || field.getJavaType() != JavaType.MESSAGE) { <END> break; } messageDescriptor = field.getMessageType(); } return false; }</code><technical_language>Do need ++i == propertyPath.size() condition here, if iterating propertyPath</technical_language>

Target:
public boolean isRepeatedProperty(String entityType, List<String> propertyPath) { Descriptor messageDescriptor; try { messageDescriptor = serializationContext.getMessageDescriptor(entityType); } catch (Exception e) { throw new IllegalStateException("Unknown entity name " + entityType); } for (String p : propertyPath) { FieldDescriptor field = messageDescriptor.findFieldByName(p); if (field == null) { break; } if (field.isRepeated()) { return true; } if (field.getJavaType() != JavaType.MESSAGE) { break; } messageDescriptor = field.getMessageType(); } return false; }
Source:
<code>public MemoryInfo getCurrentMemory(@RequestParam(name = "token", required = true) String token) throws InvalidMonitoringTokenException { if (StringUtils.isNotEmpty(token) && StringUtils.equals(token, getConfiguredToken())) { return MemoryInfo.getCurrentMemory(); } else { <START> throw new InvalidMonitoringTokenException("Invalid token for monitoring authorization"); <END> } }</code><technical_language>Change message of exception Monitoring authorization failed, invalid token</technical_language>

Target:
public MemoryInfo getCurrentMemory(@RequestParam(name = "token", required = true) String token) throws InvalidManagementTokenException { if (StringUtils.isNotEmpty(token) && StringUtils.equals(token, getConfiguredToken())) { return MemoryInfo.getCurrentMemory(); } else { throw new InvalidManagementTokenException("Management authorization failed, invalid token."); } }
Source:
<code>public void iCanCreateClientWithRequiredFieldsOnly() throws IOException { String data = "{\n" + " \"entity-type\": \"oauth2Client\",\n" + " \"id\": \"nuxeo-client-11\",\n" + <START> " \"secret\": \"4321\",\n" + END> " \"name\": \"Nuxeo Client 11\",\n" + " \"redirectURIs\": [\n" + " \"nuxeo://authorize\",\"nuxeo://authorize2\", \"nuxeo://authorize3\"\n" + " ]\n" + "}"; String expected = "{\n" + " \"entity-type\": \"oauth2Client\",\n" + " \"id\": \"nuxeo-client-11\",\n" + " \"name\": \"Nuxeo Client 11\",\n" + " \"isEnabled\": false,\n" + " \"secret\": \"4321\",\n" + " \"isAutoGrant\": false,\n" + " \"redirectURIs\": [\n" + " \"nuxeo://authorize2\", \"nuxeo://authorize\",\"nuxeo://authorize3\"\n" + " ]\n" + "}"; makeOperationAndVerify(TEST_OAUTH2_USER, CLIENT_PATH, RequestType.POST, data, Response.Status.CREATED, mapper.readTree(expected)); }</code><technical_language>I guess need secret is required</technical_language>

Target:
public void iCanCreateClientWithRequiredFieldsOnly() throws IOException { String data = "{\n" + " \"entity-type\": \"oauth2Client\",\n" + " \"id\": \"nuxeo-client-11\",\n" + " \"name\": \"Nuxeo Client 11\",\n" + " \"redirectURIs\": [\n" + " \"nuxeo://authorize\",\"nuxeo://authorize2\", \"nuxeo://authorize3\"\n" + " ]\n" + "}"; String expected = "{\n" + " \"entity-type\": \"oauth2Client\",\n" + " \"id\": \"nuxeo-client-11\",\n" + " \"name\": \"Nuxeo Client 11\",\n" + " \"isEnabled\": false,\n" + " \"secret\": null,\n" + " \"isAutoGrant\": false,\n" + " \"redirectURIs\": [\n" + " \"nuxeo://authorize2\", \"nuxeo://authorize\",\"nuxeo://authorize3\"\n" + " ]\n" + "}"; makeOperationAndVerify(TEST_OAUTH2_USER, CLIENT_PATH, RequestType.POST, data, Response.Status.CREATED, mapper.readTree(expected)); }
Source:
<code>protected List<ProcessInfo> getProcessInfo(String[] cmd, String delimiter, OSPlatform platform) throws IOException, InterruptedException { LOGGER.info("Fetching process information using the command : " + Arrays.toString(cmd)); Process process = Runtime.getRuntime().exec(cmd); StreamGobbler output = new StreamGobbler(process.getInputStream()); StreamGobbler error = new StreamGobbler(process.getErrorStream()); output.start(); error.start(); process.waitFor(); output.join(); error.join(); process.destroy(); List<ProcessInfo> processToBeKilled = new ArrayList<ProcessInfo>(); for (String eachLine : output.getContents()) { String[] eachProcessData = eachLine.split(delimiter); if (eachProcessData != null && eachProcessData.length >= 2) { ProcessInfo tProcess = null; switch (platform) { case UNIX: tProcess = new ProcessInfo(eachProcessData[0], eachProcessData[1]); break; default: tProcess = new ProcessInfo(eachProcessData[1], eachProcessData[2]); break; } <START> if (matches(tProcess.getProcessName().toLowerCase())) { <END> processToBeKilled.add(tProcess); } } } return processToBeKilled; }</code><technical_language>formatting processName in <LINK_0>, do this there</technical_language>

Target:
protected List<ProcessInfo> getProcessInfo(String[] cmd, String delimiter, OSPlatform platform) throws IOException, InterruptedException { LOGGER.info("Fetching process information using the command : " + Arrays.toString(cmd)); Process process = Runtime.getRuntime().exec(cmd); StreamGobbler output = new StreamGobbler(process.getInputStream()); StreamGobbler error = new StreamGobbler(process.getErrorStream()); output.start(); error.start(); process.waitFor(); output.join(); error.join(); process.destroy(); List<ProcessInfo> processToBeKilled = new ArrayList<ProcessInfo>(); for (String eachLine : output.getContents()) { String[] eachProcessData = eachLine.split(delimiter); if (eachProcessData != null && eachProcessData.length >= 2) { ProcessInfo tProcess = null; switch (platform) { case UNIX: tProcess = new ProcessInfo(eachProcessData[0], eachProcessData[1]); break; default: tProcess = new ProcessInfo(eachProcessData[1], eachProcessData[2]); break; } if (matches(tProcess.getProcessName())) { processToBeKilled.add(tProcess); } } } return processToBeKilled; }
Source:
<code>private void refreshLiveInstances(final HelixDataAccessor accessor, Set<HelixConstants.ChangeType> refreshedType) { if (_propertyDataChangedMap.get(HelixConstants.ChangeType.LIVE_INSTANCE).getAndSet(false)) { Map<String, LiveInstance> oldLiveInstances = getLiveInstances(); _liveInstanceCache.refresh(accessor); _updateInstanceOfflineTime = true; refreshedType.add(HelixConstants.ChangeType.LIVE_INSTANCE); long timeOutWindow = _clusterConfig.getMaintenanceOfflineNodeTimeOut(); if (timeOutWindow >= 0 && isMaintenanceModeEnabled()) { for (String instance : _liveInstanceCache.getPropertyMap().keySet()) { if (!oldLiveInstances.containsKey(instance) && isInstanceTimedOutDuringMaintenance( accessor, instance, timeOutWindow)) { _timedOutInstanceDuringMaintenance.add(instance); } } <START> for (String instance : _timedOutInstanceDuringMaintenance) { <END> _liveInstanceCache.deletePropertyByName(instance); } } if (!isMaintenanceModeEnabled()) { _timedOutInstanceDuringMaintenance.clear(); } } else { LogUtil.logInfo(logger, getClusterEventId(), String .format("No live instance change for %s cluster, %s pipeline", _clusterName, getPipelineName())); } }</code><technical_language>I place do that. do in maintenance recovery stage. I remember details of move offline time history set -1. happened cache refresh well. I is cache refresh fully complete</technical_language>

Target:
private void refreshLiveInstances(final HelixDataAccessor accessor, Set<HelixConstants.ChangeType> refreshedType) { if (_propertyDataChangedMap.get(HelixConstants.ChangeType.LIVE_INSTANCE).getAndSet(false)) { _liveInstanceCache.refresh(accessor); _updateInstanceOfflineTime = true; refreshedType.add(HelixConstants.ChangeType.LIVE_INSTANCE); } else { LogUtil.logInfo(logger, getClusterEventId(), String .format("No live instance change for %s cluster, %s pipeline", _clusterName, getPipelineName())); } }
Source:
<code>public MulticurveProviderDiscount getMulticurveProvider() { <START> IssuerProviderInterface issuerProvider = getIssuerProvider(); <END> if (issuerProvider instanceof IssuerProviderDiscount) { return ((IssuerProviderDiscount) issuerProvider).getMulticurveProvider(); } else if (issuerProvider instanceof IssuerProviderIssuerDecoratedSpreadPeriodic) { return (MulticurveProviderDiscount) ((IssuerProviderIssuerDecoratedSpreadPeriodic) issuerProvider) .getMulticurveProvider(); } throw new IllegalArgumentException("unsupported type of issuer provider"); }</code><technical_language>this "if"? original code work anymore? I a direct pass-through of underlying curves</technical_language>

Target:
public MulticurveProviderDiscount getMulticurveProvider() { return getIssuerProvider().getMulticurveProvider(); }
Source:
<code>private boolean onEnderPearlImpact(EntityPlayerMP player) { if (player.isPlayerSleeping()) { return true; } <START> try(CauseStackManager.StackFrame frame = Sponge.getCauseStackManager().pushCauseFrame()) { <END> frame.addContext(EventContextKeys.TELEPORT_TYPE, TeleportTypes.ENTITY_TELEPORT); MoveEntityEvent.Teleport event = EntityUtil.handleDisplaceEntityTeleportEvent(player, this.getLocation()); if (event.isCancelled()) { return true; } } return false; }</code><technical_language>Spacing</technical_language>

Target:
private boolean onEnderPearlImpact(EntityPlayerMP player) { if (player.isPlayerSleeping()) { return true; } try (CauseStackManager.StackFrame frame = Sponge.getCauseStackManager().pushCauseFrame()) { frame.addContext(EventContextKeys.TELEPORT_TYPE, TeleportTypes.ENTITY_TELEPORT); frame.addContext(EventContextKeys.THROWER, (Player) player).getCurrentCause(); MoveEntityEvent.Teleport event = EntityUtil.handleDisplaceEntityTeleportEvent(player, this.getLocation()); if (event.isCancelled()) { return true; } } return false; }
Source:
<code>public <ARCHIVEVIEW extends Assignable> Collection<ARCHIVEVIEW> resolveArtifactsAs(Class<ARCHIVEVIEW> archiveView) throws ResolutionException { <START> return new MavenBuilderImpl(system, session, settings, dependencies, versionManagement).resolveAs(archiveView); <END> }</code><technical_language>missing a StrictFilter well. reuse some StrictFilter test test this functionality</technical_language>

Target:
public <ARCHIVEVIEW extends Assignable> Collection<ARCHIVEVIEW> resolveArtifactsAs(Class<ARCHIVEVIEW> archiveView) throws ResolutionException { return new MavenBuilderImpl(system, session, settings, dependencies, versionManagement).resolveAs(archiveView, new StrictFilter()); }
Source:
<code>public void tearDown() throws Exception { <START> if (factoryWsName != null) { <END> workspaceServiceClient.delete(factoryWsName, user.getName()); } else { workspaceServiceClient.delete(testWorkspace.getName() + "_1", user.getName()); } }</code><technical_language>figure out workspace request factory name get workspace name config</technical_language>

Target:
public void tearDown() throws Exception { workspaceServiceClient.deleteFactoryWorkspaces(testWorkspace.getName(), user.getName()); factoryServiceClient.deleteFactory(FACTORY_NAME); }
Source:
<code>public static String getKeyString(final PublicKey key, String alias) { final byte[] keyBytes = getKeyBytes(key); if (keyBytes == null) { log.error("Can't get key bytes, will return null."); return null; } final Base64 encoder = new Base64(0); final String encoding = encoder.encodeToString(keyBytes); if (log.isDebugEnabled()) { log.debug("Key encoding is \"" + encoding + "\"."); } <START> final StringBuilder buffer = new StringBuilder(SSH_RSA.length() + 1 + encoding.length() + (alias != null? 1 + alias.length(): 0)); <END> buffer.append(SSH_RSA); buffer.append(" "); buffer.append(encoding); if (alias != null) { buffer.append(" "); buffer.append(alias); } buffer.append('\n'); final String keyString = buffer.toString(); if (log.isDebugEnabled()) { log.debug("Key string is \"" + keyString + "\"."); } return keyString; }</code><technical_language>Please amend calculation of size of buffer accordingly</technical_language>

Target:
public static String getKeyString(final PublicKey key, String alias) { final byte[] keyBytes = getKeyBytes(key); if (keyBytes == null) { log.error("Can't get key bytes, will return null."); return null; } final Base64 encoder = new Base64(0); final String encoding = encoder.encodeToString(keyBytes); if (log.isDebugEnabled()) { log.debug("Key encoding is \"" + encoding + "\"."); } final StringBuilder buffer = new StringBuilder(SSH_RSA.length() + 1 + encoding.length() + (alias != null? 1 + alias.length(): 0) + 1); buffer.append(SSH_RSA); buffer.append(" "); buffer.append(encoding); if (alias != null) { buffer.append(" "); buffer.append(alias); } buffer.append('\n'); final String keyString = buffer.toString(); if (log.isDebugEnabled()) { log.debug("Key string is \"" + keyString + "\"."); } return keyString; }
Source:
<code>protected com.liferay.portal.model.User findByPrimaryKey(String userId) throws NoSuchUserException, SystemException { com.liferay.portal.model.User user = UserPool.get(userId); try { if (user == null) { DotConnect dc = new DotConnect(); dc.setSQL(SEARCH_USER_BY_ID); dc.addParam(userId); List<Map<String, Object>> list = dc.loadObjectResults(); if(list.isEmpty()) { throw new NoSuchUserException(userId.toString()); }else{ user = userTransformer.fromMap(list.get(0)); } } return user; } <START> catch(DotDataException e){ <END> throw new NoSuchUserException(userId.toString()); } }</code><technical_language>![MAJOR](<LINK_1> 'Severity: MAJOR') log rethrow this exception. [![rule](<LINK_2>](<LINK_0></technical_language>

Target:
protected com.liferay.portal.model.User findByPrimaryKey(String userId) throws NoSuchUserException { com.liferay.portal.model.User user = UserPool.get(userId); try { if (user == null) { DotConnect dc = new DotConnect(); dc.setSQL(SEARCH_USER_BY_ID); dc.addParam(userId); List<Map<String, Object>> list = dc.loadObjectResults(); if(list.isEmpty()) { throw new NoSuchUserException(userId); }else{ user = userTransformer.fromMap(list.get(0)); UserPool.put(user.getPrimaryKey(), user); } } return user; } catch(DotDataException e){ throw new NoSuchUserException(userId); } }
Source:
<code>public void add(long markerAddress, List<SMRRecordLocator> locators) { if (locators.isEmpty()) { return; } Map<Long, SMRGarbageEntry> garbageEntries = generateGarbageEntries(markerAddress, locators); while (true) { try { for (SMRGarbageEntry garbageEntry : garbageEntries.values()) { garbageReceivingQueue.offer(garbageEntry, BLOCKING_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS); } return; } catch (InterruptedException ex) { <START> drainingExecutor.submit(this::gc); <END> } } }</code><technical_language>thread instead of another single thread pool? this thread do this::gc(). gc() method needs synchronized (even in current approach)</technical_language>

Target:
public void add(long markerAddress, List<SMRRecordLocator> locators) { if (locators.isEmpty()) { return; } List<SMRGarbageEntry> garbageEntries = generateGarbageEntries(markerAddress, locators); synchronized (this) { try { for (SMRGarbageEntry garbageEntry : garbageEntries) { boolean success = garbageReceivingQueue.offer(garbageEntry); if (!success) { drainExecutor.submit(this::gc); garbageReceivingQueue.put(garbageEntry); } } } catch (InterruptedException ie) { throw new UnrecoverableCorfuInterruptedError( "Interrupted during adding locators to GarbageInformer", ie); } } }
Source:
<code>public void init() throws NotFoundException { MockitoAnnotations.initMocks(this); evaluator = new AclGroupPermissionEvaluator(aclManager, aclUtil, sidFactory, mutableAclService, userDao, pluginManager); objectIdentity = new ObjectIdentityImpl(targetType, targetId); Mockito.when(aclUtil.createIdentity(targetId, targetType)).thenReturn(objectIdentity); user = new JCUser("username", "email@jtalks.org", "password"); <START> user.setId(1L); <END> userSid = new UserSid(user.getId()); groupSid = new UserGroupSid(targetId); group = new Group(); group.setId(2L); group.setUsers(Collections.<User>singletonList(user)); user.setGroups(Collections.singletonList(group)); when(sidFactory.createPrincipal(authentication)).thenReturn(userSid); when(sidFactory.create(group)).thenReturn(groupSid); when(authentication.getPrincipal()).thenReturn(new UserInfo(user)); when(mutableAclService.readAclById(Mockito.any(ObjectIdentity.class))).thenReturn(acl); when(userDao.get(user.getId())).thenReturn(user); List<GroupAce> controlEntries = new ArrayList<>(); Mockito.when(aclManager.getGroupPermissionsFilteredByPermissionOn(Mockito.any(ObjectIdentity.class), Mockito.any(JtalksPermission.class))).thenReturn(controlEntries); }</code><technical_language>Long()</technical_language>

Target:
public void init() throws NotFoundException { MockitoAnnotations.initMocks(this); evaluator = new AclGroupPermissionEvaluator(aclManager, aclUtil, sidFactory, mutableAclService, pluginManager, securityService); objectIdentity = new ObjectIdentityImpl(targetType, targetId); Mockito.when(aclUtil.createIdentity(targetId, targetType)).thenReturn(objectIdentity); user = new JCUser("username", "email@jtalks.org", "password"); user.setId(1); userSid = new UserSid(user.getId()); groupSid = new UserGroupSid(targetId); Group group = new Group(); group.setId(2); group.setUsers(Collections.<User>singletonList(user)); user.setGroups(Collections.singletonList(group)); when(sidFactory.createPrincipal(authentication)).thenReturn(userSid); when(sidFactory.create(group)).thenReturn(groupSid); when(authentication.getPrincipal()).thenReturn(new UserInfo(user)); when(mutableAclService.readAclById(Mockito.any(ObjectIdentity.class))).thenReturn(acl); when(securityService.getFullUserInfoFrom(any(Authentication.class))).thenReturn(user); List<GroupAce> controlEntries = new ArrayList<>(); Mockito.when(aclManager.getGroupPermissionsFilteredByPermissionOn(Mockito.any(ObjectIdentity.class), Mockito.any(JtalksPermission.class))).thenReturn(controlEntries); }
Source:
<code>protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { <START> from("undertow:http://localhost:{{port}}/headers??matchOnUriPrefix=false") <END> .to("mock:input") .transform().constant("Bye World"); from("undertow:http://localhost:{{port}}/hello") .to("mock:input") .transform().constant("Hello World"); } }; }</code><technical_language>is a double ? sign</technical_language>

Target:
protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { from("undertow:http://localhost:{{port}}/headers") .to("mock:input") .transform().constant("Bye World"); from("undertow:http://localhost:{{port}}/hello?matchOnUriPrefix=true") .to("mock:input") .transform().constant("Hello World"); } }; }
Source:
<code><START> public SlimefunItem getItem() { <END> return SlimefunItem.getById(this.id); }</code><technical_language>name "getSlimefunItem()". is this build failing</technical_language>

Target:
public SlimefunItem getItem() { return SlimefunItem.getByID(this.id); }
Source:
<code>public void activate(OperatorContext ctx) { <START> if (context.getValue(OperatorContext.ACTIVATION_WINDOW_ID) < windowDataManager.getLargestCompletedWindow()) { <END> return; } consumer.start(); }</code><technical_language>Verify condition also: context.getValue(OperatorContext.ACTIVATION_WINDOW_ID) != Stateless.WINDOW_ID</technical_language>

Target:
public void activate(OperatorContext ctx) { if (context.getValue(OperatorContext.ACTIVATION_WINDOW_ID) != Stateless.WINDOW_ID && context.getValue(OperatorContext.ACTIVATION_WINDOW_ID) < windowDataManager.getLargestCompletedWindow()) { return; } consumer.start(); }
Source:
<code>public OverPeriodDateAttribute( @JsonProperty("attribute") final ObjQualifier attribute, @JsonProperty("periodsAgo") final Integer periodsAgo) { <START> this.attribute = notNull(attribute, "'attribute' must not be null!"); <END> this.periodsAgo = notNull(periodsAgo, "'periodsAgo' must not be null!"); }</code><technical_language>please <LINK_0> gooddata-java</technical_language>

Target:
public OverPeriodDateAttribute( @JsonProperty("attribute") final ObjQualifier attribute, @JsonProperty("periodsAgo") final Integer periodsAgo) { this.attribute = notNull(attribute, "attribute"); this.periodsAgo = notNull(periodsAgo, "periodsAgo"); }
Source:
<code>private boolean unlockAssociatedEntries( final FileEntry entry, final String label ) { FileEntry alsoLocked = entry.alsoLocked; while ( alsoLocked != null ) { logger.trace( "ALSO Unlocking: {}", alsoLocked.name ); UnlockStatus unlockStatus = alsoLocked.lock.unlock( label ); try { <START> filesystem.updateDominantLocks( entry.file.getPath(), unlockStatus ); <END> } catch ( IOException e ) { LoggerFactory.getLogger( getClass().getName() ) .error( "Exception while updating dominant locks when unlocking entries associated with: " + entry.file.getPath(), e ); } if ( !alsoLocked.lock.isLocked() ) { entryMap.remove( alsoLocked.name ); } alsoLocked = alsoLocked.alsoLocked; } return true; }</code><technical_language>This needs alsoLocked.file.getPath()</technical_language>

Target:
private boolean unlockAssociatedEntries( final FileEntry entry, final String label ) throws IOException { FileEntry alsoLocked = entry.alsoLocked; while ( alsoLocked != null ) { logger.trace( "ALSO Unlocking: {}", alsoLocked.name ); UnlockStatus unlockStatus = alsoLocked.lock.unlock( label ); filesystem.updateDominantLocks( alsoLocked.file.getPath(), unlockStatus ); if ( !alsoLocked.lock.isLocked() ) { entryMap.remove( alsoLocked.name ); } alsoLocked = alsoLocked.alsoLocked; } return true; }
Source:
<code>public BigtableDataGrpcClient( Channel channel, ExecutorService executorService, RetryOptions retryOptions, <START> ClientCallService clientCallService) { <END> this.channel = channel; this.executorService = executorService; this.retryOptions = retryOptions; this.clientCallService = clientCallService; this.sampleRowKeysAsync = BigtableAsyncUtilities.createSampleRowKeyAsyncReader(this.channel, clientCallService); this.readRowsAsync = BigtableAsyncUtilities.createRowKeyAysncReader(this.channel, clientCallService); }</code><technical_language>Do want expose ClientCallService? public constructor ClientCallService package default for testing ClientCallService</technical_language>

Target:
BigtableDataGrpcClient( Channel channel, ExecutorService executorService, RetryOptions retryOptions, ClientCallService clientCallService) { this.channel = channel; this.executorService = executorService; this.retryOptions = retryOptions; this.clientCallService = clientCallService; this.sampleRowKeysAsync = BigtableAsyncUtilities.createSampleRowKeyAsyncReader(this.channel, clientCallService); this.readRowsAsync = BigtableAsyncUtilities.createRowKeyAysncReader(this.channel, clientCallService); }
Source:
<code>public QueryInfo scheduleQuery(Session session, QueryContext queryContext, String sql, String jsonExpr, LogicalRootNode plan) throws Exception { QueryId queryId = QueryIdFactory.newQueryId(masterContext.getResourceManager().getSeedQueryId()); QueryInProgress queryInProgress = new QueryInProgress(masterContext, session, queryContext, queryId, sql, jsonExpr, plan); <START> queryInProgress.getQueryInfo().setQueryMaster(""); <END> submittedQueries.put(queryInProgress.getQueryId(), queryInProgress); QuerySchedulingInfo querySchedulingInfo = new QuerySchedulingInfo("default", queryContext.getUser(), queryInProgress.getQueryId(), 1, queryInProgress.getQueryInfo().getStartTime()); masterContext.getResourceManager().submitQuery(querySchedulingInfo); return queryInProgress.getQueryInfo(); }</code><technical_language>defining a constant represent empty query master host</technical_language>

Target:
public QueryInfo scheduleQuery(Session session, QueryContext queryContext, String sql, String jsonExpr, LogicalRootNode plan) throws Exception { QueryId queryId = QueryIdFactory.newQueryId(masterContext.getResourceManager().getSeedQueryId()); QueryInProgress queryInProgress = new QueryInProgress(masterContext, session, queryContext, queryId, sql, jsonExpr, plan); queryInProgress.getQueryInfo().setQueryMaster(EMPTY_QM_HOSTNAME); submittedQueries.put(queryInProgress.getQueryId(), queryInProgress); QuerySchedulingInfo querySchedulingInfo = new QuerySchedulingInfo("default", queryContext.getUser(), queryInProgress.getQueryId(), 1, queryInProgress.getQueryInfo().getStartTime()); masterContext.getResourceManager().submitQuery(querySchedulingInfo); return queryInProgress.getQueryInfo(); }
Source:
<code>public void validate(Element element, ElementValidation validation) { super.validate(element, validation); validatorHelper.doesNotReturnPrimitive((ExecutableElement) element, validation); <START> restSpringValidatorHelper.hasAnnotatedAllParameters((ExecutableElement) element, validation); <END> restSpringValidatorHelper.hasValidBodyParameter((ExecutableElement) element, validation); restSpringValidatorHelper.doesNotMixRequestEntityAnnotations((ExecutableElement) element, validation); }</code><technical_language>hasAnnotatedAllParameters is checked in super class, right</technical_language>

Target:
public void validate(Element element, ElementValidation validation) { super.validate(element, validation); validatorHelper.doesNotReturnPrimitive((ExecutableElement) element, validation); restSpringValidatorHelper.doesNotHaveDuplicateFieldAndPartName((ExecutableElement) element, validation); restSpringValidatorHelper.hasOneOrZeroBodyParameter((ExecutableElement) element, validation); restSpringValidatorHelper.doesNotMixRequestEntityAnnotations((ExecutableElement) element, validation); }
Source:
<code>public boolean shouldAssignWork(ElasticAgentMetadata metadata, String environment, ElasticProfile elasticProfile, ClusterProfile clusterProfile, JobIdentifier identifier) { if (clusterProfile == null || !StringUtils.equals(clusterProfile.getPluginId(), metadata.elasticPluginId())) { return false; } <START> boolean secretsResolved = resolveSecrets(identifier, clusterProfile, elasticProfile); <END> if (!secretsResolved) { return false; } Map<String, String> clusterProfileProperties = clusterProfile.getConfigurationAsMap(true, true); GoPluginDescriptor pluginDescriptor = pluginManager.getPluginDescriptorFor(metadata.elasticPluginId()); Map<String, String> configuration = elasticProfile.getConfigurationAsMap(true, true); return elasticAgentPluginRegistry.shouldAssignWork(pluginDescriptor, toAgentMetadata(metadata), environment, configuration, clusterProfileProperties, identifier); }</code><technical_language>wrong for shouldAssignWork method cancelling job here. I caller of this method handle secret resolution exceptions necessary actions</technical_language>

Target:
public boolean shouldAssignWork(ElasticAgentMetadata metadata, String environment, ElasticProfile elasticProfile, ClusterProfile clusterProfile, JobIdentifier identifier) { if (clusterProfile == null || !StringUtils.equals(clusterProfile.getPluginId(), metadata.elasticPluginId())) { return false; } resolveSecrets(clusterProfile, elasticProfile); Map<String, String> clusterProfileProperties = clusterProfile.getConfigurationAsMap(true, true); GoPluginDescriptor pluginDescriptor = pluginManager.getPluginDescriptorFor(metadata.elasticPluginId()); Map<String, String> configuration = elasticProfile.getConfigurationAsMap(true, true); return elasticAgentPluginRegistry.shouldAssignWork(pluginDescriptor, toAgentMetadata(metadata), environment, configuration, clusterProfileProperties, identifier); }
Source:
<code>private FutureResult<Void> pullLoad(Project project, final Path dirPath, final String dataset) { <START> List<String> datasets = new ArrayList<>(); <END> datasets.add(dataset); return pullLoad(project, dirPath, datasets); }</code><technical_language>asList()</technical_language>

Target:
private FutureResult<Void> pullLoad(Project project, final Path dirPath, final String dataset) { return pullLoad(project, dirPath, asList(dataset)); }
Source:
<code>private int getImageType(IJavaAnnotation annotation) { int imageType= NO_IMAGE; if (annotation.hasOverlay()) imageType= OVERLAY_IMAGE; else if (!annotation.isMarkedDeleted()) { if (showQuickFix(annotation)) { <START> if (null == annotation.getType()) { <END> imageType= QUICKFIX_INFO_IMAGE; } else switch (annotation.getType()) { case JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE: imageType= QUICKFIX_ERROR_IMAGE; break; case JavaMarkerAnnotation.WARNING_ANNOTATION_TYPE: imageType= QUICKFIX_WARNING_IMAGE; break; default: imageType= QUICKFIX_INFO_IMAGE; break; } } } else { imageType= GRAY_IMAGE; } return imageType; }</code><technical_language>change to: boolean nomatch= false; if (annotation.getType() != null) switch (....) { ... default: nomatch= true; break; }... if (nomatch) { imageType= QUICKFIX_INFO_RANGE; }</technical_language>

Target:
private int getImageType(IJavaAnnotation annotation) { int imageType= NO_IMAGE; if (annotation.hasOverlay()) imageType= OVERLAY_IMAGE; else if (!annotation.isMarkedDeleted()) { if (showQuickFix(annotation)) { boolean nomatch= false; if (annotation.getType() != null) switch (annotation.getType()) { case JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE: imageType= QUICKFIX_ERROR_IMAGE; break; case JavaMarkerAnnotation.WARNING_ANNOTATION_TYPE: imageType= QUICKFIX_WARNING_IMAGE; break; default: nomatch= true; break; } if (nomatch) { imageType= QUICKFIX_INFO_IMAGE; } } } else { imageType= GRAY_IMAGE; } return imageType; }
Source:
<code>public BucketNodeMap getBucketNodeMap(Session session, PartitioningHandle partitioningHandle, boolean preferDynamic) { ConnectorId connectorId = partitioningHandle.getConnectorId() .orElseThrow(() -> new IllegalArgumentException("No connector ID for partitioning handle: " + partitioningHandle)); List<Node> sortedNodes = sortedNodes(connectorId); <START> ConnectorBucketNodeMap connectorBucketNodeMap = getConnectorBucketNodeMap(session, partitioningHandle, sortedNodes); <END> NodeSelectionStrategy nodeSelectionStrategy = connectorBucketNodeMap.getNodeSelectionStrategy(); switch (nodeSelectionStrategy) { case HARD_AFFINITY: case SOFT_AFFINITY: return new FixedBucketNodeMap(getSplitToBucket(session, partitioningHandle), getFixedMapping(connectorBucketNodeMap)); case NO_PREFERENCE: if (preferDynamic) { return new DynamicBucketNodeMap(getSplitToBucket(session, partitioningHandle), connectorBucketNodeMap.getBucketCount()); } return new FixedBucketNodeMap( getSplitToBucket(session, partitioningHandle), createArbitraryBucketToNode( nodeScheduler.createNodeSelector(partitioningHandle.getConnectorId().get()).selectRandomNodes(getMaxTasksPerStage(session)), connectorBucketNodeMap.getBucketCount())); default: throw new PrestoException(NODE_SELECTION_NOT_SUPPORTED, format("Unsupported node selection strategy %s", nodeSelectionStrategy)); } }</code><technical_language>splitting this #13966 , create a FixedBucketNodeMap for SOFT_AFFINITY play DynamicLifespanScheduler, this pull request is self-consistent. Basically need functionality in DynamicBucketNodeMap able accept a map initial state allow updates map scheduler sees fit</technical_language>

Target:
public BucketNodeMap getBucketNodeMap(Session session, PartitioningHandle partitioningHandle, boolean preferDynamic) { ConnectorBucketNodeMap connectorBucketNodeMap = getConnectorBucketNodeMap(session, partitioningHandle); NodeSelectionStrategy nodeSelectionStrategy = connectorBucketNodeMap.getNodeSelectionStrategy(); switch (nodeSelectionStrategy) { case HARD_AFFINITY: return new FixedBucketNodeMap(getSplitToBucket(session, partitioningHandle), getFixedMapping(connectorBucketNodeMap)); case SOFT_AFFINITY: if (preferDynamic) { return new DynamicBucketNodeMap(getSplitToBucket(session, partitioningHandle), connectorBucketNodeMap.getBucketCount(), getFixedMapping(connectorBucketNodeMap)); } return new FixedBucketNodeMap(getSplitToBucket(session, partitioningHandle), getFixedMapping(connectorBucketNodeMap)); case NO_PREFERENCE: if (preferDynamic) { return new DynamicBucketNodeMap(getSplitToBucket(session, partitioningHandle), connectorBucketNodeMap.getBucketCount()); } return new FixedBucketNodeMap( getSplitToBucket(session, partitioningHandle), createArbitraryBucketToNode( nodeScheduler.createNodeSelector(partitioningHandle.getConnectorId().get()).selectRandomNodes(getMaxTasksPerStage(session)), connectorBucketNodeMap.getBucketCount())); default: throw new PrestoException(NODE_SELECTION_NOT_SUPPORTED, format("Unsupported node selection strategy %s", nodeSelectionStrategy)); } }
Source:
<code>public void run() { setContinueRunning(true); while (isContinueRunning()) { try { LocalDocument doc = fetch(); if (doc == null) { Thread.sleep(holdInterval); } else { try { logger.debug("Got new doc " + doc.getID() + " to process."); ProcessThread processThread = new ProcessThread(); <START> processThread.setDocument(doc); <END> long startTime = System.currentTimeMillis(); processThread.setDaemon(true); processThread.start(); while (!processThread.isCompleted()) { Thread.yield(); if (timeout > 0 && System.currentTimeMillis() - startTime > timeout) { throw new ProcessException( "Processing was not done within configured timout"); } else if (logger.isTraceEnabled()) { logger.trace("Waiting for processing. Waited " + (System.currentTimeMillis() - startTime) + "ms so far..."); } } if (processThread.getException() != null) { throw processThread.getException(); } if(!persist()) { LocalDocument ld = new LocalDocument(doc.toJson()); IOException e = new IOException("Unable to save changes to core"); if(!getRemotePipeline().markFailed(ld, e)) { logger.error("Unable to persist an error to the database", e); } } } catch (ProcessException e) { if(failDocumentOnProcessException) { getRemotePipeline().markFailed(doc, e); } else { persistError(doc, e); } } } } catch (Exception e) { logger.error("Caught exception while running", e); Runtime.getRuntime().removeShutdownHook(getShutDownHook()); System.exit(1); } } }</code><technical_language>thread a user friendly name well</technical_language>

Target:
public void run() { setContinueRunning(true); while (isContinueRunning()) { try { LocalDocument doc = fetch(); if (doc == null) { Thread.sleep(holdInterval); } else { try { logger.debug("Got new doc " + doc.getID() + " to process."); ProcessThread processThread = new ProcessThread(getStageName()); processThread.setDocument(doc); long startTime = timeProvider.getCurrentTime(); processThread.setDaemon(true); processThread.start(); while (processThread.isRunning()) { Thread.yield(); if (timeout > 0 && timeProvider.getCurrentTime() - startTime > timeout) { String docId = null; if (doc.getID() != null) { docId = doc.getID().toString(); } throw new ProcessException( "Processing of " + docId + " by " + getStageName() + " was not done within configured timout"); } else if (logger.isTraceEnabled()) { logger.trace("Waiting for processing. Waited " + (timeProvider.getCurrentTime() - startTime) + "ms so far..."); } } if (processThread.getException() != null) { throw processThread.getException(); } if(!persist()) { LocalDocument ld = new LocalDocument(doc.toJson()); IOException e = new IOException("Unable to save changes to core"); if(!getRemotePipeline().markFailed(ld, e)) { logger.error("Unable to persist an error to the database", e); } } } catch (ProcessException e) { if(failDocumentOnProcessException) { getRemotePipeline().markFailed(doc, e); } else { persistError(doc, e); } } } } catch (Exception e) { logger.error("Caught exception while running", e); Runtime.getRuntime().removeShutdownHook(getShutDownHook()); System.exit(1); } } }
Source:
<code>public void initialize() { Configuration configuration = getConfig(); Map<String, String> properties = editProperties(); if (!super.configure()) { return; } if (getThing().getStatus() == ThingStatus.OFFLINE) { return; } if (configuration.get(CONFIG_DIGITALREFRESH) != null) { digitalRefreshInterval = ((BigDecimal) configuration.get(CONFIG_DIGITALREFRESH)).intValue() * 1000; } else { digitalRefreshInterval = 10 * 1000; } digitalLastRefresh = 0; <START> if (sensorIds.get(0).startsWith("41") || properties.get(PROPERTY_MODELID).equals(OwSensorType.DS1923.name())) { <END> sensors.add(new DS1923(sensorIds.get(0), this)); } else { sensors.add(new DS2438(sensorIds.get(0), this)); } if (THING_TYPE_BMS.equals(thingType)) { sensors.add(new DS18x20(sensorIds.get(1), this)); } else if (THING_TYPE_AMS.equals(thingType)) { sensors.add(new DS18x20(sensorIds.get(1), this)); sensors.add(new DS2438(sensorIds.get(2), this)); sensors.add(new DS2406_DS2413(sensorIds.get(3), this)); } if (thingType == THING_TYPE_BMS || thingType == THING_TYPE_AMS) { if ((properties.get(PROPERTY_PROD_DATE) == null) || (properties.get(PROPERTY_HW_REVISION) == null)) { scheduler.execute(() -> { updateSensorProperties(); }); return; } else { hwRevision = Integer.valueOf(properties.get(PROPERTY_HW_REVISION)); } } scheduler.execute(() -> { configureThingChannels(); }); }</code><technical_language>failing test: check if PROPERTY_MODELID exists</technical_language>

Target:
public void initialize() { Configuration configuration = getConfig(); Map<String, String> properties = editProperties(); if (!super.configure()) { return; } if (getThing().getStatus() == ThingStatus.OFFLINE) { return; } if (configuration.containsKey(CONFIG_DIGITALREFRESH)) { digitalRefreshInterval = ((BigDecimal) configuration.get(CONFIG_DIGITALREFRESH)).intValue() * 1000; } else { digitalRefreshInterval = 10 * 1000; } digitalLastRefresh = 0; if (sensorIds.get(0).startsWith("41") || (properties.get(PROPERTY_MODELID) != null && properties.get(PROPERTY_MODELID).equals(OwSensorType.DS1923.name()))) { sensors.add(new DS1923(sensorIds.get(0), this)); } else { sensors.add(new DS2438(sensorIds.get(0), this)); } if (THING_TYPE_BMS.equals(thingType)) { sensors.add(new DS18x20(sensorIds.get(1), this)); } else if (THING_TYPE_AMS.equals(thingType)) { sensors.add(new DS18x20(sensorIds.get(1), this)); sensors.add(new DS2438(sensorIds.get(2), this)); sensors.add(new DS2406_DS2413(sensorIds.get(3), this)); } if (THING_TYPE_BMS.equals(thingType) || THING_TYPE_AMS.equals(thingType)) { if (properties.containsKey(PROPERTY_PROD_DATE) && properties.containsKey(PROPERTY_HW_REVISION)) { hwRevision = Integer.valueOf(properties.get(PROPERTY_HW_REVISION)); } else { scheduler.execute(() -> { updateSensorProperties(); }); return; } } scheduler.execute(() -> { configureThingChannels(); }); }
Source:
<code>public void testGetCACertificate() { <START> try { <END> CertificateManagementServiceImpl instance = CertificateManagementServiceImpl.getInstance(); Certificate caCertificate = instance.getCACertificate(); Assert.assertNotNull(caCertificate); Assert.assertEquals(caCertificate.getType(), CertificateManagementConstants.X_509); log.info("GetCACertificate Test Successful"); } catch (KeystoreException e) { String msg = "Error while getting the CA Certificate"; log.error(msg, e); Assert.fail(msg, e); } }</code><technical_language>Please throw exceptions in test cases, try catch it, assert fail. normal practice. Please correct in places</technical_language>

Target:
public void testGetCACertificate() throws KeystoreException { CertificateManagementServiceImpl instance = CertificateManagementServiceImpl.getInstance(); Certificate caCertificate = instance.getCACertificate(); Assert.assertNotNull(caCertificate); Assert.assertEquals(caCertificate.getType(), CertificateManagementConstants.X_509); log.info("GetCACertificate Test Successful"); }
Source:
<code>public void onCreateGame(@Nullable String mapFolderName) { if (preferencesService.getPreferences().getForgedAlliance().getPath() == null) { CompletableFuture<Path> gameDirectoryFuture = new CompletableFuture<>(); eventBus.post(new GameDirectoryChooseEvent(gameDirectoryFuture)); gameDirectoryFuture.thenAccept(path -> Optional.ofNullable(path).ifPresent(path1 -> onCreateGame(null))); return; } CreateGameController createGameController = uiService.loadFxml("theme/play/create_game.fxml"); <START> if (mapFolderName != null && createGameController.selectMap(mapFolderName)) { <END> log.info("Map with folder name: '{}' could not be found in map list", mapFolderName); } Pane createGameRoot = createGameController.getRoot(); gamesRoot.getChildren().add(createGameRoot); AnchorPane.setTopAnchor(createGameRoot, 0d); AnchorPane.setRightAnchor(createGameRoot, 0d); AnchorPane.setBottomAnchor(createGameRoot, 0d); AnchorPane.setLeftAnchor(createGameRoot, 0d); createGameRoot.requestFocus(); }</code><technical_language>!selectMap()</technical_language>

Target:
private void onCreateGame(@Nullable String mapFolderName) { if (preferencesService.getPreferences().getForgedAlliance().getPath() == null) { CompletableFuture<Path> gameDirectoryFuture = new CompletableFuture<>(); eventBus.post(new GameDirectoryChooseEvent(gameDirectoryFuture)); gameDirectoryFuture.thenAccept(path -> Optional.ofNullable(path).ifPresent(path1 -> onCreateGame(null))); return; } CreateGameController createGameController = uiService.loadFxml("theme/play/create_game.fxml"); if (mapFolderName != null && !createGameController.selectMap(mapFolderName)) { log.warn("Map with folder name: '{}' could not be found in map list", mapFolderName); } Pane createGameRoot = createGameController.getRoot(); gamesRoot.getChildren().add(createGameRoot); AnchorPane.setTopAnchor(createGameRoot, 0d); AnchorPane.setRightAnchor(createGameRoot, 0d); AnchorPane.setBottomAnchor(createGameRoot, 0d); AnchorPane.setLeftAnchor(createGameRoot, 0d); createGameRoot.requestFocus(); }
Source:
<code>private boolean areSameArtifact(Dependency dependency, Artifact artifact) { <START> return dependency.getArtifactId().equals(artifact.getArtifactCoordinates().getArtifactId()) <END> && dependency.getGroupId().equals(artifact.getArtifactCoordinates().getGroupId()) && dependency.getVersion().equals(artifact.getArtifactCoordinates().getVersion()); }</code><technical_language>Please StringUtils.equals</technical_language>

Target:
private boolean areSameArtifact(Dependency dependency, Artifact artifact) { return StringUtils.equals(dependency.getArtifactId(), artifact.getArtifactCoordinates().getArtifactId()) && StringUtils.equals(dependency.getGroupId(), artifact.getArtifactCoordinates().getGroupId()) && StringUtils.equals(dependency.getVersion(), artifact.getArtifactCoordinates().getVersion()); }
Source:
<code>public <T> List<T> getValues(MarketDataId<T> id) { if (id instanceof NoMatchingRuleId) { MarketDataKey<?> key = ((NoMatchingRuleId) id).getKey(); throw new IllegalArgumentException("No market data rules were available to build the market data for " + key); } if (id instanceof MissingMappingId) { MarketDataKey<?> key = ((MissingMappingId) id).getKey(); throw new IllegalArgumentException("No market data mapping found for " + key); } List<?> values = this.values.get(id); if (!values.isEmpty()) { return (List<T>) values; } T baseValue = baseData.getValue(id); <START> if (baseValue != null) { <END> return Collections.nCopies(scenarioCount, baseValue); } throw new IllegalArgumentException("No market data available for " + id); }</code><technical_language>reading of code is getValue() return null</technical_language>

Target:
public <T> List<T> getValues(MarketDataId<T> id) { if (id instanceof NoMatchingRuleId) { MarketDataKey<?> key = ((NoMatchingRuleId) id).getKey(); throw new IllegalArgumentException("No market data rules were available to build the market data for " + key); } if (id instanceof MissingMappingId) { MarketDataKey<?> key = ((MissingMappingId) id).getKey(); throw new IllegalArgumentException("No market data mapping found for " + key); } List<?> values = this.values.get(id); if (!values.isEmpty()) { return (List<T>) values; } return Collections.nCopies(scenarioCount, sharedData.getValue(id)); }