auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code><START> public static void init(MainActivity mainActivity, Bitmap first_layer) { <END> instance = new LayersDialog(mainActivity, first_layer); }</code><technical_language>I add a check if instance is != null, this, overwrite current instance if null. create a new instance in getInstance methode, if instance == null</technical_language>

Target:
public static void init(MainActivity mainActivity, Bitmap first_layer) { if (instance == null) instance = new LayersDialog(mainActivity, first_layer); }
Source:
<code>private static void writeToDisk(final Context context, final String filename, final ExtendedJSONObject pickle) { PrintStream ps = null; try { final FileOutputStream fos = context.openFileOutput(filename, Context.MODE_PRIVATE); ps = new PrintStream(fos); ps.print(pickle.toJSONString()); Logger.debug(LOG_TAG, "Persisted " + pickle.keySet().size() + " account settings to " + filename + "."); } catch (Exception e) { Logger.warn(LOG_TAG, "Caught exception persisting account settings to " + filename + "; ignoring.", e); } finally { if (ps != null) { <START> ps.close(); <END> } } }</code><technical_language>This is incorrect. If ps is null, need close fos. need rearrange try block acknowledge existence of resources - nesting is usual approach</technical_language>

Target:
private static void writeToDisk(final Context context, final String filename, final ExtendedJSONObject pickle) { try { final FileOutputStream fos = context.openFileOutput(filename, Context.MODE_PRIVATE); try { final PrintStream ps = new PrintStream(fos); try { ps.print(pickle.toJSONString()); Logger.debug(LOG_TAG, "Persisted " + pickle.keySet().size() + " account settings to " + filename + "."); } finally { ps.close(); } } finally { fos.close(); } } catch (Exception e) { Logger.warn(LOG_TAG, "Caught exception persisting account settings to " + filename + "; ignoring.", e); } }
Source:
<code><START> protected ITimeGraphPresentationProvider getPresentationProvider() { <END> return fPresentation; }</code><technical_language>This is API break, wait for 5.0</technical_language>

Target:
protected ITimeGraphPresentationProvider2 getPresentationProvider() { return fPresentation; }
Source:
<code>public void onChanged(List<CidrAddress> added, List<CidrAddress> removed) { logger.debug("ip address change: added {}, removed {}", added, removed); <START> deactivate(); <END> start(); }</code><technical_language>previous implementation dealt delta restart service. Especially if permanently changing IP addresses (e.g. IPv6 privacy extensions), while keeping server IP stable, this some unnecessary service interruption</technical_language>

Target:
public void onChanged(List<CidrAddress> added, List<CidrAddress> removed) { logger.debug("ip address change: added {}, removed {}", added, removed); close(); start(); }
Source:
<code>public void onCollideWithPlayer(PlayerEntity player) { if(!this.world.isRemote&&(this.inGround||this.getNoClip())&&this.arrowShake <= 0) { boolean flag = this.pickupStatus==AbstractArrowEntity.PickupStatus.ALLOWED||this.pickupStatus==AbstractArrowEntity.PickupStatus.CREATIVE_ONLY&&player.abilities.isCreativeMode||this.getNoClip()&&this.getShooter().getUniqueID()==player.getUniqueID(); if(this.pickupStatus==AbstractArrowEntity.PickupStatus.ALLOWED&&!player.inventory.addItemStackToInventory(this.getArrowStack())) { flag = false; <START> } <END> if(flag) { player.onItemPickup(this, 1); this.remove(); } } }</code><technical_language>Formatting</technical_language>

Target:
public void onCollideWithPlayer(PlayerEntity player) { if(!this.world.isRemote&&(this.inGround||this.getNoClip())&&this.arrowShake <= 0) { boolean flag = this.pickupStatus==AbstractArrowEntity.PickupStatus.ALLOWED ||this.pickupStatus==AbstractArrowEntity.PickupStatus.CREATIVE_ONLY&&player.abilities.isCreativeMode ||this.getNoClip()&&this.getShooter().getUniqueID()==player.getUniqueID(); if(this.pickupStatus==AbstractArrowEntity.PickupStatus.ALLOWED &&!player.inventory.addItemStackToInventory(this.getArrowStack())) flag = false; if(flag) { player.onItemPickup(this, 1); this.remove(); } } }
Source:
<code>public void dateTimeSetAttributesFilters() throws Exception { final ProductProjectionSearch termSearch = ProductProjectionSearch.ofStaged() .withQueryFilters(model -> model.allVariants().attribute().ofDateTime(ATTR_NAME_DATE_TIME_SET) <START> .filtered().by(ZonedDateTime.parse("2002-10-12T23:06:10.204+00:00"))); <END> assertThat(executeAndReturnIds(termSearch)).containsOnly(product1.getId()); final ProductProjectionSearch rangeSearch = ProductProjectionSearch.ofStaged() .withQueryFilters(model -> model.allVariants().attribute().ofDateTime(ATTR_NAME_DATE_TIME_SET) .filtered().byGreaterThanOrEqualTo(ZonedDateTime.parse("2002-10-12T23:06:10.204+00:00"))); assertThat(executeAndReturnIds(rangeSearch)).containsOnly(product1.getId()); }</code><technical_language>Is hardcoded for product1</technical_language>

Target:
public void dateTimeSetAttributesFilters() throws Exception { final ProductProjectionSearch termSearch = ProductProjectionSearch.ofStaged() .withQueryFilters(model -> model.allVariants().attribute().ofDateTime(ATTR_NAME_DATE_TIME_SET) .filtered().by(DATE_TIME_2002_23H)); assertThat(executeAndReturnIds(termSearch)).containsOnly(product1.getId()); final ProductProjectionSearch rangeSearch = ProductProjectionSearch.ofStaged() .withQueryFilters(model -> model.allVariants().attribute().ofDateTime(ATTR_NAME_DATE_TIME_SET) .filtered().byGreaterThanOrEqualTo(DATE_TIME_2002_23H)); assertThat(executeAndReturnIds(rangeSearch)).containsOnly(product1.getId()); }
Source:
<code>public SpecialDay convert(final com.alliander.osgp.adapter.ws.schema.smartmetering.configuration.SpecialDay source, final Type<? extends SpecialDay> destinationType) { <START> final ByteBuffer bb = ByteBuffer.wrap(source.getSpecialDayDate()); <END> final int year = bb.getShort() & 0xFFFF; final int month = bb.get() & 0xFF; final int day = bb.get() & 0xFF; final int weekDay = bb.get() & 0xFF; final SpecialDay specialDay = new SpecialDay(new CosemDate(year, month, day, weekDay), source.getDayId()); return specialDay; }</code><technical_language>Create a CosemDateConverter for this. CosemDateTimeConverter CosemTimeConverter exist</technical_language>

