auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public boolean teleportPlayerToServer(final Player p, final String server, final PlayerChangeServerReason reason) throws PlayerStillDeadException { if (transitManager.isPlayerInExitTransit(p.getUniqueId())) { return false; } PlayerChangeServerEvent event = new PlayerChangeServerEvent(reason, p.getUniqueId(), server); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { return false; } if (combatManager.isCombatTagNPC(p)) { return false; } combatManager.unCombatTag(p); if (p.isInsideVehicle()) { BetterShardsPlugin.getInstance().getLogger().log(Level.INFO, "During BetterShards teleport, removing player {0} from vehicle", p.getUniqueId()); p.getVehicle().eject(); } if (p.isDead() && !delayedTransit.contains(p.getUniqueId())) { throw new PlayerStillDeadException(); } transitManager.addPlayerToExitTransit(p.getUniqueId(), server); MercuryManager.warnOfArrival(p.getUniqueId(), server); CustomWorldNBTStorage st = CustomWorldNBTStorage.getWorldNBTStorage(); st.save(p, st.getInvIdentifier(p.getUniqueId()), true); <START> p.setGameMode(GameMode.SPECTATOR); END> boolean delayed = delayedTransit.contains(p.getUniqueId()); sendPlayer(p, server, delayed); return true; }</code><technical_language>inventory is copied sync, if saving is done async</technical_language>

Target:
public boolean teleportPlayerToServer(final Player p, final String server, final PlayerChangeServerReason reason) throws PlayerStillDeadException { if (transitManager.isPlayerInExitTransit(p.getUniqueId())) { return false; } PlayerChangeServerEvent event = new PlayerChangeServerEvent(reason, p.getUniqueId(), server); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { return false; } if (combatManager.isCombatTagNPC(p)) { return false; } combatManager.unCombatTag(p); if (p.isInsideVehicle()) { BetterShardsPlugin.getInstance().getLogger().log(Level.INFO, "During BetterShards teleport, removing player {0} from vehicle", p.getUniqueId()); p.getVehicle().eject(); } if (p.isDead() && !delayedTransit.contains(p.getUniqueId())) { throw new PlayerStillDeadException(); } transitManager.addPlayerToExitTransit(p.getUniqueId(), server); MercuryManager.warnOfArrival(p.getUniqueId(), server); CustomWorldNBTStorage st = CustomWorldNBTStorage.getWorldNBTStorage(); st.save(p, st.getInvIdentifier(p.getUniqueId()), true); boolean delayed = delayedTransit.contains(p.getUniqueId()); sendPlayer(p, server, delayed); return true; }
Source:
<code>public double getPercentile(final double percentile) { if (percentile <= 0) throw new IllegalArgumentException("Cannot query percentiles of 0 or below"); if (percentile >= 1) throw new IllegalArgumentException("Cannot query percentiles of 1 or above"); values().stream() .filter(b -> b.getValue() < 0) .findFirst() .ifPresent(b -> { throw new IllegalArgumentException("Cannot calculate Percentile when negative counts are present " + "in histogram. Bin " + b.getId() + "=" + b.getValue()); }); <START> final double total = getCount(); <END> if (total == 0) throw new IllegalArgumentException("Cannot calculate percentiles when total is zero."); double sofar = 0; for (Bin<K> bin : values()) { sofar += bin.getValue(); if (sofar / total >= percentile) return bin.getIdValue(); } throw new IllegalStateException("UNPOSSIBLE! Could not find percentile: " + percentile); }</code><technical_language>getCount() iterates value, check for negative values. I recommend for efficiency (this PR adds a iteration values) do in go: java double total = 0; for (final Bin<K> b : values()) { if (b.getValue() < 0) { throw new IllegalArgumentException("Cannot calculate Percentile negative counts present " + "in histogram. Bin " + b.getId() + "=" + b.getValue()); } total += bin.getValue(); } This safe extra iteration..</technical_language>

Target:
public double getPercentile(final double percentile) { if (percentile <= 0) throw new IllegalArgumentException("Cannot query percentiles of 0 or below"); if (percentile >= 1) throw new IllegalArgumentException("Cannot query percentiles of 1 or above"); values().stream() .filter(b -> b.getValue() < 0) .findFirst() .ifPresent(b -> { throw new IllegalStateException("Cannot calculate Percentile when negative counts are present " + "in histogram. Bin " + b.getId() + "=" + b.getValue()); }); final double total = getCount(); if (total == 0) throw new IllegalStateException("Cannot calculate percentiles when total is zero."); double soFar = 0; for (Bin<K> bin : values()) { soFar += bin.getValue(); if (soFar / total >= percentile) return bin.getIdValue(); } throw new IllegalStateException("UNPOSSIBLE! Could not find percentile: " + percentile); }
Source:
<code>public String generatePassword(final int length, final List<CharacterRule> rules) { if (length <= 0) { throw new IllegalArgumentException("length must be greater than 0"); } final StringBuilder allChars = new StringBuilder(); final CharBuffer buffer = CharBuffer.allocate(length); if (rules != null) { <START> rules.stream().map((rule) -> { <END> fillRandomCharacters(rule.getValidCharacters(), rule.getNumberOfCharacters(), buffer); return rule; }).forEach((rule) -> { allChars.append(rule.getValidCharacters()); }); } fillRandomCharacters(allChars, length - buffer.position(), buffer); buffer.flip(); randomize(buffer); return buffer.toString(); }</code><technical_language>for streaming API if improves clarity reduces code. I here</technical_language>

Target:
public String generatePassword(final int length, final List<CharacterRule> rules) { if (length <= 0) { throw new IllegalArgumentException("length must be greater than 0"); } final StringBuilder allChars = new StringBuilder(); final CharBuffer buffer = CharBuffer.allocate(length); if (rules != null) { for (CharacterRule rule : rules) { fillRandomCharacters(rule.getValidCharacters(), rule.getNumberOfCharacters(), buffer); allChars.append(rule.getValidCharacters()); } } fillRandomCharacters(allChars, length - buffer.position(), buffer); buffer.flip(); randomize(buffer); return buffer.toString(); }
Source:
<code>private Deque<List<String>> wrap(String functionName, List<String> paramNames, int maxLineLength) { Deque<List<String>> paramLines = new ArrayDeque<>(); <START> paramLines.addLast(new ArrayList<>()); <END> int leading = functionName != null ? functionName.length() : 0; int length = leading; for (String paramName : paramNames) { length += paramName.length() + 2; if (length > maxLineLength) { length = leading + paramName.length(); paramLines.addLast(new ArrayList<>()); } paramLines.getLast().add(paramName); } return paramLines; }</code><technical_language>instead of adding mutable lists addLast adding them, ImmutableList.Builder local variable. start empty builder, then, line is done (because wrapping is required), build list add main list -- reassign variable a new builder. skip need for a Deque List<List<String>> ImmutableList for main list line lists</technical_language>

