auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected void doTest(Location loc) throws Exception { RedisStore redis = app.createAndManageChild(EntitySpec.create(RedisStore.class)); app.start(ImmutableList.of(loc)); EntityTestUtils.assertAttributeEqualsEventually(redis, RedisStore.SERVICE_UP, true); JedisSupport support = new JedisSupport(redis); try { support.redisTest(); } finally { <START> redis.stop(); <END> } EntityTestUtils.assertPredicateEventuallyTrue(redis, new Predicate<RedisStore>() { @Override public boolean apply(@Nullable RedisStore input) { return input != null && input.getAttribute(RedisStore.UPTIME) > 0; } }); }</code><technical_language>I suspect need this redis.stop - tearDown deal that</technical_language>

Target:
protected void doTest(Location loc) throws Exception { RedisStore redis = app.createAndManageChild(EntitySpec.create(RedisStore.class)); app.start(ImmutableList.of(loc)); EntityTestUtils.assertAttributeEqualsEventually(redis, RedisStore.SERVICE_UP, true); JedisSupport support = new JedisSupport(redis); support.redisTest(); EntityTestUtils.assertPredicateEventuallyTrue(redis, new Predicate<RedisStore>() { @Override public boolean apply(@Nullable RedisStore input) { return input != null && input.getAttribute(RedisStore.UPTIME) > 0 && input.getAttribute(RedisStore.TOTAL_COMMANDS_PROCESSED) >= 0 && input.getAttribute(RedisStore.TOTAL_CONNECTIONS_RECEIVED) >= 0 && input.getAttribute(RedisStore.EXPIRED_KEYS) >= 0 && input.getAttribute(RedisStore.EVICTED_KEYS) >= 0 && input.getAttribute(RedisStore.KEYSPACE_HITS) >= 0 && input.getAttribute(RedisStore.KEYSPACE_MISSES) >= 0; } }); }
Source:
<code>public String toString() { StringBuilder sb = new StringBuilder(); sb.append("jtx{").append(propagationBehavior.toString()).append(',') .append(readOnlyMode ? "readonly" : "readwrite").append(',') .append(isolationLevel.toString()).append(',').append(timeout) <START> .append('}'); <END> return sb.toString(); }</code><technical_language>return new StringBuilder().append()....toString();</technical_language>

Target:
public String toString() { return new StringBuilder().append("jtx{").append(propagationBehavior) .append(',').append(readOnlyMode ? "readonly" : "readwrite") .append(',').append(isolationLevel.toString()).append(',') .append(timeout).append('}').toString(); }
Source:
<code>public int getUserIdOrThrow() { Preconditions.checkState( !userRole.equals(UserRole.ANONYMOUS), "Anonymous user is expected to have a null user id, " + "it is the only case expected where user id would be null"); return Optional.ofNullable(userId) <START> .orElseThrow(() -> new AssertionError("Expected to have a non-null user id")); <END> }</code><technical_language>understanding this method. throws error if user role is anonymous if user a null user id? written this a bit strange create optional of Integer immediately check if null? check if userId == null? this change, do of code paths call this method properly handle expections if this kill everything</technical_language>

Target:
public int getUserIdOrThrow() { Preconditions.checkState( !userRole.equals(UserRole.ANONYMOUS), "Anonymous users always have a null user id"); return Optional.ofNullable(userId) .orElseThrow(() -> new AssertionError("Error, expected to have a non-null user id")); }
Source:
<code>private void deleteConflictBatch(DeleteConflictList theDcl, IFhirResourceDao<IBaseResource> theDao) { DeleteConflictList newBatch = new DeleteConflictList(); for (DeleteConflict next : theDcl) { IdDt nextSource = next.getSourceId(); <START> ourLog.info("Have delete conflict - Cascading delete", next); <END> theDao.delete(nextSource.toVersionless(), newBatch, null, null); } theDcl.removeIf(x -> true); theDcl.addAll(newBatch); }</code><technical_language>suggestion ourLog.info("Have delete conflict - Cascading delete", nextSource);</technical_language>

Target:
private void deleteConflictBatch(DeleteConflictList theDcl, IFhirResourceDao<IBaseResource> theDao) { DeleteConflictList newBatch = new DeleteConflictList(); for (DeleteConflict next : theDcl) { IdDt nextSource = next.getSourceId(); ourLog.info("Have delete conflict - Cascading delete", nextSource); theDao.delete(nextSource.toVersionless(), newBatch, null, null); } theDcl.removeAll(); theDcl.addAll(newBatch); }
Source:
<code><START> public int compareValueTo( ZonedTimeSchemaKey other ) <END> { int compare = Long.compare( nanosOfDayUTC, other.nanosOfDayUTC ); if ( compare == 0 ) { compare = Integer.compare( zoneOffsetSeconds, other.zoneOffsetSeconds ); } return compare; }</code><technical_language>I compareTo method in Java's OffsetTime.java is TimeValue code. implemented differently. double check method Java one</technical_language>

Target:
public int compareValueTo( ZonedTimeSchemaKey other ) { int compare = Long.compare( nanosOfDayUTC, other.nanosOfDayUTC ); if ( compare == 0 && differentValidZoneOffset( other ) ) { compare = Values.COMPARATOR.compare( asValue(), other.asValue() ); } return compare; }
Source:
<code>public Iterable<Directive> process(final XML xml) throws IOException { final XML req = xml.nodes("/talk/request").get(0); final Issue.Smart issue = new TalkIssues(this.github, xml).get(); final boolean success = Boolean.parseBoolean( req.xpath("success/text()").get(0) ); final URI home = new Home(xml).uri(); final String pattern; if (success) { pattern = "Reports.success"; } else { pattern = "Reports.failure"; } final StringBuilder msg = new StringBuilder( Logger.format( Reports.PHRASES.getString(pattern), home.toASCIIString(), Long.parseLong(req.xpath("msec/text()").get(0)) ) ).append(Reports.highlights(req)); if (!success) { msg.append(Reports.tail(req)); } final int number = Integer.parseInt(req.xpath("@id").get(0)); final Comment.Smart comment = Reports.origin(issue, number); final String message; <START> if (comment.body().contains("stop")) { <END> message = String.format( Reports.PHRASES.getString("Reports.stop-fails"), msg.toString() ); } else { message = msg.toString(); } new Answer(comment).post(success, message); Logger.info(this, "issue #%d reported: %B", issue.number(), success); return new Directives() .xpath("/talk/request[success]") .strict(1).remove(); }</code><technical_language>@xupyprmv is code related stopping in QnStop.java, do need this one</technical_language>