Target:
public SpecialDay convert(final com.alliander.osgp.adapter.ws.schema.smartmetering.configuration.SpecialDay source, final Type<? extends SpecialDay> destinationType) { return new SpecialDay(this.mapperFacade.map(source.getSpecialDayDate(), CosemDate.class), source.getDayId()); }
Source:
<code>public Location newLocationFromString(Map properties, String spec) { String provider=spec, region=null; int split = spec.indexOf(':'); if (split<0) { if (spec.equalsIgnoreCase(getPrefix())) throw new IllegalArgumentException("Cannot use '"+spec+"' as a location ID; it is insufficient. "+ "Try jclouds:aws-ec2 (for example)."); } else { provider = spec.substring(0, split); region = spec.substring(split+1); if (provider.equalsIgnoreCase(JCLOUDS)) { provider = region; region = null; split = provider.indexOf(':'); if (split>=0) { region = provider.substring(split+1); provider = provider.substring(0, split); } } } <START> if (region==null && AWS_REGIONS.contains(provider)) { <END> region = provider; provider = "aws-ec2"; } return new JcloudsLocationFactory( new CredentialsFromEnv(BrooklynProperties.Factory.newEmpty().addFromMap(properties), provider).asMap()). newLocation(region); }</code><technical_language>convinced treating aws-ec2 a default. "us-west-2" is missing; sort of complete list is want maintain here. working for some regions others confusing..</technical_language>

Target:
public Location newLocationFromString(Map properties, String spec) { String provider=spec, region=null; int split = spec.indexOf(':'); if (split<0) { if (spec.equalsIgnoreCase(getPrefix())) throw new IllegalArgumentException("Cannot use '"+spec+"' as a location ID; it is insufficient. "+ "Try jclouds:aws-ec2 (for example)."); } else { provider = spec.substring(0, split); region = spec.substring(split+1); if (provider.equalsIgnoreCase(JCLOUDS)) { provider = region; region = null; split = provider.indexOf(':'); if (split>=0) { region = provider.substring(split+1); provider = provider.substring(0, split); } } } if (region==null && AWS_REGIONS.contains(provider)) { region = provider; provider = "aws-ec2"; log.warn("Use of deprecated location '"+region+"'; in future refer to with explicit provider '"+provider+":"+region+"'"); } return new JcloudsLocationFactory( new CredentialsFromEnv(BrooklynProperties.Factory.newEmpty().addFromMap(properties), provider).asMap()). newLocation(region); }
Source:
<code>public void onClose(KubernetesClientException e) { future.completeExceptionally( new RuntimeException( <START> "Websocket connection is closed. But event about removing is not received.", e)); <END> }</code><technical_language>This is a concrete class in a concrete situation, I error message more concrete, too</technical_language>

Target:
public void onClose(KubernetesClientException e) { future.completeExceptionally( new RuntimeException( "WebSocket connection is closed. But event about removing is not received.", e)); }
Source:
<code>public void removeAuthenticationMethodEvent(final AuthenticationMethodEvent authenticationMethodEvent) { int r = -1; final int l = authenticationMethodEvents.length; for (int i = 0; i < l; i++) { if (authenticationMethodEvents[i] == authenticationMethodEvent) { r = i; break; } } if (r >= 0) { final AuthenticationMethodEvent[] newArray = new AuthenticationMethodEvent[l]; for (int i = 0, j = 0; i < l; i++) { if (j != r) { newArray[j++] = authenticationMethodEvents[i]; <START> } <END> } authenticationMethodEvents = newArray; } }</code><technical_language>ArrayList simplify this code a lot</technical_language>

Target:
public void removeAuthenticationMethodEvent(final AuthenticationMethodEvent authenticationMethodEvent) { int r = -1; final int l = authenticationMethodEvents.length; for (int i = 0; i < l; i++) { if (authenticationMethodEvents[i] == authenticationMethodEvent) { r = i; break; } } if (r >= 0) { final AuthenticationMethodEvent[] newArray = new AuthenticationMethodEvent[l - 1]; for (int i = 0, j = 0; i < l; i++) { if (i != r) { newArray[j++] = authenticationMethodEvents[i]; } } authenticationMethodEvents = newArray; } }
Source:
<code>public HttpRequestExecutingMessageHandler(String uri) { <START> this(uri, (RestTemplate) null); <END> }</code><technical_language>IDEA this cast is redundant: ![redundantcast](<LINK_0></technical_language>

Target:
public HttpRequestExecutingMessageHandler(String uri) { this(uri, null); }
Source:
<code>private void setUriParts(URI uri) { if (uri == null) { throw new IllegalArgumentException("uri is null"); } String theScheme = uri.getScheme(); if (theScheme != null) { scheme = theScheme; } String rawPath = uri.getRawPath(); if (!uri.isOpaque() && schemeSpecificPart == null && (theScheme != null || rawPath != null)) { port = uri.getPort(); host = uri.getHost(); if (rawPath != null) { setPathAndMatrix(rawPath); } String rawQuery = uri.getRawQuery(); if (rawQuery != null) { query = JAXRSUtils.getStructuredParams(rawQuery, "&", false, true); } userInfo = uri.getUserInfo(); schemeSpecificPart = null; } else { schemeSpecificPart = uri.getSchemeSpecificPart(); } <START> if (scheme != null && !"file".equalsIgnoreCase(scheme) && host == null && (query == null || query.isEmpty()) <END> && userInfo == null && uri.getSchemeSpecificPart() != null) { schemeSpecificPart = uri.getSchemeSpecificPart(); } String theFragment = uri.getFragment(); if (theFragment != null) { fragment = theFragment; } }</code><technical_language>@jgallimore, thanks for PR. I CXF assume intrinsic knowledge URI scheme handle in a specific way. For example, handling jar:file? other custom schemes? reply spec list (<LINK_0> explicitly mentions JAX-RS context is REST-over-HTTP (the CXF case), UriBuilder more flexible if general solution found. Hope sense, thank you</technical_language>

Target:
private void setUriParts(URI uri) { if (uri == null) { throw new IllegalArgumentException("uri is null"); } String theScheme = uri.getScheme(); if (theScheme != null) { scheme = theScheme; } String rawPath = uri.getRawPath(); if (!uri.isOpaque() && schemeSpecificPart == null && (theScheme != null || rawPath != null)) { port = uri.getPort(); host = uri.getHost(); if (rawPath != null) { setPathAndMatrix(rawPath); } String rawQuery = uri.getRawQuery(); if (rawQuery != null) { query = JAXRSUtils.getStructuredParams(rawQuery, "&", false, true); } userInfo = uri.getUserInfo(); schemeSpecificPart = null; } else { schemeSpecificPart = uri.getSchemeSpecificPart(); } if (scheme != null && host == null && port == -1 && userInfo == null && CollectionUtils.isEmpty(query) && uri.getSchemeSpecificPart() != null && !schemeSpecificPartMatchesUriPath(uri)) { schemeSpecificPart = uri.getSchemeSpecificPart(); } String theFragment = uri.getFragment(); if (theFragment != null) { fragment = theFragment; } }
Source:
<code>private static Intent prepareAudioLibraryIntent(String title, boolean multiSelect) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(MIME_DATA_TYPE_AUDIO); <START> if (multiSelect) { <END> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); } } return Intent.createChooser(intent, title); }</code><technical_language>Minor nit: this shortened if (multiSelect && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2)</technical_language>

