auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code><START> public void testDeleteMissingUseTrash() { <END> final DistCpOptions.Builder builder = new DistCpOptions.Builder( Collections.singletonList(new Path("hdfs://localhost:8020/source")), new Path("hdfs://localhost:8020/target/")); Assert.assertFalse(builder.build().shouldDeleteUseTrash()); DistCpOptions options = builder.withSyncFolder(true) .withDeleteMissing(true) .withDeleteUseTrash(true) .build(); Assert.assertTrue(options.shouldSyncFolder()); Assert.assertTrue(options.shouldDeleteMissing()); Assert.assertTrue(options.shouldDeleteUseTrash()); options = new DistCpOptions.Builder( Collections.singletonList(new Path("hdfs://localhost:8020/source")), new Path("hdfs://localhost:8020/target/")) .withOverwrite(true) .withDeleteMissing(true) .withDeleteUseTrash(true) .build(); Assert.assertTrue(options.shouldDeleteUseTrash()); Assert.assertTrue(options.shouldOverwrite()); Assert.assertTrue(options.shouldDeleteMissing()); try { new DistCpOptions.Builder( Collections.singletonList(new Path("hdfs://localhost:8020/source")), new Path("hdfs://localhost:8020/target/")) .withDeleteUseTrash(true) .build(); fail("Delete useTrash should fail without delete option"); } catch (IllegalArgumentException e) { assertExceptionContains( "Delete useTrash is applicable only with delete option", e); } }</code><technical_language>assert true/false calls *MUST* a string message include a failure. Imagine a report of a test run failure jenkins, want understand failed work out line specific branch of code</technical_language>

Target:
public void testDeleteMissingUseTrash() throws Exception { final DistCpOptions.Builder builder = new DistCpOptions.Builder( Collections.singletonList(new Path("hdfs://localhost:8020/source")), new Path("hdfs://localhost:8020/target/")); Assert.assertFalse("Delete does not use trash by default.", builder.build().shouldDeleteUseTrash()); DistCpOptions options = builder.withSyncFolder(true) .withDeleteMissing(true) .withDeleteUseTrash(true) .build(); Assert.assertTrue(options.shouldSyncFolder()); Assert.assertTrue(options.shouldDeleteMissing()); Assert.assertTrue(options.shouldDeleteUseTrash()); options = new DistCpOptions.Builder( Collections.singletonList(new Path("hdfs://localhost:8020/source")), new Path("hdfs://localhost:8020/target/")) .withOverwrite(true) .withDeleteMissing(true) .withDeleteUseTrash(true) .build(); Assert.assertTrue(options.shouldDeleteUseTrash()); Assert.assertTrue(options.shouldOverwrite()); Assert.assertTrue(options.shouldDeleteMissing()); LambdaTestUtils.intercept(IllegalArgumentException.class, () -> new DistCpOptions.Builder(Collections.singletonList( new Path("hdfs://localhost:8020/source")), new Path("hdfs://localhost:8020/target/")) .withDeleteUseTrash(true) .build()); }
Source:
<code>public void create() { Composite parent = getParent(); Map<String, HyperLink> model = getModel(); if (parent == null || model.size() == 0) { return; } setupControl(parent); ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); scrolledComposite.setExpandVertical(true); scrolledComposite.setExpandHorizontal(true); Browser browser = new Browser(scrolledComposite, SWT.NONE); browser.setJavascriptEnabled(false); browser.addLocationListener(new LocationListener() { @Override public void changing(LocationEvent ev) { <START> if (ev.location.startsWith(TIME_PREFIX)) { <END> String time = ev.location.substring(TIME_PREFIX.length()); Long val = Longs.tryParse(time); if (val != null) { TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(ev.getSource(), TmfTimestamp.fromNanos(val))); } ev.doit = false; } } @Override public void changed(LocationEvent ev) { } }); setupControl(browser); String toolTipHtml = toHtml(); browser.setText(toolTipHtml); scrolledComposite.setContent(browser); Point p = computePreferredSize(); scrolledComposite.setMinSize(Math.min(p.x > fScrollBarSize.x ? p.x - fScrollBarSize.x : p.x, 750 - fScrollBarSize.x), 0); }</code><technical_language>This work in windows. For some reason is a trailing /. need a regular expression work cross-platform</technical_language>

Target:
public void create() { Composite parent = getParent(); Map<String, HyperLink> model = getModel(); if (parent == null || model.size() == 0) { return; } setupControl(parent); ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); scrolledComposite.setExpandVertical(true); scrolledComposite.setExpandHorizontal(true); Browser browser = new Browser(scrolledComposite, SWT.NONE); browser.setJavascriptEnabled(false); browser.addLocationListener(new LocationListener() { @Override public void changing(LocationEvent ev) { Matcher matcher = TIME_PATTERN.matcher(ev.location); if (matcher.find()) { String time = matcher.group(1); Long val = Longs.tryParse(time); if (val != null) { TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(ev.getSource(), TmfTimestamp.fromNanos(val))); } ev.doit = false; } } @Override public void changed(LocationEvent ev) { } }); setupControl(browser); String toolTipHtml = toHtml(); browser.setText(toolTipHtml); scrolledComposite.setContent(browser); Point preferredSize = computePreferredSize(); scrolledComposite.setMinSize(Math.min(preferredSize.x > fScrollBarSize.x ? preferredSize.x - fScrollBarSize.x : preferredSize.x, MAX_SHELL_WIDTH - fScrollBarSize.x), 0); }
Source:
<code>public static void main(String[] args) { TextAnalyticsAsyncClient client = new TextAnalyticsClientBuilder() .subscriptionKey("subscription-key") .endpoint("<LINK_0>") .buildAsyncClient(); String text = "hello world"; client.detectLanguage(text).subscribe( result -> { final DetectedLanguage primaryLanguage = result.getPrimaryLanguage(); <START> System.out.printf("Detected Language: %s, ISO 6391 Name: %s, Score: %s", <END> primaryLanguage.getName(), primaryLanguage.getIso6391Name(), primaryLanguage.getScore()); }, error -> System.err.println("There was an error detecting language of the text" + error), () -> System.out.println("Language detected.")); }</code><technical_language>%n</technical_language>

