auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private static AttributeDefinition getAttributeDefinition(String name, ModelType modelType, ModelNode defaultValue) { <START> if (NO_DEFAULT.equals(defaultValue.asString())) { <END> return new SimpleAttributeDefinitionBuilder(name, modelType) .setRequired(false) .setAllowExpression(false) .build(); } else { return new SimpleAttributeDefinitionBuilder(name, modelType) .setRequired(false) .setAllowExpression(false) .setDefaultValue(defaultValue) .build(); } }</code><technical_language>Note @kabir discusses adding a child resource. If is done, do setAttributeGroup("context-params") is redundant. (You setAttributeGroup("some-subgroup") setAttributeGroup("some-other-subgroup") if other grouping is wanted though.)</technical_language>

Target:
private static AttributeDefinition getAttributeDefinition(String name, ModelType modelType, ModelNode defaultValue) { if (NO_DEFAULT.equals(defaultValue.asString())) { return new SimpleAttributeDefinitionBuilder(name, modelType) .setRequired(false) .setAllowExpression(true) .build(); } else { return new SimpleAttributeDefinitionBuilder(name, modelType) .setRequired(false) .setAllowExpression(true) .setDefaultValue(defaultValue) .build(); } }
Source:
<code>public void reset() { service = null; <START> messageBusProxy = new MessageBusProxy(); <END> requestDispatcherProxy = new RequestDispatcherProxy(); }</code><technical_language>I replacing bus dispatcher proxies is a good idea. references proxies held other classes. this proxy, want reset bus/dispatcher proxies close instances again</technical_language>

Target:
public void reset() { service = null; messageBusProxy.reset(); requestDispatcherProxy.reset(); }
Source:
<code>public Page<BundleRest> findAll(Context context, Pageable pageable) { <START> throw new RuntimeException("Method not allowed!"); <END> }</code><technical_language>RepositoryMethodNotImplementedException exception</technical_language>

Target:
public Page<BundleRest> findAll(Context context, Pageable pageable) { throw new RepositoryMethodNotImplementedException(BundleRest.NAME, "findAll"); }
Source:
<code>public String toString() { <START> return name + ":" + type + ":" + jsonPath + ":" + jsonType + ":" + isList; <END> }</code><technical_language>MoreObjects::toStringHelper()</technical_language>

Target:
public String toString() { return toStringHelper(this) .add("name", name) .add("type", type) .add("jsonPath", jsonPath) .add("jsonType", jsonType) .add("isList", isList) .add("ordinalPosition", ordinalPosition) .toString(); }
Source:
<code>public void match(BuiltinList builtinList, Term pattern) { if (!(pattern instanceof BuiltinList)) { this.fail(builtinList, pattern); } if (matchOnFunctionSymbol) { builtinList.toLabelRepresentation(termContext).accept( this, ((BuiltinList) pattern).toLabelRepresentation(termContext)); <START> evaluateSubstitution(fSubstitution, termContext); <END> return; } throw new UnsupportedOperationException( "list matching is only supported when one of the lists is a variable."); }</code><technical_language>mean? more specific "ad-hoc evaluation" in TODO item</technical_language>

Target:
public void match(BuiltinList builtinList, Term pattern) { if (!(pattern instanceof BuiltinList)) { this.fail(builtinList, pattern); } if (matchOnFunctionSymbol) { builtinList.toK(termContext).accept(this, ((BuiltinList) pattern).toK(termContext)); evaluateSubstitution(fSubstitution, termContext); return; } throw new UnsupportedOperationException( "list matching is only supported when one of the lists is a variable."); }
Source:
<code>public void logsMessage() throws IOException { final Collection<String> logs = new ArrayList<String>(1); new TkLogged( new TkText("test"), <START> new Target() { <END> @Override public void log(final String format, final Object... param) { logs.add( MessageFormatter.arrayFormat(format, param).getMessage() ); } }).act(); MatcherAssert.assertThat( logs, Matchers.everyItem(Matchers.containsString("act()")) ); }</code><technical_language>I recommend Mockito.verify for this test, shorter easier understand</technical_language>

Target:
public void logsMessage() throws IOException { final Target target = Mockito.mock(Target.class); new TkLogged(new TkText("test"), target).act(); Mockito.verify(target, Mockito.times(1)).log( Mockito.eq("[{}] #act() return in ms"), Mockito.isA(Take.class), Mockito.isA(Response.class), Mockito.anyLong() ); }
Source:
<code>public void verifyDataAccount(DataAccount dataAccount, Date date) throws DataAccessException, ServiceException { if (dataAccount != null && dataAccount.source != null) { DataAccountCollector collector = DataAccountCollectorFactory.getCollectorForSource(dataAccount.source.a3Code); if (collector != null) { try { collector.collect(dataAccount, date); } catch (ServiceException e) { <START> throw new ServiceException(e.getCode(), e.getMessage()); <END> } } } }</code><technical_language>Catching exception throw one</technical_language>

Target:
public void verifyDataAccount(DataAccount dataAccount, Date date) throws ServiceException { if (dataAccount != null && dataAccount.source != null) { DataAccountCollector collector = DataAccountCollectorFactory.getCollectorForSource(dataAccount.source.a3Code); if (collector != null) { try { collector.collect(dataAccount, date); } catch (ServiceException e) { throw e; } } } }
Source:
<code>public Variable getVariableInstance(){ if(v_inst == null){ v_inst = new Variable(getVariableIdentifierInstance(), getTypeExpression()); } return v_inst; <START> } <END></code><technical_language>do need lazily create variable instance? I convention get*Instance() methods create a new instance tests require instance multiple times hold a local copy</technical_language>

Target:
public Variable getVariableInstance(){ return new Variable(getVariableIdentifierInstance(), getTypeExpression()); }
Source:
<code>private boolean shouldMergePlugins(Map<String, String> attributes) { if (attributes.containsKey(MERGE_PLUGINS_ATTRIBUTE)) { <START> return "true".equals(attributes.get(MERGE_PLUGINS_ATTRIBUTE)); <END> } return "true".equals(defaultMergePlugins); }</code><technical_language>Boolean.parseBoolean</technical_language>

