auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testForwardTaskWithMsgEvents() { Task task = new TaskFluent().setName("This is my task name") .addPotentialGroup("Knights Templer") .setAdminUser("Administrator") .getTask(); taskService.addTask(task, new HashMap<String, Object>()); long taskId = task.getId(); assertAuditTaskInfoGroup("Knights Templer", "Ready", taskId); <START> taskService.forward(taskId, "Administrator", "Jon Snow"); <END> List<TaskEvent> taskEvents = taskAuditService.getAllTaskEvents(taskId, new QueryFilter()); Assertions.assertThat(taskEvents).hasSize(2); Assertions.assertThat(taskEvents.get(0).getType()).isEqualTo(TaskEventType.ADDED); Assertions.assertThat(taskEvents.get(0).getUserId()).isNull(); Assertions.assertThat(taskEvents.get(1).getType()).isEqualTo(TaskEventType.FORWARDED); Assertions.assertThat(taskEvents.get(1).getUserId()).isEqualTo("Administrator"); assertNotNull(taskEvents.get(1).getMessage()); Assertions.assertThat(taskEvents.get(1).getMessage()).contains("Jon Snow"); }</code><technical_language>I do user name "Jon Snow" defined anywhere. I is reason test fails</technical_language>

Target:
public void testForwardTaskWithMsgEvents() { Task task = new TaskFluent().setName("This is my task name") .addPotentialGroup("Knights Templer") .setAdminUser("Administrator") .addPotentialUser("Administrator") .getTask(); taskService.addTask(task, new HashMap<String, Object>()); long taskId = task.getId(); assertAuditTaskInfoGroup("Knights Templer", "Ready", taskId); taskService.claim(taskId, "Administrator"); assertAuditTaskInfo("Administrator", "Reserved", taskId); taskService.forward(taskId, "Administrator", "Darth Vader"); List<TaskEvent> taskEvents = taskAuditService.getAllTaskEvents(taskId, new QueryFilter()); Assertions.assertThat(taskEvents).hasSize(3); Assertions.assertThat(taskEvents.get(0).getType()).isEqualTo(TaskEventType.ADDED); Assertions.assertThat(taskEvents.get(0).getUserId()).isNull(); Assertions.assertThat(taskEvents.get(1).getType()).isEqualTo(TaskEventType.CLAIMED); Assertions.assertThat(taskEvents.get(1).getUserId()).isEqualTo("Administrator"); Assertions.assertThat(taskEvents.get(2).getType()).isEqualTo(TaskEventType.FORWARDED); Assertions.assertThat(taskEvents.get(2).getUserId()).isEqualTo("Administrator"); Assertions.assertThat(taskEvents.get(2).getMessage()).isNotNull(); Assertions.assertThat(taskEvents.get(2).getMessage()).contains("Darth Vader"); }
Source:
<code>public int getMaxExposureCompensation() { <START> return 10; <END> }</code><technical_language>do numbers from</technical_language>

Target:
public int getMaxExposureCompensation() { return 6; }
Source:
<code><START> private void setConnector(AbstractRepositoryConnector connector) { <END> this.connector = connector; }</code><technical_language>I prefer this public impossible for clients correctly initialize class. Mark @noreference hide API</technical_language>

Target:
public void setConnector(AbstractRepositoryConnector connector) { this.connector = connector; }
Source:
<code>public void executeLeaderTasksAfterBecomingLeader() { leadershipObserver.executeWhenGainedLeadership(leaderTask); gainLeadership(); <START> verify(leaderTask, times(1)).run(); <END> }</code><technical_language>I this is default behaviour (i.e. this is equivalent verify(leaderTask).run())</technical_language>

Target:
public void executeLeaderTasksAfterBecomingLeader() { registerFollowerAndLeaderTasks(); gainLeadership(); waitForTasksToFinish(); verify(leaderTask).run(); }
Source:
<code>public boolean hasAdminOrViewPermissions(final CaseInsensitiveString userName, List<Role> memberRoles) { <START> return isUserAnAdmin(userName, memberRoles) || viewConfig.isAdmin(new AdminUser(userName), memberRoles); <END> }</code><technical_language>Hmm ViewConfig extends AdminsConfig. it? viewConfig.isAdmin reads weird</technical_language>

Target:
public boolean hasAdminOrViewPermissions(final CaseInsensitiveString userName, List<Role> memberRoles) { return isUserAnAdmin(userName, memberRoles) || isViewUser(userName, memberRoles); }
Source:
<code>public boolean producesLint() { if (getProject().hasProperty("CONTAINS_LINT_REGISTRY")) { return true; } Jar jarTask = (Jar) getProject().getTasks().findByName(JavaPlugin.JAR_TASK_NAME); if (jarTask != null && (jarTask.getManifest().getAttributes().containsKey("Lint-Registry") || jarTask.getManifest().getAttributes().containsKey("Lint-Registry-v2"))) { return true; } if (getMainJavaResourceDirs().stream() .anyMatch(resourceDir -> new File(resourceDir, "META-INF" + File.separator + "services" + File.separator + "com.android.tools.lint.client.api.IssueRegistry") <START> .exists())) { <END> return true; } else { return false; } }</code><technical_language>nit: Path.resolve() api instead of File.separator</technical_language>

Target:
public boolean producesLint() { if (getProject().hasProperty("CONTAINS_LINT_REGISTRY")) { return true; } Jar jarTask = (Jar) getProject().getTasks().findByName(JavaPlugin.JAR_TASK_NAME); if (jarTask != null && (jarTask.getManifest().getAttributes().containsKey("Lint-Registry") || jarTask.getManifest().getAttributes().containsKey("Lint-Registry-v2"))) { return true; } return getMainJavaResourceDirs().stream() .anyMatch(resourceDir -> resourceDir.toPath() .resolve("META-INF") .resolve("services") .resolve("com.android.tools.lint.client.api.IssueRegistry") .toFile() .exists()); }
Source:
<code>public boolean canContinue(CruiseConfig cruiseConfig) { <START> if (goConfigService.isAdministrator(username.getUsername().toString())) { <END> return true; } result.unauthorized("Unauthorized to operate on agent", "Unauthorized to operate on agent", HealthStateType.general(HealthStateScope.GLOBAL)); return false; }</code><technical_language>Create overloaded method isAdministrator(username.getUsername) refactor existing method call for string based parameters (other methods in GoConfigService follow this pattern method(CaseInsensitiveString))</technical_language>