Target:
private List<List<String>> wrap(String functionName, List<String> paramNames, int maxLineLength) { List<List<String>> paramLines = new ArrayList<>(); ImmutableList.Builder<String> linesBuilder = new ImmutableList.Builder<String>(); int leading = functionName.length(); int length = leading; int punctuation = 2; for (String paramName : paramNames) { length += paramName.length() + punctuation; if (length > maxLineLength) { paramLines.add(linesBuilder.build()); length = leading + paramName.length(); linesBuilder = new ImmutableList.Builder<String>(); } linesBuilder.add(paramName); } paramLines.add(linesBuilder.build()); return paramLines; }
Source:
<code>private void setPayload(VM vm) { <START> try { <END> org.ovirt.engine.core.common.businessentities.VmPayload payload = getEntity(org.ovirt.engine.core.common.businessentities.VmPayload.class, VdcQueryType.GetVmPayload, new GetVmByVmIdParameters(new Guid(vm.getId())), null, false); if (payload != null) { VmPayload p = getMapper(org.ovirt.engine.core.common.businessentities.VmPayload.class, VmPayload.class) .map(payload, null); VmPayloads payloads = new VmPayloads(); payloads.getVmPayload().add(p); vm.setVmPayloads(payloads); } } catch (Exception ex) { } }</code><technical_language>1) Please catch WebFaultException (not generic 'Exception') 2) Please rephrase TODO in a more informative way: "'getEntity()' throws exception if entity is found. refactored programmer's decision. In this context legal receive a payload for this VM, exception is caught ignored."</technical_language>

Target:
protected void setPayload(VM vm) { try { org.ovirt.engine.core.common.businessentities.VmPayload payload = getEntity(org.ovirt.engine.core.common.businessentities.VmPayload.class, VdcQueryType.GetVmPayload, new GetVmByVmIdParameters(new Guid(vm.getId())), null, false); if (payload != null) { VmPayload p = getMapper(org.ovirt.engine.core.common.businessentities.VmPayload.class, VmPayload.class) .map(payload, null); VmPayloads payloads = new VmPayloads(); payloads.getVmPayload().add(p); vm.setVmPayloads(payloads); } } catch (WebFaultException ex) { } }
Source:
<code><START> public void testInsertProperties() { final DataObject dataObject = mock(DataObject.class); final String myImportedClass = "org.MyClass"; when(dataObject.getClassType()).thenReturn(myImportedClass); final DataType existingDt = mock(DataType.class); doReturn(existingDt).when(dataTypeList).findDataTypeByName(myImportedClass); final DataTypeListItem dtListItem = mock(DataTypeListItem.class); final Optional<DataTypeListItem> dtListItemOptional = Optional.of(dtListItem); doReturn(dtListItemOptional).when(dataTypeList).findItem(existingDt); final DataObjectProperty property1 = mock(DataObjectProperty.class); final DataObjectProperty property2 = mock(DataObjectProperty.class); final List<DataObjectProperty> properties = Arrays.asList(property1, property2); when(dataObject.getProperties()).thenReturn(properties); final DataType property1DataType = mock(DataType.class); final DataType property2DataType = mock(DataType.class); doReturn(property1DataType).when(dataTypeList).createNewDataType(property1); doReturn(property2DataType).when(dataTypeList).createNewDataType(property2); dataTypeList.insertProperties(dataObject); verify(dtListItem).insertNestedField(property1DataType); verify(dtListItem).insertNestedField(property2DataType); } <END></code><technical_language>please do mix doReturn thenReturn</technical_language>