Target:
private boolean shouldMergePlugins(Map<String, String> attributes) { String devfileMergePlugins = attributes.get(MERGE_PLUGINS_ATTRIBUTE); if (devfileMergePlugins != null) { return Boolean.parseBoolean(devfileMergePlugins); } return defaultMergePlugins; }
Source:
<code>public void setParams(FormRecord record, String dataTitle, Long timestamp) throws SessionUnavailableException{ if(names.containsKey(record.getFormNamespace())) { Text name = names.get(record.getFormNamespace()); mPrimaryTextView.setText(name.evaluate()); mPrimaryTextView.setText(Localizer.processArguments(name.evaluate(), new String[] {""}).trim()); <START> mPrimaryTextView.setText(MediaUtil.stripArguments(name.evaluate())); <END> } else { formExists = false; mPrimaryTextView.setText(Localization.get("form.record.gone")); } if(dataTitle != null) { mLowerTextView.setText(dataTitle); } if(timestamp != 0) { mRightTextView.setText(DateUtils.formatSameDayTime(timestamp, start.getTime(), DateFormat.DEFAULT, DateFormat.DEFAULT)); } else { mRightTextView.setText("Never"); } if(record.getStatus() == FormRecord.STATUS_UNSENT) { mUpperRight.setText(Localization.get("form.record.unsent")); mUpperRight.setTextAppearance(getContext(), R.style.WarningTextStyle); mUpperRight.setCompoundDrawablesWithIntrinsicBounds(null, null, rightHandSync, null); } else { mUpperRight.setText(""); mUpperRight.setCompoundDrawables(null, null, null, null); } }</code><technical_language>is this calling setText 3 times a row</technical_language>

Target:
public void setParams(FormRecord record, String dataTitle, Long timestamp) throws SessionUnavailableException{ if(names.containsKey(record.getFormNamespace())) { Text name = names.get(record.getFormNamespace()); mPrimaryTextView.setText(name.evaluate()); } else { formExists = false; mPrimaryTextView.setText(Localization.get("form.record.gone")); } if(dataTitle != null) { mLowerTextView.setText(dataTitle); } if(timestamp != 0) { mRightTextView.setText(DateUtils.formatSameDayTime(timestamp, start.getTime(), DateFormat.DEFAULT, DateFormat.DEFAULT)); } else { mRightTextView.setText("Never"); } if(record.getStatus() == FormRecord.STATUS_UNSENT) { mUpperRight.setText(Localization.get("form.record.unsent")); mUpperRight.setTextAppearance(getContext(), R.style.WarningTextStyle); mUpperRight.setCompoundDrawablesWithIntrinsicBounds(null, null, rightHandSync, null); } else { mUpperRight.setText(""); mUpperRight.setCompoundDrawables(null, null, null, null); } }
Source:
<code>public void deleteServiceTypes(Services services) { <START> Log.e("bbj", services.getName()); <END> RestApi restApi = RestServiceBuilder.createService(RestApi.class); Call<Services> call = restApi.deleteServiceTypes(services.getUuid(), true); call.enqueue(new Callback<Services>() { @Override public void onResponse(Call<Services> call, Response<Services> response) { if (response.isSuccessful()) { Log.e("succ","succ"); mManageServiceView.getServiceTypes(); } } @Override public void onFailure(Call<Services> call, Throwable t) { Log.e("jvk", "vkvkjkj"); } }); }</code><technical_language>this error, Log.d (d is short for debug, e is short for error). do this times in this file. Typically a Log.e is in a catch block a network request fails (as do below)</technical_language>

Target:
public void deleteServiceTypes(Services services) { RestApi restApi = RestServiceBuilder.createService(RestApi.class); Call<Services> call = restApi.deleteServiceTypes(services.getUuid(), true); call.enqueue(new Callback<Services>() { @Override public void onResponse(Call<Services> call, Response<Services> response) { if (response.isSuccessful()) { mManageServiceView.getServiceTypes(); } } @Override public void onFailure(Call<Services> call, Throwable t) { } }); }
Source:
<code>public NativeLinkable.Linkage getPreferredLinkage(CxxPlatform cxxPlatform) { if (getBuildTarget().getFlavors().contains(SWIFT_LIBRARY_FLAVOR)) { <START> return Linkage.STATIC; <END> } else { return Linkage.ANY; } }</code><technical_language>this</technical_language>

Target:
public NativeLinkable.Linkage getPreferredLinkage(CxxPlatform cxxPlatform) { if (getBuildTarget().getFlavors().contains(SWIFT_COMPANION_FLAVOR)) { return Linkage.STATIC; } else { return Linkage.ANY; } }
Source:
<code>public LdapUser getUser(final String username, final String type, final String name) throws NoLdapUserMatchingQueryException { LdapContext context = null; try { context = _ldapContextFactory.createBindContext(); final String escapedUsername = LdapUtils.escapeLDAPSearchFilter(username); return _ldapUserManagerFactory.getInstance(_ldapConfiguration.getLdapProvider()).getUser(escapedUsername, type, name, context); } catch (NamingException | IOException e) { s_logger.debug("ldap Exception: ",e); <START> throw new NoLdapUserMatchingQueryException("No Ldap User found for username: "+username + "name: " + name + "of type" + type); <END> } finally { closeContext(context); } }</code><technical_language>nit-pick - format string spaces</technical_language>

Target:
public LdapUser getUser(final String username, final String type, final String name) throws NoLdapUserMatchingQueryException { LdapContext context = null; try { context = _ldapContextFactory.createBindContext(); final String escapedUsername = LdapUtils.escapeLDAPSearchFilter(username); return _ldapUserManagerFactory.getInstance(_ldapConfiguration.getLdapProvider()).getUser(escapedUsername, type, name, context); } catch (NamingException | IOException e) { s_logger.debug("ldap Exception: ",e); throw new NoLdapUserMatchingQueryException("No Ldap User found for username: "+username + "name: " + name + "of type: " + type); } finally { closeContext(context); } }
Source:
<code>public void close() { if (dispatcher != null) { dispatcher.unsubscribe(subject); <START> conn.closeDispatcher(dispatcher); <END> dispatcher = null; } super.close(); }</code><technical_language>I dispatcher.unsubscribe(subject) removed closeDispatcher calls stop unsubscribeAll set true: <LINK_0></technical_language>

