auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void flowFromMethodInvocation(MethodYield selectedYield, ExplodedGraph.Node parentNode) { List<JavaFileScannerContext.Location> flowFromMethodInvocation; String message; Symbol argumentSymbol = correspondingArgumentSymbol(symbolicValue, parentNode); <START> if (selectedYield.exception) { <END> Preconditions.checkNotNull(argumentSymbol, "If an exception occurs, the method does not return correctly and the impacted symbolic value can only be from arguments"); message = String.format("Exception '%s' thrown from method invocation", selectedYield.exceptionType.name()); flowFromMethodInvocation = FlowComputation.flow(selectedYield.node, selectedYield.node.programState.getValue(argumentSymbol)); } else { if (argumentSymbol != null) { message = "Learns from method call"; flowFromMethodInvocation = FlowComputation.flow(selectedYield.node, selectedYield.node.programState.getValue(argumentSymbol)); } else { message = "Uses return value"; flowFromMethodInvocation = FlowComputation.flow(selectedYield.node, selectedYield.node.programState.exitValue()); } } flow.add(location(parentNode, String.format("%s [see L#%d].", message, methodDeclarationLine(parentNode)))); flow.addAll(flowFromMethodInvocation); }</code><technical_language>this simplified call Flowcomputation proper arguments</technical_language>

Target:
private void flowFromMethodInvocation(MethodYield selectedYield, ExplodedGraph.Node parentNode) { String message; int argumentIndex = correspondingArgumentIndex(symbolicValue, parentNode); if (selectedYield.exception) { Preconditions.checkState(argumentIndex != -1, "Only arguments should be considered when exception occurs"); String exceptionName = selectedYield.exceptionType == null ? "Runtime exception" : selectedYield.exceptionType.name(); message = String.format("Exception '%s' thrown from method invocation", exceptionName); } else { message = argumentIndex >= 0 ? "Learns from method call" : "Uses return value"; } flow.add(location(parentNode, String.format("%s [see L#%d].", message, methodDeclarationLine(parentNode)))); flow.addAll(selectedYield.getFlow(argumentIndex)); }
Source:
<code>public void testHalfNumComputeTasks() { final int numComputeTasks = 4; final int availableEvaluators = numComputeTasks / 2 + 1; final Collection<EvaluatorParameters> activeEvaluators = generateEvaluatorParameters( numComputeTasks, new int[][]{{2500}, {2500}, {2500}, {2500}}); final int upperBoundToDelete = (int) Math.ceil((double) numComputeTasks / 2); final Plan plan = ilpSolverOptimizer.optimize(activeEvaluators, availableEvaluators); checkPlan(activeEvaluators, plan, availableEvaluators); assertEquals(0, plan.getEvaluatorsToAdd().size()); <START> assertTrue("The number of evaluators to be deleted should be <= " + upperBoundToDelete, <END> plan.getEvaluatorsToDelete().size() <= upperBoundToDelete); }</code><technical_language>this is <= >=. for testHalfComputeTasksWithMultipleDataTypes()</technical_language>

Target:
public void testHalfNumComputeTasks() { final int numComputeTasks = 4; final int availableEvaluators = numComputeTasks / 2 + 1; final Collection<EvaluatorParameters> activeEvaluators = generateEvaluatorParameters( numComputeTasks, new int[][]{{2500}, {2500}, {2500}, {2500}}); final int lowerBoundToDelete = (int) Math.ceil((double) numComputeTasks / 2); final Plan plan = ilpSolverOptimizer.optimize(activeEvaluators, availableEvaluators); checkPlan(activeEvaluators, plan, availableEvaluators); assertEquals(0, plan.getEvaluatorsToAdd().size()); assertTrue("The number of evaluators to be deleted should be >= " + lowerBoundToDelete, plan.getEvaluatorsToDelete().size() >= lowerBoundToDelete); }
Source:
<code>private static List<SearchVariantsRequest> getShardedRequests(String variantSetId, String contig, long start, long end) { long basesPerShard = 1000000; double shards = Math.ceil((end - start) / (double) basesPerShard); List<SearchVariantsRequest> requests = Lists.newArrayList(); for (int i = 0; i < shards; i++) { long shardStart = start + (i * basesPerShard); long shardEnd = Math.min(end, shardStart + basesPerShard); LOG.info("Adding request with " + contig + " " + shardStart + " to " + shardEnd); requests.add(new SearchVariantsRequest() <START> <<<<<<< HEAD <END> .setVariantsetId(options.datasetId) .setContig(contig) .setStartPosition(shardStart) .setEndPosition(shardEnd)); ======= .setVariantSetIds(Collections.singletonList(variantSetId)) .setReferenceName(contig) .setStart(shardStart) .setEnd(shardEnd)); >>>>>>> master } return requests; }</code><technical_language>thanks for rebasing! some merge conflict stuff in needs some cleanup</technical_language>

Target:
private static List<SearchVariantsRequest> getShardedRequests(String variantSetId, String contig, long start, long end) { long basesPerShard = 1000000; double shards = Math.ceil((end - start) / (double) basesPerShard); List<SearchVariantsRequest> requests = Lists.newArrayList(); for (int i = 0; i < shards; i++) { long shardStart = start + (i * basesPerShard); long shardEnd = Math.min(end, shardStart + basesPerShard); LOG.info("Adding request with " + contig + " " + shardStart + " to " + shardEnd); requests.add(new SearchVariantsRequest() .setVariantSetIds(Collections.singletonList(variantSetId)) .setReferenceName(contig) .setStart(shardStart) .setEnd(shardEnd)); } return requests; }
Source:
<code>public void testExpectedContextWhenSNSDisabled() { this.contextRunner .withPropertyValues( "genie.notifications.sns.enabled=false" ) .run( (context) -> { <START> System.out.println(context); <END> Assertions.assertThat(context).doesNotHaveBean(AWSAutoConfiguration.SNS_CLIENT_BEAN_NAME); } ); }</code><technical_language>leave this in here</technical_language>