Target:
public static void main(String[] args) { TextAnalyticsAsyncClient client = new TextAnalyticsClientBuilder() .subscriptionKey("subscription-key") .endpoint("<LINK_0>") .buildAsyncClient(); String text = "hello world"; client.detectLanguage(text).subscribe( result -> { final DetectedLanguage primaryLanguage = result.getPrimaryLanguage(); System.out.printf("Detected Language: %s, ISO 6391 Name: %s, Score: %s.%n", primaryLanguage.getName(), primaryLanguage.getIso6391Name(), primaryLanguage.getScore()); }, error -> System.err.println("There was an error detecting language of the text." + error), () -> System.out.println("Language detected.")); try { TimeUnit.SECONDS.sleep(5); } catch (InterruptedException ignored) { } }
Source:
<code>public void testNumberOfOwners() { addNode(testAddresses[0], "m0", null, null); updateConsistentHash(1); assertNumberOwners(testAddresses[0], 1); updateConsistentHash(2); assertNumberOwners(testAddresses[0], 1); addNode(testAddresses[1], "m1", null, null); updateConsistentHash(1); <START> for (Address testAddress : ch.getMembers()) { <END> assertNumberOwners(testAddress, 1); } updateConsistentHash(2); for (Address testAddress : ch.getMembers()) { assertNumberOwners(testAddress, 2); } updateConsistentHash(3); for (Address testAddress : ch.getMembers()) { assertNumberOwners(testAddress, 2); } addNode(testAddresses[2], "m0", null, null); updateConsistentHash(1); for (Address testAddress : ch.getMembers()) { assertNumberOwners(testAddress, 1); } updateConsistentHash(2); for (Address testAddress : ch.getMembers()) { assertNumberOwners(testAddress, 2); } updateConsistentHash(3); for (Address testAddress : ch.getMembers()) { assertNumberOwners(testAddress, 3); } updateConsistentHash(4); for (Address testAddress : ch.getMembers()) { assertNumberOwners(testAddress, 3); } }</code><technical_language>This is kind of outdated, test iterate segments check owners of segment instead</technical_language>

Target:
public void testNumberOfOwners() { addNode(testAddresses[0], "m0", null, null); updateConsistentHash(1); IntStream.range(0, numSegments).forEach(i -> assertOwners(i, 1)); updateConsistentHash(2); IntStream.range(0, numSegments).forEach(i -> assertOwners(i, 1)); addNode(testAddresses[1], "m1", null, null); updateConsistentHash(1); int numSegments = ch.getNumSegments(); IntStream.range(0, numSegments).forEach(i -> assertOwners(i, 1)); updateConsistentHash(2); IntStream.range(0, numSegments).forEach(i -> assertOwners(i, 2)); updateConsistentHash(3); IntStream.range(0, numSegments).forEach(i -> assertOwners(i, 2)); addNode(testAddresses[2], "m0", null, null); updateConsistentHash(1); IntStream.range(0, numSegments).forEach(i -> assertOwners(i, 1)); updateConsistentHash(2); IntStream.range(0, numSegments).forEach(i -> assertOwners(i, 2)); updateConsistentHash(3); IntStream.range(0, numSegments).forEach(i -> assertOwners(i, 3)); updateConsistentHash(4); IntStream.range(0, numSegments).forEach(i -> assertOwners(i, 3)); }
Source:
<code>private static void runErlc(ErlangTarget target, CompileContext context, ErlangCompilerOptions compilerOptions, List<String> erlangModulePathsToCompile, BuildOutputConsumer outputConsumer, File outputDirectory, boolean isTest) throws ProjectBuildException, IOException { GeneralCommandLine commandLine = getErlcCommandLine(target, context, compilerOptions, outputDirectory, erlangModulePathsToCompile, isTest); Process process; <START> LOG.debug("Run erlc compiler with command" + commandLine.getCommandLineString()); <END> try { process = commandLine.createProcess(); } catch (ExecutionException e) { throw new ProjectBuildException("Failed to launch erlang compiler", e); } BaseOSProcessHandler handler = new BaseOSProcessHandler(process, commandLine.getCommandLineString(), Charset.defaultCharset()); ProcessAdapter adapter = new ErlangCompilerProcessAdapter(context, NAME, ""); handler.addProcessListener(adapter); handler.startNotify(); handler.waitFor(); consumeFiles(outputConsumer, getOutputErlangModuleFiles(erlangModulePathsToCompile, outputDirectory)); }</code><technical_language>hard read this log message - is space command line string</technical_language>

Target:
private static void runErlc(ErlangTarget target, CompileContext context, ErlangCompilerOptions compilerOptions, List<String> erlangModulePathsToCompile, BuildOutputConsumer outputConsumer, File outputDirectory, boolean isTest) throws ProjectBuildException, IOException { GeneralCommandLine commandLine = getErlcCommandLine(target, context, compilerOptions, outputDirectory, erlangModulePathsToCompile, isTest); Process process; LOG.debug("Run erlc compiler with command " + commandLine.getCommandLineString()); try { process = commandLine.createProcess(); } catch (ExecutionException e) { throw new ProjectBuildException("Failed to launch erlang compiler", e); } BaseOSProcessHandler handler = new BaseOSProcessHandler(process, commandLine.getCommandLineString(), Charset.defaultCharset()); ProcessAdapter adapter = new ErlangCompilerProcessAdapter(context, NAME, ""); handler.addProcessListener(adapter); handler.startNotify(); handler.waitFor(); consumeFiles(outputConsumer, getBeams(erlangModulePathsToCompile, outputDirectory)); }
Source:
<code>private static void checkCfgBlock(CfgBlock cfgBlock, SubscriptionContext ctx, DefinedVariables definedVariables, Set<CfgBlock> unreachableBlocks, DefinedVariablesAnalysis analysis, List<Symbol> ignoredSymbols) { Map<Symbol, DefinedVariablesAnalysis.VariableDefinition> currentState = new HashMap<>(definedVariables.getIn()); for (Tree element : cfgBlock.elements()) { definedVariables.getVariableUsages(element).forEach((symbol, symbolUsage) -> { if (symbolUsage.isWrite()) { currentState.put(symbol, DefinedVariablesAnalysis.VariableDefinition.DEFINED); } DefinedVariablesAnalysis.VariableDefinition varDef = currentState.getOrDefault(symbol, DefinedVariablesAnalysis.VariableDefinition.DEFINED); if (symbolUsage.isRead() && isUndefined(varDef) && !isSymbolUsedInUnreachableBlocks(analysis, unreachableBlocks, symbol) && !isParameter(element) && !ignoredSymbols.contains(symbol)) { ignoredSymbols.add(symbol); <START> Optional<Usage> suspectUsage = symbol.usages().stream().filter(u -> TreeUtils.hasDescendant(element, t -> t.equals(u.tree()))).findFirst(); <END> suspectUsage.ifPresent(s -> { PreciseIssue issue = ctx.addIssue(s.tree(), symbol.name() + " is used before it is defined. Move the definition before."); symbol.usages().stream().filter(u -> !u.equals(s)).forEach(us -> issue.secondary(us.tree(), null)); }); } }); } }</code><technical_language>This filtering is suspicious me. @andrea-guarino-sonarsource please a look</technical_language>