Target:
public void close() { if (dispatcher != null) { conn.closeDispatcher(dispatcher); dispatcher = null; } super.close(); }
Source:
<code>public String toString() { return "JarInfo{" + <START> "mJarFile=" + jarFile + <END> ", mDependencies=" + dependencies + ", mResolvedCoordinates=" + resolvedCoordinates + '}'; }</code><technical_language>add compiled packaged flgs</technical_language>

Target:
public String toString() { return "JarInfo{" + "jarFile=" + jarFile + ", compiled=" + compiled + ", packaged=" + packaged + ", dependencies=" + dependencies + ", resolvedCoordinates=" + resolvedCoordinates + '}'; }
Source:
<code>public void addSubmitRecords(ChangeAttribute ca, <START> List<SubmitRecord> submitRecords) throws IllegalStateException <END> { ca.submitRecords = new ArrayList<SubmitRecordAttribute>(); for (SubmitRecord submitRecord : submitRecords) { SubmitRecordAttribute sa = new SubmitRecordAttribute(); switch (submitRecord.status) { case OK: sa.status = "OK"; addSubmitRecordLabels(submitRecord, sa); break; case NOT_READY: sa.status = "NOT_READY"; addSubmitRecordLabels(submitRecord, sa); break; case RULE_ERROR: sa.status = "RULE_ERROR"; break; default: throw new IllegalStateException( "Unsupported SubmitRecord.status + (" + submitRecord.status + ")"); } ca.submitRecords.add(sa); } if (ca.submitRecords.isEmpty()) { ca.submitRecords = null; } }</code><technical_language>remove throws IllegalStateException changes suggested applied</technical_language>

Target:
public void addSubmitRecords(ChangeAttribute ca, List<SubmitRecord> submitRecords) { ca.submitRecords = new ArrayList<SubmitRecordAttribute>(); for (SubmitRecord submitRecord : submitRecords) { SubmitRecordAttribute sa = new SubmitRecordAttribute(); sa.status = submitRecord.status.name(); if (submitRecord.status != SubmitRecord.Status.RULE_ERROR) { addSubmitRecordLabels(submitRecord, sa); } ca.submitRecords.add(sa); } if (ca.submitRecords.isEmpty()) { ca.submitRecords = null; } }
Source:
<code>public IdLookup idLookup() { final DimensionSelector keySelector = getKeySelector(); final DimensionSelector valueSelector = getValueSelector(); final IdLookup valueLookup = valueSelector.idLookup(); if (valueLookup != null) { final IndexedInts keyIndices = keySelector.getRow(); final IndexedInts valueIndices = valueSelector.getRow(); final int limit = Math.min(keyIndices.size(), valueIndices.size()); final int valueIndex = IntStream .range(0, limit) .filter(i -> subColumnName.equals(keySelector.lookupName(keyIndices.get(i)))) .findAny() <START> .orElse(-1); <END> return name -> { final int candidate = valueLookup.lookupId(name); if (candidate == valueIndex) { return candidate; } return -1; }; } else { return null; } }</code><technical_language>this code is partly repeated times in this class, extract a common method</technical_language>

Target:
public IdLookup idLookup() { final DimensionSelector valueSelector = getValueSelector(); final IdLookup valueLookup = valueSelector.idLookup(); if (valueLookup != null) { final int valueIndex = findValueIndicesIndexForSubColumn(); return name -> { final int candidate = valueLookup.lookupId(name); if (candidate == valueIndex) { return candidate; } return -1; }; } else { return null; } }
Source:
<code>public void assertNoMBeans() { Set<ObjectInstance> instances = queryOurInstances(); <START> assertEquals(Arrays.toString(instances.toArray()), 0, instances.size()); <END> }</code><technical_language>minor: assertThat(instances, is(empty()))</technical_language>

Target:
public void assertNoMBeans() { Set<ObjectInstance> instances = queryOurInstances(); assertEquals(0, instances.size()); }
Source:
<code>public void testConfigLoad() { try { <START> ServerConfiguration configuration = ConfigurationFileLoader.loadConfiguration(); <END> assertEquals(configuration.getBooleanProperty(USE_CROSS_SITE_ORIGIN_FILTER), false); assertEquals(configuration.getProperty(ROOT_PACKAGE_FOR_CLASSPATH_SCAN), null); } catch (Exception e) { fail("Error in test", e); } }</code><technical_language>Add final keyword</technical_language>

Target:
public void testConfigLoad() { try { final ServerConfiguration configuration = ConfigurationFileLoader.loadConfiguration(); assertEquals(configuration.getBooleanProperty(USE_CROSS_SITE_ORIGIN_FILTER), false); assertEquals(configuration.getProperty(ROOT_PACKAGE_FOR_CLASSPATH_SCAN), null); } catch (Exception e) { fail("Error in test", e); } }
Source:
<code>public void status() { final HttpServletResponse sresp = new HttpServletResponseFake( new RsEmpty() ); sresp.setStatus(502); MatcherAssert.assertThat( "Can't set a status in servlet response", <START> sresp.getHeaders("HTTP/1.1"), <END> Matchers.hasItem("HTTP/1.1 502 Bad Gateway") ); }</code><technical_language>@fanifieiev put this in a constant</technical_language>