Target:
public Iterable<Directive> process(final XML xml) throws IOException { final XML req = xml.nodes("/talk/request").get(0); final Issue.Smart issue = new TalkIssues(this.github, xml).get(); final boolean success = Boolean.parseBoolean( req.xpath("success/text()").get(0) ); final URI home = new Home(xml).uri(); final String pattern; if (success) { pattern = "Reports.success"; } else { pattern = "Reports.failure"; } final int number = Integer.parseInt(req.xpath("@id").get(0)); final Comment.Smart comment = Reports.origin(issue, number); final StringBuilder message = new StringBuilder(); if (comment.body().contains("stop")) { message.append(Reports.PHRASES.getString("Reports.stop-fails")) .append(' '); } message.append( Logger.format( Reports.PHRASES.getString(pattern), home.toASCIIString(), Long.parseLong(req.xpath("msec/text()").get(0)) ) ).append(Reports.highlights(req)); if (!success) { message.append(Reports.tail(req)); } new Answer(comment).post(success, message.toString()); Logger.info(this, "issue #%d reported: %B", issue.number(), success); return new Directives() .xpath("/talk/request[success]") .strict(1).remove(); }
Source:
<code>public SearchLatencyListener(Settings settings) { super(settings); statBuckets = new HashMap<>(); lock = new ReentrantReadWriteLock(); scheduledProcedure = new ScheduledProcedure(this::rotate, <START> Scheduler.newFixedDelaySchedule(ROTATION_DELAY.millis(), <END> ROTATION_DELAY.millis(), TimeUnit.MILLISECONDS)); }</code><technical_language>difference, meant a fixed rate, a fixed delay</technical_language>

Target:
public SearchLatencyListener(Settings settings) { super(settings); statBuckets = new ConcurrentHashMap<>(); scheduledProcedure = new ScheduledProcedure(this::rotate, Scheduler.newFixedRateSchedule(ROTATION_DELAY.millis(), ROTATION_DELAY.millis(), TimeUnit.MILLISECONDS)); }
Source:
<code>public Tags tags() { <START> return new RtTags(this.entry, this.entry, this.owner); <END> }</code><technical_language>pass this.entry twice? parameter if value</technical_language>

Target:
public Tags tags() { return new RtTags(this.entry, this.owner); }
Source:
<code>private Map mapAttributes(Map<String, Object> persistentItem) { <START> Object srcs = persistentItem.getOrDefault("src_txt", Collections.emptySet()); <END> if (srcs instanceof String) { srcs = ImmutableSet.of((String) srcs); } Object metacardIds = persistentItem.getOrDefault("metacardIds_txt", Collections.emptySet()); if (metacardIds instanceof String) { metacardIds = ImmutableSet.of((String) metacardIds); } return new ImmutableMap.Builder<String, Object>() .put("id", persistentItem.get("id_txt")) .put("src", srcs) .put("metacardIds", metacardIds) .put("queryId", persistentItem.getOrDefault("queryId_txt", "")) .put("serverGenerated", persistentItem.getOrDefault("serverGenerated_txt", "true")) .put( "when", persistentItem.getOrDefault("when_lng", DateTime.now().toInstant().getMillis())) .build(); }</code><technical_language>strip stuffixes need them? I.e. call PersistentItem.stripSuffix call .getOrDefault("src", ...); instead</technical_language>

Target:
private Map<String, Object> mapAttributes(Map<String, Object> persistentItem) { persistentItem = PersistentItem.stripSuffixes(persistentItem); Object srcs = persistentItem.getOrDefault("src", Collections.emptySet()); if (srcs instanceof String) { srcs = ImmutableSet.of((String) srcs); } Object metacardIds = persistentItem.getOrDefault("metacardIds", Collections.emptySet()); if (metacardIds instanceof String) { metacardIds = ImmutableSet.of((String) metacardIds); } return new ImmutableMap.Builder<String, Object>() .put("id", persistentItem.get("id")) .put("src", srcs) .put("metacardIds", metacardIds) .put("queryId", persistentItem.getOrDefault("queryId", "")) .put("serverGenerated", persistentItem.getOrDefault("serverGenerated", "true")) .put("when", persistentItem.getOrDefault("when", DateTime.now().toInstant().getMillis())) .build(); }
Source:
<code>boolean equals(Binary other) { if (value.hasArray()) { return other.equals(value.array(), value.arrayOffset() + offset, length); } byte[] bytes = getBytes(); <START> return other.equals(bytes, 0, bytes.length); <END> }</code><technical_language>equals hashcode copy data</technical_language>

Target:
boolean equals(Binary other) { if (value.hasArray()) { return other.equals(value.array(), value.arrayOffset() + offset, length); } else { return other.equals(value, offset, length); } }
Source:
<code>public void setSeconds(double seconds) { <START> String str = String.format(Locale.ROOT,"%.6f",seconds); <END> int decimal = str.indexOf('.'); microSeconds = Integer.parseInt(str.substring(decimal + 1)); wholeSeconds = Integer.parseInt(str.substring(0,decimal)); if ( seconds < 0 ) { microSeconds = -microSeconds; } }</code><technical_language>java wholeSeconds = (int) seconds microSeconds = (seconds - wholeSeconds) / 1_000_000.0;</technical_language>

Target:
public void setSeconds(double seconds) { wholeSeconds = (int) seconds; microSeconds = (int) Math.round((seconds - wholeSeconds) * MICROS_IN_SECOND); }
Source:
<code>private OMNode readNonXML (URL url) throws IOException { <START> Properties metadata = getMetadata(url.getPath()); <END> URLConnection urlConnection = url.openConnection(); urlConnection.connect(); try (InputStream inputStream = urlConnection.getInputStream()) { if (inputStream == null) { return null; } String mediaType = metadata.getProperty(METADATA_KEY_MEDIA_TYPE, ESBRegistryConstants.DEFAULT_MEDIA_TYPE); if (ESBRegistryConstants.DEFAULT_MEDIA_TYPE.equals(mediaType)) { StringBuilder strBuilder = new StringBuilder(); try (BufferedReader bReader = new BufferedReader(new InputStreamReader(inputStream))) { String line; while ((line = bReader.readLine()) != null) { strBuilder.append(line); } } return OMAbstractFactory.getOMFactory().createOMText(strBuilder.toString()); } else { return OMAbstractFactory.getOMFactory().createOMText( new DataHandler(new SynapseBinaryDataSource(inputStream, mediaType)), true); } } }</code><technical_language>InputStream **inputStream** = urlConnection.getInputStream() null ? If so, move this line 833. If is null, need do this, returning null. If is null , remove null check there. Correct if wrong</technical_language>