Target:
public boolean canContinue(CruiseConfig cruiseConfig) { if (goConfigService.isAdministrator(username.getUsername())) { return true; } result.unauthorized(LocalizedMessage.string("UNAUTHORIZED_TO_OPERATE_AGENTS"), HealthStateType.unauthorised()); return false; }
Source:
<code>Pair<Vector[], Vector> parse() { <START> final List<double[]> dataX = new LinkedList<>(); <END> final List<Double> dataY = new LinkedList<>(); for (final Pair<LongWritable, Text> keyValue : dataSet) { final String line = keyValue.getSecond().toString().trim(); if (line.startsWith("#") || line.length() == 0) { continue; } final String[] split = line.split("\\s+"); final double[] data = new double[numFeatures]; for (int index = 0; index < numFeatures; index++) { data[index] = Double.parseDouble(split[index]); } dataX.add(data); dataY.add(Double.parseDouble(split[numFeatures])); } final double[][] arrayX = new double[dataX.size()][]; final double[][] transposedArrayX = transpose(dataX.toArray(arrayX)); final Vector[] vecX = new Vector[transposedArrayX.length]; for (int arrayIndex = 0; arrayIndex < transposedArrayX.length; arrayIndex++) { vecX[arrayIndex] = vectorFactory.newDenseVector(transposedArrayX[arrayIndex]); } final double[] arrayY = new double[dataY.size()]; int arrayIndex = 0; for (final double y : dataY) { arrayY[arrayIndex++] = y; } final Vector vecY = vectorFactory.newDenseVector(arrayY); return new Pair<>(vecX, vecY); }</code><technical_language>I wondering LinkedList is instead of ArrayList. Is more efficient ArrayList LinkedList</technical_language>

Target:
Pair<Vector[], Vector> parse() { final List<Double>[] dataX = (List<Double>[]) Array.newInstance(LinkedList.class, numFeatures); for (int index = 0; index < numFeatures; index++) { dataX[index] = new LinkedList<>(); } final List<Double> dataY = new LinkedList<>(); for (final Pair<LongWritable, Text> keyValue : dataSet) { final String line = keyValue.getSecond().toString().trim(); if (line.startsWith("#") || line.length() == 0) { continue; } final String[] split = line.split("\\s+"); for (int index = 0; index < numFeatures; index++) { dataX[index].add(Double.parseDouble(split[index])); } dataY.add(Double.parseDouble(split[numFeatures])); } final Vector[] vecX = new Vector[numFeatures]; for (int index = 0; index < numFeatures; index++) { vecX[index] = vectorFactory.createDense(Doubles.toArray(dataX[index])); } final Vector vecY = vectorFactory.createDense(Doubles.toArray(dataY)); return new Pair<>(vecX, vecY); }
Source:
<code>public void testCanRetrieveUserWorkspaceWithTrashedDomain() throws InterruptedException { try (CloseableCoreSession userSession = coreFeature.openCoreSession("toto")) { DocumentModel uw = uwm.getCurrentUserPersonalWorkspace(userSession); assertNotNull(uw); } List<DocumentModel> docs = session.getChildren(session.getRootDocument().getRef()) .stream() .collect(Collectors.toList()); TrashService trashService = Framework.getService(TrashService.class); trashService.trashDocuments(docs); <START> bulkService.await(Duration.ofSeconds(30)); <END> session.save(); try (CloseableCoreSession userSession = coreFeature.openCoreSession("toto")) { DocumentModel uw = uwm.getCurrentUserPersonalWorkspace(userSession); assertNull(uw); } trashService.untrashDocuments(docs); bulkService.await(Duration.ofSeconds(30)); session.save(); try (CloseableCoreSession userSession = coreFeature.openCoreSession("toto")) { DocumentModel uw = uwm.getCurrentUserPersonalWorkspace(userSession); assertNotNull(uw); } }</code><technical_language>ask CoreFeature#waitForAsyncCompletion instead avoid BulkService here</technical_language>

Target:
public void testCanRetrieveUserWorkspaceWithTrashedDomain() { try (CloseableCoreSession userSession = coreFeature.openCoreSession("toto")) { DocumentModel uw = uwm.getCurrentUserPersonalWorkspace(userSession); assertNotNull(uw); } List<DocumentModel> docs = session.getChildren(session.getRootDocument().getRef()) .stream() .collect(Collectors.toList()); TrashService trashService = Framework.getService(TrashService.class); trashService.trashDocuments(docs); coreFeature.waitForAsyncCompletion(); session.save(); try (CloseableCoreSession userSession = coreFeature.openCoreSession("toto")) { DocumentModel uw = uwm.getCurrentUserPersonalWorkspace(userSession); assertNull(uw); } trashService.untrashDocuments(docs); coreFeature.waitForAsyncCompletion(); session.save(); try (CloseableCoreSession userSession = coreFeature.openCoreSession("toto")) { DocumentModel uw = uwm.getCurrentUserPersonalWorkspace(userSession); assertNotNull(uw); } }
Source:
<code>public void resource_loading() { Context context = (Context) RuntimeEnvironment.application; assertEquals(context.getResources().getString(R.string.app_name), "Common"); assertEquals(context.getResources().getColor( <START> com.uber.okbuck.example.parcelable.R.color.fooColor), 0xcccccc); <END> }</code><technical_language>This is right example. This specific problem Right R class here. modify this change repro case i.e another module refer resource in main code this module invokes piece of code in test</technical_language>

Target:
public void resource_loading() { Context context = RuntimeEnvironment.application; int actualColor = Color.parseColor("#cccccc"); assertEquals(context.getResources().getString(R.string.app_name), "Common"); assertEquals(context.getResources().getColor(R.color.fooColor), actualColor); assertEquals(Person.getColor(context), actualColor); }
Source:
<code>private DockstoreTool.RegistryEnum getRegistryEnum(String registry) { for (DockstoreTool.RegistryEnum reg : DockstoreTool.RegistryEnum.values()) { if (registry.equals(reg.name())) { return reg; } } <START> return null; <END> }</code><technical_language>change this Optional return exception. I clear if unknown registry is entered</technical_language>