Target:
private static Intent prepareAudioLibraryIntent(String title, boolean multiSelect) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(MIME_DATA_TYPE_AUDIO); if (multiSelect && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); } return Intent.createChooser(intent, title); }
Source:
<code>public String toString() { <START> return "[status=" + status + "]"; <END> }</code><technical_language>spit out class name ot helpful. I remember, other classes same</technical_language>

Target:
public String toString() { return getClass().getSimpleName() + " [status=" + status + "]"; }
Source:
<code>public static SegmentAssignment getSegmentAssignment(HelixManager helixManager, TableConfig tableConfig) { SegmentAssignment segmentAssignment; <START> if (tableConfig.getTableType() == TableType.OFFLINE && Boolean.parseBoolean(tableConfig.getIsDimTable())) { segmentAssignment = new OfflineDimTableSegmentAssignment(); } else if (tableConfig.getTableType() == TableType.OFFLINE) { <END> segmentAssignment = new OfflineSegmentAssignment(); } else { segmentAssignment = new RealtimeSegmentAssignment(); } segmentAssignment.init(helixManager, tableConfig); return segmentAssignment; }</code><technical_language>(nit) suggestion if (tableConfig.getTableType() == TableType.OFFLINE) { return tableConfig.isDimTable() ? new OfflineDimTableSegmentAssignment() : new OfflineSegmentAssignment(); }</technical_language>

Target:
public static SegmentAssignment getSegmentAssignment(HelixManager helixManager, TableConfig tableConfig) { SegmentAssignment segmentAssignment; if (tableConfig.getTableType() == TableType.OFFLINE) { segmentAssignment = tableConfig.isDimTable() ? new OfflineDimTableSegmentAssignment() : new OfflineSegmentAssignment(); } else { segmentAssignment = new RealtimeSegmentAssignment(); } segmentAssignment.init(helixManager, tableConfig); return segmentAssignment; }
Source:
<code>protected void localFileInclusionAttack(HttpMessage msg) { String localFile; <START> String response; <END> Matcher matcher; String payload = null; try { for (int idx = 0; idx < LOCAL_FILE_TARGETS.length; idx++) { localFile = LOCAL_FILE_TARGETS[idx]; payload = MessageFormat.format(ATTACK_HEADER + ATTACK_BODY, localFile); msg.setRequestBody(payload); sendAndReceive(msg); response = msg.getResponseBody().toString(); matcher = LOCAL_FILE_PATTERNS[idx].matcher(response); if (matcher.find()) { newAlert() .setConfidence(Alert.CONFIDENCE_MEDIUM) .setAttack(payload) .setEvidence(matcher.group()) .setMessage(msg) .raise(); } if (isStop()) { return; } } } catch (IOException ex) { log.warn( "XXE Injection vulnerability check failed for payload [" + payload + "] due to an I/O error", ex); } }</code><technical_language>suggestion</technical_language>

Target:
private void localFileInclusionAttack(HttpMessage msg) { String payload = null; try { for (int idx = 0; idx < LOCAL_FILE_TARGETS.length; idx++) { String localFile = LOCAL_FILE_TARGETS[idx]; payload = MessageFormat.format(ATTACK_HEADER + ATTACK_BODY, localFile); msg.setRequestBody(payload); sendAndReceive(msg); String response = msg.getResponseBody().toString(); Matcher matcher = LOCAL_FILE_PATTERNS[idx].matcher(response); if (matcher.find()) { newAlert() .setConfidence(Alert.CONFIDENCE_MEDIUM) .setAttack(payload) .setEvidence(matcher.group()) .setMessage(msg) .raise(); } if (isStop()) { return; } } } catch (IOException ex) { log.warn( "XXE Injection vulnerability check failed for payload [" + payload + "] due to an I/O error", ex); } }
Source:
<code><START> public @Nullable Object columnValue(ColumnName columnName) { <END> return columnValue(columnName, DefaultColumnMapping.INSTANCE); }</code><technical_language>this method final</technical_language>

Target:
public final @Nullable Object columnValue(ColumnName columnName) { return columnValue(columnName, DefaultColumnMapping.INSTANCE); }
Source:
<code>private void addQueryToNode(final XPath xPath, final String nodeName) { <START> List<XPath> xPaths = nodeNameToXPaths.get(nodeName); <END> if (xPaths == null) { xPaths = new ArrayList<>(); nodeNameToXPaths.put(nodeName, xPaths); } xPaths.add(xPath); }</code><technical_language>xPaths xPath similar confusing, rename list xpathsForNode</technical_language>