Target:
private OMNode readNonXML (URL url) throws IOException { URLConnection urlConnection = url.openConnection(); urlConnection.connect(); try (InputStream inputStream = urlConnection.getInputStream()) { if (inputStream == null) { return null; } Properties metadata = getMetadata(url.getPath()); String mediaType = metadata.getProperty(METADATA_KEY_MEDIA_TYPE, ESBRegistryConstants.DEFAULT_MEDIA_TYPE); if (ESBRegistryConstants.DEFAULT_MEDIA_TYPE.equals(mediaType)) { StringBuilder strBuilder = new StringBuilder(); try (BufferedReader bReader = new BufferedReader(new InputStreamReader(inputStream))) { String line; while ((line = bReader.readLine()) != null) { strBuilder.append(line); } } return OMAbstractFactory.getOMFactory().createOMText(strBuilder.toString()); } else { return OMAbstractFactory.getOMFactory().createOMText( new DataHandler(new SynapseBinaryDataSource(inputStream, mediaType)), true); } } }
Source:
<code>private void beforeActions() { Properties properties = PropertiesUtil.getJttpBuildProperties(); issueCollectorSrc = properties.getProperty(PropertiesUtil.ISSUE_COLLECTOR_SRC); userSettings = settingsHelper.loadUserSettings(); globalSettings = settingsHelper.loadGlobalSettings(); parseDateParam(); boolean dayBack = getHttpRequest().getParameter(Parameter.DAY_BACK) != null; boolean dayNext = getHttpRequest().getParameter(Parameter.DAY_NEXT) != null; boolean today = getHttpRequest().getParameter(Parameter.TODAY) != null; if (dayBack || dayNext || today) { parseDateParamAfterDateSwitcher(dayBack, dayNext, today); } String actionWorklogIdValue = getHttpRequest().getParameter(Parameter.ACTION_WORKLOG_ID); if ((actionWorklogIdValue != null) && !"".equals(actionWorklogIdValue) && !"$actionWorklogId".equals(actionWorklogIdValue)) { actionWorklogId = Long.valueOf(actionWorklogIdValue); } String actionFlagValue = getHttpRequest().getParameter(Parameter.ACTION_FLAG); if (actionFlagValue != null) { actionFlag = actionFlagValue; } parseMessageParam(); showMoveAllNoPermission = <START> Boolean.valueOf(getHttpRequest().getParameter("showMoveAllNoPermission")); <END> }</code><technical_language>parameter name is isShowMoveAllNoPermission in jttp.vm</technical_language>

Target:
private void beforeActions() { Properties properties = PropertiesUtil.getJttpBuildProperties(); issueCollectorSrc = properties.getProperty(PropertiesUtil.ISSUE_COLLECTOR_SRC); userSettings = settingsHelper.loadUserSettings(); globalSettings = settingsHelper.loadGlobalSettings(); parseDateParam(); boolean dayBack = getHttpRequest().getParameter(Parameter.DAY_BACK) != null; boolean dayNext = getHttpRequest().getParameter(Parameter.DAY_NEXT) != null; boolean today = getHttpRequest().getParameter(Parameter.TODAY) != null; if (dayBack || dayNext || today) { parseDateParamAfterDateSwitcher(dayBack, dayNext, today); } String actionWorklogIdValue = getHttpRequest().getParameter(Parameter.ACTION_WORKLOG_ID); if ((actionWorklogIdValue != null) && !"".equals(actionWorklogIdValue) && !"$actionWorklogId".equals(actionWorklogIdValue)) { actionWorklogId = Long.valueOf(actionWorklogIdValue); } String actionFlagValue = getHttpRequest().getParameter(Parameter.ACTION_FLAG); if (actionFlagValue != null) { actionFlag = actionFlagValue; } parseMessageParam(); showMoveAllNoPermission = Boolean.valueOf(getHttpRequest().getParameter(Parameter.IS_SHOW_MOVE_ALL_NO_PERMISSION)); }
Source:
<code>public HashSet<T> addAll(Iterable<? extends T> elements) { Objects.requireNonNull(elements, "elements is null"); if (isEmpty() && elements instanceof HashSet) { @SuppressWarnings("unchecked") final HashSet<T> set = (HashSet<T>) elements; return set; } <START> if (Collections.isEmpty(elements) || this.equals(elements)){ <END> return this; } else { return new HashSet<>(addAll(tree, elements)); } }</code><technical_language>new is this HashSet elements equal adds overhead for other cases. Please restore previous version</technical_language>