Target:
private static void checkCfgBlock(CfgBlock cfgBlock, SubscriptionContext ctx, DefinedVariables definedVariables, Set<CfgBlock> unreachableBlocks, DefinedVariablesAnalysis analysis, List<Symbol> ignoredSymbols) { Map<Symbol, DefinedVariablesAnalysis.VariableDefinition> currentState = new HashMap<>(definedVariables.getIn()); for (Tree element : cfgBlock.elements()) { definedVariables.getSymbolReadWrites(element).forEach((symbol, symbolReadWrite) -> { if (symbolReadWrite.isWrite()) { currentState.put(symbol, DefinedVariablesAnalysis.VariableDefinition.DEFINED); } DefinedVariablesAnalysis.VariableDefinition varDef = currentState.getOrDefault(symbol, DefinedVariablesAnalysis.VariableDefinition.DEFINED); if (symbolReadWrite.isRead() && isUndefined(varDef) && !isSymbolUsedInUnreachableBlocks(analysis, unreachableBlocks, symbol) && !isParameter(element) && !ignoredSymbols.contains(symbol)) { ignoredSymbols.add(symbol); Usage suspectUsage = symbolReadWrite.usages().get(0); PreciseIssue issue = ctx.addIssue(suspectUsage.tree(), symbol.name() + " is used before it is defined. Move the definition before."); symbol.usages().stream().filter(u -> !u.equals(suspectUsage)).forEach(us -> issue.secondary(us.tree(), null)); } }); } }
Source:
<code>private void moveLog(String feedback) { try { File lFile = new File(NavigationService.LOG_FILE); FileUtils.write(lFile, System.getProperty("line.separator") + "User Feedback - " + feedback, true); Log.d(TAG, "Feedback appended"); File destFolder = new File(Application.get().getApplicationContext().getFilesDir() .getAbsolutePath() + File.separator + LOG_DIRECTORY + File.separator + mAction); Log.d(TAG, "sourceLocation: " + lFile); Log.d(TAG, "targetLocation: " + destFolder); try { FileUtils.moveFileToDirectory( FileUtils.getFile(lFile), FileUtils.getFile(destFolder), true); Log.d(TAG, "Move file successful."); } catch (Exception e) { Log.d(TAG, "File move failed"); <START> } <END> } catch (IOException e) { Log.e(TAG, "File write failed: " + e.toString()); } }</code><technical_language>is extra bracket } here</technical_language>

Target:
private void moveLog(String feedback) { try { Log.d(TAG, "Log file: "+ mLogFile); File lFile = new File(mLogFile); FileUtils.write(lFile, System.getProperty("line.separator") + feedback, true); Log.d(TAG, "Feedback appended"); File destFolder = new File(Application.get().getApplicationContext().getFilesDir() .getAbsolutePath() + File.separator + LOG_DIRECTORY + File.separator + mUserResponse); Log.d(TAG, "sourceLocation: " + lFile); Log.d(TAG, "targetLocation: " + destFolder); try { FileUtils.moveFileToDirectory( FileUtils.getFile(lFile), FileUtils.getFile(destFolder), true); Log.d(TAG, "Move file successful."); } catch (Exception e) { Log.d(TAG, "File move failed"); } setupLogUploadTask(); } catch (IOException e) { Log.e(TAG, "File write failed: " + e.toString()); } }
Source:
<code>public SSHClient create() throws Exception { ssh = new net.schmizz.sshj.SSHClient(); ssh.addHostKeyVerifier(new PromiscuousVerifier()); if (connectTimeout != 0) { ssh.setConnectTimeout(connectTimeout); } if (sessionTimeout != 0) { ssh.setTimeout(sessionTimeout); } ssh.connect(hostAndPort.getHostText(), hostAndPort.getPortOrDefault(22)); if (loginCredentials.getPassword() != null) { ssh.authPassword(loginCredentials.getUser(), loginCredentials.getPassword()); } else if (SshjSshClient.hasValidPrivateKey(loginCredentials)){ OpenSSHKeyFile key = new OpenSSHKeyFile(); key.init(loginCredentials.getPrivateKey(), null); ssh.authPublickey(loginCredentials.getUser(), key); } else { <START> AgentProxy proxy= SshjSshClient.getSSHAgentProxy(); <END> if (proxy != null) { ssh.auth(loginCredentials.getUser(), getAuthMethods(proxy)); } } return ssh; }</code><technical_language>[minor] Space =</technical_language>

Target:
public SSHClient create() throws Exception { ssh = new net.schmizz.sshj.SSHClient(); ssh.addHostKeyVerifier(new PromiscuousVerifier()); if (connectTimeout != 0) { ssh.setConnectTimeout(connectTimeout); } if (sessionTimeout != 0) { ssh.setTimeout(sessionTimeout); } ssh.connect(hostAndPort.getHostText(), hostAndPort.getPortOrDefault(22)); if (loginCredentials.getPassword() != null) { ssh.authPassword(loginCredentials.getUser(), loginCredentials.getPassword()); } else if (loginCredentials.hasUnencryptedPrivateKey()) { OpenSSHKeyFile key = new OpenSSHKeyFile(); key.init(loginCredentials.getPrivateKey(), null); ssh.authPublickey(loginCredentials.getUser(), key); } else if (agentConnector.isPresent()) { AgentProxy proxy = new AgentProxy(agentConnector.get()); ssh.auth(loginCredentials.getUser(), getAuthMethods(proxy)); } return ssh; }
Source:
<code>public ConfigurationClientBuilder connectionString(String connectionString) { Objects.requireNonNull(connectionString); try { this.credential = new ConfigurationClientCredentials(connectionString); } catch (InvalidKeyException err) { <START> throw logger.logExceptionAsError(new IllegalArgumentException( <END> "The secret is invalid and cannot instantiate the HMAC-SHA256 algorithm.")); } catch (NoSuchAlgorithmException err) { throw logger.logExceptionAsError( new IllegalArgumentException("HMAC-SHA256 MAC algorithm cannot be instantiated.")); } this.endpoint = credential.getBaseUri(); return this; }</code><technical_language>Pass err parameter IllegalArgumentException. users expand throwable</technical_language>

