auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void validateMetadata(List<Metadata> metadatas) throws InvalidProductException { for (int i = 0; i < metadatas.size(); i++) { Metadata metadata = metadatas.get(i); if (metadata.getKey().equals("open_ports")) { List<String> ports = getFields((String) metadata.getValue()); for (String port : ports) { checkPortMetadata(port); <START> } <END> } else if (metadata.getKey().equals("open_ports_udp")) { List<String> ports = getFields((String) metadata.getValue()); for (String port : ports) { checkPortMetadata(port); } } else if (metadata.getKey().equals("installator")) { if (!(metadata.getValue().equals("chef")) && !(metadata.getValue().equals("puppet"))) { String msg = "Metadata " + metadata.getValue() + " MUST BE \"chef\" or \"puppet\""; throw new InvalidProductException(msg); } } else if (metadata.getKey().equals("dependencies")) { checkDependence(metadata.getValue()); } else if (metadata.getKey().equals("public")) { if (!(metadata.getValue().equals("no")) && !(metadata.getValue().equals("yes"))) { String msg = "Metadata " + metadata.getValue() + " MUST BE \"yes\" or \"not\""; throw new InvalidProductException(msg); } } else if (metadata.getKey().equals("cloud")) { if (!(metadata.getValue().equals("no")) && !(metadata.getValue().equals("yes"))) { String msg = "Metadata " + metadata.getValue() + " MUST BE \"yes\" or \"not\""; throw new InvalidProductException(msg); } } } }</code><technical_language>I is implement this method, in fact more 100 lines of codes</technical_language>

Target:
private void validateMetadata(List<Metadata> metadatas) throws InvalidProductException { for (int i = 0; i < metadatas.size(); i++) { Metadata metadata = metadatas.get(i); if (metadata.getKey().equals("open_ports") || metadata.getKey().equals("open_ports_udp")) { List<String> ports = getFields((String) metadata.getValue()); for (String port : ports) { checkPortMetadata(port); } } else if (metadata.getKey().equals("installator")) { if (!(metadata.getValue().equals("chef")) && !(metadata.getValue().equals("puppet"))) { String msg = "Metadata " + metadata.getValue() + " MUST BE \"chef\" or \"puppet\""; throw new InvalidProductException(msg); } } else if (metadata.getKey().equals("dependencies")) { checkDependence(metadata.getValue()); } else if (metadata.getKey().equals("public") || metadata.getKey().equals("cloud")) { if (!(metadata.getValue().equals("no")) && !(metadata.getValue().equals("yes"))) { String msg = "Metadata " + metadata.getValue() + " MUST BE \"yes\" or \"not\""; throw new InvalidProductException(msg); } } } }
Source:
<code>private static boolean isRootPrivate(Component root, Map<String, ComponentDto> existingDtosByKeys) { String rootKey = root.getKey(); ComponentDto rootDto = existingDtosByKeys.get(rootKey); if (rootDto == null) { if (Component.Type.VIEW == root.getType()) { <START> return NEW_VIEWS_SHOULD_BE_PRIVATE; <END> } throw new IllegalStateException(String.format("The project '%s' is not stored in the database, during a project analysis.", rootKey)); } return rootDto.isPrivate(); }</code><technical_language>false is enough here, constant</technical_language>

Target:
private static boolean isRootPrivate(Component root, Map<String, ComponentDto> existingDtosByKeys) { String rootKey = root.getKey(); ComponentDto rootDto = existingDtosByKeys.get(rootKey); if (rootDto == null) { if (Component.Type.VIEW == root.getType()) { return false; } throw new IllegalStateException(String.format("The project '%s' is not stored in the database, during a project analysis.", rootKey)); } return rootDto.isPrivate(); }
Source:
<code>final CachedNode cachedNode( SessionCache cache, CachedNode node, Path path, String... actions ) throws PathNotFoundException, AccessDeniedException, RepositoryException { for (Segment segment : path) { if (segment.isSelfReference()) continue; if (segment.isParentReference()) { node = cache.getNode(node.getParentKey(cache)); } else { ChildReference ref = node.getChildReferences(cache).getChild(segment); if (ref == null) { throw new PathNotFoundException(JcrI18n.nodeNotFound.text(stringFactory().create(path), workspaceName())); } CachedNode child = cache.getNode(ref); assert child != null : "Found a child reference in " + node.getPath(cache) + " to a non-existant child " + segment; node = child; } } Path absPath = path.isAbsolute() ? path : null; if (absPath == null) { try { absPath = node.getPath(cache); <START> if (actions.length > 0) { <END> checkPermission(absPath, actions); } } catch (NodeNotFoundException e) { throw new PathNotFoundException(JcrI18n.nodeNotFound.text(stringFactory().create(path), workspaceName())); } } return node; }</code><technical_language>get path if block. still, a PathSupplier compute path if checking permissions needs it. UPDATE: Oh, I guess changes, merging fun</technical_language>

Target:
final CachedNode cachedNode( SessionCache cache, CachedNode node, Path path, String... actions ) throws PathNotFoundException, AccessDeniedException, RepositoryException { for (Segment segment : path) { if (segment.isSelfReference()) continue; if (segment.isParentReference()) { node = cache.getNode(node.getParentKey(cache)); } else { ChildReference ref = node.getChildReferences(cache).getChild(segment); if (ref == null) { throw new PathNotFoundException(JcrI18n.nodeNotFound.text(stringFactory().create(path), workspaceName())); } CachedNode child = cache.getNode(ref); assert child != null : "Found a child reference in " + node.getPath(cache) + " to a non-existant child " + segment; node = child; } } Path absPath = path.isAbsolute() ? path : null; if (absPath == null) { try { if (actions.length > 0) { checkPermission(node, cache, actions); } } catch (NodeNotFoundException e) { throw new PathNotFoundException(JcrI18n.nodeNotFound.text(stringFactory().create(path), workspaceName())); } } return node; }
Source:
<code>public void registerContribution(Object contribution, String xp, ComponentInstance component) { if (QUEUES_EP.equals(xp)) { WorkQueueDescriptor descriptor = (WorkQueueDescriptor) contribution; if (ALL_QUEUES.equals(descriptor.getId())) { Boolean processing = descriptor.processing; if (processing == null) { getLog().error("Ignoring work queue descriptor " + ALL_QUEUES + " with no processing/queuing"); return; } String what = " processing=" + processing + (queuing == null ? "" : " queuing=" + queuing); getLog().info("Setting on all work queues:" + what); <START> getDescriptors(QUEUES_EP).stream().forEach(d -> { <END> WorkQueueDescriptor wqd = new WorkQueueDescriptor(); wqd.id = d.getId(); wqd.processing = processing; register(QUEUES_EP, wqd); }); } else { register(QUEUES_EP, descriptor); } } else { super.registerContribution(contribution, xp, component); } }</code><technical_language>need of .stream()</technical_language>