Target:
public HashSet<T> addAll(Iterable<? extends T> elements) { Objects.requireNonNull(elements, "elements is null"); if (isEmpty() && elements instanceof HashSet) { @SuppressWarnings("unchecked") final HashSet<T> set = (HashSet<T>) elements; return set; } final HashArrayMappedTrie<T, T> that = addAll(tree, elements); if (that.size() == tree.size()) { return this; } else { return new HashSet<>(that); } }
Source:
<code><START> protected int getSize() { <END> return queue.size(); }</code><technical_language>package private? suggestion int getSize() {</technical_language>

Target:
int getSize() { return queue.size(); }
Source:
<code><START> public MapEnvironment getEnv() { <END> return env; }</code><technical_language>I leave package protected public, interested in actual environment</technical_language>

Target:
protected MapEnvironment getEnv() { return env; }
Source:
<code>public Collection<PluginMeta> get(Map<String, String> attributes) throws InfrastructureException { <START> String pluginsAttribute = <END> attributes.getOrDefault(Constants.WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE, null); String editorAttribute = attributes.getOrDefault(Constants.WORKSPACE_TOOLING_EDITOR_ATTRIBUTE, null); if (pluginRegistry == null && (!Strings.isNullOrEmpty(pluginsAttribute) || !Strings.isNullOrEmpty(editorAttribute))) { throw new InfrastructureException(CHE_REGISTRY_MISSING_ERROR); } if (Strings.isNullOrEmpty(editorAttribute) && Strings.isNullOrEmpty(pluginsAttribute)) { return emptyList(); } ArrayList<Pair<String, String>> metasIdsVersions = new ArrayList<>(); if (!isNullOrEmpty(pluginsAttribute)) { String[] plugins = pluginsAttribute.split(" *, *"); if (plugins.length != 0) { Collection<Pair<String, String>> pluginsIdsVersions = parseIdsVersions(plugins); metasIdsVersions.addAll(pluginsIdsVersions); } } if (!isNullOrEmpty(editorAttribute)) { Collection<Pair<String, String>> editorIdVersionCollection = parseIdsVersions(editorAttribute); if (editorIdVersionCollection.size() > 1) { throw new InfrastructureException( "Multiple editors found in workspace config attributes. " + "It is not supported. Please, use one editor only."); } metasIdsVersions.addAll(editorIdVersionCollection); } return getMetas(metasIdsVersions); }</code><technical_language>check map is null? Otherwise, NPE I suppose</technical_language>

Target:
public Collection<PluginMeta> get(Map<String, String> attributes) throws InfrastructureException { if (attributes == null) { return emptyList(); } String pluginsAttribute = attributes.getOrDefault(Constants.WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE, null); String editorAttribute = attributes.getOrDefault(Constants.WORKSPACE_TOOLING_EDITOR_ATTRIBUTE, null); if (Strings.isNullOrEmpty(editorAttribute) && Strings.isNullOrEmpty(pluginsAttribute)) { return emptyList(); } if (pluginRegistry == null) { throw new InfrastructureException(CHE_REGISTRY_MISSING_ERROR); } ArrayList<Pair<String, String>> metasIdsVersions = new ArrayList<>(); if (!isNullOrEmpty(pluginsAttribute)) { String[] plugins = pluginsAttribute.split(" *, *"); if (plugins.length != 0) { Collection<Pair<String, String>> pluginsIdsVersions = parseIdsVersions(plugins); metasIdsVersions.addAll(pluginsIdsVersions); } } if (!isNullOrEmpty(editorAttribute)) { Collection<Pair<String, String>> editorIdVersionCollection = parseIdsVersions(editorAttribute); if (editorIdVersionCollection.size() > 1) { throw new InfrastructureException( "Multiple editors found in workspace config attributes. " + "It is not supported. Please, use one editor only."); } metasIdsVersions.addAll(editorIdVersionCollection); } return getMetas(metasIdsVersions); }
Source:
<code>public static List<File> getTestInputFilesNoPartial(FilenameFilter filter) { File[] testFiles = getPackagePath().toFile().listFiles(filter); <START> return Lists.newArrayList(testFiles); <END> }</code><technical_language>Arrays.asList(testFiles) saves copying array</technical_language>

Target:
public static List<File> getTestInputFilesNoPartial(FilenameFilter filter) { File[] testFiles = getPackagePath().toFile().listFiles(filter); return Arrays.asList(testFiles); }
Source:
<code>public @NonNull List<E> subList(int fromIndex, int toIndex) { <START> throw new UnsupportedOperationException("No subList(fromIndex, toIndex) in " + this.getClass().getName()); END> }</code><technical_language>easy enough fun implement... if returned list is backed original list (read-only)</technical_language>

Target:
public @NonNull List<E> subList(int fromIndex, int toIndex) { throw new UnsupportedOperationException("No subList(int, int) in " + this.getClass().getName()); }
Source:
<code>private Diamond3iIterable(Vector3ic origin, int startDistance, int maxDistance) { Preconditions.checkArgument(startDistance < maxDistance, "startDistance must be < maxDistance"); Preconditions.checkArgument(maxDistance >= 0, "maxDistance must be >= 0"); <START> Preconditions.checkArgument(startDistance >= 0, "maxDistance must be >= 0"); <END> this.origin.set(origin); this.endDistance = maxDistance; this.startDistance = startDistance; }</code><technical_language>Copy paste error, startDistance maxDistance</technical_language>

Target:
private Diamond3iIterable(Vector3ic origin, int startDistance, int maxDistance) { Preconditions.checkArgument(startDistance < maxDistance, "startDistance must be < maxDistance"); Preconditions.checkArgument(maxDistance >= 0, "maxDistance must be >= 0"); Preconditions.checkArgument(startDistance >= 0, "startDistance must be >= 0"); this.origin.set(origin); this.endDistance = maxDistance; this.startDistance = startDistance; }
Source:
<code>private boolean isEditorsClean() { for (EditorPartPresenter editorPartPresenter : editorAgentProvider.get().getOpenedEditors()) { if (editorPartPresenter.isDirty()) { return false; } } <START> return true; <END> }</code><technical_language>return editorAgentProvider.get().getOpenedEditors().stream().noneMatch(editor -> editor.isDirty())</technical_language>

Target:
private boolean isEditorsClean() { return editorAgentProvider .get() .getOpenedEditors() .stream() .noneMatch(EditorPartPresenter::isDirty); }
Source:
<code>public InstructorCourseEditPageData(AccountAttributes account, CourseAttributes course, List<InstructorAttributes> instructorList, InstructorAttributes currentInstructor, int instructorToShowIndex, List<String> sectionNames, List<String> feedbackNames) { super(account); instructorPanelList = new ArrayList<CourseEditInstructorPanel>(); this.course = course; this.instructorToShowIndex = instructorToShowIndex; this.currentInstructor = currentInstructor; createButtons(); <START> createInstructorPanelList(instructorList, sectionNames, feedbackNames); <END> addInstructorPanel = createInstructorPanel(instructorPanelList.size() + 1, null, sectionNames, feedbackNames); }</code><technical_language>connect createInstructorPanelList() object initialisation. Try moving instructorPanelList = new ArrayList<... method, do a instructorPanelList = createInstructorPanelList(... done for addInstructorPanel below</technical_language>

Target:
public InstructorCourseEditPageData(AccountAttributes account, CourseAttributes course, List<InstructorAttributes> instructorList, InstructorAttributes currentInstructor, int instructorToShowIndex, List<String> sectionNames, List<String> feedbackNames) { super(account); this.course = course; this.instructorToShowIndex = instructorToShowIndex; createButtons(currentInstructor); instructorPanelList = createInstructorPanelList(currentInstructor, instructorList, sectionNames, feedbackNames); addInstructorPanel = createInstructorPanel(currentInstructor, instructorPanelList.size() + 1, null, sectionNames, feedbackNames); }
Source:
<code><START> private static String getMimeType(String path) { <END> if (path.endsWith(".png")) { return "image/png"; } else if (path.endsWith(".gif")) { return "image/gif"; } else if (path.endsWith(".jpg") || path.endsWith(".jpeg")) { return "image/jpeg"; } return null; }</code><technical_language>path = path.toLowerCase()</technical_language>

Target:
private static String getMimeType(String path) { int d = path.lastIndexOf('.'); if (d == -1) { return null; } String ext = path.substring(d + 1); return TYPES.get(ext.toLowerCase()); }
Source:
<code>protected EC2Cloud(String id, boolean useInstanceProfileForCredentials, String credentialsId, String privateKey, String sshKeysCredentialsId, String instanceCapStr, List<? extends SlaveTemplate> templates, String roleArn, String roleSessionName) { super(id); this.useInstanceProfileForCredentials = useInstanceProfileForCredentials; this.roleArn = roleArn; this.roleSessionName = roleSessionName; this.credentialsId = credentialsId; this.sshKeysCredentialsId = sshKeysCredentialsId; <START> if (this.sshKeysCredentialsId == null && privateKey != null){ <END> migratePrivateSshKeyToCredential(privateKey); } if (templates == null) { this.templates = Collections.emptyList(); } else { this.templates = templates; } if (instanceCapStr == null || instanceCapStr.isEmpty()) { this.instanceCap = Integer.MAX_VALUE; } else { this.instanceCap = Integer.parseInt(instanceCapStr); } readResolve(); }</code><technical_language>This in readResolve()</technical_language>

Target:
protected EC2Cloud(String id, boolean useInstanceProfileForCredentials, String credentialsId, String privateKey, String sshKeysCredentialsId, String instanceCapStr, List<? extends SlaveTemplate> templates, String roleArn, String roleSessionName) { super(id); this.useInstanceProfileForCredentials = useInstanceProfileForCredentials; this.roleArn = roleArn; this.roleSessionName = roleSessionName; this.credentialsId = credentialsId; this.sshKeysCredentialsId = sshKeysCredentialsId; if (this.sshKeysCredentialsId == null && ( this.privateKey != null || privateKey != null)){ migratePrivateSshKeyToCredential(this.privateKey != null ? this.privateKey.getPrivateKey() : privateKey); } this.privateKey = null; if (templates == null) { this.templates = Collections.emptyList(); } else { this.templates = templates; } if (instanceCapStr == null || instanceCapStr.isEmpty()) { this.instanceCap = Integer.MAX_VALUE; } else { this.instanceCap = Integer.parseInt(instanceCapStr); } readResolve(); }
Source:
<code>public JsonWebToken currentPrincipal() { Objects.requireNonNull(httpServletRequest, "HTTP Servlet Request is required to produce a JSonWebToken principal."); final Object tokenAttribute = httpServletRequest.getAttribute(JsonWebToken.class.getName()); <START> if (tokenAttribute != null && Function.class.isInstance(tokenAttribute)) { <END> return (JsonWebToken) Function.class.cast(tokenAttribute).apply(httpServletRequest); } return null; }</code><technical_language>null check needed class.isInstance() call. Method returns false passing a null argument</technical_language>

Target:
public JsonWebToken currentPrincipal() { Objects.requireNonNull(httpServletRequest, "HTTP Servlet Request is required to produce a JSonWebToken principal."); final Object tokenAttribute = httpServletRequest.getAttribute(JsonWebToken.class.getName()); if (Function.class.isInstance(tokenAttribute)) { return (JsonWebToken) Function.class.cast(tokenAttribute).apply(httpServletRequest); } return null; }
Source:
<code>public void currentPlaylistIndexEvent(PlayerEvent event) { <START> percentChangeEvent(event.getPlayerId(), CommandType.CURRTRACK, event.getPlayer().getCurrentPlaylistIndex()); <END> }</code><technical_language>I assume PercentType renamed method clear, this (and others here) a case DecimalType ([parent class of PercentType](<LINK_0> is more State</technical_language>

Target:
public void currentPlaylistIndexEvent(PlayerEvent event) { numberChangeEvent(event.getPlayerId(), CommandType.CURRTRACK, event.getPlayer().getCurrentPlaylistIndex()); }
Source:
<code>private void goThroughShop() { mainMenu(MAIN_SHOP); <START> shopScreen(SHOP_BACK); <END> }</code><technical_language>Please extend this part of EndToEnd test test shop. <review,testing</technical_language>

Target:
private void goThroughShop() { mainMenu(MAIN_SHOP); assertEquals(State.getSkin(), Style.getNoob()); shopScreen(SHOP_LIST); shopScreen(SHOP_LIST); assertNotEquals(State.getSkin(), Style.getNoob()); shopScreen(SHOP_BACK); }
Source:
<code>private Status parseStatusFromResult(String result) { try { JAXBContext context = JAXBContext.newInstance("com.youview.refdata.schemas.youviewstatusreport._2010_12_07"); Unmarshaller unmarshaller = context.createUnmarshaller(); StatusReport report = (StatusReport) unmarshaller.unmarshal(new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8))); TransactionReportType txnReport = report.getTransactionReport().get(0); <START> switch (txnReport.getState()) { <END> case ACCEPTED: return Status.ACCEPTED; case COMMITTED: return Status.COMMITTED; case COMMITTING: return Status.COMMITTING; case FAILED: return Status.FAILED; case PUBLISHED: return Status.PUBLISHED; case PUBLISHING: return Status.PUBLISHING; case QUARANTINED: return Status.QUARANTINED; case VALIDATING: return Status.VALIDATING; default: return Status.UNKNOWN; } } catch (JAXBException e) { throw Throwables.propagate(e); } }</code><technical_language>move this switch a separated method</technical_language>

Target:
private Status parseStatusFromResult(String result) { try { JAXBContext context = JAXBContext.newInstance("com.youview.refdata.schemas.youviewstatusreport._2010_12_07"); Unmarshaller unmarshaller = context.createUnmarshaller(); StatusReport report = (StatusReport) unmarshaller.unmarshal(new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8))); TransactionReportType txnReport = Iterables.getOnlyElement(report.getTransactionReport()); switch (txnReport.getState()) { case ACCEPTED: return Status.ACCEPTED; case COMMITTED: return Status.COMMITTED; case COMMITTING: return Status.COMMITTING; case FAILED: return Status.FAILED; case PUBLISHED: return Status.PUBLISHED; case PUBLISHING: return Status.PUBLISHING; case QUARANTINED: return Status.QUARANTINED; case VALIDATING: return Status.VALIDATING; default: return Status.UNKNOWN; } } catch (JAXBException e) { throw Throwables.propagate(e); } }
Source:
<code>private static void checkTerminateFailures() { synchronized (fTestFailedToTerminate) { <START> while (fTerminateThreadsRunning > 0) { <END> try { fTestFailedToTerminate.wait(500); } catch (InterruptedException e) { } } if (fTestFailedToTerminate.isEmpty() == false) { StringBuffer buffer = new StringBuffer(); for (String failedName : fTestFailedToTerminate) { buffer.append("\nTermination failed for test " + failedName); } fTestFailedToTerminate.clear(); Assert.assertTrue(buffer.toString(), false); } } }</code><technical_language>this infinite loop</technical_language>