Target:
public void testInsertProperties() { final DataObject dataObject = mock(DataObject.class); final String myImportedClass = "org.MyClass"; final DataType existingDt = mock(DataType.class); final DataTypeListItem dtListItem = mock(DataTypeListItem.class); final Optional<DataTypeListItem> dtListItemOptional = Optional.of(dtListItem); final DataObjectProperty property1 = mock(DataObjectProperty.class); final DataObjectProperty property2 = mock(DataObjectProperty.class); final List<DataObjectProperty> properties = Arrays.asList(property1, property2); final DataType property1DataType = mock(DataType.class); final DataType property2DataType = mock(DataType.class); when(dataObject.getClassType()).thenReturn(myImportedClass); when(dataObject.getProperties()).thenReturn(properties); doReturn(Optional.of(existingDt)).when(dataTypeList).findDataTypeByName(myImportedClass); doReturn(dtListItemOptional).when(dataTypeList).findItem(existingDt); doReturn(property1DataType).when(dataTypeList).createNewDataType(property1); doReturn(property2DataType).when(dataTypeList).createNewDataType(property2); dataTypeList.insertProperties(dataObject); verify(dtListItem).insertNestedField(property1DataType); verify(dtListItem).insertNestedField(property2DataType); }
Source:
<code>protected AbstractWebFailoverTestCase(String deploymentName, TransactionMode mode) { this.deploymentName = deploymentName; this.nonOwnerTask = () -> { <START> if (mode.isTransactional()) { <END> try { Thread.sleep(GRACE_TIME_TO_REPLICATE); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }; }</code><technical_language>Missing negation</technical_language>

Target:
protected AbstractWebFailoverTestCase(String deploymentName, TransactionMode mode) { this.deploymentName = deploymentName; this.nonOwnerTask = () -> { if (!mode.isTransactional()) { try { Thread.sleep(GRACE_TIME_TO_REPLICATE); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }; }
Source:
<code>private AsyncTaskManager() { _tasks = new ConcurrentHashMap<Guid, SPMAsyncTask>(); SchedulerUtil scheduler = SchedulerUtilQuartzImpl.getInstance(); scheduler.scheduleAFixedDelayJob(this, "_timer_Elapsed", new Class[]{}, new Object[]{}, Config.<Integer>GetValue(ConfigValues.AsyncTaskPollingRate), Config.<Integer>GetValue(ConfigValues.AsyncTaskPollingRate), TimeUnit.SECONDS); scheduler.scheduleAFixedDelayJob(this, "_cacheTimer_Elapsed", new Class[]{}, new Object[]{}, Config.<Integer>GetValue(ConfigValues.AsyncTaskStatusCacheRefreshRateInSeconds), Config.<Integer>GetValue(ConfigValues.AsyncTaskStatusCacheRefreshRateInSeconds), TimeUnit.SECONDS); _cacheTimeInMinutes = Config.<Integer>GetValue(ConfigValues.AsyncTaskStatusCachingTimeInMinutes); tasksInDbAfterRestart = new ConcurrentHashMap(); Map<Guid, List<AsyncTasks>> rootCommandIdToTasksMap = groupTasksByRootCommandId(DbFacade.getInstance().getAsyncTaskDao().getAll()); <START> for (Guid rootCommandId : rootCommandIdToTasksMap.keySet()) { <END> if (hasTasksWithoutVdsmId(rootCommandIdToTasksMap.get(rootCommandId))) { log.infoFormat("Root Command {0} has tasks without vdsm id.", rootCommandId); handleTasksOfCommandWithEmptyVdsmId(rootCommandIdToTasksMap.get(rootCommandId)); } for (AsyncTasks task : rootCommandIdToTasksMap.get(rootCommandId)) { if (!hasEmptyVdsmId(task)) { tasksInDbAfterRestart.putIfAbsent(task.getStoragePoolId(), new ArrayList<AsyncTasks>()); tasksInDbAfterRestart.get(task.getStoragePoolId()).add(task); } } } }</code><technical_language>Iterate entrySet()</technical_language>

Target:
private AsyncTaskManager() { _tasks = new ConcurrentHashMap<Guid, SPMAsyncTask>(); SchedulerUtil scheduler = SchedulerUtilQuartzImpl.getInstance(); scheduler.scheduleAFixedDelayJob(this, "_timer_Elapsed", new Class[]{}, new Object[]{}, Config.<Integer>GetValue(ConfigValues.AsyncTaskPollingRate), Config.<Integer>GetValue(ConfigValues.AsyncTaskPollingRate), TimeUnit.SECONDS); scheduler.scheduleAFixedDelayJob(this, "_cacheTimer_Elapsed", new Class[]{}, new Object[]{}, Config.<Integer>GetValue(ConfigValues.AsyncTaskStatusCacheRefreshRateInSeconds), Config.<Integer>GetValue(ConfigValues.AsyncTaskStatusCacheRefreshRateInSeconds), TimeUnit.SECONDS); _cacheTimeInMinutes = Config.<Integer>GetValue(ConfigValues.AsyncTaskStatusCachingTimeInMinutes); tasksInDbAfterRestart = new ConcurrentHashMap(); Map<Guid, List<AsyncTasks>> rootCommandIdToTasksMap = groupTasksByRootCommandId(DbFacade.getInstance().getAsyncTaskDao().getAll()); for (Entry<Guid, List<AsyncTasks>> entry : rootCommandIdToTasksMap.entrySet()) { if (hasTasksWithoutVdsmId(rootCommandIdToTasksMap.get(entry.getKey()))) { log.infoFormat("Root Command {0} has tasks without vdsm id.", entry.getKey()); handleTasksOfCommandWithEmptyVdsmId(rootCommandIdToTasksMap.get(entry.getKey())); } for (AsyncTasks task : entry.getValue()) { if (!hasEmptyVdsmId(task)) { tasksInDbAfterRestart.putIfAbsent(task.getStoragePoolId(), new ArrayList<AsyncTasks>()); tasksInDbAfterRestart.get(task.getStoragePoolId()).add(task); } } } }
Source:
<code>public void makeTestIndexer() throws Exception { <START> final MongoClient client = MockMongoSingleton.getInstance(); <END> indexer = new MongoGeoTemporalIndexer(); conf.setMongoDBName("GEO_TEMPORAL_INDEXER_TEST"); conf.set(MongoDBRdfConfiguration.MONGO_DB_NAME, "GEO_TEMPORAL_INDEXER_TEST"); conf.setMongoClient(client); conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "rya_"); indexer.setConf(conf); indexer.init(); }</code><technical_language>Is this necessary if extending MongoITBase</technical_language>

Target:
public void makeTestIndexer() throws Exception { indexer = new MongoGeoTemporalIndexer(); indexer.setConf(conf); indexer.init(); }
Source:
<code>private String computeLabel(StoragePathAdapter adapter) { String commitId = adapter.getCommitId(); String username = adapter.getUsername(); String computedLabel; if (adapter.isLocal()) { computedLabel = "Local: " + adapter.getStoragePath(); } else { computedLabel = <START> "Remote: " <END> + adapter.getStoragePath(); } if (commitId != null && !"".equals(commitId)) { computedLabel = computedLabel + " " + commitId.substring(0, 7); } if (username != null && !"".equals(username)) { computedLabel = computedLabel + " (" + username + ")"; } return computedLabel; }</code><technical_language>Please remove "Remote:" : if is a comparison local history, "Remote" is appropriate. If is a comparison EGit, commit id username added enough understand is a remote file</technical_language>

Target:
private String computeLabel(StoragePathAdapter adapter) { String commitId = adapter.getCommitId(); String username = adapter.getUsername(); String computedLabel; if (adapter.isLocal()) { computedLabel = "Local: " + adapter.getStoragePath(); } else { computedLabel = adapter.getStoragePath(); } if (commitId != null && !"".equals(commitId)) { computedLabel += " " + commitId.substring(0, 7); } if (username != null && !"".equals(username)) { computedLabel += " (" + username + ")"; } return computedLabel; }
Source:
<code>void handleLostAll() { log.debug("Closing lost active tasks as zombies."); final Iterator<Task> iterator = tasks.values().iterator(); while (iterator.hasNext()) { final Task task = iterator.next(); final Set<TopicPartition> inputPartitions = task.inputPartitions(); if (task.isActive()) { cleanupTask(task); task.closeDirty(); iterator.remove(); try { activeTaskCreator.closeAndRemoveTaskProducerIfNeeded(task.id()); } catch (final RuntimeException e) { <START> log.debug("Error handling lostAll", e); <END> } } for (final TopicPartition inputPartition : inputPartitions) { partitionToTask.remove(inputPartition); } } }</code><technical_language>1. a warn instead of a debug. 2. error message more specific here: Error closing task producer for task while handling lostAll</technical_language>

Target:
void handleLostAll() { log.debug("Closing lost active tasks as zombies."); final Iterator<Task> iterator = tasks.values().iterator(); while (iterator.hasNext()) { final Task task = iterator.next(); final Set<TopicPartition> inputPartitions = task.inputPartitions(); if (task.isActive()) { cleanupTask(task); task.closeDirty(); iterator.remove(); try { activeTaskCreator.closeAndRemoveTaskProducerIfNeeded(task.id()); } catch (final RuntimeException e) { log.warn("Error closing task producer for " + task.id() + " while handling lostAll", e); } } for (final TopicPartition inputPartition : inputPartitions) { partitionToTask.remove(inputPartition); } } }
Source:
<code>private void rematchAllNetworksAndRequests() { final long now = SystemClock.elapsedRealtime(); final NetworkAgentInfo oldDefaultNetwork = getDefaultNetwork(); final NetworkAgentInfo[] nais = mNetworkAgentInfos.values().toArray( new NetworkAgentInfo[mNetworkAgentInfos.size()]); Arrays.sort(nais); for (NetworkAgentInfo nai : nais) { rematchNetworkAndRequests(nai, now); } final NetworkAgentInfo newDefaultNetwork = getDefaultNetwork(); <START> updateLegacyTypeTrackerAfterRematch(oldDefaultNetwork, <END> newDefaultNetwork, nais); for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) { if (unneeded(nai, UnneededFor.TEARDOWN)) { if (nai.getLingerExpiry() > 0) { updateLingerState(nai, now); } else { if (DBG) log("Reaping " + nai.name()); teardownUnneededNetwork(nai); } } } }</code><technical_language>nit: IIUC xxx rematch, in a rematch function. is a confusing, strong opinion. if is a naming for this</technical_language>

Target:
private void rematchAllNetworksAndRequests() { final long now = SystemClock.elapsedRealtime(); final NetworkAgentInfo oldDefaultNetwork = getDefaultNetwork(); final NetworkAgentInfo[] nais = mNetworkAgentInfos.values().toArray( new NetworkAgentInfo[mNetworkAgentInfos.size()]); Arrays.sort(nais); for (NetworkAgentInfo nai : nais) { rematchNetworkAndRequests(nai, now); } final NetworkAgentInfo newDefaultNetwork = getDefaultNetwork(); updateLegacyTypeTrackerAndVpnLockdownForRematch(oldDefaultNetwork, newDefaultNetwork, nais); for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) { if (unneeded(nai, UnneededFor.TEARDOWN)) { if (nai.getLingerExpiry() > 0) { updateLingerState(nai, now); } else { if (DBG) log("Reaping " + nai.name()); teardownUnneededNetwork(nai); } } } }
Source:
<code>public void setIncomingHeartbeat(boolean isHeartbeat) { if (isHeartbeat && this.incomingHeartbeat != 0) { this.isIncomingHeartbeat.set(isHeartbeat); <START> } <END> this.isIncomingHeartbeat.set(false); }</code><technical_language>else here? false otherwise</technical_language>

Target:
public void setIncomingHeartbeat(boolean isHeartbeat) { if (isHeartbeat && this.incomingHeartbeat != 0) { this.isIncomingHeartbeat.set(isHeartbeat); return; } this.isIncomingHeartbeat.set(false); }
Source:
<code>public void testInvokeJmxOperationNotExposed() throws Exception { <START> try { <END> server.invoke(name, "stop", new Object[]{}, new String[]{}); fail("Method not exposed, invocation should have failed"); } catch (MBeanException mbe) { assertTrue(mbe.getCause() instanceof ServiceNotFoundException); } }</code><technical_language>Exceptions.expectException() Exceptions.expectException(MBeanException.class, ServiceNotFoundException.class, () -> server.invoke(name, "stop", new Object[]{}, new String[]{}));</technical_language>

Target:
public void testInvokeJmxOperationNotExposed() throws Exception { Exceptions.expectException(MBeanException.class, ServiceNotFoundException.class, () -> server.invoke(name, "stop", new Object[]{}, new String[]{})); }
Source:
<code>public TextBoxLabel() { super(new EmptyValueRenderer<String>() { @Override public String render(String value) { String renderedText = super.render(value); <START> renderedText = renderedText.replace("&lt;", "<"); END> return renderedText; } }); }</code><technical_language>&gt; a bunch of other encoded string elements? more sense a generic encoder/decoder</technical_language>

Target:
public TextBoxLabel() { super(new EmptyValueRenderer<String>() { @Override public String render(String value) { String renderedText = super.render(value); renderedText = SafeHtmlUtils.htmlEscape(renderedText); return renderedText; } }); }
Source:
<code>public ModuleDeploymentProperties() { <START> put(COUNT, "" + 1); <END> }</code><technical_language>about: put(COUNT, String.valueOf(1));</technical_language>

Target:
public ModuleDeploymentProperties() { map.put(COUNT_KEY, String.valueOf(1)); }
Source:
<code>public static byte[] hexStringToByteArray(String value) { <START> value = value.trim(); <END> if (value.startsWith(HEX_HEADER)) value = value.substring((HEX_HEADER).length()); int len = value.length(); if (len % 2 != 0) { value = "0" + value; len = value.length(); } byte[] data = new byte[len / 2]; for (int i = 0; i < len; i += 2) { data[i / 2] = (byte) ((Character.digit(value.charAt(i), 16) << 4) + Character.digit(value.charAt(i+1), 16)); } return data; }</code><technical_language>Check if is null</technical_language>

Target:
public static byte[] hexStringToByteArray(String value) { if (value == null) throw new NullPointerException("Value cannot be null."); value = value.trim(); if (value.startsWith(HEX_HEADER)) value = value.substring((HEX_HEADER).length()); int len = value.length(); if (len % 2 != 0) { value = "0" + value; len = value.length(); } byte[] data = new byte[len / 2]; for (int i = 0; i < len; i += 2) { data[i / 2] = (byte) ((Character.digit(value.charAt(i), 16) << 4) + Character.digit(value.charAt(i+1), 16)); } return data; }
Source:
<code>protected boolean validate() { DiskImage diskImage = diskImageDao.getAncestor(getParameters().getImageId()); if <START> (diskImage.getImageStatus() <END> == ImageStatus.LOCKED) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_DISK_IS_BEING_MIGRATED, ReplacementUtils.createSetVariableString("DiskName", diskImage.getDiskAlias())); } return true; }</code><technical_language>check if null</technical_language>