Target:
public void status() { final HttpServletResponse sresp = new HttpServletResponseFake( new RsEmpty() ); sresp.setStatus(502); new Assertion<>( "Can't set a status in servlet response", sresp.getHeaders(HttpServletResponseFakeTest.VERSION), new HasValues<>( HttpServletResponseFakeTest.ERROR ) ).affirm(); }
Source:
<code>public void getCandidateApplicationsByCandidateShouldReturnAListWithThreeElements() { given(candidateRepository.findOne(FIRST_ID)).willReturn(candidateEntity); given(applicationsRepository.findByCandidateEntity(candidateEntity)).willReturn(applicationEntityListWithThreeElements); <START> given(statesRepository.findTopByApplicationEntityOrderByStateIndexDesc(applicationEntity)).willReturn(stateEntity); <END> Collection<CandidateApplicationDTO> candidateApplicationDTOCollection = statesService.getCandidateApplicationsByCandidateId(FIRST_ID); assertCandidateApplicationDTOCollection(candidateApplicationDTOCollection, getExpectedCandidateApplicationDTOListFromApplicationEntityListAndStateEntity(applicationEntityListWithThreeElements, stateEntity)); then(candidateRepository).should(times(AT_ONE_TIME)).findOne(FIRST_ID); then(applicationsRepository).should(times(AT_ONE_TIME)).findByCandidateEntity(candidateEntity); then(statesRepository).should(times(THREE_TIMES)).findTopByApplicationEntityOrderByStateIndexDesc(applicationEntity); }</code><technical_language>3 applications in returned list</technical_language>

Target:
public void getCandidateApplicationsByCandidateShouldReturnAListWithThreeElements() { given(candidateRepository.findOne(FIRST_ID)).willReturn(firstCandidateEntity); given(applicationsRepository.findByCandidateEntity(firstCandidateEntity)).willReturn(applicationEntityListWithThreeElements); given(statesRepository.findTopByApplicationEntityOrderByStateIndexDesc(firstApplicationEntity)).willReturn(firstStateEntity); given(statesRepository.findTopByApplicationEntityOrderByStateIndexDesc(secondApplicationEntity)).willReturn(secondStateEntity); given(statesRepository.findTopByApplicationEntityOrderByStateIndexDesc(thirdApplicationEntity)).willReturn(thirdStateEntity); Collection<CandidateApplicationDTO> candidateApplicationDTOCollection = statesService.getCandidateApplicationsByCandidateId(FIRST_ID); assertCandidateApplicationDTOCollection(candidateApplicationDTOCollection, candidateApplicationDTOListWithThreeElements); then(candidateRepository).should().findOne(FIRST_ID); then(applicationsRepository).should().findByCandidateEntity(firstCandidateEntity); then(statesRepository).should().findTopByApplicationEntityOrderByStateIndexDesc(firstApplicationEntity); then(statesRepository).should().findTopByApplicationEntityOrderByStateIndexDesc(secondApplicationEntity); then(statesRepository).should().findTopByApplicationEntityOrderByStateIndexDesc(thirdApplicationEntity); }
Source:
<code>public Take route(final RqRegex req) throws IOException { final String path = req.matcher().group("path"); Response response = new RsWithType( new RsWithBody("Success!"), "text/html" ); try { this.storage.put( path, req.body() ); } catch (final IOException ex) { Logger.info( this, String.format( "Internal error saving to storage at %s: %s", path, ex.getMessage() ) <START> ); <END> response = new RsWithStatus( new RsWithBody( String.format( "Internal error saving to storage at %s", path ) ), 500 ); } return new TkFixed(response); }</code><technical_language>@pinaf com.jcabi.log.Logger.error(Object, String, Object...) instead</technical_language>

Target:
public Take route(final RqRegex req) throws IOException { final String path = req.matcher().group("path"); Response response = new RsWithType( new RsWithBody("Success!"), "text/html" ); try { this.storage.put( path, req.body() ); } catch (final IOException ex) { Logger.error( this, String.format( "Internal error saving to storage at %s: %s", path, ex.getMessage() ) ); response = new RsWithStatus( new RsWithBody( String.format( "Internal error saving to storage at %s", path ) ), 500 ); } return new TkFixed(response); }
Source:
<code>private InternalContainerResource createAndMapContainerResource(final WorkerResourceSpec workerResourceSpec) { final TaskExecutorProcessSpec taskExecutorProcessSpec = TaskExecutorProcessUtils.processSpecFromWorkerResourceSpec(flinkConfig, workerResourceSpec); final InternalContainerResource internalContainerResource = new InternalContainerResource( <START> normalize(taskExecutorProcessSpec.getTotalProcessMemorySize().getMebiBytes(), unitMemMB), normalize(taskExecutorProcessSpec.getCpuCores().getValue().intValue(), unitVcore), <END> externalResourceConfigs); if (resourceWithinMaxAllocation(internalContainerResource)) { containerResourceToWorkerSpecs.computeIfAbsent(internalContainerResource, ignored -> new HashSet<>()) .add(workerResourceSpec); containerMemoryToContainerResource.computeIfAbsent(internalContainerResource.memory, ignored -> new HashSet<>()) .add(internalContainerResource); return internalContainerResource; } else { LOG.warn("Requested container resource exceeds yarn max allocation {}. Will not allocate resource.", internalContainerResource, new InternalContainerResource(maxMemMB, maxVcore, Collections.emptyMap())); return null; } }</code><technical_language>This work. method normalize unit min values consideration. current implementation, a change normalized resource is smaller min</technical_language>