Target:
public void testExpectedContextWhenSNSDisabled() { this.contextRunner .withPropertyValues( "genie.notifications.sns.enabled=false" ).run( (context) -> { Assertions.assertThat(context).doesNotHaveBean(AWSAutoConfiguration.SNS_CLIENT_BEAN_NAME); } ); }
Source:
<code>public FieldProjectionContext<Object> rawField(String absoluteFieldPath) { <START> return field( absoluteFieldPath, Object.class ); <END> }</code><technical_language>This wrong, rawField( absoluteFieldPath, Object.class ). tests do fail, missing a test here</technical_language>

Target:
public FieldProjectionContext<Object> rawField(String absoluteFieldPath) { return rawField( absoluteFieldPath, Object.class ); }
Source:
<code>public boolean parse(ByteBuffer buffer) throws IOException { int tag; while (true) { buffer.mark(); int beginning = buffer.position(); tag = FIXTags.get(buffer); if (tag == 0) { buffer.reset(); return false; } if (!beginString.get(buffer)) { buffer.reset(); return false; } if (tag != BeginString) continue; int position = buffer.position(); tag = FIXTags.get(buffer); if (tag == 0) { buffer.reset(); return false; } if (!bodyLength.get(buffer)) { buffer.reset(); return false; } if (tag != BodyLength) { buffer.position(position); continue; } int length = (int)bodyLength.asInt(); if (buffer.remaining() < length + 7) { buffer.reset(); return false; } position = buffer.position(); if (checkSumEnabled) { buffer.position(position + length); tag = FIXTags.get(buffer); if (tag == 0) continue; if (!checkSum.get(buffer)) continue; if (tag != CheckSum) continue; <START> if ((FIXCheckSums.sum(buffer, beginning, position - beginning + length) & (256 - 1)) <END> != checkSum.asCheckSum()) continue; buffer.position(position); } int limit = buffer.limit(); buffer.limit(position + length); boolean garbled = message.get(buffer) == false; buffer.limit(limit); buffer.position(position + length + 7); if (garbled) continue; listener.message(message); return true; } }</code><technical_language>& 0xff here, hexadecimal literals pair bitwise operations</technical_language>

Target:
public boolean parse(ByteBuffer buffer) throws IOException { int tag; while (true) { buffer.mark(); int beginning = buffer.position(); tag = FIXTags.get(buffer); if (tag == 0) { buffer.reset(); return false; } if (!beginString.get(buffer)) { buffer.reset(); return false; } if (tag != BeginString) continue; int position = buffer.position(); tag = FIXTags.get(buffer); if (tag == 0) { buffer.reset(); return false; } if (!bodyLength.get(buffer)) { buffer.reset(); return false; } if (tag != BodyLength) { buffer.position(position); continue; } int length = (int)bodyLength.asInt(); if (buffer.remaining() < length + 7) { buffer.reset(); return false; } position = buffer.position(); if (checkSumEnabled) { buffer.position(position + length); tag = FIXTags.get(buffer); if (tag == 0) continue; if (!checkSum.get(buffer)) continue; if (tag != CheckSum) continue; if ((FIXCheckSums.sum(buffer, beginning, position - beginning + length) & 0xff) != checkSum.asCheckSum()) continue; buffer.position(position); } int limit = buffer.limit(); buffer.limit(position + length); boolean garbled = message.get(buffer) == false; buffer.limit(limit); buffer.position(position + length + 7); if (garbled) continue; listener.message(message); return true; } }
Source:
<code>public Ldap() { <START> super(0); <END> }</code><technical_language>do: setXyz(0)? other config classes? if want initialize 0, simply default field 0 instead</technical_language>

Target:
public Ldap() { setMinPoolSize(0); }
Source:
<code>public void close() { isOpen = false; wrappedIterator.close(); if (metrics.UMI_LENGTH > 0) { collectMetrics(); } <START> <END> }</code><technical_language>extra newline</technical_language>

Target:
public void close() { isOpen = false; wrappedIterator.close(); metrics.calculateDerivedFields(); }
Source:
<code>private PatchLink createLink(int index, PatchScreen.Type patchType, String before, String after) { Patch patch = patchList.get(index); <START> String fileName = patch.getFileName(); <END> Key thisKey = patch.getKey(); PatchLink result = null; switch (patchType) { case UNIFIED: result = new PatchLink.Unified(before + " " + fileName + " " + after, thisKey, index, this); break; case SIDE_BY_SIDE: result = new PatchLink.SideBySide(before + " " + fileName + " " + after, thisKey, index, this); break; } return result; }</code><technical_language>I thought talking base name here, e.g.: final int s = fileName.lastIndexOf('/'); if (0 < s) { fileName = fileName.substring(s + 1); } pulling some utility method code cleaner. :-)</technical_language>

Target:
private PatchLink createLink(int index, PatchScreen.Type patchType, String before, String after) { Patch patch = patchList.get(index); String fileName = patch.getFileName(); int s = fileName.indexOf(File.pathSeparator); if (s >= 0) { fileName.substring(s + 1); } Key thisKey = patch.getKey(); PatchLink result = null; String linkText = before + " " + fileName + " " + after; if (patchType == PatchScreen.Type.SIDE_BY_SIDE && patch.getPatchType() == Patch.PatchType.UNIFIED) { result = new PatchLink.SideBySide(linkText, thisKey, index, this); } else { result = new PatchLink.Unified(linkText, thisKey, index, this); } return result; }
Source:
<code>public void killPlugin(String name, long maxWaitTime, boolean reloading) { for (PluginInfoWrapper pluginInfoWrapper : pluginWrappers) { <START> if (pluginInfoWrapper.getThreadName().equals(name)) { <END> pluginInfoWrapper.stopPlugin(this, maxWaitTime, reloading); } } }</code><technical_language>remove break stopping plugin? I threads</technical_language>