Target:
private void addQueryToNode(final XPath xPath, final String nodeName) { List<XPath> xPathsForNode = nodeNameToXPaths.get(nodeName); if (xPathsForNode == null) { xPathsForNode = new ArrayList<>(); nodeNameToXPaths.put(nodeName, xPathsForNode); } xPathsForNode.add(xPath); }
Source:
<code>public boolean visit(IResourceDelta delta) throws CoreException { final IResource resource = delta.getResource(); final RepositoryMapping mapping = RepositoryMapping .getMapping(resource); if (mapping == null || mapping.getRepository() != repository) return true; IndexDiffCache cache = Activator.getDefault().getIndexDiffCache(); IndexDiffCacheEntry entry = null; if (cache != null) entry = cache.getIndexDiffCacheEntry(mapping.getRepository()); if (resource instanceof IFolder && delta.getKind() == IResourceDelta.ADDED) { String repoRelativePath = mapping.getRepoRelativePath(resource) + "/"; if (isIgnoredInOldIndex(entry, repoRelativePath)) { <START> return false; END> } filesToUpdate.add(repoRelativePath); resourcesToUpdate.add(resource); return true; } if (delta.getKind() == IResourceDelta.CHANGED && (delta.getFlags() & INTERESTING_CHANGES) == 0) return true; if (resource.getType() != IResource.FILE) return true; String repoRelativePath = mapping.getRepoRelativePath(resource); if (isIgnoredInOldIndex(entry, repoRelativePath)) { return false; } if (resource.getName().equals(GITIGNORE_NAME)) { gitIgnoreChanged = true; return false; } if (repoRelativePath!= null) filesToUpdate.add(repoRelativePath); resourcesToUpdate.add(resource); return true; }</code><technical_language>new folder new .gitignore file somewhere, *must* included in update. returning "false" is wrong - children of new folder visited</technical_language>

Target:
public boolean visit(IResourceDelta delta) throws CoreException { final IResource resource = delta.getResource(); final RepositoryMapping mapping = RepositoryMapping .getMapping(resource); if (mapping == null || mapping.getRepository() != repository) return true; IndexDiffCache cache = Activator.getDefault().getIndexDiffCache(); IndexDiffCacheEntry entry = null; if (cache != null) entry = cache.getIndexDiffCacheEntry(mapping.getRepository()); if (resource instanceof IFolder && delta.getKind() == IResourceDelta.ADDED) { String path = mapping.getRepoRelativePath(resource) + "/"; if (isIgnoredInOldIndex(entry, path)) { return true; } filesToUpdate.add(path); resourcesToUpdate.add(resource); return true; } if (delta.getKind() == IResourceDelta.CHANGED && (delta.getFlags() & INTERESTING_CHANGES) == 0) return true; if (resource.getType() != IResource.FILE) return true; if (resource.getName().equals(GITIGNORE_NAME)) { gitIgnoreChanged = true; return false; } String repoRelativePath = mapping.getRepoRelativePath(resource); if (repoRelativePath == null) { resourcesToUpdate.add(resource); return true; } if (isIgnoredInOldIndex(entry, repoRelativePath)) { return false; } filesToUpdate.add(repoRelativePath); resourcesToUpdate.add(resource); return true; }
Source:
<code>private GerritTopMenus gerritTopMenusWithModule(AbstractModule module) { <START> Injector injector = <END> baseInjector.createChildInjector(module); return injector.getInstance(GerritTopMenus.class); }</code><technical_language>need for variable. inline in return statement</technical_language>

Target:
private GerritTopMenus gerritTopMenusWithModule(AbstractModule module) { return baseInjector.createChildInjector(module).getInstance( GerritTopMenus.class); }
Source:
<code><START> protected void compensate() { <END> getCurrentTaskHandler().compensate(); }</code><technical_language>is NullPointerException</technical_language>

Target:
protected void compensate() { if (hasTaskHandlers()) { getCurrentTaskHandler().compensate(); } else { internalCompensate(); } }
Source:
<code>private void initOptionsIfNeeded() { if(status == null) { status = TF_NewStatus(); } if (options == null) { options = TF_NewSessionOptions(); if(protoBufConfigProto != null) { BytePointer bytePointer = new BytePointer(protoBufConfigProto.toByteArray()); TF_SetConfig(options,bytePointer,bytePointer.getStringBytes().length,status); if (TF_GetCode(status) != TF_OK) { <START> throw new RuntimeException("ERROR: Unable to set value configuration:" + TF_Message(status).getString()); <END> } } } }</code><technical_language>thing..IllegalStateException</technical_language>

Target:
private void initOptionsIfNeeded() { if(status == null) { status = TF_NewStatus(); } if (options == null) { options = TF_NewSessionOptions(); if(protoBufConfigProto != null) { BytePointer bytePointer = new BytePointer(protoBufConfigProto.toByteArray()); TF_SetConfig(options,bytePointer,bytePointer.getStringBytes().length,status); if (TF_GetCode(status) != TF_OK) { throw new IllegalStateException("ERROR: Unable to set value configuration:" + TF_Message(status).getString()); } } } }
Source:
<code>public static ProductGroup get(int id){ return new ProductGroup(dataVault.get(id)); <START> } <END></code><technical_language>happen if ID exist</technical_language>

Target:
public static ProductGroup get(int id){ ProductGroup pg = dataVault.get(id); if(pg == null) return null; return new ProductGroup(pg); }
Source:
<code>private List<ICraftingRecipe> getAllForIngredient(IIngredient target) { Set<Map.Entry<ResourceLocation, IRecipe>> recipes; List<ICraftingRecipe> results = new ArrayList<>(); recipes = ForgeRegistries.RECIPES.getEntries(); for(Map.Entry<ResourceLocation, IRecipe> recipeEntry : recipes) { <START> OreIngredient oi; <END> IRecipe recipe = recipeEntry.getValue(); for (Ingredient ingredient :recipe.getIngredients()){ IIngredient iIngredient =CraftTweakerMC.getIIngredient(ingredient); if (iIngredient == null) continue; if (target.contains(iIngredient)){ if(recipe instanceof MCRecipeBase) results.add((MCRecipeBase) recipe); else results.add(new MCRecipeWrapper(recipe)); } } } return results; }</code><technical_language>for? I assignments it..</technical_language>