Target:
public void registerContribution(Object contribution, String xp, ComponentInstance component) { if (QUEUES_EP.equals(xp)) { WorkQueueDescriptor descriptor = (WorkQueueDescriptor) contribution; if (ALL_QUEUES.equals(descriptor.getId())) { Boolean processing = descriptor.processing; if (processing == null) { getLog().error("Ignoring work queue descriptor " + ALL_QUEUES + " with no processing/queuing"); return; } String what = " processing=" + processing + (queuing == null ? "" : " queuing=" + queuing); getLog().info("Setting on all work queues:" + what); getDescriptors(QUEUES_EP).forEach(d -> { WorkQueueDescriptor wqd = new WorkQueueDescriptor(); wqd.id = d.getId(); wqd.processing = processing; register(QUEUES_EP, wqd); }); } else { register(QUEUES_EP, descriptor); } } else { super.registerContribution(contribution, xp, component); } }
Source:
<code>public WorkflowResponse complete(WorkflowDTO workFlowDTO) throws WorkflowException { workFlowDTO.setUpdatedTime(System.currentTimeMillis()); ApiMgtDAO dao = ApiMgtDAO.getInstance(); try { if (dao.getApplicationById(Integer.parseInt(workFlowDTO.getWorkflowReference())) != null) { super.complete(workFlowDTO); log.info("Application Creation [Complete] Workflow Invoked. Workflow ID : " + workFlowDTO .getExternalWorkflowReference() + "Workflow State : " + workFlowDTO.getStatus()); String status = null; if (WorkflowStatus.CREATED.equals(workFlowDTO.getStatus())) { status = APIConstants.ApplicationStatus.APPLICATION_CREATED; } else if (WorkflowStatus.REJECTED.equals(workFlowDTO.getStatus())) { status = APIConstants.ApplicationStatus.APPLICATION_REJECTED; } else if (WorkflowStatus.APPROVED.equals(workFlowDTO.getStatus())) { status = APIConstants.ApplicationStatus.APPLICATION_APPROVED; } try { dao.updateApplicationStatus(Integer.parseInt(workFlowDTO.getWorkflowReference()), status); } catch (APIManagementException e) { String msg = "Error occurred when updating the status of the Application creation " + "process"; <START> log.error(msg, e); <END> throw new WorkflowException(msg, e); } } else { String msg = "Application does not exist"; throw new WorkflowException(msg); } } catch (APIManagementException e) { String msg = "Error occurred when retrieving the Application creation with workflow ID :" + workFlowDTO .getWorkflowReference(); log.error(msg, e); throw new WorkflowException(msg, e); } return new GeneralWorkflowResponse(); }</code><technical_language>remove +</technical_language>

Target:
public WorkflowResponse complete(WorkflowDTO workFlowDTO) throws WorkflowException { workFlowDTO.setUpdatedTime(System.currentTimeMillis()); ApiMgtDAO dao = ApiMgtDAO.getInstance(); try { if (dao.getApplicationById(Integer.parseInt(workFlowDTO.getWorkflowReference())) != null) { super.complete(workFlowDTO); log.info("Application Creation [Complete] Workflow Invoked. Workflow ID : " + workFlowDTO .getExternalWorkflowReference() + "Workflow State : " + workFlowDTO.getStatus()); String status = null; if (WorkflowStatus.CREATED.equals(workFlowDTO.getStatus())) { status = APIConstants.ApplicationStatus.APPLICATION_CREATED; } else if (WorkflowStatus.REJECTED.equals(workFlowDTO.getStatus())) { status = APIConstants.ApplicationStatus.APPLICATION_REJECTED; } else if (WorkflowStatus.APPROVED.equals(workFlowDTO.getStatus())) { status = APIConstants.ApplicationStatus.APPLICATION_APPROVED; } try { dao.updateApplicationStatus(Integer.parseInt(workFlowDTO.getWorkflowReference()), status); } catch (APIManagementException e) { String msg = "Error occurred when updating the status of the Application creation process"; log.error(msg, e); throw new WorkflowException(msg, e); } } else { String msg = "Application does not exist"; throw new WorkflowException(msg); } } catch (APIManagementException e) { String msg = "Error occurred when retrieving the Application creation with workflow ID :" + workFlowDTO .getWorkflowReference(); log.error(msg, e); throw new WorkflowException(msg, e); } return new GeneralWorkflowResponse(); }
Source:
<code>public String findMailAddressFor(User u) { if (disabled) return null; String username = u.getId(); for (JiraSite site : JiraGlobalConfiguration.get().getSites()) { <START> JiraSession session = site.getSession(null); <END> if (session == null) { continue; } com.atlassian.jira.rest.client.api.domain.User user = session.service.getUser(username); if (user != null) { String email = user.getEmailAddress(); if (email != null) { email = unmaskEmail(email); return email; } } } return null; }</code><technical_language>Potentially getSession(null) eliminated in this PR, of I fix</technical_language>

Target:
public String findMailAddressFor(User u) { if (disabled) { return null; } String username = u.getId(); Job<?, ?> job = Stapler.getCurrentRequest().findAncestorObject( Job.class); for (JiraSite site : JiraSite.getJiraSites(job)) { JiraSession session = site.getSession(job); if (session == null) { continue; } com.atlassian.jira.rest.client.api.domain.User user = session.service.getUser(username); if (user != null) { String email = user.getEmailAddress(); if (email != null) { email = unmaskEmail(email); return email; } } } return null; }
Source:
<code>public boolean remove(final K key) throws CacheAccessException { removeObserver.begin(); checkKey(key); final StoreEventSink<K, V> eventSink = eventDispatcher.eventSink(); final long now = timeSource.getTimeMillis(); final AtomicBoolean removed = new AtomicBoolean(false); try { backingMap().computeIfPresent(key, new BiFunction<K, OffHeapValueHolder<V>, OffHeapValueHolder<V>>() { @Override public OffHeapValueHolder<V> apply(K mappedKey, OffHeapValueHolder<V> mappedValue) { <START> if (mappedValue != null && mappedValue.isExpired(now, TimeUnit.MILLISECONDS)) { <END> onExpiration(key, mappedValue, eventSink); return null; } if (mappedValue != null) { removed.set(true); eventSink.removed(mappedKey, mappedValue.value()); } return null; } }); eventDispatcher.releaseEventSink(eventSink); if (removed.get()) { removeObserver.end(StoreOperationOutcomes.RemoveOutcome.REMOVED); } else { removeObserver.end(StoreOperationOutcomes.RemoveOutcome.MISS); } return removed.get(); } catch (RuntimeException re) { eventDispatcher.releaseEventSinkAfterFailure(eventSink, re); handleRuntimeException(re); return false; } }</code><technical_language>computeIfPresent means mappedValue null</technical_language>