Target:
public void killPlugin(String name, long maxWaitTime, boolean reloading) { for (PluginInfoWrapper pluginInfoWrapper : loadedPlugins.getLoadedPlugins()) { if (pluginInfoWrapper.getThreadName().equals(name)) { pluginInfoWrapper.stopPlugin(this, maxWaitTime, reloading); break; } } }
Source:
<code>public void onReceive(Context context, Intent intent) { final String methodName = "onReceive"; if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED)) { Logger.v(TAG + methodName, "Application install message is received"); if (intent.getData() != null) { Logger.v(TAG + methodName, "ApplicationReceiver detectes the installation of " + intent.getData().toString()); final String receivedInstalledPackageName = intent.getData().toString(); if (receivedInstalledPackageName.equalsIgnoreCase("package:" + AuthenticationConstants.Broker.AZURE_AUTHENTICATOR_APP_PACKAGE_NAME) || receivedInstalledPackageName.equalsIgnoreCase("package:" + AuthenticationSettings.INSTANCE.getBrokerPackageName())) { <START> String installedPackageName = receivedInstalledPackageName.equalsIgnoreCase("package:" + AuthenticationConstants.Broker.AZURE_AUTHENTICATOR_APP_PACKAGE_NAME)? <END> AuthenticationConstants.Broker.AZURE_AUTHENTICATOR_APP_PACKAGE_NAME : AuthenticationConstants.Broker.COMPANY_PORTAL_APP_PACKAGE_NAME; String request = getInstallRequestInthisApp(context); brokerProxy = new BrokerProxy(context); final Date dateTimeForSavedRequest = new Date(getInstallRequestTimeStamp(context)); if (!StringExtensions.IsNullOrBlank(request) && brokerProxy.canSwitchToBroker() && isRequestTimestampValidForResume(dateTimeForSavedRequest)) { Logger.v(TAG + methodName, receivedInstalledPackageName + " is installed, start sending request to broker."); resumeRequestInBroker(context, request); } else { Logger.v(TAG + methodName, "No request saved in sharedpreferences or request already timeout" + ", cannot resume broker request."); } } } } }</code><technical_language>final</technical_language>

Target:
public void onReceive(Context context, Intent intent) { final String methodName = "onReceive"; if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED)) { Logger.v(TAG + methodName, "Application install message is received"); if (intent.getData() != null) { Logger.v(TAG + methodName, "ApplicationReceiver detectes the installation of " + intent.getData().toString()); final String receivedInstalledPackageName = intent.getData().toString(); if (receivedInstalledPackageName.equalsIgnoreCase("package:" + AuthenticationConstants.Broker.AZURE_AUTHENTICATOR_APP_PACKAGE_NAME) || receivedInstalledPackageName.equalsIgnoreCase("package:" + AuthenticationSettings.INSTANCE.getBrokerPackageName())) { String request = getInstallRequestInthisApp(context); brokerProxy = new BrokerProxy(context); final Date dateTimeForSavedRequest = new Date(getInstallRequestTimeStamp(context)); if (!StringExtensions.IsNullOrBlank(request) && brokerProxy.canSwitchToBroker() && isRequestTimestampValidForResume(dateTimeForSavedRequest)) { Logger.v(TAG + methodName, receivedInstalledPackageName + " is installed, start sending request to broker."); resumeRequestInBroker(context, request); } else { Logger.v(TAG + methodName, "No request saved in sharedpreferences or request already timeout" + ", cannot resume broker request."); } } } } }
Source:
<code>public static <T> QosClient.QueryWeigher<T> writeWeigher(long numRows, Supplier<Long> bytesWritten) { Supplier<Long> weight = Suppliers.memoize(() -> safeGetNumBytesOrDefault(bytesWritten))::get; return new QosClient.QueryWeigher<T>() { @Override public QueryWeight estimate() { return ImmutableQueryWeight.builder() .from(DEFAULT_ESTIMATED_WEIGHT) .numBytes(weight.get()) .numDistinctRows(numRows) .build(); } @Override public QueryWeight weigh(T result, long timeTakenNanos) { return ImmutableQueryWeight.builder() .from(estimate()) <START> .timeTakenNanos((int) timeTakenNanos) <END> .build(); } }; }</code><technical_language>above, timeTakenNanos a long this broken for times ~3 seconds (Integer.MAX_VALUE nanoseconds)</technical_language>

Target:
public static <T> QosClient.QueryWeigher<T> writeWeigher(long numRows, Supplier<Long> bytesWritten) { Supplier<Long> weight = Suppliers.memoize(() -> safeGetNumBytesOrDefault(bytesWritten))::get; return new QosClient.QueryWeigher<T>() { @Override public QueryWeight estimate() { return ImmutableQueryWeight.builder() .from(DEFAULT_ESTIMATED_WEIGHT) .numBytes(weight.get()) .numDistinctRows(numRows) .build(); } @Override public QueryWeight weigh(T result, long timeTakenNanos) { return ImmutableQueryWeight.builder() .from(estimate()) .timeTakenNanos(timeTakenNanos) .build(); } }; }
Source:
<code>public static List<List<BakedQuad>> sortQuadsByIndex(IBakedModel model) { List<List<BakedQuad>> layers = new ArrayList(); List<BakedQuad> quads = new ArrayList(); for (EnumFacing dir : EnumFacing.values()) { quads.addAll(model.getQuads(null, dir, 0)); } quads.addAll(model.getQuads(null, null, 0)); for (BakedQuad quad : quads) { int index = quad.hasTintIndex() ? quad.getTintIndex() : 0; <START> try { layers.get(index); } catch (IndexOutOfBoundsException e) { layers.add(index, new ArrayList()); } <END> layers.get(index).add(quad); } return layers; }</code><technical_language>easier check if index >= layers.size() add a new ArrayList layers based that</technical_language>

Target:
public static List<List<BakedQuad>> sortQuadsByIndex(IBakedModel model) { List<List<BakedQuad>> layers = new ArrayList(); List<BakedQuad> quads = new ArrayList(); for (EnumFacing dir : EnumFacing.values()) { quads.addAll(model.getQuads(null, dir, 0)); } quads.addAll(model.getQuads(null, null, 0)); for (BakedQuad quad : quads) { int index = quad.hasTintIndex() ? quad.getTintIndex() : 0; if (index >= layers.size()) layers.add(index, new ArrayList()); layers.get(index).add(quad); } return layers; }
Source:
<code>public static PublicKey getPublicKey(KeyPairType type, byte[] pub) throws UnsupportedTypeException{ if(type.equals(KeyPairType.DSA)){ throw new UnsupportedTypeException(type); } try { KeyFactory kf = KeyFactory.getInstance(type.alg); X509EncodedKeySpec xks = new X509EncodedKeySpec(pub); <START> return kf.generatePublic(xks); <END> } catch (GeneralSecurityException e) { Logger.error(KeyGenUtils.class, "Internal error; please report:", e); } return null; }</code><technical_language>Mind whitespace, please</technical_language>