Target:
private static void checkTerminateFailures() { synchronized (fTestFailedToTerminate) { while (fTerminateThreadsRunning > 0) { try { fTestFailedToTerminate.wait(500); } catch (InterruptedException e) { } } if (fTestFailedToTerminate.isEmpty() == false) { StringBuilder buffer = new StringBuilder(); for (String failedName : fTestFailedToTerminate) { buffer.append("\nTermination failed for test " + failedName); } fTestFailedToTerminate.clear(); Assert.assertTrue(buffer.toString(), false); } } }
Source:
<code>public Collection<Object> getAttributeValues(IAtsWorkItem workItem, IAttributeType attributeType) throws OseeCoreException { Set<Object> results = new HashSet<Object>(); Artifact artifact = WorkItemUtil.get(workItem); if (artifact == null) { throw new OseeArgumentException("Can't Find Artifact matching " + workItem.toStringWithId()); <START> } <END> IAttributeType attrType = AttributeTypeManager.getType(attributeType); if (attrType == null) { throw new OseeArgumentException(String.format("Can't resolve Attribute Type [%s]", attributeType)); } else { results.addAll(artifact.getAttributeValues(attributeType)); } return results; }</code><technical_language>Conditions class checkNotNull method, lines. this class reduce some of this code more readable. consider part of a larger refactor/code reduction</technical_language>