Target:
private InternalContainerResource createAndMapContainerResource(final WorkerResourceSpec workerResourceSpec) { final TaskExecutorProcessSpec taskExecutorProcessSpec = TaskExecutorProcessUtils.processSpecFromWorkerResourceSpec(flinkConfig, workerResourceSpec); final InternalContainerResource internalContainerResource = new InternalContainerResource( normalize(taskExecutorProcessSpec.getTotalProcessMemorySize().getMebiBytes(), minMemMB, unitMemMB), normalize(taskExecutorProcessSpec.getCpuCores().getValue().intValue(), minVcore, unitVcore), externalResourceConfigs); if (resourceWithinMaxAllocation(internalContainerResource)) { containerResourceToWorkerSpecs.computeIfAbsent(internalContainerResource, ignored -> new HashSet<>()) .add(workerResourceSpec); containerMemoryToContainerResource.computeIfAbsent(internalContainerResource.memory, ignored -> new HashSet<>()) .add(internalContainerResource); return internalContainerResource; } else { LOG.warn("Requested container resource exceeds yarn max allocation {}. Will not allocate resource.", internalContainerResource, new InternalContainerResource(maxMemMB, maxVcore, Collections.emptyMap())); return null; } }
Source:
<code>public void testGetGroupsForUserFullRepresentation() { RealmResource realm = adminClient.realms().realm("test"); String userName = "averagejoe"; String groupName = "groupWithAttribute"; Map<String, List<String>> attributes = new HashMap<String, List<String>>(); attributes.put("attribute1", Arrays.asList("attribute1","attribute2")); <START> try (Creator<GroupResource> g = Creator.create(realm, GroupBuilder.create().name(groupName).attributes(attributes).build())) { <END> String groupId = g.resource().toRepresentation().getId(); UserRepresentation userRepresentation = UserBuilder .edit(createUserRepresentation(userName, "joe@average.com", "average", "joe", true)) .addPassword("password") .build(); try (Creator<UserResource> u = Creator.create(realm, userRepresentation)) { UserResource user = u.resource(); user.joinGroup(groupId); List<GroupRepresentation> userGroups = user.groups(0, 100, false); assertFalse(userGroups.isEmpty()); assertTrue(userGroups.get(0).getAttributes().containsKey("attribute1")); } } }</code><technical_language>Nit: level of try nesting call get representation (lines 1690 - 1698) simplified to: suggestion UserRepresentation userRepresentation = UserBuilder .edit(createUserRepresentation(userName, "joe@average.com", "average", "joe", true)) .addPassword("password") .build(); try (Creator<UserResource> u = Creator.create(realm, userRepresentation); Creator<GroupResource> g = Creator.create(realm, GroupBuilder.create().name(groupName).attributes(attributes).build())) { String groupId = g.id());</technical_language>

Target:
public void testGetGroupsForUserFullRepresentation() { RealmResource realm = adminClient.realms().realm("test"); String userName = "averagejoe"; String groupName = "groupWithAttribute"; Map<String, List<String>> attributes = new HashMap<String, List<String>>(); attributes.put("attribute1", Arrays.asList("attribute1","attribute2")); UserRepresentation userRepresentation = UserBuilder .edit(createUserRepresentation(userName, "joe@average.com", "average", "joe", true)) .addPassword("password") .build(); try (Creator<UserResource> u = Creator.create(realm, userRepresentation); Creator<GroupResource> g = Creator.create(realm, GroupBuilder.create().name(groupName).attributes(attributes).build())) { String groupId = g.id(); UserResource user = u.resource(); user.joinGroup(groupId); List<GroupRepresentation> userGroups = user.groups(0, 100, false); assertFalse(userGroups.isEmpty()); assertTrue(userGroups.get(0).getAttributes().containsKey("attribute1")); } }
Source:
<code>private Operation<Void> actionComplete(final List<ResourceBasedNode<?>> nodes) { final ProjectConfigDto project = appContext.getCurrentProject().getRootProject(); return new Operation<Void>() { @Override public void apply(Void arg) throws OperationException { if (actionCompletedCallBack != null) { actionCompletedCallBack.onSuccess(null); } Map<String, List<String>> atributes = project.getAttributes(); if (!(atributes.containsKey("vcs.provider.name") && atributes.get("vcs.provider.name").contains("git")) || nodes.get(0) instanceof ProjectNode) { return; } final Unmarshallable<Status> unmarshall = dtoUnmarshallerFactory.newUnmarshaller(Status.class); gitService.status(project, new AsyncRequestCallback<Status>(unmarshall) { @Override protected void onSuccess(final Status result) { if (!result.getMissing().isEmpty()) { askAddToIndex(project, nodes, result.getMissing()); } } @Override protected void onFailure(Throwable exception) { <START> notificationManager.notify("Git", exception.getMessage()); <END> } }); } }; }</code><technical_language>Git</technical_language>

Target:
private Operation<Void> actionComplete(final List<ResourceBasedNode<?>> nodes) { final ProjectConfigDto project = appContext.getCurrentProject().getRootProject(); return new Operation<Void>() { @Override public void apply(Void arg) throws OperationException { if (actionCompletedCallBack != null) { actionCompletedCallBack.onSuccess(null); } Map<String, List<String>> atributes = project.getAttributes(); if (!(atributes.containsKey("vcs.provider.name") && atributes.get("vcs.provider.name").contains("git")) || nodes.get(0) instanceof ProjectNode) { return; } final Unmarshallable<Status> unmarshall = dtoUnmarshallerFactory.newUnmarshaller(Status.class); gitService.status(project, new AsyncRequestCallback<Status>(unmarshall) { @Override protected void onSuccess(final Status result) { if (!result.getMissing().isEmpty()) { askAddToIndex(project, nodes, result.getMissing()); } } @Override protected void onFailure(Throwable exception) { notificationManager.notify(exception.getMessage()); } }); } }; }
Source:
<code>private String getSpecialName(MethodReference methodReference) { MethodReader method = classSource.resolve(methodReference); <START> ClassReader cls = classSource.get(method.getReference().getClassName()); <END> if (method == null) { return null; } AnnotationReader exportAnnot = method.getAnnotations().get(Export.class.getName()); if (exportAnnot != null && !ModelUtils.isScalaInternalClass(cls)) { return exportAnnot.getValue("name").getString(); } AnnotationReader importAnnot = method.getAnnotations().get(Import.class.getName()); if (importAnnot != null) { return importAnnot.getValue("name").getString(); } return null; }</code><technical_language>I spoil compiler core Scala-specific hacks. dedicated class for this called ScalaHacks. detect synthetic Scala classes remove @Export annotations methods</technical_language>

Target:
private String getSpecialName(MethodReference methodReference) { MethodReader method = classSource.resolve(methodReference); if (method == null) { return null; } AnnotationReader exportAnnot = method.getAnnotations().get(Export.class.getName()); if (exportAnnot != null) { return exportAnnot.getValue("name").getString(); } AnnotationReader importAnnot = method.getAnnotations().get(Import.class.getName()); if (importAnnot != null) { return importAnnot.getValue("name").getString(); } return null; }
Source:
<code>public Dialog build(Controller controller, Object... arguments) { String infoMessage = (String) arguments[0]; Skin skin = controller.getApplicationAssets().getSkin(); dialogController = new DialogController(skin, false, false); TopBottomLayout messageContainer = new TopBottomLayout(); TextArea text = new TextArea(infoMessage, skin); text.setLineCharacters(200); text.setDisabled(true); text.setPreferredLines(3); messageContainer.addTop(text); <START> messageContainer.layout(); <END> return dialogController.title("").root(messageContainer).getDialog(); }</code><technical_language>layout is automatically called. need call it. More info layouts in <LINK_0></technical_language>