Target:
public static PublicKey getPublicKey(KeyPairType type, byte[] pub){ if(type.equals(KeyPairType.DSA)){ throw new UnsupportedTypeException(type); } try { KeyFactory kf = KeyFactory.getInstance(type.alg); X509EncodedKeySpec xks = new X509EncodedKeySpec(pub); return kf.generatePublic(xks); } catch (GeneralSecurityException e) { Logger.error(KeyGenUtils.class, "Internal error; please report:", e); } return null; }
Source:
<code>public synchronized static void upgradeTo7Dot1() { final SharedPreferences prefs = SalesforceSDKManager.getInstance().getAppContext().getSharedPreferences(SHARED_PREF_FILE, 0); final Map<String, ?> prefContents = prefs.getAll(); if (prefContents != null) { final Set<String> keys = prefContents.keySet(); for (final String key : keys) { if (key != null && key.startsWith("id")) { final String value = prefs.getString(key, null); if (value != null) { <START> final PublicKey publicKey = KeyStoreWrapper.getInstance().getECPublicKey(KEYSTORE_ALIAS); <END> final String encryptedValue = Encryptor.encryptWithRSA(publicKey, value); storeInSharedPrefs(key, encryptedValue); prefs.edit().remove(key).commit(); } } } } }</code><technical_language>KeyStoreWrapper.getInstance().getRSAPublicKey</technical_language>

Target:
public synchronized static void upgradeTo7Dot1() { final SharedPreferences prefs = SalesforceSDKManager.getInstance().getAppContext().getSharedPreferences(SHARED_PREF_FILE, 0); final Map<String, ?> prefContents = prefs.getAll(); if (prefContents != null) { final Set<String> keys = prefContents.keySet(); for (final String key : keys) { if (key != null && key.startsWith("id")) { final String value = prefs.getString(key, null); if (value != null) { final PublicKey publicKey = KeyStoreWrapper.getInstance().getRSAPublicKey(KEYSTORE_ALIAS); final String keyBase = key.replaceFirst(ID_PREFIX, ""); final String mutatedValue = value + String.format(Locale.US, ADDENDUM, keyBase); final String encryptedValue = Encryptor.encryptWithRSA(publicKey, mutatedValue); storeInSharedPrefs(key, encryptedValue); prefs.edit().remove(key).commit(); } } } } }
Source:
<code>public Capabilities getCapabilities() { <START> return this.capabilities; <END> }</code><technical_language>This this needed. Generally, this keyword code unambiguous</technical_language>

Target:
public Capabilities getCapabilities() { return capabilities; }
Source:
<code>public TestClass(Class<?> klass) { fClass = klass; if (klass != null && klass.getConstructors().length > 1) { throw new IllegalArgumentException( "Test class can only have one constructor"); } Map<Class<? extends Annotation>, List<FrameworkMethod>> methodsForAnnotations = new LinkedHashMap<Class<? extends Annotation>, List<FrameworkMethod>>(); Map<Class<? extends Annotation>, List<FrameworkField>> fieldsForAnnotations = new LinkedHashMap<Class<? extends Annotation>, List<FrameworkField>>(); for (Class<?> eachClass : getSuperClasses(fClass)) { for (Method eachMethod : MethodSorter.getDeclaredMethods(eachClass)) { addToAnnotationLists(new FrameworkMethod(eachMethod), methodsForAnnotations); } for (Field eachField : getSortedDeclaredFields(eachClass)) { addToAnnotationLists(new FrameworkField(eachField), fieldsForAnnotations); } } <START> fMethodsForAnnotations = Collections.unmodifiableMap(methodsForAnnotations); <END> fFieldsForAnnotations = Collections.unmodifiableMap(fieldsForAnnotations); }</code><technical_language>this change</technical_language>

Target:
public TestClass(Class<?> klass) { fClass = klass; if (klass != null && klass.getConstructors().length > 1) { throw new IllegalArgumentException( "Test class can only have one constructor"); } Map<Class<? extends Annotation>, List<FrameworkMethod>> methodsForAnnotations = new LinkedHashMap<Class<? extends Annotation>, List<FrameworkMethod>>(); Map<Class<? extends Annotation>, List<FrameworkField>> fieldsForAnnotations = new LinkedHashMap<Class<? extends Annotation>, List<FrameworkField>>(); scanAnnotatedMembers(methodsForAnnotations, fieldsForAnnotations); fMethodsForAnnotations = makeDeeplyUnmodifiable(methodsForAnnotations); fFieldsForAnnotations = makeDeeplyUnmodifiable(fieldsForAnnotations); }
Source:
<code>private String getSubtypeString(COSBase item) { if (item instanceof COSString) return ((COSString) item).getString(); else if (item instanceof COSName) return ((COSName) item).getName(); else if (item instanceof COSObject) return getSubtypeString(((COSObject) item).getObject()); else return null; <START> } <END></code><technical_language>please format this lines of code properly</technical_language>

Target:
private String getSubtypeString(COSBase item) { if (item instanceof COSString) { return ((COSString) item).getString(); } else if (item instanceof COSName) { return ((COSName) item).getName(); } else if (item instanceof COSObject) { return getSubtypeString(((COSObject) item).getObject()); } else { return null; } }
Source:
<code>public void testWritePlan() throws MalformedURLException, ParseException, URISyntaxException { Bpmn4JsonParser parser = new Bpmn4JsonParser(); URI uri = Paths.get("src/test/resources/bpmn4tosca/bpmn4tosca.json") .toUri(); <START> parser.parse(uri); <END> }</code><technical_language>This test parse. I think, method name is contradicting</technical_language>

Target:
public void testWritePlan() throws MalformedURLException, ParseException, URISyntaxException { Bpmn4JsonParser parser = new Bpmn4JsonParser(); URI uri = Paths.get("src/test/resources/bpmn4tosca/bpmn4tosca.json").toUri(); ManagementFlow mngmtFlow = parser.parse(uri); }
Source:
<code>public void kill() { try { <START> JobConfig jc = new JobConfig(JobConfigUtil.generateJobIdAndName(appDesc.getConfig())); <END> LOG.info("Killing job {}", jc.getName()); JobRunner runner = new JobRunner(jc); runner.kill(); } catch (Throwable t) { throw new SamzaException("Failed to kill application", t); } }</code><technical_language>This JobConfigUtil.generateJobIdAndName in planner. add a function planer.createSingleJobConfig(). This handled in a single place</technical_language>