Target:
private Optional<DockstoreTool.RegistryEnum> getRegistryEnum(String registry) { for (DockstoreTool.RegistryEnum reg : DockstoreTool.RegistryEnum.values()) { if (registry.equals(reg.name())) { return Optional.of(reg); } } return Optional.empty(); }
Source:
<code>public void translateByteRangeReturnsCorrectRange() throws Exception { ByteRangeConversion byteRange1 = AesCtrCipherDetails.INSTANCE_128_BIT.translateByteRange(5, 10); Assert.assertEquals(byteRange1.getCiphertextStartPositionInclusive(), 0); Assert.assertEquals(byteRange1.getCiphertextEndPositionInclusive(), 15); Assert.assertEquals(byteRange1.getPlaintextBytesToSkipInitially(), 5); Assert.assertEquals(byteRange1.getLengthOfPlaintextIncludingSkipBytes(), 11); ByteRangeConversion byteRange2 = AesCtrCipherDetails.INSTANCE_128_BIT.translateByteRange(5, 22); Assert.assertEquals(byteRange2.getCiphertextStartPositionInclusive(), 0); Assert.assertEquals(byteRange2.getCiphertextEndPositionInclusive(), 31); Assert.assertEquals(byteRange2.getPlaintextBytesToSkipInitially(), 5); Assert.assertEquals(byteRange2.getLengthOfPlaintextIncludingSkipBytes(), 23); ByteRangeConversion byteRange3 = AesCtrCipherDetails.INSTANCE_128_BIT.translateByteRange(32, 35); Assert.assertEquals(byteRange3.getCiphertextStartPositionInclusive(), 32); Assert.assertEquals(byteRange3.getCiphertextEndPositionInclusive(), 47); Assert.assertEquals(byteRange3.getPlaintextBytesToSkipInitially(), 0); <START> <END> }</code><technical_language>delete this line</technical_language>

Target:
public void translateByteRangeReturnsCorrectRange() throws Exception { ByteRangeConversion byteRange1 = AesCtrCipherDetails.INSTANCE_128_BIT.translateByteRange(5, 10); Assert.assertEquals(byteRange1.getCiphertextStartPositionInclusive(), 0); Assert.assertEquals(byteRange1.getCiphertextEndPositionInclusive(), 15); Assert.assertEquals(byteRange1.getPlaintextBytesToSkipInitially(), 5); Assert.assertEquals(byteRange1.getLengthOfPlaintextIncludingSkipBytes(), 11); ByteRangeConversion byteRange2 = AesCtrCipherDetails.INSTANCE_128_BIT.translateByteRange(5, 22); Assert.assertEquals(byteRange2.getCiphertextStartPositionInclusive(), 0); Assert.assertEquals(byteRange2.getCiphertextEndPositionInclusive(), 31); Assert.assertEquals(byteRange2.getPlaintextBytesToSkipInitially(), 5); Assert.assertEquals(byteRange2.getLengthOfPlaintextIncludingSkipBytes(), 23); ByteRangeConversion byteRange3 = AesCtrCipherDetails.INSTANCE_128_BIT.translateByteRange(32, 35); Assert.assertEquals(byteRange3.getCiphertextStartPositionInclusive(), 32); Assert.assertEquals(byteRange3.getCiphertextEndPositionInclusive(), 47); Assert.assertEquals(byteRange3.getPlaintextBytesToSkipInitially(), 0); Assert.assertEquals(byteRange3.getLengthOfPlaintextIncludingSkipBytes(), 4); }
Source:
<code>private void populateNextRate() { if (source.hasNext()) { moveToNextDatapoint(); double difference = getValueDifference(); if (options.isCounter() && difference < 0) { while(source.hasNext()) { moveToNextDatapoint(); difference = getValueDifference(); <START> if (difference > 0) { <END> break; } } if (!source.hasNext()) { markEndOfSeries(); return; } } final double time_delta_secs = getTimeDeltaSecs(); next_rate.reset(next_data.timestamp(), (difference / time_delta_secs)); } else { markEndOfSeries(); } }</code><technical_language>I this >= 0, currently this skips counter increases, not, for some time</technical_language>

Target:
private void populateNextRate() { if (source.hasNext()) { moveToNextDatapoint(); double difference = getValueDifference(); if (options.isCounter() && difference < 0) { while(source.hasNext()) { moveToNextDatapoint(); difference = getValueDifference(); if (difference >= 0) { break; } } if (!source.hasNext()) { markEndOfSeries(); return; } } final double time_delta_secs = getTimeDeltaSecs(); next_rate.reset(next_data.timestamp(), (difference / time_delta_secs)); } else { markEndOfSeries(); } }
Source:
<code>public void withForceFailsIn31Cluster() { validator = spy(new GlusterVolumeValidator()); ValidationResult result = validator.isForceCreateVolumeAllowed(Version.v3_1, true); assertEquals (new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_ADD_BRICK_FORCE_NOT_SUPPORTED), <START> result); <END> }</code><technical_language>here: assertThat(result, failsWith(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_ADD_BRICK_FORCE_NOT_SUPPORTED));</technical_language>

Target:
public void withForceFailsIn31Cluster() { validator = spy(new GlusterVolumeValidator()); ValidationResult result = validator.isForceCreateVolumeAllowed(Version.v3_1, true); assertThat(result, failsWith(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_ADD_BRICK_FORCE_NOT_SUPPORTED)); }
Source:
<code>public ApplicationServiceImpl(List<BundleStateService> bundleStateServices) { this.bundleStateServices = bundleStateServices; ignoredApplicationNames = new HashSet<>(); BundleContext context = getContext(); if (context == null) { <START> LOGGER.warn("There is no context for this service"); <END> return; } ServiceReference<FeaturesService> featuresServiceRef = context.getServiceReference(FeaturesService.class); this.featuresService = context.getService(featuresServiceRef); try { if (context.getServiceReference("org.apache.karaf.features.BootFinished") == null) { context.addServiceListener(this, "(objectclass=org.apache.karaf.features.BootFinished)"); } } catch (InvalidSyntaxException e) { LOGGER.warn("Failed to create service listener filter", e); } }</code><technical_language>Is warn sufficient here</technical_language>