Target:
public ConfigurationClientBuilder connectionString(String connectionString) { Objects.requireNonNull(connectionString); try { this.credential = new ConfigurationClientCredentials(connectionString); } catch (InvalidKeyException err) { throw logger.logExceptionAsError(new IllegalArgumentException( "The secret is invalid and cannot instantiate the HMAC-SHA256 algorithm.", err)); } catch (NoSuchAlgorithmException err) { throw logger.logExceptionAsError( new IllegalArgumentException("HMAC-SHA256 MAC algorithm cannot be instantiated.", err)); } this.endpoint = credential.getBaseUri(); return this; }
Source:
<code>private List<EvaluatorParameters> filterLatestParams(final List<EvaluatorParameters> params) { final Set<String> uniqueIds = <START> params.stream().map(EvaluatorParameters::getId).distinct().collect(Collectors.toSet()); <END> final List<EvaluatorParameters> latestParams = new ArrayList<>(uniqueIds.size()); for (final String id : uniqueIds) { final List<EvaluatorParameters> filteredList = params.stream().filter(param -> param.getId().equals(id)).collect(Collectors.toList()); final EvaluatorParameters latestParam = filteredList.get(filteredList.size() - 1); latestParams.add(latestParam); } return latestParams; }</code><technical_language>distinct() Collectors.toSet()? need of them</technical_language>

Target:
private List<EvaluatorParameters> filterLatestParams(final List<EvaluatorParameters> params) { final Map<String, EvaluatorParameters> evalIdToParameters = new HashMap<>(); final ListIterator<EvaluatorParameters> listIterator = params.listIterator(params.size()); while (listIterator.hasPrevious()) { final EvaluatorParameters evalParams = listIterator.previous(); evalIdToParameters.putIfAbsent(evalParams.getId(), evalParams); } return new ArrayList<>(evalIdToParameters.values()); }
Source:
<code>public String getBulkSamples(@RequestBody JSONObject json) throws IOException { JSONArray ids = JSONArray.fromObject(json.get("ids")); StringBuffer stringBuffer = new StringBuffer(); for (int i = 0; i < ids.size(); ++i) { stringBuffer.append(ids.getLong(i)); <START> if (i + 1 < ids.size()) { <END> stringBuffer.append(","); } } return "redirect:/miso/sample/bulk/edit/" + stringBuffer.toString(); }</code><technical_language>This is easier read as: for (int i = 0; i < ids.size(); ++i) { if (i>0) { stringBuffer.append(","); } stringBuffer.append(ids.getLong(i)); }</technical_language>

Target:
public String getBulkSamples(@RequestBody JSONObject json) throws IOException { JSONArray ids = JSONArray.fromObject(json.get("ids")); StringBuffer stringBuffer = new StringBuffer(); for (int i = 0; i < ids.size(); ++i) { if (i > 0) stringBuffer.append(","); stringBuffer.append(ids.getLong(i)); } return "redirect:/miso/sample/bulk/edit/" + stringBuffer.toString(); }
Source:
<code>public Map<String, Integer> getStats() { int in = 0; int out = 0; for (Peer peer : peers.values()) { Map<String, Integer> connStats = peer.getStats(); in += connStats.get("connections.in"); out += connStats.get("connections.out"); } <START> Map<String, Integer> result = new HashMap<>(2); <END> result.put("connections.in", in); result.put("connections.out", out); return result; }</code><technical_language>new HashMap(3) hold 2 entries... more 3 - reduce chance of hash collisions</technical_language>

Target:
public Map<String, Integer> getStats() { int in = 0; int out = 0; for (Peer peer : peers.values()) { Map<String, Integer> connStats = peer.getStats(); in += connStats.get("connections.in"); out += connStats.get("connections.out"); } Map<String, Integer> result = new HashMap<>(3); result.put("connections.in", in); result.put("connections.out", out); return result; }
Source:
<code>private void runReplicableCommand(ReplicableCommand command, Reply reply, boolean preserveOrder) { try { invokeReplicableCommand(command, reply, preserveOrder); } catch (Throwable throwable) { <START> if (throwable.getCause() != null && (throwable instanceof CompletionException || throwable instanceof CacheConfigurationException)) { <END> throwable = throwable.getCause(); } if (throwable instanceof InterruptedException || throwable instanceof IllegalLifecycleStateException) { log.shutdownHandlingCommand(command); reply.reply(shuttingDownResponse()); } else { log.exceptionHandlingCommand(command, throwable); reply.reply(exceptionHandlingCommand(throwable)); } } }</code><technical_language>I prefer changing AbstractComponentRegistry.wireDependencies() stop wrapping IllegalLifecycleStateException</technical_language>

Target:
private void runReplicableCommand(ReplicableCommand command, Reply reply, boolean preserveOrder) { try { invokeReplicableCommand(command, reply, preserveOrder); } catch (Throwable throwable) { if (throwable.getCause() != null && throwable instanceof CompletionException) { throwable = throwable.getCause(); } if (throwable instanceof InterruptedException || throwable instanceof IllegalLifecycleStateException) { log.shutdownHandlingCommand(command); reply.reply(shuttingDownResponse()); } else { log.exceptionHandlingCommand(command, throwable); reply.reply(exceptionHandlingCommand(throwable)); } } }
Source:
<code>public DurableTracker(int leeway, String topic, int partition, String consumerGroup) { if (leeway <= 0) { throw new IllegalArgumentException("leeways is zero or negative"); } <START> lag = new long[leeway]; <END> this.topic = topic; this.partition = partition; this.consumerGroup = consumerGroup; }</code><technical_language>For sake of readability, lag reimplemented a RangeSet<Long>, commit insert a new range RangeSet, merge previous range if possible. Commit tracker return end offset of contiguous range. DRConsumerDrIdTracker similar implementation</technical_language>