Target:
public void kill() { try { JobConfig jc = new JobConfig(JobPlanner.generateSingleJobConfig(appDesc.getConfig())); LOG.info("Killing job {}", jc.getName()); JobRunner runner = new JobRunner(jc); runner.kill(); } catch (Throwable t) { throw new SamzaException("Failed to kill application", t); } }
Source:
<code><START> private boolean perform(Run src, Run<?,?> dst, String expandedFilter, String expandedExcludes, FilePath targetDir, <END> FilePath baseTargetDir, Copier copier, PrintStream console) throws IOException, InterruptedException { FilePath srcDir = selector.getSourceDirectory(src, console); if (srcDir == null) { return isOptional(); } copier.init(src,dst,srcDir,baseTargetDir); try { int cnt; if (!isFlatten()) cnt = copier.copyAll(srcDir, expandedFilter, expandedExcludes, targetDir, isFingerprintArtifacts()); else { targetDir.mkdirs(); FilePath[] list = srcDir.list(expandedFilter, expandedExcludes, false); for (FilePath file : list) copier.copyOne(file, new FilePath(targetDir, file.getName()), isFingerprintArtifacts()); cnt = list.length; } console.println(Messages.CopyArtifact_Copied(cnt, HyperlinkNote.encodeTo('/'+ src.getParent().getUrl(), src.getParent().getFullDisplayName()), HyperlinkNote.encodeTo('/'+src.getUrl(), Integer.toString(src.getNumber())))); return cnt > 0 || isOptional(); } finally { copier.end(); } }</code><technical_language>this return void throw AbortException needed</technical_language>

Target:
private boolean perform(Run src, Run<?,?> dst, String expandedFilter, String expandedExcludes, FilePath targetDir, FilePath baseTargetDir, Copier copier, PrintStream console) throws IOException, InterruptedException { FilePath srcDir = selector.getSourceDirectory(src, console); if (srcDir == null) { return isOptional(); } copier.initialize(src, dst, srcDir, baseTargetDir); try { int cnt; if (!isFlatten()) cnt = copier.copyAll(srcDir, expandedFilter, expandedExcludes, targetDir, isFingerprintArtifacts()); else { targetDir.mkdirs(); FilePath[] list = srcDir.list(expandedFilter, expandedExcludes, false); for (FilePath file : list) copier.copyOne(file, new FilePath(targetDir, file.getName()), isFingerprintArtifacts()); cnt = list.length; } console.println(Messages.CopyArtifact_Copied(cnt, HyperlinkNote.encodeTo('/'+ src.getParent().getUrl(), src.getParent().getFullDisplayName()), HyperlinkNote.encodeTo('/'+src.getUrl(), Integer.toString(src.getNumber())))); return cnt > 0 || isOptional(); } finally { copier.end(); } }
Source:
<code>protected int destination(int offset, TextContent content, int count) throws CommandExecutionException { LineInformation line = content.getLineInformationOfOffset(offset); ParenthesesPair pair = null; int startIndex = offset; if (offset == line.getEndOffset() && line.getLength() > 0) { startIndex--; } for (int index = startIndex; index < line.getEndOffset(); index++) { String c = content.getText(index, 1); if (PARENTHESES.containsKey(c)) { pair = PARENTHESES.get(c); return findMatch(index, pair, content, count); } } <START> if (pair == null) { <END> pair = getBlockComment(offset, content); if(pair != null) { return findBlockMatch(offset, pair, content); } } if (CPreProcessorMove.containsPreProcessor(content, line, offset)) { return new CPreProcessorMove().destination(offset, content, count); } throw new CommandExecutionException("no parentheses to jump found"); }</code><technical_language>changed logic in previous for loop pair null here. remove this if check</technical_language>

Target:
protected int destination(int offset, TextContent content, int count) throws CommandExecutionException { LineInformation line = content.getLineInformationOfOffset(offset); int startIndex = offset; if (offset == line.getEndOffset() && line.getLength() > 0) { startIndex--; } for (int index = startIndex; index < line.getEndOffset(); index++) { String c = content.getText(index, 1); if (PARENTHESES.containsKey(c)) { return findMatch(index, PARENTHESES.get(c), content, count); } } ParenthesesPair pair = getBlockComment(offset, content); if (pair != null) { return findBlockMatch(offset, pair, content); } if (CPreProcessorMove.containsPreProcessor(content, line, offset)) { return new CPreProcessorMove().destination(offset, content, count); } throw new CommandExecutionException("no parentheses to jump found"); }
Source:
<code>public TimestampIncrementingTableQuerier(QueryMode mode, String name, String topicPrefix, String timestampColumn, Long timestampOffset, String incrementingColumn, Long incrementingOffset, Long timestampDelay) { super(mode, name, topicPrefix); this.timestampColumn = timestampColumn; this.timestampOffset = timestampOffset; this.incrementingColumn = incrementingColumn; this.incrementingOffset = incrementingOffset; <START> this.timestampDelay = timestampDelay == null ? 0L : timestampDelay; <END> }</code><technical_language>a big deal, if resolve this 0 anyway, force this option (which do) pass in a long instead of Long. For other fields, fact null is determine mode in, is not</technical_language>

Target:
public TimestampIncrementingTableQuerier(QueryMode mode, String name, String topicPrefix, String timestampColumn, Long timestampOffset, String incrementingColumn, Long incrementingOffset, Long timestampDelay) { super(mode, name, topicPrefix); this.timestampColumn = timestampColumn; this.timestampOffset = timestampOffset; this.incrementingColumn = incrementingColumn; this.incrementingOffset = incrementingOffset; this.timestampDelay = timestampDelay; }
Source:
<code>private LookupScenarioFxRateProvider(ScenarioMarketData marketData, FxRateLookup lookup) { <START> this.marketData = marketData; <END> this.lookup = lookup; }</code><technical_language>Null checks</technical_language>