Target:
private List<MCRecipeBase> getAllForIngredient(IIngredient target) { Set<Map.Entry<ResourceLocation, IRecipe>> recipes; List<MCRecipeBase> results = new ArrayList<>(); recipes = ForgeRegistries.RECIPES.getEntries(); for(Map.Entry<ResourceLocation, IRecipe> recipeEntry : recipes) { IRecipe recipe = recipeEntry.getValue(); for (Ingredient ingredient :recipe.getIngredients()){ IIngredient iIngredient =CraftTweakerMC.getIIngredient(ingredient); if (iIngredient == null) continue; if (target.contains(iIngredient)){ if(recipe instanceof MCRecipeBase) { results.add((MCRecipeBase) recipe); break; } else { results.add(new MCRecipeWrapper(recipe)); break; } } } } return results; }
Source:
<code>static boolean detect() { final String path = AccessController .doPrivileged(new PrivilegedAction<String>() { public String run() { return System.getProperty("java.library.path"); } }); if (path == null) return false; <START> cygpath = FS.scanPath(path, "cygpath.exe"); <END> return cygpath != null; }</code><technical_language>I put getAbsolutePath() part want a String</technical_language>

Target:
static boolean detect() { final String path = AccessController .doPrivileged(new PrivilegedAction<String>() { public String run() { return System.getProperty("java.library.path"); } }); if (path == null) return false; File found = FS.searchPath(path, "cygpath.exe"); if (found != null) cygpath = found.getPath(); return cygpath != null; }
Source:
<code><START> protected void updateIndex(CanonicalTreeParser base, <END> CanonicalTreeParser ours, CanonicalTreeParser theirs, MergeResult<RawText> result, File of) throws FileNotFoundException, IOException { if (result.containsConflicts()) { add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, 0, 0); add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, 0, 0); add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, 0, 0); mergeResults.put(tw.getPathString(), result); } else { DirCacheEntry dce = new DirCacheEntry(tw.getPathString()); int newMode = mergeFileModes(tw.getRawMode(0), tw.getRawMode(1), tw.getRawMode(2)); dce.setFileMode((newMode == FileMode.MISSING.getBits()) ? FileMode.REGULAR_FILE : FileMode.fromBits(newMode)); dce.setLastModified(of.lastModified()); dce.setLength((int) of.length()); InputStream is = new FileInputStream(of); try { dce.setObjectId(getObjectInserter().insert( Constants.OBJ_BLOB, of.length(), is)); } finally { is.close(); if (inCore) FileUtils.delete(of); } builder.add(dce); } }</code><technical_language>need change this method signature. I leave this method private</technical_language>

Target:
private void updateIndex(CanonicalTreeParser base, CanonicalTreeParser ours, CanonicalTreeParser theirs, MergeResult<RawText> result, File of) throws FileNotFoundException, IOException { if (result.containsConflicts()) { add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, 0, 0); add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, 0, 0); add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, 0, 0); mergeResults.put(tw.getPathString(), result); } else { DirCacheEntry dce = new DirCacheEntry(tw.getPathString()); int newMode = mergeFileModes(tw.getRawMode(0), tw.getRawMode(1), tw.getRawMode(2)); dce.setFileMode((newMode == FileMode.MISSING.getBits()) ? FileMode.REGULAR_FILE : FileMode.fromBits(newMode)); dce.setLastModified(of.lastModified()); dce.setLength((int) of.length()); InputStream is = new FileInputStream(of); try { dce.setObjectId(getObjectInserter().insert( Constants.OBJ_BLOB, of.length(), is)); } finally { is.close(); if (inCore) FileUtils.delete(of); } builder.add(dce); } }
Source:
<code>public BufferPoolsExports() { try { final Class<?> bufferPoolMXBeanClass = Class.forName("java.lang.management.BufferPoolMXBean"); bufferPoolMXBeans.addAll(accessBufferPoolMXBeans(bufferPoolMXBeanClass)); getName = bufferPoolMXBeanClass.getMethod("getName"); getMemoryUsed = bufferPoolMXBeanClass.getMethod("getMemoryUsed"); getTotalCapacity = bufferPoolMXBeanClass.getMethod("getTotalCapacity"); getCount = bufferPoolMXBeanClass.getMethod("getCount"); } catch (ClassNotFoundException e) { <START> LOGGER.info("BufferPoolMXBean not available, not metrics for buffer pools will be exported"); <END> } catch (NoSuchMethodException e) { LOGGER.info("Can not get necessary accessor from BufferPoolMXBean: " + e.getMessage()); } }</code><technical_language>putting this in logs, debug is fine. s/not/no/</technical_language>

Target:
public BufferPoolsExports() { try { final Class<?> bufferPoolMXBeanClass = Class.forName("java.lang.management.BufferPoolMXBean"); bufferPoolMXBeans.addAll(accessBufferPoolMXBeans(bufferPoolMXBeanClass)); getName = bufferPoolMXBeanClass.getMethod("getName"); getMemoryUsed = bufferPoolMXBeanClass.getMethod("getMemoryUsed"); getTotalCapacity = bufferPoolMXBeanClass.getMethod("getTotalCapacity"); getCount = bufferPoolMXBeanClass.getMethod("getCount"); } catch (ClassNotFoundException e) { LOGGER.fine("BufferPoolMXBean not available, no metrics for buffer pools will be exported"); } catch (NoSuchMethodException e) { LOGGER.fine("Can not get necessary accessor from BufferPoolMXBean: " + e.getMessage()); } }
Source:
<code>public Iterable<Attribute> getSubAttributes() { synchronized (subAttributes) { <START> return new LinkedList<>(subAttributes.values()); <END> } }</code><technical_language>ArrayList more efficient here</technical_language>