Target:
public DurableTracker(int leeway, String topic, int partition, String consumerGroup) { if (leeway <= 0) { throw new IllegalArgumentException("leeways is zero or negative"); } committedOffsets = new long[leeway]; this.topic = topic; this.partition = partition; this.consumerGroup = consumerGroup; }
Source:
<code>private void registerAllOvfDisks(List<DiskImage> ovfStoreDiskImages) { for (DiskImage ovfStoreDiskImage : ovfStoreDiskImages) { ovfStoreDiskImage.setDiskAlias(OvfInfoFileConstants.OvfStoreDescriptionLabel); ovfStoreDiskImage.setDiskDescription(OvfInfoFileConstants.OvfStoreDescriptionLabel); ovfStoreDiskImage.setShareable(true); RegisterDiskParameters registerDiskParams = new RegisterDiskParameters(ovfStoreDiskImage, getParameters().getStorageDomainId()); boolean registerDiskResult = runInternalAction(VdcActionType.RegisterDisk, registerDiskParams, cloneContext()).getSucceeded(); log.infoFormat("Register new floating OVF_STORE disk with disk id {0} for storage domain {1} has {2}", ovfStoreDiskImage.getId(), getParameters().getStorageDomainId(), registerDiskResult ? "succeeded" : "failed"); if (registerDiskResult) { <START> log.infoFormat("Adding OVF_STORE disk with disk id {0} to storage domain {1}", <END> ovfStoreDiskImage.getId(), getParameters().getStorageDomainId()); addOvfStoreDiskToDomain(ovfStoreDiskImage); } } }</code><technical_language>a log indicating this, is benefit add another</technical_language>

Target:
private void registerAllOvfDisks(List<DiskImage> ovfStoreDiskImages) { for (DiskImage ovfStoreDiskImage : ovfStoreDiskImages) { ovfStoreDiskImage.setDiskAlias(OvfInfoFileConstants.OvfStoreDescriptionLabel); ovfStoreDiskImage.setDiskDescription(OvfInfoFileConstants.OvfStoreDescriptionLabel); ovfStoreDiskImage.setShareable(true); RegisterDiskParameters registerDiskParams = new RegisterDiskParameters(ovfStoreDiskImage, getParameters().getStorageDomainId()); boolean registerDiskResult = runInternalAction(VdcActionType.RegisterDisk, registerDiskParams, cloneContext()).getSucceeded(); log.info("Register new floating OVF_STORE disk with disk id '{}' for storage domain '{}' has {}", ovfStoreDiskImage.getId(), getParameters().getStorageDomainId(), registerDiskResult ? "succeeded" : "failed"); if (registerDiskResult) { addOvfStoreDiskToDomain(ovfStoreDiskImage); } } }
Source:
<code><START> public boolean equals(Object obj) { <END> if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } RealmConfiguration that = (RealmConfiguration) obj; if (schemaVersion != that.schemaVersion) { return false; } if (deleteRealmIfMigrationNeeded != that.deleteRealmIfMigrationNeeded) { return false; } if (!realmDirectory.equals(that.realmDirectory)) { return false; } if (!realmFileName.equals(that.realmFileName)) { return false; } if (!canonicalPath.equals(that.canonicalPath)) { return false; } if (!Arrays.equals(key, that.key)) { return false; } if (!durability.equals(that.durability)) { return false; } if (migration != null ? !migration.equals(that.migration) : that.migration != null) { return false; } if (rxObservableFactory != null ? !rxObservableFactory.equals(that.rxObservableFactory) : that.rxObservableFactory != null) { return false; } if (initialDataTransaction != null ? !initialDataTransaction.equals(that.initialDataTransaction) : that.initialDataTransaction != null) { return false; } return schemaMediator.equals(that.schemaMediator); }</code><technical_language>is allowed user create a read-only realm in thread A, writeable Realm in thread B? I this matches behaviour Object Store -- need ensure behaviour is migrate Object Store schema, is a breaking change</technical_language>

Target:
public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } RealmConfiguration that = (RealmConfiguration) obj; if (schemaVersion != that.schemaVersion) { return false; } if (deleteRealmIfMigrationNeeded != that.deleteRealmIfMigrationNeeded) { return false; } if (!realmDirectory.equals(that.realmDirectory)) { return false; } if (!realmFileName.equals(that.realmFileName)) { return false; } if (!canonicalPath.equals(that.canonicalPath)) { return false; } if (!Arrays.equals(key, that.key)) { return false; } if (!durability.equals(that.durability)) { return false; } if (migration != null ? !migration.equals(that.migration) : that.migration != null) { return false; } if (rxObservableFactory != null ? !rxObservableFactory.equals(that.rxObservableFactory) : that.rxObservableFactory != null) { return false; } if (initialDataTransaction != null ? !initialDataTransaction.equals(that.initialDataTransaction) : that.initialDataTransaction != null) { return false; } if (readOnly != that.readOnly) { return false; } return schemaMediator.equals(that.schemaMediator); }
Source:
<code>private boolean isHttpWebsite(String siteUrl) throws IOException { URL url = new URL("http://" + siteUrl); HttpURLConnection httpCon = (HttpURLConnection)url.openConnection(); int responseCode = 0; if (httpCon == null) return (false); try { responseCode = httpCon.getResponseCode(); <START> } catch (UnknownHostException e) { <END> e.printStackTrace(); return (false); } httpCon.disconnect(); if (responseCode == 200) return (true); return (false); }</code><technical_language>above: catching some other exceptions? And: missing details if connection fails. "Host 'xxx' found" a typo, for example</technical_language>

Target:
private boolean isHttpWebsite(String siteUrl) throws IOException { URL url = new URL("http://" + siteUrl); HttpURLConnection httpCon = (HttpURLConnection)url.openConnection(); int responseCode = 0; if (httpCon == null) return (false); try { responseCode = httpCon.getResponseCode(); } catch (UnknownHostException e) { Log.e("URLHelper", "UnknownHostException", e.getCause()); return (false); } httpCon.disconnect(); if (responseCode == 200) return (true); return (false); }
Source:
<code>static <K, V, M extends Map<K, V>> M replaceValue(M map, K key, V value) { <START> return map.containsKey(key) ? put(map, Tuple(key, value)) : map; <END> }</code><technical_language>I version avoid cast M. Is OK? Please cast (M) map.put(key, value). save additional Tuple instance scales for calls. I collections low-level, performant possible. A cast is fast</technical_language>