Target:
private LookupScenarioFxRateProvider(ScenarioMarketData marketData, FxRateLookup lookup) { this.marketData = ArgChecker.notNull(marketData, "marketData"); this.lookup = ArgChecker.notNull(lookup, "lookup"); }
Source:
<code>private void init() { try { getWorkbench().addWindowListener(WINDOW_LISTENER); IWorkbenchWindow[] windows = getWorkbench().getWorkbenchWindows(); if (windows.length > 0) { launchingWorkbenchWindow = windows[0]; } for (IWorkbenchWindow window : windows) { addListenersToWindow(window); } <START> monitors.add(new WorkbenchUserActivityMonitor()); <END> new MonitorUiExtensionPointReader().initExtensions(); activityContextManager.init(monitors); updateActivityTimout(); activityContextManager.start(); setActivityTrackingEnabled(getPreferenceStore().getBoolean(ACTIVITY_TRACKING_ENABLED)); getPreferenceStore().addPropertyChangeListener(PROPERTY_LISTENER); } catch (Exception e) { StatusHandler.log(new Status(IStatus.ERROR, MonitorUiPlugin.ID_PLUGIN, "Monitor UI start failed", e)); } }</code><technical_language>I do this calling initExtensions this is item in list</technical_language>

Target:
private void init() { try { getWorkbench().addWindowListener(WINDOW_LISTENER); IWorkbenchWindow[] windows = getWorkbench().getWorkbenchWindows(); if (windows.length > 0) { launchingWorkbenchWindow = windows[0]; } for (IWorkbenchWindow window : windows) { addListenersToWindow(window); } MonitorUiExtensionPointReader.initExtensions(monitors); monitors.add(new WorkbenchUserActivityMonitor()); activityContextManager.init(monitors); updateActivityTimout(); activityContextManager.start(); setActivityTrackingEnabled(getPreferenceStore().getBoolean(ACTIVITY_TRACKING_ENABLED)); getPreferenceStore().addPropertyChangeListener(PROPERTY_LISTENER); } catch (Exception e) { StatusHandler.log(new Status(IStatus.ERROR, MonitorUiPlugin.ID_PLUGIN, "Monitor UI start failed", e)); } }
Source:
<code>public void setLoginRequest(SiteNode loginSiteNode) throws Exception { this.loginSiteNode = loginSiteNode; HttpMessage requestMessage = loginSiteNode.getHistoryReference().getHttpMessage(); this.loginRequestURL = requestMessage.getRequestHeader().getURI().toString(); <START> if (!requestMessage.getRequestHeader().getMethod().equals(HttpRequestHeader.GET)) { <END> this.loginRequestBody = requestMessage.getRequestBody().toString(); } else { this.loginRequestBody = null; } }</code><technical_language>This equals ignoring case</technical_language>

Target:
public void setLoginRequest(SiteNode loginSiteNode) throws Exception { this.loginSiteNode = loginSiteNode; HttpMessage requestMessage = loginSiteNode.getHistoryReference().getHttpMessage(); this.loginRequestURL = requestMessage.getRequestHeader().getURI().toString(); if (!requestMessage.getRequestHeader().getMethod().equalsIgnoreCase(HttpRequestHeader.GET)) { this.loginRequestBody = requestMessage.getRequestBody().toString(); } else { this.loginRequestBody = null; } }
Source:
<code>public void leavesPullRequestOpenWhenNoRebaseMode() throws Exception { final Repo repo = new MkGithub().randomRepo(); final Issue issue = repo.issues().create("", ""); final Profile profile = new Profile.Fixed( new XMLDocument( StringUtils.join( "<p> <entry key='merge'>", " <entry key='rebase'>false</entry>", "</entry> </p>" ) ) ); <START> final Agent agent = new ClosePullRequest(profile, repo.github()); <END> final Talk talk = ClosePullRequestTest.createTalk(repo, issue); agent.execute(talk); MatcherAssert.assertThat( new Issue.Smart(issue).state(), Matchers.is("open") ); }</code><technical_language>@vkuchyn here, inlined</technical_language>