Target:
protected boolean validate() { DiskImage diskImage = diskImageDao.getAncestor(getParameters().getImageId()); if (diskImage == null) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_DISK_NOT_EXIST); } if (diskImage.getImageStatus() == ImageStatus.LOCKED) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_DISK_IS_BEING_MIGRATED, ReplacementUtils.createSetVariableString("DiskName", diskImage.getDiskAlias())); } return true; }
Source:
<code>public LeadImagesHandler(PageViewFragment parentFragment, CommunicationBridge bridge, ObservableWebView webview, ViewGroup hidingView) { this.parentFragment = parentFragment; <START> this.webview = webview; <END> this.imageContainer = hidingView; this.bridge = bridge; image1 = (ImageView)imageContainer.findViewById(R.id.page_image_1); pageTitleContainer = imageContainer.findViewById(R.id.page_title_container); pageTitleText = (TextView)imageContainer.findViewById(R.id.page_title_text); webview.addOnScrollChangeListener(this); displayDensity = parentFragment.getResources().getDisplayMetrics().density; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { Point size = new Point(); parentFragment.getActivity().getWindowManager().getDefaultDisplay().getSize(size); displayHeight = (int)(size.y / displayDensity); } else { displayHeight = (int)(parentFragment.getActivity() .getWindowManager().getDefaultDisplay().getHeight() / displayDensity); } hide(); }</code><technical_language>this.webview is</technical_language>