Target:
static <K, V, M extends Map<K, V>> M replaceValue(M map, K key, V value) { return map.containsKey(key) ? (M) map.put(key, value) : map; }
Source:
<code>protected void recomputeNumBuckets() { if(useSystemTime){ Calendar calendar = Calendar.getInstance(); long now = calendar.getTimeInMillis()/1000; calendar.add(Calendar.SECOND, (int) -expiryPeriod); <START> startOfBuckets = calendar.getTimeInMillis()/1000; <END> expiryPoint = startOfBuckets; noOfBuckets = (int) Math.ceil((now - startOfBuckets) / (bucketSpan * 1.0)) + 1; logger.debug("Now {}, StartOfBuckets {}, Expiry Point {}, Num Buckets {}, Expiry Period: {}", now, startOfBuckets, expiryPoint, noOfBuckets, expiryPeriod); } else{ startOfBuckets = 0; expiryPoint = startOfBuckets; noOfBuckets = (int) Math.ceil((expiryPeriod) / (bucketSpan * 1.0)) + 1; } noOfBucketsInMemory = noOfBuckets; if (bucketStore != null) { bucketStore.setNoOfBuckets(noOfBuckets); bucketStore.setWriteEventKeysOnly(writeEventKeysOnly); } maxExpiryPerBucket = new Long[noOfBuckets]; }</code><technical_language>Do formatting here. spaces missing</technical_language>

Target:
protected void recomputeNumBuckets() { if(useSystemTime){ Calendar calendar = Calendar.getInstance(); long now = calendar.getTimeInMillis() / 1000; calendar.add(Calendar.SECOND, (int) -expiryPeriod); startOfBuckets = calendar.getTimeInMillis() / 1000; expiryPoint = startOfBuckets; noOfBuckets = (int) Math.ceil(( now - startOfBuckets ) / ( bucketSpan * 1.0 )) + 1; logger.debug("Now {}, StartOfBuckets {}, Expiry Point {}, Num Buckets {}, Expiry Period: {}", now, startOfBuckets, expiryPoint, noOfBuckets, expiryPeriod); } else{ startOfBuckets = 0; expiryPoint = startOfBuckets; noOfBuckets = (int) Math.ceil((expiryPeriod) / (bucketSpan * 1.0)) + 1; } noOfBucketsInMemory = noOfBuckets; if (bucketStore != null) { bucketStore.setNoOfBuckets(noOfBuckets); bucketStore.setWriteEventKeysOnly(writeEventKeysOnly); } maxExpiryPerBucket = new long[noOfBuckets]; }
Source:
<code>void setUp() { aggregateIdentifier = UUID.randomUUID().toString(); commandBus = SimpleCommandBus.builder().build(); eventStore = spy(EmbeddedEventStore.builder().storageEngine(new InMemoryEventStorageEngine()).build()); <START> eventStore.publish(new GenericDomainEventMessage<>(CountingAggregate.class.getSimpleName(), aggregateIdentifier, 0, <END> new AggregateCreatedEvent(aggregateIdentifier), null)); reset(eventStore); reportErrorCallback = (commandMessage, commandResultMessage) -> { if (commandResultMessage.isExceptional()) { Throwable cause = commandResultMessage.exceptionResult(); throw new RuntimeException("Failure", cause); } }; expectErrorCallback = (commandMessage, commandResultMessage) -> { if (commandResultMessage.isExceptional()) { Throwable cause = commandResultMessage.exceptionResult(); assertEquals("Mock exception", cause.getMessage()); } else { fail("Expected this command to fail"); } }; }</code><technical_language>this test work changes? If so, I suggest this change. If not, a compatibility issue</technical_language>

Target:
void setUp() { aggregateIdentifier = UUID.randomUUID().toString(); commandBus = SimpleCommandBus.builder().build(); eventStore = spy(EmbeddedEventStore.builder().storageEngine(new InMemoryEventStorageEngine()).build()); eventStore.publish(new GenericDomainEventMessage<>("test", aggregateIdentifier, 0, new AggregateCreatedEvent(aggregateIdentifier), null)); reset(eventStore); reportErrorCallback = (commandMessage, commandResultMessage) -> { if (commandResultMessage.isExceptional()) { Throwable cause = commandResultMessage.exceptionResult(); throw new RuntimeException("Failure", cause); } }; expectErrorCallback = (commandMessage, commandResultMessage) -> { if (commandResultMessage.isExceptional()) { Throwable cause = commandResultMessage.exceptionResult(); assertEquals("Mock exception", cause.getMessage()); } else { fail("Expected this command to fail"); } }; }
Source:
<code>protected void executeVmCommand() { <START> importVmLease(); <END> super.executeVmCommand(); }</code><technical_language>import create (considering imported configuration)? a good patch Liron [1] called handleVmLease. important [1] <LINK_0></technical_language>

Target:
protected void executeVmCommand() { handleVmLease(); super.executeVmCommand(); }
Source:
<code>public void closeSearch() { isSearchActive = false; getActivity().supportInvalidateOptionsMenu(); <START> getActivity().supportInvalidateOptionsMenu(); <END> ((PageActivity)getActivity()).getSearchBarHideHandler().setForceNoFade(false); setSearchViewEnabled(false); ((PageActivity) getActivity()).getDrawerToggle().setDrawerIndicatorEnabled(true); searchContainerView.setVisibility(View.GONE); hideSoftKeyboard(getActivity()); addRecentSearch(lastSearchedText); }</code><technical_language>Is this intentional</technical_language>

Target:
public void closeSearch() { isSearchActive = false; getActivity().supportInvalidateOptionsMenu(); ((PageActivity)getActivity()).getSearchBarHideHandler().setForceNoFade(false); setSearchViewEnabled(false); ((PageActivity) getActivity()).getDrawerToggle().setDrawerIndicatorEnabled(true); searchContainerView.setVisibility(View.GONE); hideSoftKeyboard(getActivity()); addRecentSearch(lastSearchedText); }
Source:
<code>public static boolean hasCompatibleCapabilities( RecordFormats one, RecordFormats other, CapabilityType type ) { Set<Capability> myFormatCapabilities = Stream.of( one.capabilities() ) .filter( capability -> capability.isType( type ) ).collect( toSet() ); Set<Capability> otherFormatCapabilities = Stream.of( other.capabilities() ) .filter( capability -> capability.isType( type ) ).collect( toSet() ); if ( myFormatCapabilities.equals( otherFormatCapabilities ) ) { return true; } <START> Set<Capability> removedCapabilities = <END> new HashSet<>( myFormatCapabilities ).stream().filter( capability -> !otherFormatCapabilities.contains( capability ) ).collect( toSet() ); Set<Capability> addedCapabilities = new HashSet<>( otherFormatCapabilities ).stream().filter( capability -> !myFormatCapabilities.contains( capability ) ).collect( toSet() ); boolean allAddedAreAdditive = addedCapabilities.stream().allMatch( Capability::isAdditive ); if ( removedCapabilities.isEmpty() && allAddedAreAdditive ) { return true; } return false; }</code><technical_language>i this is more shorted equivalent: boolean capabilitiesNotRemoved = otherFormatCapabilities.containsAll( myFormatCapabilities ); otherFormatCapabilities.removeAll( myFormatCapabilities ); boolean allAddedAreAdditive = otherFormatCapabilities.stream().allMatch( Capability::isAdditive ); // if capabilities of a special case if additional // capabilities of other format additive compatible data // in existing store needs migrated. return capabilitiesNotRemoved && allAddedAreAdditive;</technical_language>