Target:
public void leavesPullRequestOpenWhenNoRebaseMode() throws Exception { final Repo repo = new MkGithub().randomRepo(); final Issue issue = repo.issues().create("", ""); final Profile profile = new Profile.Fixed( new XMLDocument( StringUtils.join( "<p> <entry key='merge'>", " <entry key='rebase'>false</entry>", "</entry> </p>" ) ) ); final Talk talk = ClosePullRequestTest.talk(repo, issue); new ClosePullRequest(profile, repo.github()).execute(talk); final Issue.Smart smart = new Issue.Smart(issue); MatcherAssert.assertThat( smart.state(), Matchers.is("open") ); MatcherAssert.assertThat( smart.comments().iterate(), Matchers.is(Matchers.<Comment>emptyIterable()) ); }
Source:
<code>private boolean warnIfReferenceIsTooLargeForBinField(final SAMRecord rec) { final SAMSequenceRecord sequence = rec.getHeader() != null ? rec.getHeader().getSequence(rec.getReferenceName()) : null; final boolean tooLarge = sequence != null && SAMUtils.isReferenceSequenceIncompatibleWithBAI(sequence); <START> if (!isReferenceSizeWarningShowed & tooLarge && rec.getValidationStringency() != ValidationStringency.SILENT) { <END> LOG.warn("Reference length is too large for BAM bin field."); LOG.warn("Reads on references longer than " + GenomicIndexUtil.BIN_GENOMIC_SPAN + "bp will have bin set to 0."); isReferenceSizeWarningShowed = true; } return tooLarge; }</code><technical_language>While bitwise a boolean give result want, IMO clearer boolean suggestion if (!isReferenceSizeWarningShowed && tooLarge && rec.getValidationStringency() != ValidationStringency.SILENT) {</technical_language>

Target:
private boolean warnIfReferenceIsTooLargeForBinField(final SAMRecord rec) { final SAMSequenceRecord sequence = rec.getHeader() != null ? rec.getHeader().getSequence(rec.getReferenceName()) : null; final boolean tooLarge = sequence != null && SAMUtils.isReferenceSequenceIncompatibleWithBAI(sequence); if (!isReferenceSizeWarningShowed && tooLarge && rec.getValidationStringency() != ValidationStringency.SILENT) { LOG.warn("Reference length is too large for BAM bin field."); LOG.warn("Reads on references longer than " + GenomicIndexUtil.BIN_GENOMIC_SPAN + "bp will have bin set to 0."); isReferenceSizeWarningShowed = true; } return tooLarge; }
Source:
<code>private String getFolderName(File file) { if (file.getParentFile().getName().equals("jobs") <START> && file.getParentFile().getParentFile().getParentFile().getName().equals("jobs")) { <END> return file.getParentFile().getParentFile().getName(); } else return ""; }</code><technical_language>this work in cases? Note: folders in folders in folder etc.. I easier way</technical_language>

Target:
private String getFolderName(File file) { if (isJobInFolder(file)) { File nextAncestor = file.getParentFile().getParentFile(); String folderName = ""; File jobConfigHistoryJobDirection = new File(PluginUtils.getPlugin().getConfiguredHistoryRootDir(), "jobs"); while (nextAncestor.isDirectory() && !nextAncestor.toString().equals(jobConfigHistoryJobDirection.toString())) { folderName = nextAncestor.getName() + (folderName.isEmpty() ? "" : "/") + folderName; nextAncestor = nextAncestor.getParentFile(); } return folderName; } else return ""; }
Source:
<code>public SourceReference build() { if ( sourceName == null ) { return null; } String sourceNameTrimmed = sourceName.trim(); <START> if ( !sourceName.equals( sourceNameTrimmed ) && messager != null ) { <END> messager.printMessage( method.getExecutable(), annotationMirror, sourceAnnotationValue, Message.PROPERTYMAPPING_WHITESPACE_TRIMMED, sourceName, sourceNameTrimmed ); } String[] segments = sourceNameTrimmed.split( "\\." ); SourceReference result = new SourceReference( null, new ArrayList<>( ), false ); if ( method.getSourceParameters().size() > 1 ) { Parameter parameter = fetchMatchingParameterFromFirstSegment( segments ); if ( parameter != null ) { result = buildFromMultipleSourceParameters( segments, parameter ); } } else { Parameter parameter = method.getSourceParameters().get( 0 ); result = buildFromSingleSourceParameters( segments, parameter ); } return result; }</code><technical_language>is messager is null? pass it, print messages</technical_language>

Target:
public SourceReference build() { if ( sourceName == null ) { return null; } Objects.requireNonNull( messager ); String sourceNameTrimmed = sourceName.trim(); if ( !sourceName.equals( sourceNameTrimmed ) ) { messager.printMessage( method.getExecutable(), annotationMirror, sourceAnnotationValue, Message.PROPERTYMAPPING_WHITESPACE_TRIMMED, sourceName, sourceNameTrimmed ); } String[] segments = sourceNameTrimmed.split( "\\." ); SourceReference result = new SourceReference( null, new ArrayList<>( ), false ); if ( method.getSourceParameters().size() > 1 ) { Parameter parameter = fetchMatchingParameterFromFirstSegment( segments ); if ( parameter != null ) { result = buildFromMultipleSourceParameters( segments, parameter ); } } else { Parameter parameter = method.getSourceParameters().get( 0 ); result = buildFromSingleSourceParameters( segments, parameter ); } return result; }
Source:
<code><START> public boolean isAuthorized(AuthenticatedClient authenticatedClient, TimelockNamespace namespace) { <END> return !namespaceLocker.isLocked(namespace) || privileges.getOrDefault(authenticatedClient, Privileges.EMPTY).hasPrivilege(namespace); }</code><technical_language>AuthenticatedClient ClientId, do authenticatedClient.id()</technical_language>

Target:
public boolean isAuthorized(AuthenticatedClient authenticatedClient, TimelockNamespace namespace) { return !namespaceLocker.isLocked(namespace) || privileges.getOrDefault(authenticatedClient.id(), Privileges.EMPTY).hasPrivilege(namespace); }
Source:
<code>public void testQueryGroupedInput(final File input) { final AbstractMarkDuplicatesCommandLineProgramTester tester = new BySumOfBaseQAndInOriginalOrderMDTester(); final SamReader reader = SamReaderFactory.makeDefault().open(input); tester.setHeader(reader.getFileHeader()); reader.iterator().stream().forEach(tester::addRecord); <START> CloserUtil.close(reader); <END> tester.setExpectedOpticalDuplicate(0); tester.addArg("ASSUME_SORT_ORDER=queryname"); tester.runTest(); }</code><technical_language>try-with-resources remove explicit close()</technical_language>

Target:
public void testQueryGroupedInput(final File input) throws IOException { final AbstractMarkDuplicatesCommandLineProgramTester tester = new BySumOfBaseQAndInOriginalOrderMDTester(); try(final SamReader reader = SamReaderFactory.makeDefault().open(input)) { tester.setHeader(reader.getFileHeader()); reader.iterator().stream().forEach(tester::addRecord); } tester.setExpectedOpticalDuplicate(0); tester.addArg("ASSUME_SORT_ORDER=queryname"); tester.runTest(); }
Source:
<code>public void testBundleRuntimeExecutionEnvironment() throws Exception { File basedir = getBasedir("projects/bree"); Properties properties = new Properties(); properties.put("tycho-version", TychoVersion.getTychoVersion()); List<MavenProject> projects = getSortedProjects(basedir, properties, null); assertEquals(5, projects.size()); TychoProject bundleProject = lookup(TychoProject.class, ArtifactKey.TYPE_ECLIPSE_PLUGIN); assertEquals("executionenvironment.manifest", projects.get(1).getArtifactId()); assertEquals("CDC-1.0/Foundation-1.0", bundleProject.getExecutionEnvironment(projects.get(1)).getProfileName()); assertEquals("executionenvironment.pom-hard", projects.get(2).getArtifactId()); assertEquals("OSGi/Minimum-1.2", bundleProject.getExecutionEnvironment(projects.get(2)).getProfileName()); assertEquals("executionenvironment.pom-soft-buildproperties", projects.get(3).getArtifactId()); assertEquals("OSGi/Minimum-1.1", bundleProject.getExecutionEnvironment(projects.get(3)).getProfileName()); assertEquals("executionenvironment.pom-soft-manifest", projects.get(4).getArtifactId()); <START> assertEquals("OSGi/Minimum-1.0", bundleProject.getExecutionEnvironment(projects.get(4)).getProfileName()); <END> }</code><technical_language>executionenvironment.pom-soft* tests do apply more. replace executionenvironment.pom-default test(s) validate default configuration is considered other sources</technical_language>

Target:
public void testBundleRuntimeExecutionEnvironment() throws Exception { File basedir = getBasedir("projects/bree"); Properties properties = new Properties(); properties.put("tycho-version", TychoVersion.getTychoVersion()); List<MavenProject> projects = getSortedProjects(basedir, properties, null); assertEquals(5, projects.size()); TychoProject bundleProject = lookup(TychoProject.class, ArtifactKey.TYPE_ECLIPSE_PLUGIN); assertEquals("executionenvironment.manifest", projects.get(1).getArtifactId()); assertEquals("CDC-1.0/Foundation-1.0", bundleProject.getExecutionEnvironment(projects.get(1)).getProfileName()); assertEquals("executionenvironment.pom-hard", projects.get(2).getArtifactId()); assertEquals("OSGi/Minimum-1.2", bundleProject.getExecutionEnvironment(projects.get(2)).getProfileName()); assertEquals("executionenvironment.buildproperties", projects.get(3).getArtifactId()); assertEquals("OSGi/Minimum-1.1", bundleProject.getExecutionEnvironment(projects.get(3)).getProfileName()); assertEquals("executionenvironment.pom-default", projects.get(4).getArtifactId()); assertEquals("OSGi/Minimum-1.2", bundleProject.getExecutionEnvironment(projects.get(4)).getProfileName()); }
Source:
<code>public ReloadableRegistrationHandle<T> set(Key<T> key, Provider<T> impl, String pluginName) { <START> NamedProvider<T> old = ref.get(); final NamedProvider<T> item = new NamedProvider<T>(impl, pluginName); if (replaceable) { ref.compareAndSet(old, item); <END> } else { while (!ref.compareAndSet(null, item)) { if (old != null) { throw new ProvisionException(String.format( "%s already provided by %s, ignoring plugin %s", this.key.getTypeLiteral(), old.pluginName, pluginName)); } } } return new ReloadableHandle(key, item, old); }</code><technical_language>instead of this plugins bind implementation a DynamicMap server a config setting identify DynamicMap entry is served WebSession. This explicit for admin plugin provides web session. Currently replaceable a plugin hijack web session in random orderings installing 2 plugins provide feature</technical_language>

Target:
public ReloadableRegistrationHandle<T> set(Key<T> key, Provider<T> impl, String pluginName) { final NamedProvider<T> item = new NamedProvider<T>(impl, pluginName); while (!ref.compareAndSet(null, item)) { NamedProvider<T> old = ref.get(); if (old != null) { throw new ProvisionException(String.format( "%s already provided by %s, ignoring plugin %s", this.key.getTypeLiteral(), old.pluginName, pluginName)); } } return new ReloadableHandle(key, item); }
Source:
<code><START> private Stream<Metacard> loadFile(File file, Function<? super Map, Metacard> mapper) { <END> if (!file.exists()) { LOGGER.debug("Could not locate {}", file.getName()); return Stream.empty(); } String payload = getFileContent(file); if (payload == null) { LOGGER.debug("Problem reading {}", file.getName()); return Stream.empty(); } try { return Stream.of(Boon.fromJson(payload)) .map(List.class::cast) .flatMap(List::stream) .filter(Map.class::isInstance) .map(Map.class::cast) .map(mapper) .filter(Objects::nonNull) .collect(Collectors.toList()) .stream(); } catch (ClassCastException e) { LOGGER.warn( "Could not load forms configuration in {}, JSON should be a list of maps", file.getName()); return Stream.empty(); } }</code><technical_language>Yes. Problems file operations logged a level higher debug a system admin do fix them</technical_language>

Target:
private Stream<Metacard> loadFile(File file, Function<? super Map, Metacard> mapper) { if (!file.exists()) { LOGGER.debug("Could not locate {}", file.getName()); return Stream.empty(); } String payload = getFileContent(file); if (payload == null) { LOGGER.debug("Problem reading {}", file.getName()); return Stream.empty(); } Object configObject = Boon.fromJson(payload); if (!List.class.isInstance(configObject)) { LOGGER.warn( "Could not load forms configuration in {}, JSON should be a list of maps", file.getName()); return Stream.empty(); } List<Object> configs = (List) configObject; return configs .stream() .peek(obj -> loggingConsumerFactory(file).accept(obj)) .filter(Map.class::isInstance) .map(Map.class::cast) .map(mapper) .filter(Objects::nonNull); }
Source:
<code>public void loadHacoMap() { String clientDirPath = "."; DfHacoMapFile hacoMapFile = new DfHacoMapFile(() -> DBFluteSystem.currentLocalDateTime()); try { List<DfHacoMapPiece> pieceList = hacoMapFile.readPieceList(clientDirPath); OptionalThing<DfHacoMapPickup> optPickup = hacoMapFile.readPickup(clientDirPath); _hacoMapPickup = hacoMapFile.merge(optPickup, pieceList); <START> } catch (RuntimeException e){ <END> final ExceptionMessageBuilder br = new ExceptionMessageBuilder(); br.addNotice("Failed to load haco-map."); br.addItem("Exception"); br.addElement(e.getClass().getName()); br.addElement(e.getMessage()); final String msg = br.buildExceptionMessage(); throw new IllegalStateException(msg, e); } }</code><technical_language>is this exception handling for? If want improve debug information, e.g. show "clientDIrPath" in exception message. While, addItem("Exception") is unneeded IllegalStateException wraps it. (Sometimes do for emphasis, I here)</technical_language>

Target:
public void loadHacoMap() { String clientDirPath = "."; DfHacoMapFile hacoMapFile = new DfHacoMapFile(() -> DBFluteSystem.currentLocalDateTime()); try { List<DfHacoMapPiece> pieceList = hacoMapFile.readPieceList(clientDirPath); OptionalThing<DfHacoMapPickup> optPickup = hacoMapFile.readPickup(clientDirPath); _hacoMapPickup = hacoMapFile.merge(optPickup, pieceList); } catch (RuntimeException e) { final ExceptionMessageBuilder br = new ExceptionMessageBuilder(); br.addNotice("Failed to load haco-map."); br.addItem("File Path"); br.addElement(clientDirPath); final String msg = br.buildExceptionMessage(); throw new IllegalStateException(msg, e); } }