Target:
public Dialog build(Controller controller, Object... arguments) { String infoMessage = (String) arguments[0]; Skin skin = controller.getApplicationAssets().getSkin(); dialogController = new DialogController(skin, false, false); TopBottomLayout messageContainer = new TopBottomLayout(); Label label = new Label(infoMessage, skin); messageContainer.addTop(label); return dialogController.title("").root(messageContainer).getDialog(); }
Source:
<code>public Response retrieveMetadata() throws WSSecurityException, CertificateEncodingException { X509Certificate issuerCert = findCertificate(systemCrypto.getSignatureAlias(), systemCrypto.getSignatureCrypto()); X509Certificate encryptionCert = findCertificate(systemCrypto.getEncryptionAlias(), systemCrypto.getEncryptionCrypto()); <START> String hostname = SystemBaseUrl.EXTERNAL.getHost(); <END> String port = SystemBaseUrl.EXTERNAL.getPort(); String rootContext = SystemBaseUrl.EXTERNAL.getRootContext(); String entityId = String.format("https://%s:%s%s/saml", hostname, port, rootContext); String logoutLocation = String.format("https://%s:%s%s/saml/logout", hostname, port, rootContext); String assertionConsumerServiceLocation = String.format("https://%s:%s%s/saml/sso", hostname, port, rootContext); EntityDescriptor entityDescriptor = SamlProtocol.createSpMetadata( entityId, Base64.getEncoder().encodeToString(issuerCert.getEncoded()), Base64.getEncoder().encodeToString(encryptionCert.getEncoded()), logoutLocation, assertionConsumerServiceLocation, assertionConsumerServiceLocation, assertionConsumerServiceLocation); Document doc = DOMUtils.createDocument(); doc.appendChild(doc.createElement("root")); return Response.ok(DOM2Writer.nodeToString(OpenSAMLUtil.toDom(entityDescriptor, doc, false))) .build(); }</code><technical_language>I leave IdP for now. enough independently configurable URLs for work a reverse proxy today</technical_language>

Target:
public Response retrieveMetadata() throws WSSecurityException, CertificateEncodingException { X509Certificate issuerCert = findCertificate(systemCrypto.getSignatureAlias(), systemCrypto.getSignatureCrypto()); X509Certificate encryptionCert = findCertificate(systemCrypto.getEncryptionAlias(), systemCrypto.getEncryptionCrypto()); String hostname = SystemBaseUrl.INTERNAL.getHost(); String port = SystemBaseUrl.INTERNAL.getPort(); String rootContext = SystemBaseUrl.INTERNAL.getRootContext(); String entityId = String.format("https://%s:%s%s/saml", hostname, port, rootContext); String logoutLocation = String.format("https://%s:%s%s/saml/logout", hostname, port, rootContext); String assertionConsumerServiceLocation = String.format("https://%s:%s%s/saml/sso", hostname, port, rootContext); EntityDescriptor entityDescriptor = SamlProtocol.createSpMetadata( entityId, Base64.getEncoder().encodeToString(issuerCert.getEncoded()), Base64.getEncoder().encodeToString(encryptionCert.getEncoded()), logoutLocation, assertionConsumerServiceLocation, assertionConsumerServiceLocation, assertionConsumerServiceLocation); Document doc = DOMUtils.createDocument(); doc.appendChild(doc.createElement("root")); return Response.ok(DOM2Writer.nodeToString(OpenSAMLUtil.toDom(entityDescriptor, doc, false))) .build(); }
Source:
<code>public long getReadyTimestamp(Constraints viewConstraints) { String normalizedConstraints = getNormalizedConstraints(viewConstraints); Path signalPath = new Path(signalDirectory, normalizedConstraints); try { try { FileStatus signalStatus = rootFileSystem.getFileStatus(signalPath); return signalStatus.getModificationTime(); } catch (final FileNotFoundException ex) { } return -1; <START> } catch (NumberFormatException e) { <END> throw new DatasetException("Signal contents were modified to not be a number: " + signalPath, e); } catch (IOException e) { throw new DatasetIOException("Could not access signal path: " + signalPath, e); } }</code><technical_language>Is this needed? throws NumberFormatException</technical_language>

Target:
public long getReadyTimestamp(Constraints viewConstraints) { String normalizedConstraints = getNormalizedConstraints(viewConstraints); Path signalPath = new Path(signalDirectory, normalizedConstraints); try { try { FileStatus signalStatus = rootFileSystem.getFileStatus(signalPath); return signalStatus.getModificationTime(); } catch (final FileNotFoundException ex) { } return -1; } catch (IOException e) { throw new DatasetIOException("Could not access signal path: " + signalPath, e); } }
Source:
<code>public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) { super.eventRaised(ev, sender, args); if (this.equals(sender)) { getChoiceGroupNone().setIsChangable(getIsChangable()); getChoiceGroupTotal().setIsChangable(getIsChangable()); getChoiceGroupReadWrite().setIsChangable(getIsChangable()); } <START> else if (((EntityModel) sender).getEntity() == Boolean.TRUE) { <END> if (!getChoiceGroupNone().equals(sender)) { getChoiceGroupNone().setEntity(false); } if (!getChoiceGroupTotal().equals(sender)) { getChoiceGroupTotal().setEntity(false); getTotal().setEntity(null); } if (!getChoiceGroupReadWrite().equals(sender)) { getChoiceGroupReadWrite().setEntity(false); getRead().setEntity(null); getWrite().setEntity(null); } updateChangeability(); } }</code><technical_language>add instanceof check casting, in case</technical_language>