Target:
public boolean remove(final K key) throws CacheAccessException { removeObserver.begin(); checkKey(key); final StoreEventSink<K, V> eventSink = eventDispatcher.eventSink(); final long now = timeSource.getTimeMillis(); final AtomicBoolean removed = new AtomicBoolean(false); try { backingMap().computeIfPresent(key, new BiFunction<K, OffHeapValueHolder<V>, OffHeapValueHolder<V>>() { @Override public OffHeapValueHolder<V> apply(K mappedKey, OffHeapValueHolder<V> mappedValue) { if (mappedValue != null && mappedValue.isExpired(now, TimeUnit.MILLISECONDS)) { onExpiration(mappedKey, mappedValue, eventSink); return null; } if (mappedValue != null) { removed.set(true); eventSink.removed(mappedKey, mappedValue.value()); } return null; } }); eventDispatcher.releaseEventSink(eventSink); if (removed.get()) { removeObserver.end(StoreOperationOutcomes.RemoveOutcome.REMOVED); } else { removeObserver.end(StoreOperationOutcomes.RemoveOutcome.MISS); } return removed.get(); } catch (RuntimeException re) { eventDispatcher.releaseEventSinkAfterFailure(eventSink, re); handleRuntimeException(re); return false; } }
Source:
<code>public ServerLRAFilter() throws Exception { String rcHost = System.getProperty("lra.http.host", "localhost"); <START> int rcPort = Integer.getInteger("lra.http.port", 8082); <END> String coordinatorPath = System.getProperty("lra.coordinator.path", "lra-coordinator"); lraClient = (LRAClient) Class.forName(NarayanaLRAClient.class.getCanonicalName()).getDeclaredConstructor().newInstance(); lraClient.setCoordinatorURI(new URI(String.format("http://%s:%d/%s", rcHost, rcPort, coordinatorPath))); }</code><technical_language>I raise a JBTM reference instead of TODO</technical_language>

Target:
public ServerLRAFilter() throws Exception { if (!NarayanaLRAClient.isInitialised()) { String rcHost = System.getProperty(LRA_COORDINATOR_HOST_KEY, "localhost"); int rcPort = Integer.getInteger(LRA_COORDINATOR_PORT_KEY, 8082); String coordinatorPath = System.getProperty(LRA_COORDINATOR_PATH_KEY, "lra-coordinator"); NarayanaLRAClient.setDefaultEndpoint(new URI(String.format("http://%s:%d/%s", rcHost, rcPort, coordinatorPath))); } lraClient = (LRAClient) Class.forName(NarayanaLRAClient.class.getCanonicalName()).getDeclaredConstructor().newInstance(); }
Source:
<code>protected ICompletableFuture<Void> setAsyncInternal(long ttl, TimeUnit timeunit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value) { try { Data keyData = toData(key); Data valueData = toData(value); long ttlMillis = timeInMsOrOneIfResultIsZero(ttl, timeunit); ClientMessage request; if (maxIdle != null) { request = MapSetCodec.encodeRequest(name, keyData, valueData, getThreadId(), ttlMillis, timeInMsOrOneIfResultIsZero(maxIdle, maxIdleUnit)); } else { <START> request = MapPutCodec.encodeRequest(name, keyData, valueData, getThreadId(), ttlMillis); <END> } ClientInvocationFuture future = invokeOnKeyOwner(request, keyData); return new ClientDelegatingFuture<Void>(future, getSerializationService(), SET_ASYNC_RESPONSE_DECODER); } catch (Exception e) { throw rethrow(e); } }</code><technical_language>This a typo. MapSetCodec</technical_language>

Target:
protected ICompletableFuture<Void> setAsyncInternal(long ttl, TimeUnit timeunit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value) { try { Data keyData = toData(key); Data valueData = toData(value); long ttlMillis = timeInMsOrOneIfResultIsZero(ttl, timeunit); ClientMessage request; if (maxIdle != null) { request = MapSetCodec.encodeRequest(name, keyData, valueData, getThreadId(), ttlMillis, timeInMsOrOneIfResultIsZero(maxIdle, maxIdleUnit)); } else { request = MapSetCodec.encodeRequest(name, keyData, valueData, getThreadId(), ttlMillis); } ClientInvocationFuture future = invokeOnKeyOwner(request, keyData); return new ClientDelegatingFuture<Void>(future, getSerializationService(), SET_ASYNC_RESPONSE_DECODER); } catch (Exception e) { throw rethrow(e); } }
Source:
<code>public static String doubleToString(double d) { <START> if (d == Double.POSITIVE_INFINITY) { return "Infinity"; } else if (d == Double.NEGATIVE_INFINITY) { return "-Infinity"; } return String.valueOf(d); <END> }</code><technical_language>treat final String.valueof(d) else seams thought of combinations</technical_language>

Target:
public static String doubleToString(double d) { if (d == Double.POSITIVE_INFINITY) { return "Infinity"; } if (d == Double.NEGATIVE_INFINITY) { return "-Infinity"; } return String.valueOf(d); }
Source:
<code>public static boolean isValidBooleanPropertyKey(String key) { return validProperties.contains(key) <START> && getPropertyByKey(key).getType().equals(PropertyType.BOOLEAN); <END> }</code><technical_language>== compare enums (such PropertyType), equals() accepts Object, == forces compiler check sides type, easier catch coding mistakes. Enums instances in Java JVM-wide singletons, of typical risks get == comparing sameness instead of equality. For enums equality implies sameness. suggestion && getPropertyByKey(key).getType() == PropertyType.BOOLEAN;</technical_language>