Target:
public LeadImagesHandler(PageViewFragment parentFragment, CommunicationBridge bridge, ObservableWebView webview, ViewGroup hidingView) { this.parentFragment = parentFragment; this.imageContainer = hidingView; this.bridge = bridge; image1 = (ImageView)imageContainer.findViewById(R.id.page_image_1); pageTitleContainer = imageContainer.findViewById(R.id.page_title_container); pageTitleText = (TextView)imageContainer.findViewById(R.id.page_title_text); webview.addOnScrollChangeListener(this); displayDensity = parentFragment.getResources().getDisplayMetrics().density; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { Point size = new Point(); parentFragment.getActivity().getWindowManager().getDefaultDisplay().getSize(size); displayHeight = (int)(size.y / displayDensity); } else { displayHeight = (int)(parentFragment.getActivity() .getWindowManager().getDefaultDisplay().getHeight() / displayDensity); } hide(); }
Source:
<code>public void visitToken(DetailAST ast) { if (!skipAnnotationArgs(ast) <START> && !skipAnnotationDefaults(ast) <END> && !isInIgnoreList(ast) && (!ignoreHashCodeMethod || !isInHashCodeMethod(ast))) { final DetailAST constantDefAST = findContainingConstantDef(ast); if (constantDefAST == null) { if (!ignoreFieldDeclaration || !isFieldDeclaration(ast)) { reportMagicNumber(ast); } } else { final boolean found = isMagicNumberExists(ast, constantDefAST); if (found) { reportMagicNumber(ast); } } } }</code><technical_language>double negative in expressions ... avoid this ? lets as: if (shouldTestAnnotationArgs(ast) && shouldTestAnnotationDefaults(ast)</technical_language>

Target:
public void visitToken(DetailAST ast) { if (shouldTestAnnotationArgs(ast) && shouldTestAnnotationDefaults(ast) && !isInIgnoreList(ast) && (!ignoreHashCodeMethod || !isInHashCodeMethod(ast))) { final DetailAST constantDefAST = findContainingConstantDef(ast); if (constantDefAST == null) { if (!ignoreFieldDeclaration || !isFieldDeclaration(ast)) { reportMagicNumber(ast); } } else { final boolean found = isMagicNumberExists(ast, constantDefAST); if (found) { reportMagicNumber(ast); } } } }
Source:
<code>private void setupToolBar() { <START> CreateNewAboAction newAboAction = new CreateNewAboAction(Daten.getInstance().getListeAbo()); <END> JavaFxUtils.invokeInFxThreadAndWait(() -> { toolBar = new FXAboToolBar(); toolBar.btnOn.setOnAction(e -> SwingUtilities.invokeLater(() -> aboEinAus(true))); toolBar.btnOff.setOnAction(e -> SwingUtilities.invokeLater(() -> aboEinAus(false))); toolBar.btnDelete.setOnAction(e -> SwingUtilities.invokeLater(this::aboLoeschen)); toolBar.btnEdit.setOnAction(e -> SwingUtilities.invokeLater(this::editAbo)); toolBar.btnNewAbo.setOnAction(e -> SwingUtilities.invokeLater(() -> newAboAction.actionPerformed(null))); toolBar.cbSender.setOnAction(e -> SwingUtilities.invokeLater(this::tabelleLaden)); toolBarPanel.setScene(new Scene(toolBar)); }); }</code><technical_language>is operating system? Applying this change a NPE runtime of program macOS. original reason is block</technical_language>

Target:
private void setupToolBar() { JavaFxUtils.invokeInFxThreadAndWait(() -> { toolBar = new FXAboToolBar(); toolBar.btnOn.setOnAction(e -> SwingUtilities.invokeLater(() -> aboEinAus(true))); toolBar.btnOff.setOnAction(e -> SwingUtilities.invokeLater(() -> aboEinAus(false))); toolBar.btnDelete.setOnAction(e -> SwingUtilities.invokeLater(this::aboLoeschen)); toolBar.btnEdit.setOnAction(e -> SwingUtilities.invokeLater(this::editAbo)); CreateNewAboAction newAboAction = new CreateNewAboAction(Daten.getInstance().getListeAbo()); toolBar.btnNewAbo.setOnAction(e -> SwingUtilities.invokeLater(() -> newAboAction.actionPerformed(null))); toolBar.cbSender.setOnAction(e -> SwingUtilities.invokeLater(this::tabelleLaden)); toolBarPanel.setScene(new Scene(toolBar)); }); }
Source:
<code>private void removeImages() { for (final DiskImage source : getSourceImages()) { DiskImage dest = getDiskImageDao().getAllSnapshotsForParent(source.getImageId()).get(0); if (getSnapshotActionType() == VdcActionType.RemoveSnapshotSingleDisk) { VdcReturnValueBase vdcReturnValue = runInternalActionWithTasksContext( getSnapshotActionType(), buildRemoveSnapshotSingleDiskParameters(source, dest)); if (vdcReturnValue != null && vdcReturnValue.getInternalVdsmTaskIdList() != null) { getReturnValue().getVdsmTaskIdList().addAll(vdcReturnValue.getInternalVdsmTaskIdList()); } } else { TaskManagerUtil.executeAsyncCommand( getSnapshotActionType(), buildRemoveSnapshotSingleDiskParameters(source, dest), <START> getContext()); <END> } List<Guid> quotasToRemoveFromCache = new ArrayList<Guid>(); quotasToRemoveFromCache.add(source.getQuotaId()); quotasToRemoveFromCache.add(dest.getQuotaId()); QuotaManager.getInstance().removeQuotaFromCache(getStoragePoolId(), quotasToRemoveFromCache); } }</code><technical_language>Please duplicate context object. In addition, please notice passing context duplicating it, pass lock, execution compensation context parent child. Is want? based original, I so. a cloneFromParentContextAndDetach in order prevent that</technical_language>

Target:
private void removeImages() { for (final DiskImage source : getSourceImages()) { DiskImage dest = getDiskImageDao().getAllSnapshotsForParent(source.getImageId()).get(0); if (getSnapshotActionType() == VdcActionType.RemoveSnapshotSingleDisk) { VdcReturnValueBase vdcReturnValue = runInternalActionWithTasksContext( getSnapshotActionType(), buildRemoveSnapshotSingleDiskParameters(source, dest)); if (vdcReturnValue != null && vdcReturnValue.getInternalVdsmTaskIdList() != null) { getReturnValue().getVdsmTaskIdList().addAll(vdcReturnValue.getInternalVdsmTaskIdList()); } } else { TaskManagerUtil.executeAsyncCommand( getSnapshotActionType(), buildRemoveSnapshotSingleDiskParameters(source, dest), cloneContextAndDetachFromParent()); } List<Guid> quotasToRemoveFromCache = new ArrayList<Guid>(); quotasToRemoveFromCache.add(source.getQuotaId()); quotasToRemoveFromCache.add(dest.getQuotaId()); QuotaManager.getInstance().removeQuotaFromCache(getStoragePoolId(), quotasToRemoveFromCache); } }
Source:
<code>public long estimatedInMemorySize() { <START> return INSTANCE_SIZE + getRequiredBytesForSerialization(); <END> }</code><technical_language>ditto getRequiredBytesForSerialization</technical_language>

Target:
public long estimatedInMemorySize() { return INSTANCE_SIZE + indices.length * (SizeOf.SIZE_OF_INT + SizeOf.SIZE_OF_DOUBLE + SizeOf.SIZE_OF_LONG); }
Source:
<code>protected Iterator<Size> getSizeIterator(AccumuloClient client, String tablename, Text start, Text end) throws MergeException { Table.ID tableId; TabletsMetadata tablets; try { ClientContext context = new ClientContext(client.info()); tableId = Tables.getTableId(context, tablename); tablets = TabletsMetadata.builder().scanMetadataTable() .overRange(new KeyExtent(tableId, end, start).toMetadataRange()).fetchFiles().fetchPrev() <START> .build(context); <END> } catch (Exception e) { throw new MergeException(e); } return tablets.stream().map(tm -> { long size = tm.getFilesMap().values().stream().mapToLong(DataFileValue::getSize).sum(); return new Size(tm.getExtent(), size); }).iterator(); }</code><technical_language>This is great</technical_language>

Target:
protected Iterator<Size> getSizeIterator(AccumuloClient client, String tablename, Text start, Text end) throws MergeException { Table.ID tableId; TabletsMetadata tablets; try { ClientContext context = new ClientContext(client); tableId = Tables.getTableId(context, tablename); tablets = TabletsMetadata.builder().scanMetadataTable() .overRange(new KeyExtent(tableId, end, start).toMetadataRange()).fetchFiles().fetchPrev() .build(context); } catch (Exception e) { throw new MergeException(e); } return tablets.stream().map(tm -> { long size = tm.getFilesMap().values().stream().mapToLong(DataFileValue::getSize).sum(); return new Size(tm.getExtent(), size); }).iterator(); }
Source:
<code>public void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction(ACTION_CREATE) .setPost(true) .setDescription("Create a Webhook.<br>" + <START> "Requires the global, organization or project permission.") <END> .setSince("7.1") .setResponseExample(getClass().getResource("example-webhook-create.json")) .setHandler(this); action.createParam(NAME_PARAM) .setRequired(true) .setMaximumLength(NAME_PARAM_MAXIMUM_LENGTH) .setDescription("The name of the webhook to create") .setExampleValue(NAME_WEBHOOK_EXAMPLE_001); action.createParam(URL_PARAM) .setRequired(true) .setMaximumLength(URL_PARAM_MAXIMUM_LENGTH) .setDescription("The url to be called by the webhook") .setExampleValue(URL_WEBHOOK_EXAMPLE_001); action.createParam(PROJECT_KEY_PARAM) .setRequired(false) .setMaximumLength(PROJECT_KEY_PARAM_MAXIMUN_LENGTH) .setDescription("The key of the project that will own the webhook") .setExampleValue(KEY_PROJECT_EXAMPLE_001); action.createParam(ORGANIZATION_KEY_PARAM) .setInternal(true) .setRequired(false) .setMaximumLength(ORGANIZATION_KEY_PARAM_MAXIMUM_LENGTH) .setDescription("The key of the organization that will own the webhook") .setExampleValue(KEY_ORG_EXAMPLE_001); }</code><technical_language>In current state of SonarQube SonarCloud, description mention organizations ("global" means "organization" SonarCloud). Description "Requires 'Administer' permission project, global 'Administer' permission."</technical_language>