Target:
public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) { super.eventRaised(ev, sender, args); if (this.equals(sender)) { getChoiceGroupNone().setIsChangable(getIsChangable()); getChoiceGroupTotal().setIsChangable(getIsChangable()); getChoiceGroupReadWrite().setIsChangable(getIsChangable()); } else if ((sender instanceof EntityModel) && ((EntityModel) sender).getEntity() == Boolean.TRUE) { if (!getChoiceGroupNone().equals(sender)) { getChoiceGroupNone().setEntity(false); } if (!getChoiceGroupTotal().equals(sender)) { getChoiceGroupTotal().setEntity(false); getTotal().setEntity(null); } if (!getChoiceGroupReadWrite().equals(sender)) { getChoiceGroupReadWrite().setEntity(false); getRead().setEntity(null); getWrite().setEntity(null); } updateChangeability(); } }
Source:
<code>private void umount(String localRootPath) { if (!mountExists(localRootPath)) { return; } Script command = new Script(true, "umount", timeout, s_logger); command.add(localRootPath); String result = command.execute(); if (result != null) { String errMsg = "Unable to umount " + localRootPath + " due to " + result; s_logger.error(errMsg); throw new CloudRuntimeException(errMsg); } deleteMountPath(localRootPath); <START> s_logger.debug("Successfully umounted " + localRootPath); <END> }</code><technical_language>info, debug</technical_language>

Target:
private void umount(String localRootPath) { if (!mountExists(localRootPath)) { return; } Script command = new Script(true, "umount", timeout, s_logger); command.add(localRootPath); String result = command.execute(); if (result != null) { String errMsg = "Unable to umount " + localRootPath + " due to " + result; s_logger.error(errMsg); throw new CloudRuntimeException(errMsg); } deleteMountPath(localRootPath); s_logger.info("Successfully umounted " + localRootPath); }
Source:
<code>private Boolean isValidIndex(int index) { Boolean isValid; if (index >= 0 && index <= this.actions.size()) { isValid = true; } else { isValid = false; } return isValid; <START> <END> }</code><technical_language>Replace with: return index >= 0 && index <= this.actions.size(); need return a boxed boolean</technical_language>

Target:
private Boolean isValidIndex(int index) { return index >= 0 && index <= this.actions.size(); }
Source:
<code>public void onAttach(Context context) { super.onAttach(context); <START> rangePickerViewModel = new ViewModelProvider(requireActivity(), new ViewModelProvider.NewInstanceFactory()).get(RangePickerViewModel.class); <END> }</code><technical_language>I need pass a NewInstanceFactory here. 1 arg constructor for ViewModelProvider</technical_language>

Target:
public void onAttach(Context context) { super.onAttach(context); try { listener = (NumberPickerListener) context; } catch (ClassCastException e) { throw new ClassCastException(context.toString() + " must implement OnHeadlineSelectedListener"); } }
Source:
<code>public void process(JSONRequestContext jsonRequestContext) { StudentGroupDAO studentGroupDAO = DAOFactory.getInstance().getStudentGroupDAO(); StudentGroupContactLogEntryDAO contactLogEntryDAO = DAOFactory.getInstance().getStudentGroupContactLogEntryDAO(); try { <START> Long studentGroupId = NumberUtils.createLong(jsonRequestContext.getRequest().getParameter("studentGroupId")); <END> StudentGroup studentGroup = studentGroupDAO.findById(studentGroupId); String entryText = jsonRequestContext.getRequest().getParameter("entryText"); String entryCreator = jsonRequestContext.getRequest().getParameter("entryCreatorName"); Date entryDate = new Date(NumberUtils.createLong(jsonRequestContext.getRequest().getParameter("entryDate"))); StudentContactLogEntryType entryType = StudentContactLogEntryType.valueOf(jsonRequestContext.getString("entryType")); StudentGroupContactLogEntry entry = contactLogEntryDAO.create(studentGroup, entryType, entryText, entryDate, entryCreator); Map<String, Object> info = new HashMap<String, Object>(); info.put("id", entry.getId()); info.put("creatorName", entry.getCreatorName()); info.put("timestamp", entry.getEntryDate().getTime()); info.put("text", entry.getText()); info.put("type", entry.getType()); info.put("studentGroupId", studentGroupId); jsonRequestContext.addResponseParameter("results", info); } catch (Exception e) { throw new SmvcRuntimeException(e); } }</code><technical_language>getLong</technical_language>