Target:
public ApplicationServiceImpl(List<BundleStateService> bundleStateServices) { this.bundleStateServices = bundleStateServices; ignoredApplicationNames = new HashSet<>(); BundleContext context = getContext(); ServiceReference<FeaturesService> featuresServiceRef = context.getServiceReference(FeaturesService.class); this.featuresService = context.getService(featuresServiceRef); try { if (context.getServiceReference("org.apache.karaf.features.BootFinished") == null) { context.addServiceListener(this, "(objectclass=org.apache.karaf.features.BootFinished)"); } } catch (InvalidSyntaxException e) { LOGGER.warn("Failed to create service listener filter", e); } }
Source:
<code>public void createTableAsync(final HTableDescriptor desc, byte[][] splitKeys) throws IOException { LOG.warn("Creating the table synchronously"); <START> CreateTableRequest createTableRequest = TableAdapter.adapt(desc, splitKeys).toProto(instanceName); <END> createTableAsync(createTableRequest, desc.getTableName()); }</code><technical_language>request variable name, please</technical_language>

Target:
public void createTableAsync(final HTableDescriptor desc, byte[][] splitKeys) throws IOException { LOG.warn("Creating the table synchronously"); CreateTableRequest request = TableAdapter.adapt(desc, splitKeys) .toProto(bigtableInstanceName.toAdminInstanceName()); createTableAsync(request, desc.getTableName()); }
Source:
<code>public void is_0xff() { <START> ExpressionTree tree = getReturnExpression("int foo() { return 0xFF; }"); <END> assertThat(LiteralUtils.is0xff(tree)).isTrue(); tree = getReturnExpression("int foo() { return 0x01; }"); assertThat(LiteralUtils.is0xff(tree)).isFalse(); tree = getReturnExpression("char foo() { return '0'; }"); assertThat(LiteralUtils.is0xff(tree)).isFalse(); }</code><technical_language>add case for "0xff;"</technical_language>

Target:
public void is_0xff() { ExpressionTree tree = getReturnExpression("int foo() { return 0xFF; }"); assertThat(LiteralUtils.is0xff(tree)).isTrue(); tree = getReturnExpression("int foo() { return 0x01; }"); assertThat(LiteralUtils.is0xff(tree)).isFalse(); tree = getReturnExpression("int foo() { return 0Xff; }"); assertThat(LiteralUtils.is0xff(tree)).isTrue(); tree = getReturnExpression("char foo() { return '0'; }"); assertThat(LiteralUtils.is0xff(tree)).isFalse(); }
Source:
<code>protected void initFileSystem() { <START> URI uri = spacesAPI.resolveFileSystemURI(SpacesAPI.Scheme.DEFAULT, <END> SpacesAPI.DASHBUILDER_SPACE, "datasets"); HashMap<String, Object> env = new HashMap<String, Object>() {{ put("init", Boolean.TRUE); put("internal", Boolean.TRUE); }}; fileSystem = ioService.getOrNewFileSystem(uri, env); root = fileSystem.getRootDirectories().iterator().next(); }</code><technical_language>a producer for filesystem? (datasetsFS, navigationFS perspectiveFS) This filesystems configuration initialization centralized in a single class inject @Named("datasetsFS") Filesystem fileSystem Making a producer for FS is important repeat this code making migration feature</technical_language>

Target:
protected void initFileSystem() { root = fileSystem.getRootDirectories().iterator().next(); }
Source:
<code>public String getUuid() { <START> return null; <END> }</code><technical_language>put uuid of identifier source a log entry</technical_language>

Target:
public String getUuid() { return "100892"; }
Source:
<code>public void sendMessagesToPushNetwork(@Observes @Dequeue MessageHolderWithTokens msg) { final Variant variant = msg.getVariant(); final UnifiedPushMessage unifiedPushMessage = msg.getUnifiedPushMessage(); final Collection<String> deviceTokens = msg.getDeviceTokens(); logger.info("Received UnifiedPushMessage from JMS queue, will now trigger the Push Notification delivery for the variant {}", variant.getType().getTypeName(), variant.getVariantID()); <START> <END> senders.select(new SenderTypeLiteral(variant.getType())).get() .sendPushMessage(variant, deviceTokens, unifiedPushMessage, msg.getPushMessageInformation().getId(), new SenderServiceCallback( variant, deviceTokens.size(), msg.getPushMessageInformation() ) ); }</code><technical_language>update this statement? In notification dispatcher ticket had: UnifiedPushMessage successfully received. Push Notification delivery for variant ({}) triggered</technical_language>

Target:
public void sendMessagesToPushNetwork(@Observes @Dequeue MessageHolderWithTokens msg) { final Variant variant = msg.getVariant(); final UnifiedPushMessage unifiedPushMessage = msg.getUnifiedPushMessage(); final Collection<String> deviceTokens = msg.getDeviceTokens(); logger.info("UnifiedPushMessage was successfully received. Push Notification delivery for the variant ({}) will now be triggered.", variant.getType().getTypeName(), variant.getVariantID()); senders.select(new SenderTypeLiteral(variant.getType())).get() .sendPushMessage(variant, deviceTokens, unifiedPushMessage, msg.getPushMessageInformation().getId(), new SenderServiceCallback( variant, deviceTokens.size(), msg.getPushMessageInformation() ) ); }
Source:
<code>public synchronized void configure(final DolphinLoggerConfiguration configuration) { Assert.requireNonNull(configuration, "configuration"); bridges.clear(); Iterator<DolphinLoggerBridgeFactory> iterator = ServiceLoader.load(DolphinLoggerBridgeFactory.class).iterator(); while (iterator.hasNext()) { DolphinLoggerBridge bridge = iterator.next().create(configuration); if(bridge != null) { bridges.add(bridge); } } markers.clear(); <START> for(DolphinLogger logger : loggerMap.values()) { <END> logger.updateBridges(Collections.unmodifiableList(bridges)); final Level level = configuration.getLevelFor(logger.getName()); logger.setLevel(level); } this.configuration = configuration; configured.set(true); }</code><technical_language>Add final keyword</technical_language>