Target:
public void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction(ACTION_CREATE) .setPost(true) .setDescription("Create a Webhook.<br>" + "Requires 'Administer' permission on the specified project, or global 'Administer' permission.") .setSince("7.1") .setResponseExample(getClass().getResource("example-webhook-create.json")) .setHandler(this); action.createParam(NAME_PARAM) .setRequired(true) .setMaximumLength(NAME_PARAM_MAXIMUM_LENGTH) .setDescription("Name displayed in the administration console of webhooks") .setExampleValue(NAME_WEBHOOK_EXAMPLE_001); action.createParam(URL_PARAM) .setRequired(true) .setMaximumLength(URL_PARAM_MAXIMUM_LENGTH) .setDescription("Server endpoint that will receive the webhook payload, for example 'http://my_server/foo'." + " If HTTP Basic authentication is used, HTTPS is recommended to avoid man in the middle attacks." + " Example: 'https://myLogin:myPassword@my_server/foo'") .setExampleValue(URL_WEBHOOK_EXAMPLE_001); action.createParam(PROJECT_KEY_PARAM) .setRequired(false) .setMaximumLength(PROJECT_KEY_PARAM_MAXIMUN_LENGTH) .setDescription("The key of the project that will own the webhook") .setExampleValue(KEY_PROJECT_EXAMPLE_001); action.createParam(ORGANIZATION_KEY_PARAM) .setInternal(true) .setRequired(false) .setMaximumLength(ORGANIZATION_KEY_PARAM_MAXIMUM_LENGTH) .setDescription("The key of the organization that will own the webhook") .setExampleValue(KEY_ORG_EXAMPLE_001); }
Source:
<code>public void testSplitProcedureMetrics() { HELPER.assertGauge(MetricsMasterProcSource.NUM_SPLIT_PROCEDURE_REQUEST_NAME, 32, masterProcSource); HELPER.assertGauge(MetricsMasterProcSource.NUM_SPLIT_PROCEDURE_SUCCESS_NAME, 24, masterProcSource); <START> HELPER.assertGauge("SplitProcedureTime_max", 2082, masterProcSource); <END> HELPER.assertGauge("SplitProcedureTime_min", 2082, masterProcSource); }</code><technical_language>change test max > min</technical_language>