Target:
public Iterable<Attribute> getSubAttributes() { return ImmutableList.copyOf(subAttributes.values()); }
Source:
<code>public void onInitializeAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SELECTED) { event.setSource(this); event.setClassName(getClass().getName()); event.setPackageName(getContext().getPackageName()); event.setEnabled(isEnabled()); Map<String, CharSequence> map = new HashMap<>(); map.put("rating", String.valueOf((int) getRating())); map.put("num_of_stars", String.valueOf(getNumStars())); event.setContentDescription(ResourceUtil.getFormattedString(getResources(), R.string.rating_bar_selection, map)); return; } <START> super.onInitializeAccessibilityEvent(event); <END> }</code><technical_language>benefit of super call in this case populate event object instead of applying properties other contentDescription ourselves. code compared code above: java super.onInitializeAccessibilityEvent(event); if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SELECTED) { final Map<String, CharSequence> map = new HashMap<>(); map.put("rating", String.valueOf((int) getRating())); map.put("num_of_stars", String.valueOf(getNumStars())); event.setContentDescription(ResourceUtil.getFormattedString(getResources(), R.string.rating_bar_selection, map)); }</technical_language>

Target:
public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SELECTED) { final Map<String, CharSequence> map = new HashMap<>(); map.put("rating", String.valueOf((int) getRating())); map.put("num_of_stars", String.valueOf(getNumStars())); event.setContentDescription(ResourceUtil.getFormattedString(getResources(), R.string.rating_bar_selection, map)); } }
Source:
<code>public void handleMessage(Message msg) { Pair<Account, OCFile> itemSyncKey = (Pair<Account, OCFile>) msg.obj; <START> nextOperation(itemSyncKey.first,itemSyncKey.second); <END> mService.stopSelf(msg.arg1); }</code><technical_language>change nextOperation doOperation; next a prefix exists intrinsic order, is case now</technical_language>

Target:
public void handleMessage(Message msg) { Pair<Account, String> itemSyncKey = (Pair<Account, String>) msg.obj; doOperation(itemSyncKey.first, itemSyncKey.second); mService.stopSelf(msg.arg1); }
Source:
<code>public void test() throws Exception { <START> MoodManager mm1 = MoodManager.getInstanceFor(conOne); <END> MoodManager mm2 = MoodManager.getInstanceFor(conTwo); Roster r1 = Roster.getInstanceFor(conOne); Roster r2 = Roster.getInstanceFor(conTwo); syncSubscribe(conOne, conTwo, "two"); syncSubscribe(conTwo, conOne, "one"); final SimpleResultSyncPoint moodReceived = new SimpleResultSyncPoint(); mm2.addMoodListener(new MoodListener() { @Override public void onMoodUpdated(BareJid jid, Message message, MoodElement moodElement) { if (moodElement.getMood() == Mood.satisfied) { moodReceived.signal(); } } }); mm1.setMood(Mood.satisfied); moodReceived.waitForResult(timeout); r1.removeEntry(r1.getEntry(conTwo.getUser().asBareJid())); r2.removeEntry(r2.getEntry(conOne.getUser().asBareJid())); }</code><technical_language>moodManager(1|2) final fields of test set in constructor</technical_language>

Target:
public void test() throws Exception { RosterIntegrationTest.ensureBothAccountsAreSubscribedToEachOther(conOne, conTwo, timeout); final SimpleResultSyncPoint moodReceived = new SimpleResultSyncPoint(); mm2.addMoodListener(new MoodListener() { @Override public void onMoodUpdated(BareJid jid, Message message, MoodElement moodElement) { if (moodElement.getMood() == Mood.satisfied) { moodReceived.signal(); } } }); mm1.setMood(Mood.satisfied); moodReceived.waitForResult(timeout); }
Source:
<code>public void testCallService_FAIL() throws Exception { <START> when(httpsClient.doHttpsPost(Mockito.anyString(), Mockito.anyString(),(Map<String,String>)Mockito.anyObject())).thenReturn(500); <END> puppetInstallator.generateFilesinPuppetMaster(host, "test", productRelease, "install", "token"); puppetInstallator.callService(host, "test", productRelease, "install", "token"); }</code><technical_language>gt 120</technical_language>

Target:
public void testCallService_FAIL() throws Exception { when( httpsClient.doHttps(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), (Map<String, String>) Mockito.anyObject())).thenReturn(500); puppetInstallator.generateFilesinPuppetMaster(host, "test", productRelease, "install", "token"); puppetInstallator.callService(host, "test", productRelease, "install", "token"); }
Source:
<code>private File createIndexFile(File bamFile) throws IOException { final File bamIndexFile = File.createTempFile("Bai.", ".bai"); <START> final SamReader bam = SamReaderFactory.makeDefault().open(bamFile); <END> BAMIndexer.createIndex(bam, bamIndexFile); verbose("Wrote BAM Index file " + bamIndexFile); return bamIndexFile; }</code><technical_language>is reader closed somewhere</technical_language>

Target:
private File createIndexFile(File bamFile) throws IOException { final File bamIndexFile = File.createTempFile("Bai.", ".bai"); final SamReader bam = SamReaderFactory.makeDefault().open(bamFile); BAMIndexer.createIndex(bam, bamIndexFile); verbose("Wrote BAM Index file " + bamIndexFile); bam.close(); return bamIndexFile; }
Source:
<code>protected ToStringBuilder appendAttributes(ToStringBuilder tsb) { return super.appendAttributes(tsb) <START> .append("operations", imageTicket.getOps()) .append("size", imageTicket.getSize()) .append("url", imageTicket.getUrl()) .append("filename", imageTicket.getFilename()) .append("sparse", imageTicket.isSparse()) .append("transferId", Guid.createGuidFromString(imageTicket.getTransferId())) .append("dirty", imageTicket.isDirty()); <END> }</code><technical_language>not: .append("imageTicket", imageTicket) ImageTicket (or know) format string. This code care contents of ticket. add ore remove fields need change this code</technical_language>