Target:
public static boolean isValidBooleanPropertyKey(String key) { return validProperties.contains(key) && getPropertyByKey(key).getType() == PropertyType.BOOLEAN; }
Source:
<code>protected Size onSuggestedResolutionUpdated(@NonNull Size suggestedResolution) { MeteringRepeatingConfig configWithDefaults = (MeteringRepeatingConfig) getUseCaseConfig(); SurfaceTexture surfaceTexture = new SurfaceTexture(0); <START> surfaceTexture.setDefaultBufferSize(640, 480); <END> Surface surface = new Surface(surfaceTexture); SessionConfig.Builder builder = SessionConfig.Builder.createFrom(configWithDefaults); builder.setTemplateType(CameraDevice.TEMPLATE_PREVIEW); if (mDeferrableSurface != null) { mDeferrableSurface.close(); } mDeferrableSurface = new ImmediateSurface(surface); mDeferrableSurface.getTerminationFuture().addListener(() -> { Log.d(TAG, "Release metering surface and surface texture"); surface.release(); surfaceTexture.release(); }, CameraXExecutors.directExecutor()); builder.addSurface(mDeferrableSurface); attachToCamera(builder.build()); notifyActive(); return new Size(640, 480); }</code><technical_language>Do rationale of setting this surface size</technical_language>

Target:
protected Size onSuggestedResolutionUpdated(@NonNull Size suggestedResolution) { MeteringRepeatingConfig configWithDefaults = (MeteringRepeatingConfig) getUseCaseConfig(); SurfaceTexture surfaceTexture = new SurfaceTexture(0); surfaceTexture.setDefaultBufferSize(0, 0); Surface surface = new Surface(surfaceTexture); SessionConfig.Builder builder = SessionConfig.Builder.createFrom(configWithDefaults); builder.setTemplateType(CameraDevice.TEMPLATE_PREVIEW); if (mDeferrableSurface != null) { mDeferrableSurface.close(); } mDeferrableSurface = new ImmediateSurface(surface); mDeferrableSurface.getTerminationFuture().addListener(() -> { Log.d(TAG, "Release metering surface and surface texture"); surface.release(); surfaceTexture.release(); }, CameraXExecutors.directExecutor()); builder.addSurface(mDeferrableSurface); attachToCamera(builder.build()); notifyActive(); return new Size(0, 0); }
Source:
<code>boolean filter(Attr attr) { if (attributeFilter == null) return false; String name = attr.getNodeName(); for (String <START> element : <END> attributeFilter) { if (name.matches(element)) return false; } return true; }</code><technical_language>rename filteredName</technical_language>

Target:
boolean filter(Attr attr) { if (attributeFilter == null) return false; String name = attr.getNodeName(); for (String filteredName : attributeFilter) { if (name.matches(filteredName)) return false; } return true; }
Source:
<code>public List<PermissionSubject> getPermissionCheckSubjects() { List<PermissionSubject> permissions = new ArrayList<PermissionSubject>(); <START> Guid networkId = getParameters().getNetwork() == null ? null : getParameters().getNetwork().getId(); <END> permissions.add(new PermissionSubject(networkId, VdcObjectType.Network, getActionType().getActionGroup())); if (networkExists()) { permissions.add(new PermissionSubject(getParameters().getVdsGroupId(), VdcObjectType.VdsGroups, ActionGroup.CONFIGURE_CLUSTER_NETWORK)); } return permissions; }</code><technical_language>get NetworkCluster field</technical_language>

Target:
public List<PermissionSubject> getPermissionCheckSubjects() { List<PermissionSubject> permissions = new ArrayList<PermissionSubject>(); Guid networkId = getClusterNetwork() == null ? null : getClusterNetwork().getnetwork_id(); permissions.add(new PermissionSubject(networkId, VdcObjectType.Network, getActionType().getActionGroup())); if (networkExists()) { permissions.add(new PermissionSubject(getParameters().getVdsGroupId(), VdcObjectType.VdsGroups, ActionGroup.CONFIGURE_CLUSTER_NETWORK)); } return permissions; }
Source:
<code>public void onSubscribe(Disposable d) { <START> if (DisposableHelper.set(this, d)) { <END> actual.onSubscribe(this); } }</code><technical_language>setOnce</technical_language>

Target:
public void onSubscribe(Disposable d) { if (DisposableHelper.setOnce(this, d)) { actual.onSubscribe(this); } }
Source:
<code>public List<Permission> getAdmins() { try { <START> return ImmutableList.copyOf( <END> addDefaultAdmin(resourceCache.get(ADMIN_RESOURCE, authorizationDbRepository::listAdmins))); } catch (ExecutionException e) { return addDefaultAdmin(authorizationDbRepository.listAdmins()); } }</code><technical_language>This code is in a hot path. Do avoid copies</technical_language>

Target:
public List<Permission> getAdmins() { return addDefaultAdmin(authorizationDbRepository.listAdmins()); }
Source:
<code>public TestCase(Annotated<String, LocationData> definition, List<Annotated<String, LocationData>> programs, String[] extensions, String[] excludes, List<Annotated<String, LocationData>> results, List<PgmArg> kompileOpts, ProgramProfile krunOpts, Map<String, ProgramProfile> pgmSpecificKRunOpts, Set<KTestStep> skips) throws InvalidConfigError { File definitionFile = new File(definition.getObj()); File output = new File(definitionFile.getParentFile(), FilenameUtils.removeExtension(definitionFile.getName()) + "-kompiled"); for (PgmArg arg : kompileOpts) { <START> if (arg.arg.equals("--output")) { <END> output = new File(definitionFile.getParentFile(), arg.val); } } this.compiledDir = output; this.definition = definition; this.programs = programs; this.extensions = toSet(extensions); this.excludes = toSet(excludes); this.results = results; this.kompileOpts = kompileOpts; this.krunOpts = krunOpts; this.pgmSpecificKRunOpts = pgmSpecificKRunOpts; this.skips = skips; }</code><technical_language>need --output argument in some other places in ktest too. review this part in details later</technical_language>

Target:
public TestCase(Annotated<String, LocationData> definition, List<Annotated<String, LocationData>> programs, String[] extensions, String[] excludes, List<Annotated<String, LocationData>> results, List<PgmArg> kompileOpts, ProgramProfile krunOpts, Map<String, ProgramProfile> pgmSpecificKRunOpts, Set<KTestStep> skips) throws InvalidConfigError { this.definition = definition; this.programs = programs; this.extensions = toSet(extensions); this.excludes = toSet(excludes); this.results = results; this.kompileOpts = kompileOpts; this.krunOpts = krunOpts; this.pgmSpecificKRunOpts = pgmSpecificKRunOpts; this.skips = skips; }
Source:
<code>public static void denySelectColumns(String tableName, Collection<String> columnNames, String extraInfo) { <START> throw new AccessDeniedException(format("Cannot select from columns %s in table %s%s", columnNames, tableName, formatExtraInfo(extraInfo))); <END> }</code><technical_language>This a view: table -> relation in table view %s (might avoid term "relation" in user error messages)</technical_language>