Target:
public static boolean hasCompatibleCapabilities( RecordFormats one, RecordFormats other, CapabilityType type ) { Set<Capability> myFormatCapabilities = Stream.of( one.capabilities() ) .filter( capability -> capability.isType( type ) ).collect( toSet() ); Set<Capability> otherFormatCapabilities = Stream.of( other.capabilities() ) .filter( capability -> capability.isType( type ) ).collect( toSet() ); if ( myFormatCapabilities.equals( otherFormatCapabilities ) ) { return true; } boolean capabilitiesNotRemoved = otherFormatCapabilities.containsAll( myFormatCapabilities ); otherFormatCapabilities.removeAll( myFormatCapabilities ); boolean allAddedAreAdditive = otherFormatCapabilities.stream().allMatch( Capability::isAdditive ); return capabilitiesNotRemoved && allAddedAreAdditive; }
Source:
<code>public List<Metric> getMetrics() throws AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException, IOException { Map<String, List<Metric>> subMetrics = new HashMap<String, List<Metric>>(); for (Map.Entry<String, List<String>> entry : subAttributeList.entrySet()) { String dataKey = entry.getKey(); List<String> subSub = entry.getValue(); for (String metricKey : subSub) { <START> String alias = getAlias(metricKey); <END> String metricType = getMetricType(metricKey); String[] tags = getTags(dataKey, metricKey); Metric metric = new Metric(alias, metricType, tags, checkName); double value = castToDouble(getValue(dataKey, metricKey), null); metric.setValue(value); String fullMetricKey = getAttributeName() + "." + metricKey; if (!subMetrics.containsKey(fullMetricKey)) { subMetrics.put(fullMetricKey, new ArrayList<Metric>()); } subMetrics.get(fullMetricKey).add(new Metric(alias, metricType, value, tags)); } } List<Metric> metrics = new ArrayList<Metric>(subMetrics.keySet().size()); for (String key : subMetrics.keySet()) { if (getAttributesFor(key) != null) { metrics.addAll(sortAndFilter(key, subMetrics.get(key))); } } return metrics; }</code><technical_language>this fine getAlias() calls convertMetricName, duplicating work</technical_language>

Target:
public List<Metric> getMetrics() throws AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException, IOException { Map<String, List<Metric>> subMetrics = new HashMap<String, List<Metric>>(); for (Map.Entry<String, List<String>> entry : subAttributeList.entrySet()) { String dataKey = entry.getKey(); List<String> subSub = entry.getValue(); for (String metricKey : subSub) { String alias = getAlias(metricKey); String metricType = getMetricType(metricKey); String[] tags = getTags(dataKey, metricKey); Metric metric = new Metric(alias, metricType, tags, checkName); double value = castToDouble(getValue(dataKey, metricKey), null); metric.setValue(value); String fullMetricKey = getAttributeName() + "." + metricKey; if (!subMetrics.containsKey(fullMetricKey)) { subMetrics.put(fullMetricKey, new ArrayList<Metric>()); } subMetrics.get(fullMetricKey).add(metric); } } List<Metric> metrics = new ArrayList<Metric>(subMetrics.keySet().size()); for (String key : subMetrics.keySet()) { if (getAttributesFor(key) != null) { metrics.addAll(sortAndFilter(key, subMetrics.get(key))); } } return metrics; }
Source:
<code>private void registerBrush(int id) { int subId, completId; BrushDescriptor whiteDesc = null; String name; String[] subNames = { TR_NAME(Type.NONE, "Black Brush"), TR_NAME(Type.NONE, "Red Brush"), TR_NAME(Type.NONE, "Green Brush"), TR_NAME(Type.NONE, "Brown Brush"), TR_NAME(Type.NONE, "Blue Brush"), TR_NAME(Type.NONE, "Purple Brush"), TR_NAME(Type.NONE, "Cyan Brush"), TR_NAME(Type.NONE, "Silver Brush"), TR_NAME(Type.NONE, "Gray Brush"), TR_NAME(Type.NONE, "Pink Brush"), TR_NAME(Type.NONE, "Lime Brush"), TR_NAME(Type.NONE, "Yellow Brush"), TR_NAME(Type.NONE, "Light Blue Brush"), TR_NAME(Type.NONE, "Magenta Brush"), TR_NAME(Type.NONE, "Orange Brush"), TR_NAME(Type.NONE, "White Brush")}; for (int idx = 0; idx < 16; idx++) { subId = idx; name = subNames[idx]; BrushDescriptor desc = new BrushDescriptor(name); sharedItem.addElement(subId + (id << 6), desc); whiteDesc = desc; } ItemStack emptyStack = findItemStack("White Brush"); whiteDesc.setLife(emptyStack, 0); for (int idx = 0; idx < 16; idx++) { addShapelessRecipe(emptyStack.copy(), new ItemStack(Blocks.wool, 1, idx), <START> findItemStack("Iron Cable")); <END> } for (int idx = 0; idx < 16; idx++) { name = subNames[idx]; addShapelessRecipe(findItemStack(name, 1), new ItemStack(Items.dye, 1, idx), emptyStack.copy()); } }</code><technical_language>.fair enough, I feel flop in hand. change recipe produce multiple outputs instead; 1 wool is a lot of wool, 3 a bed</technical_language>