Target:
public void process(JSONRequestContext jsonRequestContext) { StudentGroupDAO studentGroupDAO = DAOFactory.getInstance().getStudentGroupDAO(); StudentGroupContactLogEntryDAO contactLogEntryDAO = DAOFactory.getInstance().getStudentGroupContactLogEntryDAO(); Long studentGroupId = jsonRequestContext.getLong("studentGroupId"); if (studentGroupId == null) throw new SmvcRuntimeException(StatusCode.UNDEFINED, "StudentGroupId was not defined."); try { StudentGroup studentGroup = studentGroupDAO.findById(studentGroupId); String entryText = jsonRequestContext.getString("entryText"); String entryCreator = jsonRequestContext.getString("entryCreatorName"); Date entryDate = jsonRequestContext.getDate("entryDate"); StudentContactLogEntryType entryType = StudentContactLogEntryType.valueOf(jsonRequestContext.getString("entryType")); StudentGroupContactLogEntry entry = contactLogEntryDAO.create(studentGroup, entryType, entryText, entryDate, entryCreator); Map<String, Object> info = new HashMap<String, Object>(); info.put("id", entry.getId()); info.put("creatorName", entry.getCreatorName()); info.put("timestamp", entry.getEntryDate() != null ? entry.getEntryDate().getTime() : ""); info.put("text", entry.getText()); info.put("type", entry.getType()); info.put("studentGroupId", studentGroupId); jsonRequestContext.addResponseParameter("results", info); } catch (Exception e) { throw new SmvcRuntimeException(e); } }
Source:
<code>private <T> List<T> getOpenEditorsByType(Class<T> clazz) { return FluentIterable.from(Arrays.asList(page.getEditorReferences())) .transform(new Function<IEditorReference, IEditorPart>() { @Override public IEditorPart apply(IEditorReference ref) { return ref.getEditor(true); } }) .filter(clazz) <START> .toList(); <END> }</code><technical_language>assertions simplified if returned a set. write assertEquals(ImmutableSet.of(task1), getOpenEditorsByType(..</technical_language>

Target:
private <T> Set<T> getOpenEditorsByType(Class<T> clazz) { return FluentIterable.from(Arrays.asList(page.getEditorReferences())) .transform(new Function<IEditorReference, IEditorPart>() { @Override public IEditorPart apply(IEditorReference ref) { return ref.getEditor(true); } }) .filter(clazz) .toSet(); }
Source:
<code>public void testEquals() throws Exception { FixedWidthConfiguration conf1 = new FixedWidthConfiguration(1, "UTF8", <START> 10, true, false, true); <END> FixedWidthConfiguration conf2 = new FixedWidthConfiguration(1, "UTF8", 10, true, false, true); assertEquals(conf1, conf2); FixedWidthConfiguration conf3 = new FixedWidthConfiguration(1, "UTF8", 10, false, false, true); assertFalse(conf1.equals(conf3)); }</code><technical_language>Please overloaded constructors for constructor signature. wont change this existing test</technical_language>

Target:
public void testEquals() throws Exception { FixedWidthConfiguration conf1 = new FixedWidthConfiguration(1, "UTF8", 10, true); FixedWidthConfiguration conf2 = new FixedWidthConfiguration(1, "UTF8", 10, true); assertEquals(conf1, conf2); FixedWidthConfiguration conf3 = new FixedWidthConfiguration(1, "UTF8", 10, false); assertFalse(conf1.equals(conf3)); }
Source:
<code>protected void executeVdsBrokerCommand() { try { DeviceInfoReturn deviceInfoReturn = <START> getBroker().attachManagedBlockStorageVolume(getParameters().getVolumeId(), JsonHelper.mapToJson(getParameters().getConnectionInfo())); <END> setReturnValue(deviceInfoReturn.getDeviceInfo()); } catch (IOException e) { log.error("attachment of managed block storage device failed {}", e); return; } }</code><technical_language>please break line</technical_language>

Target:
protected void executeVdsBrokerCommand() { DeviceInfoReturn deviceInfoReturn = getBroker().attachManagedBlockStorageVolume(getParameters().getVolumeId(), getParameters().getConnectionInfo()); setReturnValue(deviceInfoReturn.getDeviceInfo()); }
Source:
<code>private void ensurePowerOfTwo(String parameter, int number) { if (Integer.bitCount(number) > 1) { <START> LOG.debug("Parameter should be power of two but was {}", parameter, number); <END> } }</code><technical_language>This warn</technical_language>

Target:
private void ensurePowerOfTwo(String parameter, int number) { if (Integer.bitCount(number) > 1) { LOG.warn("Parameter should be power of two but was {}", parameter, number); } }
Source:
<code>JoystickOptionsPanel(JoystickOptionsPanelController controller) { super(controller); <START> joystickService = CentralLookup.getDefault().lookup(JoystickServiceImpl.class); <END> joystickService.addListener(this); super.setLayout(new BorderLayout()); }</code><technical_language>suggestion joystickService = CentralLookup.getDefault().lookup(JoystickService.class);</technical_language>

Target:
JoystickOptionsPanel(JoystickOptionsPanelController controller) { super(controller); joystickService = CentralLookup.getDefault().lookup(JoystickService.class); joystickService.addListener(this); super.setLayout(new BorderLayout()); }
Source:
<code>public void processRecord(ComputationContext context, String inputStreamName, Record record) { Codec<DataBucket> codec = BulkCodecs.getDataBucketCodec(); DataBucket in = codec.decode(record.getData()); String commandId = in.getCommandId(); String storeName = Framework.getService(BulkService.class).getStatus(commandId).getAction(); Blob tmpBlob = getBlob(in.getDataAsString(), storeName); tmpBlob = sort(tmpBlob, commandId); Path path = createTemp(commandId); try (InputStream is = tmpBlob.getStream(); FileOutputStream os = new FileOutputStream(path.toFile(), true)) { os.write(in.getHeader()); IOUtils.copy(is, os); os.write(in.getFooter()); os.flush(); tmpBlob.getFile().delete(); } catch (IOException e) { log.error("Unable to copy header/footer", e); } storeBlob(new FileBlob(path.toFile()), commandId, storeName); BulkCommand command = Framework.getService(BulkService.class).getCommand(commandId); if (command.getParam(ZIP_PARAMETER) != null) { zip = command.getParam(ZIP_PARAMETER); } <START> String outputStream = zip ? OUTPUT_1 : OUTPUT_2; <END> DataBucket out = new DataBucket(commandId, in.getCount(), getTransientStoreKey(commandId)); context.produceRecord(outputStream, Record.of(commandId, codec.encode(out))); context.askForCheckpoint(); }</code><technical_language>output stream convention clear constant (ZIP_STREAM=OUTPUT_1, ...)</technical_language>

Target:
public void processRecord(ComputationContext context, String inputStreamName, Record record) { Codec<DataBucket> codec = BulkCodecs.getDataBucketCodec(); DataBucket in = codec.decode(record.getData()); String commandId = in.getCommandId(); String storeName = Framework.getService(BulkService.class).getStatus(commandId).getAction(); Blob tmpBlob = getBlob(in.getDataAsString(), storeName); tmpBlob = sort(tmpBlob, commandId); Path path = createTemp(commandId); try (InputStream is = tmpBlob.getStream(); FileOutputStream os = new FileOutputStream(path.toFile(), true)) { os.write(in.getHeader()); IOUtils.copy(is, os); os.write(in.getFooter()); os.flush(); tmpBlob.getFile().delete(); } catch (IOException e) { log.error("Unable to copy header/footer", e); } storeBlob(new FileBlob(path.toFile()), commandId, storeName); BulkCommand command = Framework.getService(BulkService.class).getCommand(commandId); boolean zip = command.getParam(ZIP_PARAMETER) != null ? command.getParam(ZIP_PARAMETER) : false; String outputStream = zip ? ZIP_STREAM : EXPOSE_BLOB_STREAM; DataBucket out = new DataBucket(commandId, in.getCount(), getTransientStoreKey(commandId)); context.produceRecord(outputStream, Record.of(commandId, codec.encode(out))); context.askForCheckpoint(); }