Target:
public synchronized void configure(final DolphinLoggerConfiguration configuration) { Assert.requireNonNull(configuration, "configuration"); bridges.clear(); final Iterator<DolphinLoggerBridgeFactory> iterator = ServiceLoader.load(DolphinLoggerBridgeFactory.class).iterator(); while (iterator.hasNext()) { final DolphinLoggerBridge bridge = iterator.next().create(configuration); if(bridge != null) { bridges.add(bridge); } } markers.clear(); for(final DolphinLogger logger : loggerMap.values()) { logger.updateBridges(Collections.unmodifiableList(bridges)); final Level level = configuration.getLevelFor(logger.getName()); logger.setLevel(level); } this.configuration = configuration; configured.set(true); }
Source:
<code>public Token getUserIdentityFromJWT() { Token token = new Token(); Map<String, Object> jsonData = getJsonData(); if (jsonData == null) { return null; } <START> AuthToken authToken= authTokenDao.getTokenByKey(getJWT()); <END> String tokenId = (String)ApiContext.getContext().getIdFormatter().formatId(objectManager.getType(Account.class), authToken.getId()); token.setId(tokenId); Object idObject = jsonData.get(USER_IDENTITY); if (idObject != null) { Map<String, Object> idMap = CollectionUtils.toMap(idObject); Identity userIdentity = jsonToIdentity(idMap); String userType = ObjectUtils.toString(jsonData.get(USER_TYPE), null); token.setUserIdentity(userIdentity); token.setUserType(userType); } return token; }</code><technical_language>if getJWT() returns null? Check authTokenDao.getTokenByKey(null) behaves. If throws NPE, a null check added calling</technical_language>

Target:
public Token getUserIdentityFromJWT() { Token token = new Token(); Map<String, Object> jsonData = getJsonData(); if (jsonData == null) { return null; } Object idObject = jsonData.get(USER_IDENTITY); if (idObject != null) { Map<String, Object> idMap = CollectionUtils.toMap(idObject); Identity userIdentity = jsonToIdentity(idMap); String userType = ObjectUtils.toString(jsonData.get(USER_TYPE), null); token.setUserIdentity(userIdentity); token.setUserType(userType); } return token; }
Source:
<code><START> public WorkDefinitionMatch getWorkDefinition(String id) { <END> if (!workDefIdToWorkDefintion.containsKey(id)) { WorkDefinitionMatch match = new WorkDefinitionMatch(); if (!match.isMatched()) { try { XResultData resultData = new XResultData(false); if (workDefinitionService == null) { throw new IllegalStateException("ATS Work Definition Service is not found."); } IAtsWorkDefinition workDef = workDefinitionService.getWorkDef(id, resultData); if (workDef != null) { match.setWorkDefinition(workDef); if (!resultData.isEmpty()) { match.addTrace((String.format("from DSL provider loaded id [%s] [%s]", id, resultData.toString()))); } else { match.addTrace((String.format("from DSL provider loaded id [%s]", id))); } } if (match.isMatched()) { workDefIdToWorkDefintion.put(id, match); } else { System.out.println(String.format("Unable to load Work Definition [%s]", id)); } } catch (Exception ex) { return new WorkDefinitionMatch(null, ex.getLocalizedMessage()); } } } WorkDefinitionMatch match = workDefIdToWorkDefintion.get(id); if (match == null) { match = new WorkDefinitionMatch(); } return match; }</code><technical_language>Searching map - for checking contains key another time return statment. improved search map once</technical_language>

Target:
public WorkDefinitionMatch getWorkDefinition(String id) { WorkDefinitionMatch workDefinitionMatch = workDefIdToWorkDefintion.get(id); if (workDefinitionMatch != null) { return workDefinitionMatch; } WorkDefinitionMatch match = new WorkDefinitionMatch(); try { XResultData resultData = new XResultData(false); if (workDefinitionService == null) { throw new OseeStateException("ATS Work Definition Service is not found."); } IAtsWorkDefinition workDef = workDefinitionService.getWorkDef(id, resultData); if (workDef != null) { match.setWorkDefinition(workDef); if (!resultData.isEmpty()) { match.addTrace((String.format("from DSL provider loaded id [%s] [%s]", id, resultData.toString()))); } else { match.addTrace((String.format("from DSL provider loaded id [%s]", id))); } } if (match.isMatched()) { workDefIdToWorkDefintion.put(id, match); } else { System.out.println(String.format("Unable to load Work Definition [%s]", id)); } } catch (OseeCoreException ex) { return new WorkDefinitionMatch(null, ex.getLocalizedMessage()); } return match; }
Source:
<code>public void testQueryBuilder() { CanonicalPath cp1 = CanonicalPath.fromString("/t;tenant1"); CanonicalPath cp2 = CanonicalPath.fromString("/t;tenant2"); Query qMetricsRelationships = Query.path().with( With.path(cp1), SwitchElementType.incomingRelationships(), RelationWith.name("name")).get(); Query qTypesRelationships = Query.path().with( With.path(cp2), SwitchElementType.incomingRelationships(), RelationWith.name("name")).get(); Query oldQuery = new Query.Builder().with(new PathFragment(new NoopFilter())) .branch().with(qMetricsRelationships).done() .branch().with(qTypesRelationships).done().build(); Query.Builder builder = new Query.Builder().path().with(new NoopFilter()).builder() .branch().path().with(With.path(cp1), SwitchElementType.incomingRelationships(), RelationWith.name("name")).builder().done() .branch().path().with(With.path(cp2), SwitchElementType.incomingRelationships(), RelationWith.name("name")).builder().done(); <START> <END> Query newQuery = builder.build(); Assert.assertTrue(newQuery.equals(oldQuery)); }</code><technical_language>I .builder().branch() .builder().done() "bridges". .branch() .done() directly</technical_language>