Target:
public static void denySelectColumns(String tableName, Collection<String> columnNames, String extraInfo) { throw new AccessDeniedException(format("Cannot select from columns %s in table or view %s%s", columnNames, tableName, formatExtraInfo(extraInfo))); }
Source:
<code>private Set<String> translateToPrivileges(String permission) { <START> if (permission == null || permission.equalsIgnoreCase("rw")) <END> { return Privileges.rw(); } else { return Privileges.r(); } }</code><technical_language>![MAJOR](<LINK_0> 'Severity: MAJOR') Move "rw" string literal left side of this string comparison. [![rule](<LINK_1>](<LINK_2></technical_language>

Target:
private Set<String> translateToPrivileges(String permission) { if (permission == null || permission.equalsIgnoreCase(Privileges.DEFAULT)) { return Privileges.rw(); } else { return Privileges.r(); } }
Source:
<code>private void moveReceivedFiles() { File receiveFolder = new File(toBeSubmittedDirectory); if (!receiveFolder.isDirectory() || !receiveFolder.exists()) { return; } File[] files = receiveFolder.listFiles(); try { Log.d(TAG, "We have " + files.length + " toBeSubmitted files to transfer"); <START> for (File instanceDirectory : files) { <END> FileUtil.copyFileDeep(instanceDirectory, new File(toBeTransferredDirectory, instanceDirectory.getName())); Log.d(TAG, "Transferred " + instanceDirectory + " to " + toBeTransferredDirectory + "/" + instanceDirectory.getName()); } } catch(IOException e){ for (File instanceDirectory : files) { File newDestination = new File(toBeTransferredDirectory, instanceDirectory.getName()); if(newDestination.exists()){ FileUtil.deleteFileOrDir(newDestination); } } } for (File instanceDirectory : files) { if(instanceDirectory.exists()){ FileUtil.deleteFileOrDir(instanceDirectory); } } }</code><technical_language>is instanceDirectory a directory a file? confirm is a directory, if not, rename denotes a file</technical_language>

Target:
private void moveReceivedFiles() { File receiveFolder = new File(toBeSubmittedDirectory); if (!receiveFolder.isDirectory() || !receiveFolder.exists()) { return; } File[] originFiles = receiveFolder.listFiles(); File[] destinationFiles = new File[originFiles.length]; for(int i=0; i< originFiles.length; i++){ destinationFiles[i] = new File(toBeTransferredDirectory, originFiles[i].getName()); } try { Log.d(TAG, "We have " + originFiles.length + " toBeSubmitted files to transfer"); for (int i=0; i< originFiles.length; i++) { FileUtil.copyFileDeep(originFiles[i], destinationFiles[i]); Log.d(TAG, "Transferred " + originFiles[i] + " to " + destinationFiles[i]); } } catch(IOException e){ for (File destinationFile : destinationFiles) { if(destinationFile.exists()){ FileUtil.deleteFileOrDir(destinationFile); } } } for (File originFile : originFiles) { if(originFile.exists()){ FileUtil.deleteFileOrDir(originFile); } } }
Source:
<code>public void scheduleInitial(SourceScheduler scheduler) { checkState(!initialScheduled, "Initial scheduling happened before scheduleInitial is called"); int driverGroupsScheduledPerTask = 0; synchronized (this) { while (!driverGroupNoPreferenceQueue.isEmpty() || !driverGroupWithPreferenceMapQueue.isEmpty()) { for (int taskId = 0; taskId < nodeByTaskId.size() && (!driverGroupNoPreferenceQueue.isEmpty() || !driverGroupWithPreferenceMapQueue.isEmpty()); taskId++) { InternalNode node = nodeByTaskId.get(taskId); int driverGroupId = pickDriverGroupForNode(node); <START> if (driverGroupId == -1) { <END> continue; } scheduler.startLifespan(Lifespan.driverGroup(driverGroupId), partitionHandles.get(driverGroupId)); taskByDriverGroup[driverGroupId] = taskId; runningDriverGroupIdsByTask[taskId].add(driverGroupId); } driverGroupsScheduledPerTask++; if (concurrentLifespansPerTask.isPresent() && driverGroupsScheduledPerTask == concurrentLifespansPerTask.getAsInt()) { break; } } initialScheduled = true; } }</code><technical_language>Instead of magical -1, returning OptionalInt</technical_language>

Target:
public void scheduleInitial(SourceScheduler scheduler) { checkState(!initialScheduled, "Initial scheduling happened before scheduleInitial is called"); int driverGroupsScheduledPerTask = 0; synchronized (this) { while (!noPreferenceDriverGroups.isEmpty() || !nodeToPreferredDriverGroups.isEmpty()) { for (int taskId = 0; taskId < nodeByTaskId.size() && (!noPreferenceDriverGroups.isEmpty() || !nodeToPreferredDriverGroups.isEmpty()); taskId++) { InternalNode node = nodeByTaskId.get(taskId); OptionalInt driverGroupId = getNextDriverGroup(node); if (!driverGroupId.isPresent()) { continue; } scheduler.startLifespan(Lifespan.driverGroup(driverGroupId.getAsInt()), partitionHandles.get(driverGroupId.getAsInt())); taskByDriverGroup[driverGroupId.getAsInt()] = taskId; runningDriverGroupIdsByTask[taskId].add(driverGroupId.getAsInt()); } driverGroupsScheduledPerTask++; if (concurrentLifespansPerTask.isPresent() && driverGroupsScheduledPerTask == concurrentLifespansPerTask.getAsInt()) { break; } } initialScheduled = true; } }
Source:
<code><START> public String formatResult(String msg) { <END> StringBuilder res = new StringBuilder("%table "); Matcher ml = KYLIN_TABLE_FORMAT_REGEX_LABEL.matcher(msg); while (!ml.hitEnd() && ml.find()) { res.append(ml.group(1) + " \t"); } res.append(" \n"); Matcher mr = KYLIN_TABLE_FORMAT_REGEX_RESULTS.matcher(msg); String table = null; while (!mr.hitEnd() && mr.find()) { table = mr.group(1); } String[] row = table.split("],\\["); for (int i = 0; i < row.length; i++) { String[] col = row[i].split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", -1); for (int j = 0; j < col.length; j++) { if (col[j] != null) { col[j] = col[j].replaceAll("^\"|\"$", ""); } res.append(col[j] + " \t"); } res.append(" \n"); } return res.toString(); }</code><technical_language>LGTM it. changing package of test class this class this method package-local</technical_language>