Target:
protected ToStringBuilder appendAttributes(ToStringBuilder tsb) { return super.appendAttributes(tsb) .append("imageTicket", ticket.getOps()) .append("size", ticket.getSize()) .append("url", ticket.getUrl()) .append("filename", ticket.getFilename()) .append("sparse", ticket.isSparse()) .append("transferId", Guid.createGuidFromString(ticket.getTransferId())) .append("dirty", ticket.isDirty()); }
Source:
<code><START> static void appendTableName(DatabaseType databaseType, StringBuilder sb, String prefix, TableInfo<?, ?> tableInfo) { <END> if (prefix != null) { sb.append(prefix); } if (tableInfo.getSchemaName() != null && tableInfo.getSchemaName().length() > 0){ databaseType.appendEscapedEntityName(sb, tableInfo.getSchemaName()); sb.append("."); } databaseType.appendEscapedEntityName(sb, tableInfo.getTableName()); sb.append(' '); }</code><technical_language>Dropping this break existing apps. add another function signature</technical_language>

Target:
static void appendTableName(DatabaseType databaseType, StringBuilder sb, String prefix, TableInfo<?, ?> tableInfo) { if (prefix != null) { sb.append(prefix); } if (tableInfo.getSchemaName() != null && tableInfo.getSchemaName().length() > 0){ databaseType.appendEscapedEntityName(sb, tableInfo.getSchemaName()); sb.append('.'); } databaseType.appendEscapedEntityName(sb, tableInfo.getTableName()); sb.append(' '); }
Source:
<code>public KieServerState load(@NotNull String serverId) { KieServerState kieServerState = null; try (KubernetesClient client = createKubernetesClient()) { Map<String, String> data = client.configMaps() .withName(serverId) .get() <START> .getData(); <END> kieServerState = (KieServerState) xs.fromXML(data.get(CFG_MAP_DATA_KEY)); } catch (Exception e) { logger.error("Loading KieServerState failed.", e); } if (kieServerState == null || kieServerState.getConfiguration() .getConfigItem(KieServerConstants.KIE_SERVER_ID) == null || kieServerState.getConfiguration().getConfigItem(KieServerConstants.KIE_SERVER_ID) .getValue().length() == 0) { throw new IllegalStateException("Invalid KieServerId: " + serverId + ", or inconsistent state data."); } return kieServerState; }</code><technical_language>This line produces NPE in case server id loaded exists. I avoid NPE checking Config map, returning more specific exception (for example "KieServerId " + serverId + " found. Please create a config map configuration first.")</technical_language>

Target:
public KieServerState load(@NotNull String serverId) { KieServerState kieServerState = processKieServerState(client -> { ConfigMap cm = client.configMaps().withName(serverId).get(); if (cm == null) { throw new IllegalStateException(("KieServerId: [" + serverId + "], not found. Please create an associated ConfigMap with configuration first.")); } return (KieServerState) xs.fromXML(cm.getData().get(CFG_MAP_DATA_KEY)); }); if (kieServerState == null || !retrieveKieServerId(kieServerState).equals(serverId)) { throw new IllegalStateException("Invalid KieServerId: " + serverId + ", or inconsistent state data."); } return kieServerState; }
Source:
<code><START> public void thenTheEntityDeviceAuthorizationDoesNotExist(final Map<String, String> expectedEntity) <END> throws Throwable { Wait.until(() -> { final Device device = this.deviceRepository .findByDeviceIdentification(expectedEntity.get(PlatformKeys.KEY_DEVICE_IDENTIFICATION)); if (device == null) { Assert.assertFalse(true); } final List<DeviceAuthorization> deviceAuthorizations = this.deviceAuthorizationRepository .findByDevice(device); final DeviceFunctionGroup expectedFunctionGroup = getEnum(expectedEntity, PlatformKeys.KEY_DEVICE_FUNCTION_GROUP, com.alliander.osgp.domain.core.valueobjects.DeviceFunctionGroup.class, PlatformDefaults.DEVICE_FUNCTION_GROUP); final String expectedOrganizationIdentification = getString(expectedEntity, PlatformKeys.KEY_ORGANIZATION_IDENTIFICATION, PlatformDefaults.DEFAULT_ORGANIZATION_IDENTIFICATION); boolean testPassed = true; for (final DeviceAuthorization deviceAuthorization : deviceAuthorizations) { if (expectedOrganizationIdentification .equals(deviceAuthorization.getOrganisation().getOrganisationIdentification()) && expectedFunctionGroup == deviceAuthorization.getFunctionGroup()) { testPassed = false; } } Assert.assertTrue(testPassed); }); }</code><technical_language>This code is thenTheEntityDeviceAuthorizationExists. Create a separate method _EntityDeviceHasAuthorization_ (or a similar name), returns a boolean. boolean if device authorization. If a method, thenTheEntityDeviceAuthorizationExists thenTheEntityDeviceAuthorizationDoesNotExist oneliners</technical_language>

Target:
public void thenTheEntityDeviceAuthorizationDoesNotExist(final Map<String, String> expectedEntity) throws Throwable { final String expectedAuthorization = expectedEntity.get(PlatformKeys.KEY_DEVICE_FUNCTION_GROUP); final Device device = this.deviceRepository .findByDeviceIdentification(expectedEntity.get(PlatformKeys.KEY_DEVICE_IDENTIFICATION)); Wait.until(() -> { final List<DeviceAuthorization> storedDeviceAuthorizations = this.deviceAuthorizationRepository .findByDevice(device); final String organizationIdentification = getString(expectedEntity, PlatformKeys.KEY_ORGANIZATION_IDENTIFICATION, PlatformDefaults.DEFAULT_ORGANIZATION_IDENTIFICATION); Assert.assertFalse(this.entityDeviceHasAuthorization(expectedAuthorization, organizationIdentification, storedDeviceAuthorizations)); }); }
Source:
<code>public List<Building> getBuildings(String campusCode, String queryCode, String queryName) { Criteria criteria = new Criteria(); criteria.addEqualTo(CuCamsConstants.CapAssetApi.CAMPUS_CODE_PARAMETER, campusCode); if (StringUtils.isNotEmpty(queryName)) { <START> criteria.addLike(getDbPlatform().getUpperCaseFunction() + "(" + "buildingName" + ")", "%" + queryName.toUpperCase() + "%"); <END> } else if (StringUtils.isNotEmpty(queryCode)) { criteria.addLike(getDbPlatform().getUpperCaseFunction() + "(" + "buildingCode" + ")", "%" + queryCode.toUpperCase() + "%"); } Query query = QueryFactory.newQuery(Building.class, criteria); return (List<Building>) getPersistenceBrokerTemplate().getCollectionByQuery(query); }</code><technical_language>good constants instead of hard coded property names. KFSPropertyConstants.BUILDING_NAME constant instead of "buildingName" add new constants CuCamsConstants.java</technical_language>