Target:
public Collection<Object> getAttributeValues(IAtsWorkItem workItem, IAttributeType attributeType) throws OseeCoreException { Artifact artifact = WorkItemUtil.get(workItem); Conditions.checkNotNull(artifact, "workItem", "Can't Find Artifact matching " + workItem.toStringWithId()); IAttributeType attrType = AttributeTypeManager.getType(attributeType); if (attrType == null) { throw new OseeArgumentException(String.format("Can't resolve Attribute Type [%s]", attributeType)); } return artifact.getAttributeValues(attributeType); }
Source:
<code>public void fireEvents(TaskType taskType, long delay, Object entity) throws InterruptedException { final String WaitForLaunch = "WaitForLaunch".intern(); final String PoweringUp = "Powering up".intern(); final String Up = "Up".intern(); final String PoweredDown = "Powering down".intern(); final String Down = "Down".intern(); VM vm = null; Host host = null; StorageDomain storageDomain = null; <START> if (entity instanceof VM){ <END> vm = (VM) entity; } else if (entity instanceof Host){ host = (Host) entity; } else if (entity instanceof StorageDomain){ storageDomain = (StorageDomain) entity; } else { log.error("{} unsupported entity type for events", entity); } switch (taskType){ case START_VM: vmUpdateStatus(vm, VM.VMStatus.WaitForLaunch, delay / 2, WaitForLaunch, false); vmUpdateStatus(vm, VM.VMStatus.PoweringUp, delay / 2, PoweringUp, false); break; case START_VM_AS_UP: vmUpdateStatus(vm, VM.VMStatus.Up, delay, Up, true); break; case SHUTDOWN_VM: vmUpdateStatus(vm, VM.VMStatus.PoweredDown, delay, PoweredDown, false); if (vm != null) { vm.getHost().getRunningVMs().remove(vm.getId()); } vmUpdateStatus(vm, VM.VMStatus.Down, 0, Down, true); break; default: log.error("Unhandled status detected."); break; } }</code><technical_language>I understand is finished I do a need for it. is goal this code</technical_language>

Target:
public void fireEvents(TaskType taskType, long delay, Object entity) throws InterruptedException { final String WaitForLaunch = "WaitForLaunch".intern(); final String PoweringUp = "Powering up".intern(); final String Up = "Up".intern(); final String PoweredDown = "Powering down".intern(); final String Down = "Down".intern(); VM vm = (VM) entity; switch (taskType){ case START_VM: ExecutorService srv_preUp = getNewService(); vmUpdateStatus(vm, VM.VMStatus.WaitForLaunch, delay, WaitForLaunch, srv_preUp); vmUpdateStatus(vm, VM.VMStatus.PoweringUp, delay, PoweringUp, srv_preUp); break; case START_VM_AS_UP: ExecutorService srv_up = getNewService(); vmUpdateStatus(vm, VM.VMStatus.Up, delay, Up, srv_up); break; case SHUTDOWN_VM: ExecutorService srv_down = getNewService(); vmUpdateStatus(vm, VM.VMStatus.PoweredDown, delay, PoweredDown, srv_down); if (vm != null) { vm.getHost().getRunningVMs().remove(vm.getId()); } vmUpdateStatus(vm, VM.VMStatus.Down, 0, Down, srv_down); break; default: log.error("Unhandled status detected."); break; } }
Source:
<code>public Cursor convert(final NakadiCursor nakadiCursor) { final boolean zeroPaddedOffsets = featureToggleService.isFeatureEnabled(FeatureToggleService.Feature.ZERO_PADDED_OFFSETS); final String offset; if (nakadiCursor.getOffset().equals("-1")) { offset = Cursor.BEFORE_OLDEST_OFFSET; } else { if (zeroPaddedOffsets) { <START> offset = StringUtils.leftPad(nakadiCursor.getOffset(), 18, '0'); <END> } else { offset = nakadiCursor.getOffset(); } } return new Cursor( nakadiCursor.getPartition(), offset); }</code><technical_language>a constant for 18</technical_language>