Target:
String formatResult(String msg) { StringBuilder res = new StringBuilder("%table "); Matcher ml = KYLIN_TABLE_FORMAT_REGEX_LABEL.matcher(msg); while (!ml.hitEnd() && ml.find()) { res.append(ml.group(1) + " \t"); } res.append(" \n"); Matcher mr = KYLIN_TABLE_FORMAT_REGEX_RESULTS.matcher(msg); String table = null; while (!mr.hitEnd() && mr.find()) { table = mr.group(1); } String[] row = table.split("],\\["); for (int i = 0; i < row.length; i++) { String[] col = row[i].split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", -1); for (int j = 0; j < col.length; j++) { if (col[j] != null) { col[j] = col[j].replaceAll("^\"|\"$", ""); } res.append(col[j] + " \t"); } res.append(" \n"); } return res.toString(); }
Source:
<code>protected JmsSubscription createJmsSubscription(IDestination<?> destination, SubscribeInput input, IJmsSessionProvider sessionProvider, IFuture<?> worker) throws JMSException { JmsSubscription subscription = new JmsSubscription(destination, input, sessionProvider, worker); <START> subscription.awaitStarted(30, TimeUnit.SECONDS); <END> return subscription; }</code><technical_language>this timeout configurable well</technical_language>

Target:
protected JmsSubscription createJmsSubscription(IDestination<?> destination, SubscribeInput input, IJmsSessionProvider sessionProvider, IFuture<?> worker) throws JMSException { JmsSubscription subscription = new JmsSubscription(destination, input, sessionProvider, worker); subscription.awaitStarted(m_subscriptionAwaitStartedSeconds, TimeUnit.SECONDS); return subscription; }
Source:
<code>public InputRow nextRow() { if (!it.hasNext()) { try { CloseQuietly.close(jsonParser); if (++fileIndex >= files.size()) { throw new IllegalStateException("No more data!"); } jsonParser = factory.createParser(files.get(fileIndex)); it = jsonParser.readValuesAs(Row.class); } <START> catch (IOException e) { <END> Throwables.propagate(e); } } return Rows.toCaseInsensitiveInputRow(it.next(), dimensions); }</code><technical_language>If catching IOException, Throwables.propagate() is synonym throw new RuntimeException(e), preferred IMO is library-ish</technical_language>

Target:
public InputRow nextRow() { return Rows.toCaseInsensitiveInputRow(it.next(), dimensions); }
Source:
<code>protected int doWork() { IOUtil.assertFileIsReadable(PED_FILE); IOUtil.assertFileIsReadable(MAP_FILE); IOUtil.assertFileIsReadable(ZCALL_THRESHOLDS_FILE); IOUtil.assertFileIsWritable(OUTPUT); try { parseZCallThresholds(); <START> ZCallPedFile zCallPedFile = ZCallPedFile.fromFile(PED_FILE, MAP_FILE); <END> VCFFileReader vcfFileReader = new VCFFileReader(ORIGINAL_VCF, false); VCFHeader header = vcfFileReader.getFileHeader(); addAdditionalHeaderFields(header); writeVcf(vcfFileReader.iterator(), OUTPUT, vcfFileReader.getFileHeader().getSequenceDictionary(), header, zCallPedFile); } catch (FileNotFoundException e) { e.printStackTrace(); } return 0; }</code><technical_language>finals..</technical_language>