Target:
public List<Building> getBuildings(String campusCode, String queryCode, String queryName) { Criteria criteria = new Criteria(); criteria.addEqualTo(CuCamsConstants.CapAssetApi.CAMPUS_CODE_PARAMETER, campusCode); if (StringUtils.isNotEmpty(queryName)) { criteria.addLike(getDbPlatform().getUpperCaseFunction() + "(" + KFSPropertyConstants.BUILDING_NAME + ")", "%" + queryName.toUpperCase() + "%"); } else if (StringUtils.isNotEmpty(queryCode)) { criteria.addLike(getDbPlatform().getUpperCaseFunction() + "(" + KFSPropertyConstants.BUILDING_CODE + ")", "%" + queryCode.toUpperCase() + "%"); } Query query = QueryFactory.newQuery(Building.class, criteria); return (List<Building>) getPersistenceBrokerTemplate().getCollectionByQuery(query); }
Source:
<code>public void testVisitForZoom() { ConfigureForDosVisitor conDos = new ConfigureForDosVisitor(); <START> Zoom zoom = mock(Zoom.class); <END> ((ZoomVisitor)conDos).visit(zoom); assertThat(logger.getLoggingEvents()).extracting("level", "message").contains( tuple(INFO, zoom + " used with Dos configurator.")); }</code><technical_language>is need mock Zoom</technical_language>

Target:
public void testVisitForZoom() { ConfigureForDosVisitor conDos = new ConfigureForDosVisitor(); Zoom zoom = new Zoom(); conDos.visit(zoom); assertThat(logger.getLoggingEvents()).extracting("level", "message").contains( tuple(INFO, zoom + " used with Dos configurator.")); }
Source:
<code>public BlockLease getBlockView(int[] positions, int positionCount) { checkArgument(outputPositionCount > 0, "outputPositionCount must be greater than zero"); checkState(outputRequired, "This stream reader doesn't produce output"); checkState(positionCount <= outputPositionCount, "Not enough values"); checkState(!valuesInUse, "BlockLease hasn't been closed yet"); if (allNulls) { return newLease(new RunLengthEncodedBlock(outputType.createBlockBuilder(null, 1).appendNull().build(), outputPositionCount)); } <START> boolean includeNulls = nullsAllowed && presentStream != null; <END> return newLease(new VariableWidthBlock(positionCount, slice, offsetVector, Optional.ofNullable(includeNulls ? nulls : null))); }</code><technical_language>compactValues logic appears missing</technical_language>

Target:
public BlockLease getBlockView(int[] positions, int positionCount) { checkArgument(outputPositionCount > 0, "outputPositionCount must be greater than zero"); checkState(outputRequired, "This stream reader doesn't produce output"); checkState(positionCount <= outputPositionCount, "Not enough values"); checkState(!valuesInUse, "BlockLease hasn't been closed yet"); if (allNulls) { return newLease(new RunLengthEncodedBlock(outputType.createBlockBuilder(null, 1).appendNull().build(), outputPositionCount)); } boolean includeNulls = nullsAllowed && presentStream != null; if (positionCount != outputPositionCount) { compactValues(positions, positionCount, includeNulls); } return newLease(new VariableWidthBlock(positionCount, dataAsSlice, offsets, Optional.ofNullable(includeNulls ? nulls : null))); }
Source:
<code>public <R, X extends Exception> R inTransaction(HandleCallback<R, X> callback) throws X { <START> if (isInTransaction()) { <END> return callback.withHandle(this); } return transactions.inTransaction(this, callback); }</code><technical_language>Nitpick: I a ternary nice here. This reads a lot a guard block, while a binary decision</technical_language>

Target:
public <R, X extends Exception> R inTransaction(HandleCallback<R, X> callback) throws X { return isInTransaction() ? callback.withHandle(this) : transactions.inTransaction(this, callback); }
Source:
<code>public int hashCode() { return Objects.hash( unitAmountUSD, <START> unitAmountAUD, <END> unitAmountEUR, unitAmountGBP, unitAmountCZK, unitAmountDKK, unitAmountHUF, unitAmountNOK, unitAmountNZD, unitAmountPLN, unitAmountSGD, unitAmountSEK, unitAmountCHF, unitAmountZAR ); }</code><technical_language>Missing CAD</technical_language>

Target:
public int hashCode() { return Objects.hashCode( unitAmountUSD, unitAmountCAD, unitAmountAUD, unitAmountEUR, unitAmountGBP, unitAmountCZK, unitAmountDKK, unitAmountHUF, unitAmountNOK, unitAmountNZD, unitAmountPLN, unitAmountSGD, unitAmountSEK, unitAmountCHF, unitAmountZAR ); }
Source:
<code><START> public void dumpDiagnostics(PrintWriter w) throws IOException { <END> w.printf("Channel %s%n",name); w.printf(" Created=%s%n", new Date(createdAt)); w.printf(" Commands sent=%d%n", commandsSent); w.printf(" Commands received=%d%n", commandsReceived); w.printf(" Last command sent=%s%n", new Date(lastCommandSent)); w.printf(" Last command received=%s%n", new Date(lastCommandReceived)); w.printf(" Pending outgoing calls=%d%n", pendingCalls.size()); w.printf(" Pending incoming calls=%d%n", pendingCalls.size()); }</code><technical_language>Unsynchronized access <code> pendingCalls</code> container</technical_language>

Target:
public void dumpDiagnostics(PrintWriter w) throws IOException { w.printf("Channel %s%n",name); w.printf(" Created=%s%n", new Date(createdAt)); w.printf(" Commands sent=%d%n", commandsSent); w.printf(" Commands received=%d%n", commandsReceived); w.printf(" Last command sent=%s%n", new Date(lastCommandSentAt)); w.printf(" Last command received=%s%n", new Date(lastCommandReceivedAt)); w.printf(" Pending outgoing calls=%d%n", pendingCalls.size()); w.printf(" Pending incoming calls=%d%n", pendingCalls.size()); }