Target:
public void testQueryBuilder() { CanonicalPath cp1 = CanonicalPath.fromString("/t;tenant1"); CanonicalPath cp2 = CanonicalPath.fromString("/t;tenant2"); Query qMetricsRelationships = Query.path().with( With.path(cp1), SwitchElementType.incomingRelationships(), RelationWith.name("name")).get(); Query qTypesRelationships = Query.path().with( With.path(cp2), SwitchElementType.incomingRelationships(), RelationWith.name("name")).get(); Query oldQuery = new Query.Builder().with(new PathFragment(new NoopFilter())) .branch().with(qMetricsRelationships).done() .branch().with(qTypesRelationships).done().build(); Query.Builder builder = new Query.Builder() .branch().path().with(With.path(cp1), SwitchElementType.incomingRelationships(), RelationWith.name("name")).done() .branch().path().with(With.path(cp2), SwitchElementType.incomingRelationships(), RelationWith.name("name")).done(); Query newQuery = builder.build(); Assert.assertTrue(newQuery.equals(oldQuery)); }
Source:
<code>public int[] transformToIntValuesSV(ProjectionBlock projectionBlock) { if (_intResult == null) { _intResult = new int[DocIdSetPlanNode.MAX_DOC_PER_CALL]; <START> Arrays.fill(_intResult, Double.valueOf(_literal).intValue()); <END> } return _intResult; }</code><technical_language>follow convention in ArrayCopyUtils behavior is consistent everywhere? (Use Integer.parseInt, Long.parseLong, Float.parseFloat, Double.parseDouble, BytesUtils.toBytes) If String is of target format, current behavior is throw exception. For this PR, I need change this class binary operator check data type fetch String Literal. Ideally check for Literal call getLiteral()</technical_language>

Target:
public int[] transformToIntValuesSV(ProjectionBlock projectionBlock) { if (_intResult == null) { _intResult = new int[DocIdSetPlanNode.MAX_DOC_PER_CALL]; Arrays.fill(_intResult, Integer.parseInt(_literal)); } return _intResult; }
Source:
<code>public Config unset(String name) throws GitException { ConfigKey key = parseName(name); repository.getConfig().unset(key.section, key.subsection, key.name); try { this.repository.getConfig().save(); } catch (IOException e) { <START> throw new GitException("Failed to save to config file"); <END> } return this; }</code><technical_language>exception is dropped, log</technical_language>

Target:
public Config unset(String name) throws GitException { ConfigKey key = parseName(name); repository.getConfig().unset(key.section, key.subsection, key.name); try { this.repository.getConfig().save(); } catch (IOException e) { throw new GitException(e.getMessage(), e); } return this; }
Source:
<code>private static <T> T logIfNull(@Nullable T value) { if (value == null) { log.warn("Detected a null value, null values are not allowed by Conjure", new IllegalArgumentException()); } <START> assert value != null : "Null values are not allowed by Conjure"; <END> return value; }</code><technical_language>This is a pretty cool solution :) I need excavate out (or bake a plugin) tests run -ea, I putting assert false in a test passed</technical_language>

Target:
private static <T> T logIfNull(@Nullable T value) { if (value == null) { onNull(); } return value; }
Source:
<code>public ModernSplitCardRenderer(CardView view, boolean isTransformed) { super(view, isTransformed); rightHalf.manaCostString = ManaSymbols.getStringManaCost(cardView.getRightSplitCosts().getSymbols()); leftHalf.manaCostString = ManaSymbols.getStringManaCost(cardView.getLeftSplitCosts().getSymbols()); rightHalf.color = getColorFromManaCostHack(cardView.getRightSplitCosts()); leftHalf.color = getColorFromManaCostHack(cardView.getLeftSplitCosts()); parseRules(view.getRightSplitRules(), rightHalf.keywords, rightHalf.rules); parseRules(view.getLeftSplitRules(), leftHalf.keywords, leftHalf.rules); rightHalf.name = cardView.getRightSplitName(); leftHalf.name = cardView.getLeftSplitName(); for (String rule: view.getRules()) { if (rule.contains("Fuse")) { isFuse = true; break; } <START> } <END> for (String rule: view.getRightSplitRules()) { if (rule.contains("Aftermath")) { isAftermath = true; break; } } if (!isAftermath()) { HalfCardProps tmp = leftHalf; leftHalf = rightHalf; rightHalf = tmp; } }</code><technical_language>if view.getRules() returns array a list, in case returns a list, I stream().anyMatch() more</technical_language>

Target:
public ModernSplitCardRenderer(CardView view, boolean isTransformed) { super(view, isTransformed); rightHalf.manaCostString = ManaSymbols.getStringManaCost(cardView.getRightSplitCosts().getSymbols()); leftHalf.manaCostString = ManaSymbols.getStringManaCost(cardView.getLeftSplitCosts().getSymbols()); rightHalf.color = getColorFromManaCostHack(cardView.getRightSplitCosts()); leftHalf.color = getColorFromManaCostHack(cardView.getLeftSplitCosts()); parseRules(view.getRightSplitRules(), rightHalf.keywords, rightHalf.rules); parseRules(view.getLeftSplitRules(), leftHalf.keywords, leftHalf.rules); rightHalf.name = cardView.getRightSplitName(); leftHalf.name = cardView.getLeftSplitName(); isFuse = view.getRules().stream().anyMatch(rule -> rule.contains("Fuse")); isAftermath = view.getRightSplitRules().stream().anyMatch(rule -> rule.contains("Aftermath")); if (!isAftermath()) { HalfCardProps tmp = leftHalf; leftHalf = rightHalf; rightHalf = tmp; } }
Source:
<code>public void testCreateSymlink() throws IOException { FS fs = FS.DETECTED; Assume.assumeTrue(fs.supportsSymlinks()); fs.createSymLink(new File(trash, "x"), "y"); <START> assertTrue(fs.supportsSymlinks()); <END> String target = fs.readSymLink(new File(trash, "x")); assertEquals("y", target); }</code><technical_language>This assertion is needed anymore</technical_language>

Target:
public void testCreateSymlink() throws IOException { FS fs = FS.DETECTED; Assume.assumeTrue(fs.supportsSymlinks()); fs.createSymLink(new File(trash, "x"), "y"); String target = fs.readSymLink(new File(trash, "x")); assertEquals("y", target); }
Source:
<code>public CreateAlgorithmCommand(final BasicFBType fbType) { <START> this.fbType = fbType; this.index = fbType.getAlgorithm().size() - 1; this.name = DEFAULT_ALGORITHM_NAME; <END> }</code><technical_language>a this call new constructor name = null nicer here? this(fbType, fType.getAlgorithm().size() - 1, null);</technical_language>