Target:
public void testSplitProcedureMetrics() { HELPER .assertGauge(MetricsMasterProcSource.NUM_SPLIT_PROCEDURE_REQUEST_NAME, 32, masterProcSource); HELPER .assertGauge(MetricsMasterProcSource.NUM_SPLIT_PROCEDURE_SUCCESS_NAME, 24, masterProcSource); HELPER.assertGauge("SplitProcedureTime_max", 3011, masterProcSource); HELPER.assertGauge("SplitProcedureTime_min", 2082, masterProcSource); }
Source:
<code>public ChatClient createChatClient() { String endpoint = "https://<RESOURCE_NAME>.communcationservices.azure.com"; NettyAsyncHttpClientBuilder httpClientBuilder = new NettyAsyncHttpClientBuilder(); HttpClient httpClient = httpClientBuilder.build(); String accessKey = "SECRET"; <START> CommunicationUserCredential credential = new CommunicationUserCredential(accessKey); <END> final ChatClientBuilder builder = new ChatClientBuilder(); builder.endpoint(endpoint) .credential(credential) .httpClient(httpClient); ChatClient chatClient = builder.buildClient(); return chatClient; }</code><technical_language>here, Chat takes a token, access key. (Look out for CommunicationUserCredential wraps a token)</technical_language>

Target:
public ChatClient createChatClient() { String endpoint = "https://<RESOURCE_NAME>.communcationservices.azure.com"; NettyAsyncHttpClientBuilder httpClientBuilder = new NettyAsyncHttpClientBuilder(); HttpClient httpClient = httpClientBuilder.build(); String token = "SECRET"; CommunicationUserCredential credential = new CommunicationUserCredential(token); final ChatClientBuilder builder = new ChatClientBuilder(); builder.endpoint(endpoint) .credential(credential) .httpClient(httpClient); ChatClient chatClient = builder.buildClient(); return chatClient; }
Source:
<code><START> public long hash(Object value) { <END> ByteBuffer plain = null; if (value instanceof Binary) { return hashFunction.hashBytes(((Binary) value).getBytes()).asLong(); } if (value instanceof Integer) { plain = ByteBuffer.allocate(Integer.SIZE/Byte.SIZE); plain.order(ByteOrder.LITTLE_ENDIAN).putInt(((Integer)value).intValue()); } else if (value instanceof Long) { plain = ByteBuffer.allocate(Long.SIZE/Byte.SIZE); plain.order(ByteOrder.LITTLE_ENDIAN).putLong(((Long)value).longValue()); } else if (value instanceof Float) { plain = ByteBuffer.allocate(Float.SIZE/Byte.SIZE); plain.order(ByteOrder.LITTLE_ENDIAN).putFloat(((Float)value).floatValue()); } else if (value instanceof Double) { plain = ByteBuffer.allocate(Double.SIZE/ Byte.SIZE); plain.order(ByteOrder.LITTLE_ENDIAN).putDouble(((Double)value).doubleValue()); } else { throw new RuntimeException("Parquet Bloom filter: Not supported type"); } return hashFunction.hashBytes(plain.array()).asLong(); }</code><technical_language>This implementation fine for filtering is executed searched value. for building bloomfilter write time a huge performance penalty is invoked for value. I suggest keeping hash functions for parquet primitives support write time performance. implement a convenient method for type T for filtering</technical_language>

Target:
public long hash(Object value) { ByteBuffer plain; if (value instanceof Binary) { return hashFunction.hashBytes(((Binary) value).getBytes()).asLong(); } if (value instanceof Integer) { plain = ByteBuffer.allocate(Integer.SIZE/Byte.SIZE); plain.order(ByteOrder.LITTLE_ENDIAN).putInt(((Integer)value).intValue()); } else if (value instanceof Long) { plain = ByteBuffer.allocate(Long.SIZE/Byte.SIZE); plain.order(ByteOrder.LITTLE_ENDIAN).putLong(((Long)value).longValue()); } else if (value instanceof Float) { plain = ByteBuffer.allocate(Float.SIZE/Byte.SIZE); plain.order(ByteOrder.LITTLE_ENDIAN).putFloat(((Float)value).floatValue()); } else if (value instanceof Double) { plain = ByteBuffer.allocate(Double.SIZE/ Byte.SIZE); plain.order(ByteOrder.LITTLE_ENDIAN).putDouble(((Double)value).doubleValue()); } else { throw new RuntimeException("Parquet Bloom filter: Not supported type"); } return hashFunction.hashBytes(plain.array()).asLong(); }
Source:
<code>private List<String> buildKeywordSuggestions() { return asList( <START> "in", "or", "and", "between", "if", "then", "else", "for", "return" <END> ); }</code><technical_language>is fine do FEEL_RESERVED_KEYWORDS</technical_language>

Target:
private List<String> buildKeywordSuggestions() { return asList( "for", "return", "if", "then", "else", "some", "every", "satisfies", "instance", "of", "in", "function", "external", "or", "and", "between", "not", "null", "true", "false" ); }
Source:
<code>public static synchronized String getEncryptionKey(String name) { <START> final String keyString = getUniqueId(name); <END> if (CACHED_ENCRYPTION_KEYS.get(keyString) == null) { generateEncryptionKey(keyString); } return CACHED_ENCRYPTION_KEYS.get(keyString); }</code><technical_language>name key in CACHED_ENCRYPTION_KEYS</technical_language>