Target:
private void registerBrush(int id) { int subId, completId; BrushDescriptor whiteDesc = null; String name; String[] subNames = { TR_NAME(Type.NONE, "Black Brush"), TR_NAME(Type.NONE, "Red Brush"), TR_NAME(Type.NONE, "Green Brush"), TR_NAME(Type.NONE, "Brown Brush"), TR_NAME(Type.NONE, "Blue Brush"), TR_NAME(Type.NONE, "Purple Brush"), TR_NAME(Type.NONE, "Cyan Brush"), TR_NAME(Type.NONE, "Silver Brush"), TR_NAME(Type.NONE, "Gray Brush"), TR_NAME(Type.NONE, "Pink Brush"), TR_NAME(Type.NONE, "Lime Brush"), TR_NAME(Type.NONE, "Yellow Brush"), TR_NAME(Type.NONE, "Light Blue Brush"), TR_NAME(Type.NONE, "Magenta Brush"), TR_NAME(Type.NONE, "Orange Brush"), TR_NAME(Type.NONE, "White Brush")}; for (int idx = 0; idx < 16; idx++) { subId = idx; name = subNames[idx]; BrushDescriptor desc = new BrushDescriptor(name); sharedItem.addElement(subId + (id << 6), desc); whiteDesc = desc; } ItemStack emptyStack = findItemStack("White Brush"); whiteDesc.setLife(emptyStack, 0); for (int idx = 0; idx < 16; idx++) { addShapelessRecipe(emptyStack.copy(), new ItemStack(Blocks.wool, 1, idx), new ItemStack(Items.iron_ingot)); } for (int idx = 0; idx < 16; idx++) { name = subNames[idx]; addShapelessRecipe(findItemStack(name, 1), new ItemStack(Items.dye, 1, idx), emptyStack.copy()); } }
Source:
<code>public RqWithDefaultHeader(final Request req, <START> final String hdr, <END> final String val) { try { if (new RqHeaders.Base(req) .header(hdr) .iterator() .hasNext() ) { this.request = req; } else { this.request = new RqWithHeader(req, hdr, val); } } catch (final IOException ex) { throw new IllegalStateException(ex); } }</code><technical_language>@exper0 indentation here. combine hdr val line</technical_language>

Target:
public RqWithDefaultHeader(final Request req, final String hdr, final String val) throws IOException { super(RqWithDefaultHeader.buildRequest(req, hdr, val)); }
Source:
<code>public Set<IProject> getProjects(Set<IReferencePoint> referencePoints) { if (referencePoints == null) throw new IllegalArgumentException("Set of reference points is null"); <START> Set<IProject> projectSet = new HashSet<IProject>(); <END> for (IReferencePoint referencePoint : referencePoints) { if (referencePointToProjectMapper.containsKey(referencePoint)) projectSet.add(get(referencePoint)); } return projectSet; }</code><technical_language>Minor - unnecessary explicit type argument declaration for HashSet initilization. Suggestion Set<IProject> projectSet = new HashSet<>();</technical_language>

Target:
public Set<IProject> getProjects(Set<IReferencePoint> referencePoints) { if (referencePoints == null) throw new IllegalArgumentException("Set of reference points is null"); Set<IProject> projectSet = new HashSet<>(); for (IReferencePoint referencePoint : referencePoints) { if (referencePointToProjectMapper.containsKey(referencePoint)) projectSet.add(getProject(referencePoint)); } return projectSet; }
Source:
<code>public void testEndTime() { Trace trace = new Trace(); trace.setStartTime(100); Consumer node1 = new Consumer(); node1.setBaseTime(100000000); trace.getNodes().add(node1); Component node2 = new Component(); node2.setBaseTime(150000000); node2.setDuration(0); node1.getNodes().add(node2); Producer node3 = new Producer(); node3.setBaseTime(200000000); node3.setDuration(50000000); node1.getNodes().add(node3); <START> assertEquals(150000100, trace.endTime()); <END> }</code><technical_language>I for tests need apply changes applied json test data - i.e. convert startTime ms micro node baseTime ns micro. results (except in micro)</technical_language>

Target:
public void testEndTime() { Trace trace = new Trace(); trace.setStartTime(100000); Consumer node1 = new Consumer(); node1.setBaseTime(100000); trace.getNodes().add(node1); Component node2 = new Component(); node2.setBaseTime(150000); node2.setDuration(0); node1.getNodes().add(node2); Producer node3 = new Producer(); node3.setBaseTime(200000); node3.setDuration(50000); node1.getNodes().add(node3); assertEquals(250000, trace.endTime()); }
Source:
<code><START> private static void logException(Throwable e) { <END> Platform.getLog(AntCorePlugin.getPlugin().getBundle()).log(new Status(IStatus.ERROR, AntCorePlugin.PI_ANTCORE, "", e)); }</code><technical_language>please provide error message instead of empty string</technical_language>

Target:
private static void logException(Throwable e) { Platform.getLog(AntCorePlugin.getPlugin().getBundle()).log(new Status(IStatus.ERROR, AntCorePlugin.PI_ANTCORE, e.getLocalizedMessage(), e)); }
Source:
<code>public static Document makeEnhancementOperationBody(String userid, PID pid, Boolean force) { Document msg = new Document(); Element entry = new Element("entry", ATOM_NS); entry.addContent(new Element("author", ATOM_NS) .addContent(new Element("name", ATOM_NS).setText(userid))); Element paramForce = new Element("force", CDR_MESSAGE_NS); if (force) { paramForce.setText("true"); } else { paramForce.setText("false"); } <START> Element enhancements = new Element(ENHANCEMENTS.getName(), ATOM_NS); <END> enhancements.addContent(new Element("pid", ATOM_NS).setText(pid.getRepositoryPath())); enhancements.addContent(paramForce); entry.addContent(enhancements); msg.addContent(entry); return msg; }</code><technical_language>cdr message namespace for enhancement element pid element</technical_language>

Target:
public static Document makeEnhancementOperationBody(String userid, PID pid, Boolean force) { Document msg = new Document(); Element entry = new Element("entry", ATOM_NS); entry.addContent(new Element("author", ATOM_NS) .addContent(new Element("name", ATOM_NS).setText(userid))); Element paramForce = new Element("force", CDR_MESSAGE_NS); if (force) { paramForce.setText("true"); } else { paramForce.setText("false"); } Element enhancements = new Element(RUN_ENHANCEMENTS.getName(), CDR_MESSAGE_NS); enhancements.addContent(new Element("pid", CDR_MESSAGE_NS).setText(pid.getRepositoryPath())); enhancements.addContent(paramForce); entry.addContent(enhancements); msg.addContent(entry); return msg; }