Target:
public Cursor convert(final NakadiCursor nakadiCursor) { final boolean zeroPaddedOffsets = featureToggleService.isFeatureEnabled(FeatureToggleService.Feature.ZERO_PADDED_OFFSETS); final String offset; if (nakadiCursor.getOffset().equals("-1")) { offset = Cursor.BEFORE_OLDEST_OFFSET; } else { if (zeroPaddedOffsets) { offset = StringUtils.leftPad(nakadiCursor.getOffset(), CURSOR_OFFSET_LENGTH, '0'); } else { offset = nakadiCursor.getOffset(); } } return new Cursor( nakadiCursor.getPartition(), offset); }
Source:
<code>public long getTimeInMillisSinceEpoch() { <START> return SystemClock.currentThreadTimeMillis(); <END> }</code><technical_language>This right - [the docs](<LINK_0> SystemClock.currentThreadTimeMillis() is: >milliseconds running in current thread. This method is supposed return wall clock time, right? If I methods in SystemClock - for measuring elapsed time events</technical_language>

Target:
public long getTimeInMillisSinceEpoch() { Calendar currentTime = Calendar.getInstance(); long offset = currentTime.get(Calendar.ZONE_OFFSET) + currentTime.get(Calendar.DST_OFFSET); return currentTime.getTimeInMillis() + offset; }
Source:
<code>public void testAddItem() { Category category = new Category(new NamespacedKey(plugin, "items_test"), new CustomItem(Material.DIAMOND_AXE, "&6Testing")); SlimefunItem item = SlimefunMocks.mockSlimefunItem(plugin, "CATEGORY_ITEMS_TEST_ITEM", new CustomItem(Material.BAMBOO, "&6Test Bamboo")); item.setCategory(category); item.register(plugin); item.load(); Assertions.assertEquals(1, category.getItems().size()); <START> item.setCategory(category); <END> item.setCategory(category); Assertions.assertEquals(1, category.getItems().size()); Assertions.assertThrows(IllegalArgumentException.class, () -> category.add(null)); Assertions.assertTrue(category.getItems().contains(item)); }</code><technical_language>check size this one. checking intended initial behaviour a checked behaviour (dupe)</technical_language>

Target:
public void testAddItem() { Category category = new Category(new NamespacedKey(plugin, "items_test"), new CustomItem(Material.DIAMOND_AXE, "&6Testing")); SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CATEGORY_ITEMS_TEST_ITEM", new CustomItem(Material.BAMBOO, "&6Test Bamboo")); item.setCategory(category); item.register(plugin); item.load(); Assertions.assertTrue(category.getItems().contains(item)); Assertions.assertEquals(1, category.getItems().size()); item.setCategory(category); Assertions.assertEquals(1, category.getItems().size()); Assertions.assertThrows(IllegalArgumentException.class, () -> category.add(null)); }
Source:
<code>public void testWhenAnyResultFirstError() { final Exception error = new RuntimeException("This task failed."); runTaskTest(new Callable<Task<?>>() { @Override <START> public Task<?> call() throws Exception { <END> final ArrayList<Task<Void>> tasks = new ArrayList<Task<Void>>(); final Task<Void> firstToCompleteError = Task.callInBackground(new Callable<Void>() { @Override public Void call() throws Exception { Thread.sleep(50); throw error; } }); tasks.addAll(launchTasksWithRandomCompletions(10)); tasks.add(firstToCompleteError); return Task.whenAnyResult(tasks).continueWith(new Continuation<Task<Void>, Object>() { @Override public Object then(Task<Task<Void>> task) throws Exception { assertTrue(task.isCompleted()); assertFalse(task.isFaulted()); assertFalse(task.isCancelled()); assertEquals(task.getResult(), firstToCompleteError); assertTrue(task.getResult().isCompleted()); assertFalse(task.getResult().isCancelled()); assertTrue(task.getResult().isFaulted()); return null; } }); } }); }</code><technical_language>a non-wildcard result whenAnyResult</technical_language>

Target:
public void testWhenAnyResultFirstError() { final Exception error = new RuntimeException("This task failed."); runTaskTest(new Callable<Task<?>>() { @Override public Task<?> call() throws Exception { final ArrayList<Task<Integer>> tasks = new ArrayList<>(); final Task<Integer> firstToCompleteError = Task.callInBackground(new Callable<Integer>() { @Override public Integer call() throws Exception { Thread.sleep(50); throw error; } }); tasks.addAll(launchTasksWithRandomCompletions(5)); tasks.add(firstToCompleteError); tasks.addAll(launchTasksWithRandomCompletions(5)); return Task.whenAnyResult(tasks).continueWith(new Continuation<Task<Integer>, Object>() { @Override public Object then(Task<Task<Integer>> task) throws Exception { assertTrue(task.isCompleted()); assertFalse(task.isFaulted()); assertFalse(task.isCancelled()); assertEquals(firstToCompleteError, task.getResult()); assertTrue(task.getResult().isCompleted()); assertFalse(task.getResult().isCancelled()); assertTrue(task.getResult().isFaulted()); assertEquals(error, task.getResult().getError()); return null; } }); } }); }
Source:
<code>public void addsMultipleCookies() throws IOException { final String setcookie = "Set-Cookie: xoo=value?;Path=/;"; final String xoo = "xoo"; final String bar = "bar"; final String value = "value?"; MatcherAssert.assertThat( new RsPrint( new RsWithCookie( new RsWithCookie( new RsEmpty(), xoo, value, <START> RsWithCookieTest.PATH <END> ), bar, "worksToo?", "Path=/2nd/path/" ) ).print(), Matchers.equalTo( Joiner.on(RsWithCookieTest.CRLF).join( RsWithCookieTest.HTTP_OK, setcookie, "Set-Cookie: bar=worksToo?;Path=/2nd/path/;", "", "" ) ) ); }</code><technical_language>@dalifreire I another unique path get rid of shared PATH variable</technical_language>

Target:
public void addsMultipleCookies() throws IOException { final String qux = "qux"; final String bar = "bar"; final String value = "value?"; final String path = "Path=/qux"; MatcherAssert.assertThat( new RsPrint( new RsWithCookie( new RsWithCookie( new RsEmpty(), qux, value, path ), bar, "worksToo?", "Path=/2nd/path/" ) ).print(), Matchers.equalTo( RsWithCookieTest.cookies( RsWithCookieTest.formatCookie(qux, value, path), "bar=worksToo?;Path=/2nd/path/" ) ) ); }
Source:
<code>protected void doWrite(List<? extends Variant> variants) { numVariantsWritten += variants.size(); if(numVariantsWritten % 1000 == 0) { logger.info("Num variants written " + numVariantsWritten); <START> } <END> for (Variant variant : variants) { variant.setAnnotation(null); String id = variantConverter.buildStorageId(variant); for (VariantSourceEntry variantSourceEntry : variant.getSourceEntries().values()) { if (!variantSourceEntry.getFileId().equals(fileId)) { continue; } BasicDBObject query = new BasicDBObject("_id", id) .append(DBObjectToVariantConverter.CHROMOSOME_FIELD, variant.getChromosome()) .append(DBObjectToVariantConverter.START_FIELD, variant.getStart()); BasicDBObject addToSet = new BasicDBObject() .append(DBObjectToVariantConverter.FILES_FIELD, sourceEntryConverter.convertToStorageType(variantSourceEntry)); if (includeStats) { List<DBObject> sourceEntryStats = statsConverter.convertCohortsToStorageType(variantSourceEntry.getCohortStats(), variantSourceEntry.getStudyId(), variantSourceEntry.getFileId()); addToSet.put(DBObjectToVariantConverter.STATS_FIELD, new BasicDBObject("$each", sourceEntryStats)); } if (variant.getIds() != null && !variant.getIds().isEmpty()) { addToSet.put(DBObjectToVariantConverter.IDS_FIELD, new BasicDBObject("$each", variant.getIds())); } BasicDBObject update = new BasicDBObject() .append("$addToSet", addToSet) .append("$setOnInsert", variantConverter.convertToStorageType(variant)); bulk.find(query).upsert().updateOne(update); currentBulkSize++; } if (currentBulkSize >= bulkSize) { executeBulk(); } } if(currentBulkSize<bulkSize){ executeBulk(); } }</code><technical_language>This handled a ChunkListener</technical_language>

Target:
protected void doWrite(List<? extends Variant> variants) { for (Variant variant : variants) { String id = MongoDBHelper.buildStorageId(variant.getChromosome(), variant.getStart(), variant.getReference(), variant.getAlternate()); BasicDBObject query = new BasicDBObject("_id", id) .append(DBObjectToVariantConverter.CHROMOSOME_FIELD, variant.getChromosome()) .append(DBObjectToVariantConverter.START_FIELD, variant.getStart()); DBObject update = variantToMongoDbObjectConverter.convert(variant); bulk.find(query).upsert().updateOne(update); currentBulkSize++; } executeBulk(); }
Source:
<code>public static Set<Concept> conceptSetHelper(String descriptor) { <START> Set<Concept> ret = new HashSet<>(conceptListHelper(descriptor)); <END> return ret; }</code><technical_language>remove code for this method instead delegated conceptListHelper(arg..); do methods treat collections in way</technical_language>

Target:
public static Set<Concept> conceptSetHelper(String descriptor) { Set<Concept> ret = new HashSet<>(); if (descriptor == null || descriptor.length() == 0) { return ret; } ConceptService cs = Context.getConceptService(); for (StringTokenizer st = new StringTokenizer(descriptor, "|"); st.hasMoreTokens();) { String s = st.nextToken().trim(); boolean isSet = s.startsWith("set:"); if (isSet) { s = s.substring(4).trim(); } Concept c = null; if (s.startsWith("name:")) { String name = s.substring(5).trim(); c = cs.getConceptByName(name); } else { try { c = cs.getConcept(Integer.valueOf(s.trim())); } catch (Exception ex) } if (c != null) { if (isSet) { List<Concept> inSet = cs.getConceptsByConceptSet(c); ret.addAll(inSet); } else { ret.add(c); } } } return ret; }
Source:
<code>public Result apply(AggregationNode parent, Captures captures, Context context) { if (!parent.hasDefaultOutput() || parent.getOutputSymbols().size() != 1) { return Result.empty(); } Map<Symbol, AggregationNode.Aggregation> assignments = parent.getAggregations(); for (Map.Entry<Symbol, AggregationNode.Aggregation> entry : assignments.entrySet()) { AggregationNode.Aggregation aggregation = entry.getValue(); requireNonNull(aggregation, "aggregation is null"); <START> if (!"count".equals(functionManager.getFunctionMetadata(aggregation.getFunctionHandle()).getName()) || !aggregation.getArguments().isEmpty()) { <END> return Result.empty(); } } if (!assignments.isEmpty() && isScalar(parent.getSource(), context.getLookup())) { return Result.ofPlanNode(new ValuesNode( parent.getId(), parent.getOutputSymbols(), ImmutableList.of(ImmutableList.of(constant(1L, BIGINT))))); } return Result.empty(); }</code><technical_language>other this...? cc: @rongrong</technical_language>

Target:
public Result apply(AggregationNode parent, Captures captures, Context context) { if (!parent.hasDefaultOutput() || parent.getOutputVariables().size() != 1) { return Result.empty(); } Map<VariableReferenceExpression, AggregationNode.Aggregation> assignments = parent.getAggregations(); for (Map.Entry<VariableReferenceExpression, AggregationNode.Aggregation> entry : assignments.entrySet()) { AggregationNode.Aggregation aggregation = entry.getValue(); requireNonNull(aggregation, "aggregation is null"); if (!functionResolution.isCountFunction(aggregation.getFunctionHandle()) || !aggregation.getArguments().isEmpty()) { return Result.empty(); } } if (!assignments.isEmpty() && isScalar(parent.getSource(), context.getLookup())) { return Result.ofPlanNode(new ValuesNode( parent.getId(), parent.getOutputVariables(), ImmutableList.of(ImmutableList.of(constant(1L, BIGINT))))); } return Result.empty(); }