Target:
protected int doWork() { IOUtil.assertFileIsReadable(PED_FILE); IOUtil.assertFileIsReadable(MAP_FILE); IOUtil.assertFileIsReadable(ZCALL_THRESHOLDS_FILE); IOUtil.assertFileIsWritable(OUTPUT); try { parseZCallThresholds(); final ZCallPedFile zCallPedFile = ZCallPedFile.fromFile(PED_FILE, MAP_FILE); final VCFFileReader vcfFileReader = new VCFFileReader(ORIGINAL_VCF, false); final VCFHeader header = vcfFileReader.getFileHeader(); if (header.getGenotypeSamples().size() > 1) { throw new PicardException("MergePedIntoVCF only works with single-sample VCFs."); } addAdditionalHeaderFields(header); writeVcf(vcfFileReader.iterator(), OUTPUT, vcfFileReader.getFileHeader().getSequenceDictionary(), header, zCallPedFile); } catch (Exception e) { e.printStackTrace(); } return 0; }
Source:
<code>public final Session[] listSessions() { getLog().info("fetching sessions information"); final List<String> zkSessions; try { zkSessions = getCurator().getChildren().forPath(getSubscriptionPath("/sessions")); } catch (final KeeperException.NoNodeException e) { throw new SubscriptionNotInitializedException(getSubscriptionId()); } catch (Exception ex) { throw new NakadiRuntimeException(ex); } try { final CountDownLatch latch = new CountDownLatch(zkSessions.size()); final Map<String, Session> resultSessions = new HashMap<>(); for (final String sessionId : zkSessions) { getCurator().getData() .inBackground((client, event) -> { try { if (event.getResultCode() == KeeperException.Code.OK.intValue()) { synchronized (resultSessions) { resultSessions.put( sessionId, new Session( sessionId, <START> Integer.parseInt(new String(event.getData(), UTF_8)))); <END> } } } finally { latch.countDown(); } }) .forPath(getSubscriptionPath("/sessions/" + sessionId)); } if (latch.await(10, TimeUnit.SECONDS)) { return resultSessions.values().toArray(new Session[resultSessions.size()]); } else { throw new ServiceTemporarilyUnavailableException( "Failed to finish waiting for sessions list from zk", null); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new NakadiRuntimeException(e); } catch (MyNakadiRuntimeException1 e) { throw e; } catch (final Exception e) { throw new NakadiRuntimeException(e); } }</code><technical_language>please format this code in a way? difficult read 28 nested levels</technical_language>

Target:
public final Collection<Session> listSessions() throws SubscriptionNotInitializedException, NakadiRuntimeException, ServiceTemporarilyUnavailableException { getLog().info("fetching sessions information"); final List<String> zkSessions; try { zkSessions = getCurator().getChildren().forPath(getSubscriptionPath("/sessions")); } catch (final KeeperException.NoNodeException e) { throw new SubscriptionNotInitializedException(getSubscriptionId()); } catch (Exception ex) { throw new NakadiRuntimeException(ex); } return loadDataAsync( zkSessions, key -> getSubscriptionPath("/sessions/" + key), (key, data) -> new Session(key, Integer.parseInt(new String(data, UTF_8)))).values(); }
Source:
<code>public AttributeDefinition getAttributeDefinition() { AttributeDefinition attr = new AttributeDefinition(); attr.setNamespace(AttributesManager.NS_FACILITY_ATTR_DEF); <START> attr.setFriendlyName("googleGroupName-namespace"); <END> attr.setDisplayName("Google group name namespace"); attr.setType(String.class.getName()); attr.setDescription("Allowed google group name namespace on facility."); return attr; }</code><technical_language>name googleGroupNameNamespace</technical_language>

Target:
public AttributeDefinition getAttributeDefinition() { AttributeDefinition attr = new AttributeDefinition(); attr.setNamespace(AttributesManager.NS_FACILITY_ATTR_DEF); attr.setFriendlyName("googleGroupNameNamespace"); attr.setDisplayName("Google group name namespace"); attr.setType(String.class.getName()); attr.setDescription("Allowed google group name namespace on facility."); return attr; }
Source:
<code>public void testBlockingFacetBlocksDeletion() throws IOException { createFolderStructure(); TestTaskListener testTaskListener = new TestTaskListener(); Fingerprint fp = new TestFingerprint(false); fp.facets.setOwner(Saveable.NOOP); TestFingperprintFacet facet = new TestFingperprintFacet(fp, System.currentTimeMillis(), true); fp.facets.add(facet); FingerprintCleanupThread cleanupThread = new TestFingerprintCleanupThread(fp); cleanupThread.execute(testTaskListener); <START> assertTrue("Should have deleted obsolete file.", fpFile.toFile().exists()); <END> }</code><technical_language>Is a race condition cleanup thread completed deletion of fingerprint file? Also, is worth considering a hamcrest assertion assertTrue? suggestion assertThat(fpFile.toFile()., is(aReadableFile()));</technical_language>

Target:
public void testBlockingFacetBlocksDeletion() throws IOException { createFolderStructure(); TestTaskListener testTaskListener = new TestTaskListener(); Fingerprint fp = new TestFingerprint(false); fp.facets.setOwner(Saveable.NOOP); TestFingperprintFacet facet = new TestFingperprintFacet(fp, System.currentTimeMillis(), true); fp.facets.add(facet); FingerprintCleanupThread cleanupThread = new TestFingerprintCleanupThread(fp); cleanupThread.execute(testTaskListener); String logOutput = testTaskListener.outputStream.toString(); assertThat(logOutput, containsString("blocked deletion of")); }
Source:
<code>public void canRemoveEntityWithBlob() { inTransaction( em -> { Photo photo = new Photo(); photo.setId( ENTITY_ID_2 ); photo.setDescription( "photo2" ); Blob blob = Hibernate.getLobCreator( em.unwrap( Session.class ) ).createBlob( BLOB_CONTENT_1 ); photo.setContentAsBlob( blob ); photo.setContentAsByteArray( BLOB_CONTENT_1 ); photo.setContentAsString( BLOB_STRING_CONTENT_1 ); em.persist( photo ); } ); inTransaction( em -> { Photo photo = em.find( Photo.class, ENTITY_ID_2 ); assertThat( photo ).isNotNull(); assertThat( photo.getContentAsBlob() ).isNotNull(); assertBlobAreEqual( photo.getContentAsBlob(), BLOB_CONTENT_1 ); assertThat( photo.getContentAsByteArray() ).isNotNull(); assertThat( photo.getContentAsByteArray() ).isEqualTo( BLOB_CONTENT_1 ); assertThat( photo.getContentAsString() ).isNotNull(); <START> assertThat( photo.getContentAsString() ).isEqualTo( BLOB_STRING_CONTENT_1 ); <END> em.remove( photo ); } ); inTransaction( em -> { GridFSBucket gridFSFilesBucket = GridFSBuckets.create( getCurrentDB( em ), BUCKET_NAME ); MongoCursor<GridFSFile> cursor = gridFSFilesBucket.find().iterator(); List<GridFSFile> files = new LinkedList<>(); while ( cursor.hasNext() ) { files.add( cursor.next() ); } assertThat( files.size() ).isEqualTo( 3 ); } ); }</code><technical_language>I tests right for this issue. pass if store field GridFS. Is a check if field store effectively GridFS</technical_language>

Target:
public void canRemoveEntityWithBlob() { inTransaction( em -> { Photo photo = new Photo(); photo.setId( ENTITY_ID_2 ); photo.setDescription( "photo2" ); Blob blob = Hibernate.getLobCreator( em.unwrap( Session.class ) ).createBlob( BLOB_CONTENT_1 ); photo.setContentAsBlob( blob ); photo.setContentAsByteArray( BLOB_CONTENT_1 ); photo.setContentAsString( BLOB_STRING_CONTENT_1 ); em.persist( photo ); } ); inTransaction( em -> { Photo photo = em.find( Photo.class, ENTITY_ID_2 ); assertThat( photo ).isNotNull(); assertBlobAreEqual( photo.getContentAsBlob(), BLOB_CONTENT_1 ); assertThat( photo.getContentAsByteArray() ).isEqualTo( BLOB_CONTENT_1 ); assertThat( photo.getContentAsString() ).isEqualTo( BLOB_STRING_CONTENT_1 ); em.remove( photo ); } ); inTransaction( em -> { GridFSBucket gridFSFilesBucket = GridFSBuckets.create( getCurrentDB( em ), BUCKET_NAME ); MongoCursor<GridFSFile> cursor = gridFSFilesBucket.find().iterator(); List<GridFSFile> files = new LinkedList<>(); while ( cursor.hasNext() ) { files.add( cursor.next() ); } assertThat( files.size() ).isEqualTo( 3 ); } ); }
Source:
<code>public int mktime(ZoneInfo zoneInfo) { this.isDst = this.isDst > 0 ? this.isDst = 1 : this.isDst < 0 ? this.isDst = -1 : 0; copyFieldsToCalendar(); final long longWallTimeSeconds = <START> roundDownMillisToSeconds(calendar.getTimeInMillis()); <END> if (Integer.MIN_VALUE > longWallTimeSeconds || longWallTimeSeconds > Integer.MAX_VALUE) { return -1; } try { final int wallTimeSeconds = (int) longWallTimeSeconds; final int rawOffsetSeconds = zoneInfo.mRawOffset / 1000; final int rawTimeSeconds = checkedSubtract(wallTimeSeconds, rawOffsetSeconds); if (zoneInfo.mTransitions.length == 0) { if (this.isDst > 0) { return -1; } copyFieldsFromCalendar(); this.isDst = 0; this.gmtOffsetSeconds = rawOffsetSeconds; return rawTimeSeconds; } final int initialTransitionIndex = findTransitionIndex(zoneInfo, rawTimeSeconds); if (isDst < 0) { Integer result = doWallTimeSearch(zoneInfo, initialTransitionIndex, wallTimeSeconds, true ); return result == null ? -1 : result; } Integer result = doWallTimeSearch(zoneInfo, initialTransitionIndex, wallTimeSeconds, true ); if (result == null) { result = doWallTimeSearch(zoneInfo, initialTransitionIndex, wallTimeSeconds, false ); } if (result == null) { result = -1; } return result; } catch (CheckedArithmeticException e) { return -1; } }</code><technical_language>This strictly necessary ensure time in millis millisecond component, harmful. impact performance a tiny bit</technical_language>

Target:
public int mktime(ZoneInfo zoneInfo) { this.isDst = this.isDst > 0 ? this.isDst = 1 : this.isDst < 0 ? this.isDst = -1 : 0; copyFieldsToCalendar(); final long longWallTimeSeconds = calendar.getTimeInMillis() / 1000; if (Integer.MIN_VALUE > longWallTimeSeconds || longWallTimeSeconds > Integer.MAX_VALUE) { return -1; } try { final int wallTimeSeconds = (int) longWallTimeSeconds; final int rawOffsetSeconds = zoneInfo.mRawOffset / 1000; final int rawTimeSeconds = checkedSubtract(wallTimeSeconds, rawOffsetSeconds); if (zoneInfo.mTransitions.length == 0) { if (this.isDst > 0) { return -1; } copyFieldsFromCalendar(); this.isDst = 0; this.gmtOffsetSeconds = rawOffsetSeconds; return rawTimeSeconds; } final int initialTransitionIndex = findTransitionIndex(zoneInfo, rawTimeSeconds); if (isDst < 0) { Integer result = doWallTimeSearch(zoneInfo, initialTransitionIndex, wallTimeSeconds, true ); return result == null ? -1 : result; } Integer result = doWallTimeSearch(zoneInfo, initialTransitionIndex, wallTimeSeconds, true ); if (result == null) { result = doWallTimeSearch(zoneInfo, initialTransitionIndex, wallTimeSeconds, false ); } if (result == null) { result = -1; } return result; } catch (CheckedArithmeticException e) { return -1; } }
Source:
<code>public <E extends RealmModel> Observable<E> from(final Realm realm, final E object) { final RealmConfiguration realmConfig = realm.getConfiguration(); return Observable.create(new Observable.OnSubscribe<E>() { @Override public void call(final Subscriber<? super E> subscriber) { final Realm observableRealm = Realm.getInstance(realmConfig); objectRefs.get().acquireReference(object); final RealmChangeListener<E> listener = new RealmChangeListener<E>() { @Override <START> public void onChange(E result) { <END> if (!subscriber.isUnsubscribed()) { subscriber.onNext(object); } } }; RealmObject.addChangeListener(object, listener); subscriber.add(Subscriptions.create(new Action0() { @Override public void call() { RealmObject.removeChangeListener(object, listener); observableRealm.close(); objectRefs.get().releaseReference(object); } })); subscriber.onNext(object); } }); }</code><technical_language>object result</technical_language>

Target:
public <E extends RealmModel> Observable<E> from(final Realm realm, final E object) { final RealmConfiguration realmConfig = realm.getConfiguration(); return Observable.create(new Observable.OnSubscribe<E>() { @Override public void call(final Subscriber<? super E> subscriber) { final Realm observableRealm = Realm.getInstance(realmConfig); objectRefs.get().acquireReference(object); final RealmChangeListener<E> listener = new RealmChangeListener<E>() { @Override public void onChange(E object) { if (!subscriber.isUnsubscribed()) { subscriber.onNext(object); } } }; RealmObject.addChangeListener(object, listener); subscriber.add(Subscriptions.create(new Action0() { @Override public void call() { RealmObject.removeChangeListener(object, listener); observableRealm.close(); objectRefs.get().releaseReference(object); } })); subscriber.onNext(object); } }); }
Source:
<code>public boolean containsQuorum(Set<Long> set){ HashMap<Long, Long> expansion = new HashMap<Long, Long>(); if(set.size() == 0) return false; else LOG.debug("Set size: " + set.size()); for(long sid : set){ Long gid = serverGroup.get(sid); if (gid == null) continue; if(!expansion.containsKey(gid)) expansion.put(gid, serverWeight.get(sid)); else { long totalWeight = serverWeight.get(sid) + expansion.get(gid); expansion.put(gid, totalWeight); } } int majGroupCounter = 0; for (Entry<Long, Long> entry : expansion.entrySet()) { Long gid = entry.getKey(); <START> LOG.debug("Group info: " + entry.getValue() + ", " + gid + ", " + groupWeight.get(gid)); <END> if(entry.getValue() > (groupWeight.get(gid) / 2) ) majGroupCounter++; } LOG.debug("Majority group counter: " + majGroupCounter + ", " + numGroups); if((majGroupCounter > (numGroups / 2))){ LOG.debug("Positive set size: " + set.size()); return true; } else { LOG.debug("Negative set size: " + set.size()); return false; } }</code><technical_language>modern LOG printing here: LOG.debug("Group info: {}, {}, {}", entry.getValue(), gid, groupWeight.get(gid));</technical_language>

Target:
public boolean containsQuorum(Set<Long> set){ HashMap<Long, Long> expansion = new HashMap<Long, Long>(); if(set.size() == 0) return false; else LOG.debug("Set size: " + set.size()); for(long sid : set){ Long gid = serverGroup.get(sid); if (gid == null) continue; if(!expansion.containsKey(gid)) expansion.put(gid, serverWeight.get(sid)); else { long totalWeight = serverWeight.get(sid) + expansion.get(gid); expansion.put(gid, totalWeight); } } int majGroupCounter = 0; for (Entry<Long, Long> entry : expansion.entrySet()) { Long gid = entry.getKey(); LOG.debug("Group info: {}, {}, {}", entry.getValue(), gid, groupWeight.get(gid)); if (entry.getValue() > (groupWeight.get(gid) / 2)) majGroupCounter++; } LOG.debug("Majority group counter: {}, {}", majGroupCounter, numGroups); if ((majGroupCounter > (numGroups / 2))){ LOG.debug("Positive set size: {}", set.size()); return true; } else { LOG.debug("Negative set size: {}", set.size()); return false; } }
Source:
<code>public int kPercentileLatency(double percentile) { if (m_latencyHistogram.getTotalCount() == 0) return 0; <START> percentile = Math.max(0.0, percentile); <END> return (int) (Math.round(m_latencyHistogram.getValueAtPercentile(percentile * 100.0)) / 1000.0); }</code><technical_language>double literal 0.0D</technical_language>

Target:
public int kPercentileLatency(double percentile) { if (m_latencyHistogram.getTotalCount() == 0) return 0; percentile = Math.max(0.0D, percentile); return (int) (Math.round(m_latencyHistogram.getValueAtPercentile(percentile * 100.0D)) / 1000.0); }