Target:
public static synchronized String getEncryptionKey(String name) { if (CACHED_ENCRYPTION_KEYS.get(name) == null) { generateEncryptionKey(name); } return CACHED_ENCRYPTION_KEYS.get(name); }
Source:
<code><START> Package getPackage(){ <END> return mPackage; }</code><technical_language>Space {</technical_language>

Target:
Package getPackage() { return pkg; }
Source:
<code>Attribute(String name, ModelType type, CapabilityReferenceRecorder reference) { <START> this.definition = new SimpleAttributeDefinitionBuilder(name, type, true) <END> .setCapabilityReference(reference) .setFlags(Flag.RESTART_RESOURCE_SERVICES) .build(); }</code><technical_language>attribute is required. reporting incorrect metadata work a test fixture problem</technical_language>

Target:
Attribute(String name, ModelType type, CapabilityReferenceRecorder reference) { this.definition = new SimpleAttributeDefinitionBuilder(name, type) .setCapabilityReference(reference) .setFlags(Flag.RESTART_RESOURCE_SERVICES) .build(); }
Source:
<code>protected AvailabilityZone(String name, ZoneState zoneState) { this.name = name; <START> this.state = zoneState; <END> }</code><technical_language>fields mandatory nullable</technical_language>

Target:
protected AvailabilityZone(String name, ZoneState zoneState) { this.name = checkNotNull(name); this.state = checkNotNull(zoneState); }
Source:
<code>protected void deserialize(JsonObject src, K builder, JsonDeserializationContext context) { for (JsonElement item : src.getAsJsonArray(MEMBER_ITEMS)) { T deserializedItem = deserializeItem(item, context); <START> if (!(deserializedItem instanceof Undefined)) { <END> builder.addItem(deserializedItem); } } builder.setLabel(getString(src, MEMBER_LABEL)); }</code><technical_language>is more efficient compare instance of deserializedItem Undefined.INSTANCE instanceof operator</technical_language>

Target:
protected void deserialize(JsonObject src, K builder, JsonDeserializationContext context) { for (JsonElement item : src.getAsJsonArray(MEMBER_ITEMS)) { T deserializedItem = deserializeItem(item, context); if (deserializedItem != null) { builder.addItem(deserializedItem); } } builder.setLabel(getString(src, MEMBER_LABEL)); }
Source:
<code>public static SPMAsyncTask construct(CommandCoordinator coco, AsyncTaskCreationInfo creationInfo) { AsyncTasks asyncTask = coco.getByVdsmTaskId(creationInfo.getVdsmTaskId()); if (asyncTask == null || asyncTask.getActionParameters() == null) { asyncTask = new AsyncTasks(AsyncTaskResultEnum.success, AsyncTaskStatusEnum.running, creationInfo.getVdsmTaskId(), creationInfo.getStepId(), creationInfo.getStoragePoolID(), creationInfo.getTaskType(), getCommandEntity(coco, <START> asyncTask == null ? Guid.newGuid() : asyncTask.getRootCommandId(), <END> VdcActionType.Unknown, new VdcActionParametersBase()), getCommandEntity(coco, asyncTask == null ? Guid.newGuid() : asyncTask.getRootCommandId(), VdcActionType.Unknown, new VdcActionParametersBase())); creationInfo.setTaskType(AsyncTaskType.unknown); } AsyncTaskParameters asyncTaskParams = new AsyncTaskParameters(creationInfo, asyncTask); return construct(coco, creationInfo.getTaskType(), asyncTaskParams, true); }</code><technical_language>please extract method this trinary if - appears more once</technical_language>

Target:
public static SPMAsyncTask construct(CommandCoordinator coco, AsyncTaskCreationInfo creationInfo) { AsyncTask asyncTask = coco.getByVdsmTaskId(creationInfo.getVdsmTaskId()); if (asyncTask == null || asyncTask.getActionParameters() == null) { asyncTask = new AsyncTask(AsyncTaskResultEnum.success, AsyncTaskStatusEnum.running, creationInfo.getVdsmTaskId(), creationInfo.getStepId(), creationInfo.getStoragePoolID(), creationInfo.getTaskType(), getCommandEntity(coco, asyncTask == null ? Guid.newGuid() : asyncTask.getRootCommandId(), VdcActionType.Unknown, new VdcActionParametersBase()), getCommandEntity(coco, asyncTask == null ? Guid.newGuid() : asyncTask.getCommandId(), VdcActionType.Unknown, new VdcActionParametersBase())); creationInfo.setTaskType(AsyncTaskType.unknown); } AsyncTaskParameters asyncTaskParams = new AsyncTaskParameters(creationInfo, asyncTask); return construct(coco, creationInfo.getTaskType(), asyncTaskParams, true); }
Source:
<code>private void waitForAuditToComplete() throws Exception { <START> Auditor auditor = getAuditorBookiesAuditor(); <END> if (auditor != null) { Future<?> task = auditor.getAuditTask(); if (task != null) { task.get(5, TimeUnit.SECONDS); } } }</code><technical_language>If is Auditor AuditTask fail test ? wait for Auditor active</technical_language>

Target:
private void waitForAuditToComplete() throws Exception { long endTime = System.currentTimeMillis() + 5_000; while (System.currentTimeMillis() < endTime) { Auditor auditor = getAuditorBookiesAuditor(); if (auditor != null) { Future<?> task = auditor.submitAuditTask(); task.get(5, TimeUnit.SECONDS); return; } Thread.sleep(100); } throw new TimeoutException("Could not find an audit within 5 seconds"); }
Source:
<code>private RetryPolicyTemplate createRetryPolicyTemplate(CoreEvent event) { <START> Integer maxRetries = <END> (Integer) expressionManager.evaluate(this.maxRetries, DataType.NUMBER, NULL_BINDING_CONTEXT, event).getValue(); Integer millisBetweenRetries = (Integer) expressionManager.evaluate(this.millisBetweenRetries, DataType.NUMBER, NULL_BINDING_CONTEXT, event).getValue(); return this.policyTemplatesCache.get(new Pair<>(millisBetweenRetries, maxRetries)); }</code><technical_language>a DW session</technical_language>

Target:
private RetryPolicyTemplate createRetryPolicyTemplate(CoreEvent event) { ExpressionManagerSession session = expressionManager.openSession(getLocation(), event, NULL_BINDING_CONTEXT); Integer maxRetries = (Integer) session.evaluate(this.maxRetries, DataType.NUMBER).getValue(); Integer millisBetweenRetries = (Integer) session.evaluate(this.millisBetweenRetries, DataType.NUMBER).getValue(); return this.policyTemplatesCache.get(new Pair<>(millisBetweenRetries, maxRetries)); }
Source:
<code>private static File findMainDescriptor( List<String> roots ) { for ( String root : roots ) { File descriptorFile = new File( root, "module-info.java" ).getAbsoluteFile(); <START> if ( descriptorFile.exists() ) <END> { return descriptorFile; } } return null; }</code><technical_language>isFile() instead of exists()</technical_language>

Target:
private static File findMainDescriptor( List<String> roots ) throws MavenReportException { for ( String root : roots ) { File descriptorFile = new File( root, "module-info.java" ).getAbsoluteFile(); if ( descriptorFile.exists() ) { if ( !descriptorFile.isFile() ) { throw new MavenReportException( descriptorFile + " is not a regular file" ); } return descriptorFile; } } return null; }