Target:
public CreateAlgorithmCommand(final BasicFBType fbType) { this(fbType, fbType.getAlgorithm().size() - 1, null); }
Source:
<code>public void testPvaluefromZscorePostAggregator() throws Exception { zscore = new ConstantPostAggregator("zscore", -1783.8762354220219); pvaluefromZscorePostAggregator = new PvaluefromZscorePostAggregator("pvalue", zscore); <START> System.out.print("zscore = " + zscore + "\n"); <END> double pvalue = ((Number) pvaluefromZscorePostAggregator.compute(ImmutableMap.of( "zscore", -1783.8762354220219 ))).doubleValue(); System.out.print("pvalue = " + pvalue + "\n"); Assert.assertTrue(pvalue >= 0 && pvalue < 0.00001); System.out.print(pvaluefromZscorePostAggregator.toString()); }</code><technical_language>Please remove debug code</technical_language>

Target:
public void testPvaluefromZscorePostAggregator() throws Exception { zscore = new ConstantPostAggregator("zscore", -1783.8762354220219); pvaluefromZscorePostAggregator = new PvaluefromZscorePostAggregator("pvalue", zscore); double pvalue = ((Number) pvaluefromZscorePostAggregator.compute(ImmutableMap.of( "zscore", -1783.8762354220219 ))).doubleValue(); Assert.assertTrue(pvalue >= 0 && pvalue < 0.00001); }
Source:
<code>public void test_git_ssh_executable_found_on_windows() { <START> if (!gitImplName.equals("git")) { return; } <END> cliGitAPIImplTest.setTimeoutVisibleInCurrentTest(false); if (!SystemUtils.IS_OS_WINDOWS) { return; } CliGitAPIImpl git = new CliGitAPIImpl("git", new File("."), cliGitAPIImplTest.listener, cliGitAPIImplTest.env); assertTrue("ssh.exe not found", git.getSSHExecutable().exists()); }</code><technical_language>JUnit offers a more elegant skip a test some condition is incorrect. assumeThat(gitImplName, is("git")); is in file is understood test reporting frameworks early return technique</technical_language>

Target:
public void test_git_ssh_executable_found_on_windows() { assumeThat(gitImplName, is("git")); cliGitAPIImplTest.setTimeoutVisibleInCurrentTest(false); if (!SystemUtils.IS_OS_WINDOWS) { return; } CliGitAPIImpl git = new CliGitAPIImpl("git", new File("."), cliGitAPIImplTest.listener, cliGitAPIImplTest.env); assertTrue("ssh.exe not found", git.getSSHExecutable().exists()); }
Source:
<code>public void shouldHandOutNonOverLappingTimestampRanges() { TimestampRange first = timestamp.incrementBy(10); TimestampRange second = timestamp.incrementBy(10); <START> assertThat(first.getUpperBound(), is(lessThan(second.getUpperBound()))); <END> }</code><technical_language>lessThan(second.getLowerBound())</technical_language>

Target:
public void shouldHandOutNonOverLappingTimestampRanges() { TimestampRange first = timestamp.incrementBy(10); TimestampRange second = timestamp.incrementBy(10); assertThat(first.getUpperBound(), is(lessThan(second.getLowerBound()))); }
Source:
<code>private void threadIsStarting() { <START> synchronized (active) { <END> int actualCount = active.incrementAndGet(); reporter.reportConsumerThreadsActual(actualCount); } }</code><technical_language>avoid synchronizing making interaction reporting framework: java reporter.incrementActiveThreads() /* */ reporter.decrementActiveThreads() active-threads a counter. reporter is shared threads, synchronization happen there. guarantees arbitrary caller yield this lock. I realize compelling active counter in-sync reported is not. for things, a big deal if not</technical_language>

Target:
private void threadIsStarting() { active.incrementAndGet(); reporter.reportConsumerThreadsIncrement(); }
Source:
<code>protected void verifyProfile(final UserProfile userProfile) { final Google2Profile profile = (Google2Profile) userProfile; logger.debug("userProfile : {}", profile); assertEquals("113675986756217860428", profile.getId()); assertEquals(Google2Profile.class.getSimpleName() + UserProfile.SEPARATOR + "113675986756217860428", profile.getTypedId()); assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), Google2Profile.class)); assertTrue(StringUtils.isNotBlank(profile.getAccessToken())); assertCommonProfile(userProfile, "testscribeup@gmail.com", "Jérôme", "ScribeUP", "Jérôme ScribeUP", null, Gender.MALE, Locale.ENGLISH, "<LINK_0>", "<LINK_1>", null); assertNull(profile.getBirthday()); assertEquals(10, profile.getAttributes().size()); <START> } <END></code><technical_language>I guess is more update do new attributes, this test fail depending (on Earth) launch it. Try if update properly, do myself</technical_language>

Target:
protected void verifyProfile(final UserProfile userProfile) { final Google2Profile profile = (Google2Profile) userProfile; logger.debug("userProfile : {}", profile); assertEquals("113675986756217860428", profile.getId()); assertEquals(Google2Profile.class.getSimpleName() + UserProfile.SEPARATOR + "113675986756217860428", profile.getTypedId()); assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), Google2Profile.class)); assertTrue(StringUtils.isNotBlank(profile.getAccessToken())); assertCommonProfile(userProfile, "testscribeup@gmail.com", "Jérôme", "ScribeUP", "Jérôme ScribeUP", null, Gender.MALE, Locale.ENGLISH, "<LINK_0>", "<LINK_1>", null); assertNull(profile.getBirthday()); assertTrue(profile.getEmails() != null && profile.getEmails().size() == 1); assertEquals(9, profile.getAttributes().size()); }
Source:
<code>public void insertData() { try { dataStoreOut = DataStoreFactory.getDataStore(Long.class, ResultPageView.class, new Configuration()); } catch (GoraException e) { e.printStackTrace(); } ResultPageView resultPageView = new ResultPageView(); resultPageView.setIp("123"); resultPageView.setTimestamp(123L); resultPageView.setUrl("I am the the one"); ResultPageView resultPageView1 = new ResultPageView(); resultPageView1.setIp("123"); resultPageView1.setTimestamp(123L); resultPageView1.setUrl("How are you"); try { dataStoreOut.put(1L,resultPageView); dataStoreOut.put(2L,resultPageView1); <START> dataStoreOut.flush(); <END> } catch (GoraException e) { e.printStackTrace(); } }</code><technical_language>Verify insert happened correctly retrieving</technical_language>

Target:
public static void insertData() throws Exception { utility = new HBaseTestingUtility(); utility.startMiniCluster(); dataStoreOut = DataStoreFactory.getDataStore(Long.class, ResultPageView.class, utility.getConfiguration()); ResultPageView resultPageView = new ResultPageView(); resultPageView.setIp("88.240.129.183"); resultPageView.setTimestamp(123L); resultPageView.setUrl("I am the the one"); ResultPageView resultPageView1 = new ResultPageView(); resultPageView1.setIp("87.240.129.170"); resultPageView1.setTimestamp(124L); resultPageView1.setUrl("How are you"); ResultPageView resultPageView2 = new ResultPageView(); resultPageView1.setIp("88.240.129.183"); resultPageView1.setTimestamp(124L); resultPageView1.setUrl("This is the jet engine"); dataStoreOut.put(1L,resultPageView); dataStoreOut.put(2L,resultPageView1); dataStoreOut.put(3L,resultPageView2); dataStoreOut.flush(); }
Source:
<code>public void spec312_cancelMustMakeThePublisherToEventuallyStopSignaling() throws Throwable { final int elementsCount = 20; activePublisherTest(elementsCount, new PublisherTestRun<T>() { @Override @SuppressWarnings("ThrowableResultOfMethodCallIgnored") public void run(Publisher<T> pub) throws Throwable { final ManualSubscriber<T> sub = env.newManualSubscriber(pub); int demand1 = 10; int demand2 = 5; sub.request(demand1); sub.request(demand2); final int totalDemand = demand1 + demand2; <START> sub.nextElement(); <END> sub.cancel(); int onNextsSignalled = 1; boolean stillBeingSignalled; do { sub.expectNone(); Throwable error = env.dropAsyncError(); if (error == null) { stillBeingSignalled = false; } else { onNextsSignalled += 1; stillBeingSignalled = true; } assertTrue(onNextsSignalled <= totalDemand, String.format("Publisher signalled [%d] elements, which is more than the signalled demand: %d", onNextsSignalled, totalDemand)); } while (stillBeingSignalled); } }); env.verifyNoAsyncErrors(); }</code><technical_language>reason for change order here</technical_language>

Target:
public void spec312_cancelMustMakeThePublisherToEventuallyStopSignaling() throws Throwable { final int publisherElements = 20; final int demand1 = 10; final int demand2 = 5; final int totalDemand = demand1 + demand2; activePublisherTest(publisherElements, new PublisherTestRun<T>() { @Override @SuppressWarnings("ThrowableResultOfMethodCallIgnored") public void run(Publisher<T> pub) throws Throwable { final ManualSubscriber<T> sub = env.newManualSubscriber(pub); sub.request(demand1); sub.request(demand2); sub.nextElement(); sub.cancel(); int onNextsSignalled = 1; boolean stillBeingSignalled; do { sub.expectNone(); Throwable error = env.dropAsyncError(); if (error == null) { stillBeingSignalled = false; } else { onNextsSignalled += 1; stillBeingSignalled = true; } assertTrue(onNextsSignalled <= totalDemand, String.format("Publisher signalled [%d] elements, which is more than the signalled demand: %d", onNextsSignalled, totalDemand)); } while (stillBeingSignalled); } }); env.verifyNoAsyncErrors(); }
Source:
<code>private String getTriggerGuard(Trigger trigger) { UMLRTTrigger rtTrigger = UMLRTTrigger.getInstance(trigger); UMLRTGuard guard = rtTrigger.getGuard(); if (guard != null) { try { <START> IDefaultLanguageService service; service = ServiceUtilsForEObject.getInstance().getService(IDefaultLanguageService.class, trigger); IDefaultLanguage language = service.getActiveDefaultLanguage(trigger); <END> if (guard.getBodies().containsKey(language.getName())) { return guard.getBodies().get(language.getName()); } } catch (ServiceException e) { Activator.log.error(e); } } return ""; }</code><technical_language>ModelUtils in other files in this patch</technical_language>

Target:
private String getTriggerGuard(Trigger trigger) { UMLRTTrigger rtTrigger = UMLRTTrigger.getInstance(trigger); UMLRTGuard guard = rtTrigger.getGuard(); if (guard != null) { IDefaultLanguage language = ModelUtils.getDefaultLanguage(trigger); if (language != null && guard.getBodies().containsKey(language.getName())) { return guard.getBodies().get(language.getName()); } } return ""; }
Source:
<code>protected void onCreate(Bundle savedInstance) { super.onCreate(savedInstance); mAuthHelper = new AuthHelper(getFlowParams()); mProgressDialogHolder = new ProgressDialogHolder(this); <START> getFlowHolder().getIntentStarter().observe(this, new Observer<Pair<Intent, Integer>>() { <END> @Override public void onChanged(@Nullable Pair<Intent, Integer> request) { if (request == null) { throw new IllegalStateException("Cannot start null request"); } startActivityForResult(request.first, request.second); } }); getFlowHolder().getPendingIntentStarter() .observe(this, new Observer<Pair<PendingIntent, Integer>>() { @Override public void onChanged(@Nullable Pair<PendingIntent, Integer> request) { if (request == null) { throw new IllegalStateException("Cannot start null request"); } try { startIntentSenderForResult( request.first.getIntentSender(), request.second, null, 0, 0, 0); } catch (IntentSender.SendIntentException e) { Log.e("PendingIntentStarter", "Unable to start pending intent", e); onActivityResult(request.second, Activity.RESULT_CANCELED, null); } } }); }</code><technical_language>data types ActivityResult create a custom object type IntentRequest a Pair here</technical_language>

Target:
protected void onCreate(Bundle savedInstance) { super.onCreate(savedInstance); mAuthHelper = new AuthHelper(getFlowParams()); mProgressDialogHolder = new ProgressDialogHolder(this); }