auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(args.length == 0) { return showUsage; } Player player = Bukkit.getServer().getPlayer(args[0]); if (player == null) { sender.sendMessage(ChatColor.DARK_RED + "Player not found!"); return true; } if (player.getName().equals(sender.getName())) { sender.sendMessage(ChatColor.DARK_RED + "Please do not attempt to smite yourself."); return true; } if (ICM_Rank.getRank(sender).level <= ICM_Rank.getRank(player).level) { sender.sendMessage(ChatColor.DARK_RED + "You cannot smite someone that is an equal or higher rank than yourself."); return true; } String smiteReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " "); World world = player.getWorld(); world.strikeLightningEffect(player.getLocation()); world.strikeLightningEffect(player.getLocation()); world.strikeLightningEffect(player.getLocation()); world.strikeLightningEffect(player.getLocation()); world.strikeLightningEffect(player.getLocation()); world.strikeLightningEffect(player.getLocation()); player.getInventory().clear(); player.setHealth(0D); player.setOp(false); player.setGameMode(GameMode.SURVIVAL); Bukkit.broadcastMessage(ChatColor.RED + player.getName() + " has been very naughty, indeed.\nThey have thus been smitten.\nReason - " + ChatColor.YELLOW + smiteReason); player.sendMessage(ChatColor.RED + "You were smitten by: " + sender.getName() ", Reason - " + ChatColor.YELLOW + smiteReason); return true; }

Target:
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(args.length == 0) { return false; } Player player = Bukkit.getServer().getPlayer(args[0]); if (player == null) { sender.sendMessage(ChatColor.DARK_RED + "Player not found!"); return true; } if (player.getName().equals(sender.getName())) { sender.sendMessage(ChatColor.DARK_RED + "Please do not attempt to smite yourself."); return true; } if (ICM_Rank.getRank(sender).level <= ICM_Rank.getRank(player).level) { sender.sendMessage(ChatColor.DARK_RED + "You cannot smite someone that is an equal or higher rank than yourself."); return true; } String smiteReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " "); World world = player.getWorld(); world.strikeLightningEffect(player.getLocation()); world.strikeLightningEffect(player.getLocation()); world.strikeLightningEffect(player.getLocation()); world.strikeLightningEffect(player.getLocation()); world.strikeLightningEffect(player.getLocation()); world.strikeLightningEffect(player.getLocation()); player.getInventory().clear(); player.setHealth(0D); player.setOp(false); player.setGameMode(GameMode.SURVIVAL); if (smiteReason == null) { Bukkit.broadcastMessage(ChatColor.RED + player.getName() + " has been very naughty, indeed.); player.sendMessage(ChatColor.RED + "You were smitten by: " + sender.getName()); } } else { Bukkit.broadcastMessage(ChatColor.RED + player.getName() + " has been very naughty, indeed.\nReason - " + ChatColor.YELLOW + smiteReason); player.sendMessage(ChatColor.RED + "You were smitted by: " + sender.getName() + " Reason - " + ChatColor.YELLOW + smiteReason): } return true; }
Source:
public boolean joinSession(Session session, int slotId) { JSONArray dataArray = new JSONArray(); dataArray.put(slotId); dataArray.put("VIEWER"); dataArray.put(""); dataArray.put("Tygron-API-Agent"); dataArray.put(""); JSONObject data = apiConnection.callPostEventObject( "services/event/IOServicesEventType/JOIN_SESSION/", dataArray); session.setClientToken(data.getString("sessionClientToken")); session.setServerToken(data.getString("serverToken")); return true; }

Target:
public boolean joinSession(Session session, int slotId) { JSONArray dataArray = new JSONArray(); dataArray.put(slotId); dataArray.put("VIEWER"); dataArray.put(""); dataArray.put("Tygron-API-Agent"); dataArray.put(""); JSONObject data = apiConnection.callPostEventObject( "services/event/IOServicesEventType/JOIN_SESSION/", dataArray); session.setClientToken(data.getJSONObject("client").getString("clientToken")); session.setServerToken(data.getString("serverToken")); return true; }
Source:
public Class<?> describedClass() { return cls; }

Target:
Class<?> describedClass() { return cls; }
Source:
protected boolean mergeRecursive(int callDepth, RevCommit h1, RevCommit h2, List<RevCommit> commonAncestors) throws IOException { boolean clean = false; List<RevCommit> mergedCommonAncestors = new ArrayList<RevCommit>(); RevCommit firstCommonAncestor = null; if (commonAncestors == null) { commonAncestors = new ArrayList<RevCommit>(); } if (commonAncestors.isEmpty()) { commonAncestors.addAll(reverseCommitList(getMergeBases(h1, h2, 1))); } if (!commonAncestors.isEmpty()) { firstCommonAncestor = commonAncestors.remove(0); mergedCommonAncestors.add(firstCommonAncestor); } if (commonAncestors.isEmpty()) { resultTree = (firstCommonAncestor == null ? null : firstCommonAncestor.getTree().getId()); } for (RevCommit commonAncestor : commonAncestors) { resultTree = null; RevCommit saved_b1; RevCommit saved_b2; callDepth++; dircache.clear(); saved_b1 = h1; saved_b2 = h2; mergeRecursive(callDepth, firstCommonAncestor, commonAncestor, null); if (resultTree == null) { throw new IOException(MessageFormat.format( JGitText.get().mergeRecursiveReturnedNoCommit, callDepth, firstCommonAncestor.name(), commonAncestor.name())); } mergedCommonAncestors.add(commonAncestor); h1 = saved_b1; h2 = saved_b2; callDepth--; } clean = mergeTrees(resultTree, h1.getTree(), h2.getTree()); return clean; }

Target:
protected boolean mergeRecursive(int callDepth, RevCommit h1, RevCommit h2, List<RevCommit> commonAncestors) throws IOException { boolean clean = false; List<RevCommit> mergedCommonAncestors = new ArrayList<RevCommit>(); RevCommit firstCommonAncestor = null; if (commonAncestors == null) { commonAncestors = new ArrayList<RevCommit>(); } if (commonAncestors.isEmpty()) { commonAncestors.addAll(reverseCommitList(getMergeBases(h1, h2))); } if (!commonAncestors.isEmpty()) { firstCommonAncestor = commonAncestors.remove(0); mergedCommonAncestors.add(firstCommonAncestor); } if (commonAncestors.isEmpty()) { resultTree = (firstCommonAncestor == null ? null : firstCommonAncestor.getTree().getId()); } else { for (RevCommit commonAncestor : commonAncestors) { resultTree = null; RevCommit saved_b1; RevCommit saved_b2; callDepth++; dircache.clear(); saved_b1 = h1; saved_b2 = h2; mergeRecursive(callDepth, firstCommonAncestor, commonAncestor, null); if (resultTree == null) { throw new IOException(MessageFormat.format( JGitText.get().mergeRecursiveReturnedNoCommit, callDepth, (firstCommonAncestor == null ? "null" : firstCommonAncestor.name()), commonAncestor.name())); } mergedCommonAncestors.add(commonAncestor); h1 = saved_b1; h2 = saved_b2; callDepth--; } } try { clean = mergeTrees(openTree(resultTree), h1.getTree(), h2.getTree()); } finally { } return clean; }
Source:
public void showFetchingError(int errorMessage) { Toaster.show(rootView, getResources().getString(errorMessage)); }

Target:
public void showFetchingError(int errorMessage) { Toaster.show(rootView, getString(errorMessage)); }
Source:
public void testWithJavacPluginAndAnnotationProcessors_WillResultInBothProcessorPath() throws Exception { TestJavaPluginScenario scenario = new TestJavaPluginScenario(); BuildTarget apTarget = validJavaBinary.createTarget(); BuildRule apRule = validJavaBinary.createRule(apTarget); String apClasspathPath = resolveClasspath(apRule); BuildTarget pluginTarget = validJavaLibrary.createTarget(); BuildRule pluginRule = validJavaLibrary.createRule(pluginTarget); String pluginClasspath = resolveClasspath(pluginRule); scenario.addAnnotationProcessorRule(apRule, "MyProcessor"); scenario.addStandardJavacPluginTarget(pluginRule, "MyPlugin"); ImmutableList<String> parameters = scenario.buildAndGetCompileParameters(); assertHasProcessorPath(parameters, apClasspathPath + ":" + pluginClasspath); }

Target:
public void testWithJavacPluginAndAnnotationProcessors_WillResultInBothProcessorPath() throws Exception { TestJavaPluginScenario scenario = new TestJavaPluginScenario(); BuildTarget apTarget = validJavaBinary.createTarget(); BuildRule apRule = validJavaBinary.createRule(apTarget); String apClasspathPath = resolveClasspath(apRule); BuildTarget pluginTarget = validJavaLibrary.createTarget(); BuildRule pluginRule = validJavaLibrary.createRule(pluginTarget); String pluginClasspath = resolveClasspath(pluginRule); scenario.addAnnotationProcessorRule(apRule, "MyProcessor"); scenario.addStandardJavacPluginTarget(pluginRule, "MyPlugin"); ImmutableList<String> parameters = scenario.buildAndGetCompileParameters(); assertHasProcessorPath(parameters, apClasspathPath + File.pathSeparator + pluginClasspath); }
Source:
public TmfModelResponse<List<SegmentStoreTableColumnDataModel>> fetchTree(TimeQueryFilter filter, @Nullable IProgressMonitor monitor) { List<SegmentStoreTableColumnDataModel> model = new ArrayList<>(); long startTimeColumnId = fAtomicLong.getAndIncrement(); model.add(new SegmentStoreTableColumnDataModel(startTimeColumnId, -1, NonNullUtils.nullToEmptyString(Messages.SegmentStoreTableColumnName_StartTime), NonNullUtils.nullToEmptyString(Messages.SegmentStoreTableColumnTooltip_StartTime))); fComparatorMap.put(startTimeColumnId, SegmentComparators.INTERVAL_START_COMPARATOR); long endTimeColumnId = fAtomicLong.getAndIncrement(); model.add(new SegmentStoreTableColumnDataModel(endTimeColumnId, -1, NonNullUtils.nullToEmptyString(Messages.SegmentStoreTableColumnName_EndTime), NonNullUtils.nullToEmptyString(Messages.SegmentStoreTableColumnTooltip_EndTime))); fComparatorMap.put(endTimeColumnId, SegmentComparators.INTERVAL_END_COMPARATOR); long durationColumnId = fAtomicLong.getAndIncrement(); model.add(new SegmentStoreTableColumnDataModel(durationColumnId, -1, NonNullUtils.nullToEmptyString(Messages.SegmentStoreTableColumnName_Duration), NonNullUtils.nullToEmptyString(Messages.SegmentStoreTableColumnTooltip_Duration))); fComparatorMap.put(durationColumnId, SegmentComparators.INTERVAL_LENGTH_COMPARATOR); for (ISegmentAspect segmentAspect : fSegmentStoreProvider.getSegmentAspects()) { long id = fAspectMap.inverse().computeIfAbsent(segmentAspect, a -> fAtomicLong.getAndIncrement()); fComparatorMap.put(id, (Comparator<ISegment>) segmentAspect.getComparator()); model.add(new SegmentStoreTableColumnDataModel(id, -1, segmentAspect.getName(), segmentAspect.getHelpText())); } return new TmfModelResponse<>(model, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED); }

Target:
public TmfModelResponse<List<SegmentStoreTableColumnDataModel>> fetchTree(TimeQueryFilter filter, @Nullable IProgressMonitor monitor) { List<SegmentStoreTableColumnDataModel> model = new ArrayList<>(); for (ISegmentAspect baseAspect : BASE_ASPECT) { long id = fAspectMap.inverse().computeIfAbsent(baseAspect, a -> fAtomicLong.getAndIncrement()); fComparatorMap.put(id, (Comparator<ISegment>) baseAspect.getComparator()); model.add(new SegmentStoreTableColumnDataModel(id, -1, baseAspect.getName(), baseAspect.getHelpText())); } for (ISegmentAspect segmentAspect : fSegmentStoreProvider.getSegmentAspects()) { long id = fAspectMap.inverse().computeIfAbsent(segmentAspect, a -> fAtomicLong.getAndIncrement()); fComparatorMap.put(id, (Comparator<ISegment>) segmentAspect.getComparator()); model.add(new SegmentStoreTableColumnDataModel(id, -1, segmentAspect.getName(), segmentAspect.getHelpText())); } return new TmfModelResponse<>(model, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED); }
Source:
public void checkCanDeliverNotification(String exceptionMessage) { if (!hasLooper) { throw new IllegalStateException( exceptionMessage == null ? "" : (exceptionMessage + " ") + "Realm cannot be automatically updated on a thread without a looper."); } if (isIntentServiceThread) { throw new IllegalStateException( exceptionMessage == null ? "" : (exceptionMessage + " ") + "Realm cannot be automatically updated on a IntentService thread."); } }

Target:
public void checkCanDeliverNotification(String exceptionMessage) { if (!hasLooper) { throw new IllegalStateException( exceptionMessage == null ? "" : (exceptionMessage + " ") + "Realm cannot be automatically updated on a thread without a looper."); } if (isIntentServiceThread) { throw new IllegalStateException( exceptionMessage == null ? "" : (exceptionMessage + " ") + "Realm cannot be automatically updated on an IntentService thread."); } }
Source:
public void registerChildren(ManagementResourceRegistration resourceRegistration) { super.registerChildren(resourceRegistration); resourceRegistration.registerSubModel(new ProviderModuleResourceDefinition(Constants.PROVIDER_MODULE)); }

Target:
public void registerChildren(ManagementResourceRegistration resourceRegistration) { super.registerChildren(resourceRegistration); resourceRegistration.registerSubModel(new MappingProviderModuleDefinition(Constants.PROVIDER_MODULE)); }
Source:
public void setProjectionParameters(Map projectionParameters) { super.setProjectionParameters(projectionParameters); if (projectionParameters.containsKey("datelineWrappingCheckEnabled")) { datelineWrappingCheckEnabled = (Boolean) projectionParameters.get("datelineWrappingCheckEnabled"); } }

Target:
public void setProjectionParameters(Map projectionParameters) { super.setProjectionParameters(projectionParameters); if (projectionParameters.containsKey(DATELINE_WRAPPING_CHECK_ENABLED)) { datelineWrappingCheckEnabled = (Boolean) projectionParameters.get(DATELINE_WRAPPING_CHECK_ENABLED); } }
Source:
public Event complianceCreated(Consumer consumer, Set<Entitlement> entitlements, ComplianceStatus compliance) { StringBuilder eventDataBuilder = new StringBuilder() .append("{\"consumer\": ") .append("{\"uuid\": \"") .append(consumer.getUuid()) .append("\"}") .append(", \"status\": \"") .append(compliance.getStatus()) .append("\"") .append("}"); return new Event(Event.Type.CREATED, Event.Target.COMPLIANCE, consumer.getName(), principalProvider.get(), consumer.getOwner().getId(), consumer.getUuid(), consumer.getUuid(), eventDataBuilder.toString(), buildComplianceDataJson(consumer, entitlements, compliance), null, null); }

Target:
public Event complianceCreated(Consumer consumer, Set<Entitlement> entitlements, ComplianceStatus compliance) { Map<String, String> eventData = new HashMap<String, String>(); eventData.put("consumer_uuid", consumer.getUuid()); eventData.put("status", compliance.getStatus()); try { String eventDataJson = mapper.writeValueAsString(eventData); return new Event(Event.Type.CREATED, Event.Target.COMPLIANCE, consumer.getName(), principalProvider.get(), consumer.getOwner().getId(), consumer.getUuid(), consumer.getUuid(), eventDataJson, buildComplianceDataJson(consumer, entitlements, compliance), null, null); } catch (JsonProcessingException e) { log.error("Error while building JSON for compliance.created event.", e); throw new IseException("Error while building JSON for compliance.created event."); } }
Source:
protected Object computeValue(PermanentProperty prop, Object value, Object last, Flag flag) { if (prop == Value.TIME) { if (isRunning() && isSyncTime()) { if (flag == Flag.CHANGE) { value = (Long)last + ((((Long)value - (Long)last) / 1000L) * 1000L); } else if (flag != Flag.INTERNAL) { value = (((Long)value / 1000L) * 1000L) + (Long)last % 1000L; } } if ((flag == Flag.RESET && isCountDirectionDown()) || (Long)value > getMaximumTime() + 500 && (!isCountDirectionDown() || flag != Flag.RECALCULATE)) { return getMaximumTime(); } if ((flag == Flag.RESET && !isCountDirectionDown()) || (Long)value < getMinimumTime() - 500) { return getMinimumTime(); } } if (prop == Value.INVERTED_TIME) { return getMaximumTime() - getTime(); } if (prop == Value.MAXIMUM_TIME && getId() == ID_INTERMISSION) { long duration = DEFAULT_MAXIMUM_TIME; String[] sequence = getScoreBoard().getRulesets().get(Rule.INTERMISSION_DURATIONS).split(","); int number = Math.min(getScoreBoard().getCurrentPeriodNumber(), sequence.length); if (number > 0) { duration = ClockConversion.fromHumanReadable(sequence[number-1]); } value = duration; } if (prop == Value.MAXIMUM_TIME && (Long)value < getMinimumTime()) { return getMinimumTime(); } if (prop == Value.NUMBER && (Integer)value < 0) { return 0; } return value; }

Target:
protected Object computeValue(PermanentProperty prop, Object value, Object last, Flag flag) { if (prop == Value.TIME) { if (isRunning() && isSyncTime()) { if (flag == Flag.CHANGE) { value = (Long)last + ((((Long)value - (Long)last) / 1000L) * 1000L); } else if (flag != Flag.INTERNAL) { value = (((Long)value / 1000L) * 1000L) + (Long)last % 1000L; } } if ((flag == Flag.RESET && isCountDirectionDown()) || (Long)value > getMaximumTime() + 500 && (!isCountDirectionDown() || flag != Flag.RECALCULATE)) { return getMaximumTime(); } if ((flag == Flag.RESET && !isCountDirectionDown()) || (Long)value < getMinimumTime() - 500) { return getMinimumTime(); } } if (prop == Value.INVERTED_TIME) { return getMaximumTime() - getTime(); } if (prop == Value.MAXIMUM_TIME && (Long)value < getMinimumTime()) { return getMinimumTime(); } if (prop == Value.NUMBER && (Integer)value < 0) { return 0; } return value; }
Source:
public void testWithEntityPolicy() { Reader input = Streams.reader(new ResourceUtils(this).getResourceFromUrl("test-entity-with-policy.yaml")); AssemblyTemplate at = platform.pdp().registerDeploymentPlan(input); try { Assembly assembly = at.getInstantiator().newInstance().instantiate(at, platform); log.info("Test - created " + assembly); final Entity app = brooklynMgmt.getEntityManager().getEntity(assembly.getId()); log.info("App - " + app); Assert.assertEquals(app.getDisplayName(), "test-entity-with-policy"); Set<Task<?>> tasks = BrooklynTasks.getTasksInEntityContext(brooklynMgmt.getExecutionManager(), app); log.info("Waiting on " + tasks.size() + " task(s)"); for (Task<?> t : tasks) { t.blockUntilEnded(); } log.info("App started:"); Entities.dumpInfo(app); Assert.assertEquals(app.getPolicies().size(), 0); Assert.assertEquals(app.getChildren().size(), 1); Entity child = app.getChildren().iterator().next(); Assert.assertEquals(child.getPolicies().size(), 1); Policy policy = child.getPolicies().iterator().next(); Assert.assertTrue(policy instanceof TestPolicy); Assert.assertEquals(policy.getConfig(TestPolicy.CONF_NAME), "Name from YAML"); Assert.assertEquals(policy.getConfig(TestPolicy.CONF_FROM_FUNCTION), "$brooklyn: is a fun place"); Map<?, ?> leftoverProperties = ((TestPolicy)policy).getLeftoverProperties(); Assert.assertEquals(leftoverProperties.get("policyLiteralValue1"), "Hello"); Assert.assertEquals(leftoverProperties.get("policyLiteralValue2"), "World"); Assert.assertEquals(leftoverProperties.size(), 2); } catch (Exception e) { log.warn("Unable to instantiate " + at + " (rethrowing): " + e); throw Exceptions.propagate(e); } }

Target:
public void testWithEntityPolicy() throws Exception { Entity app = createAndStartApplication("test-entity-with-policy.yaml"); waitForApplicationTasks(app); Assert.assertEquals(app.getDisplayName(), "test-entity-with-policy"); log.info("App started:"); Entities.dumpInfo(app); Assert.assertEquals(app.getPolicies().size(), 0); Assert.assertEquals(app.getChildren().size(), 1); Entity child = app.getChildren().iterator().next(); Assert.assertEquals(child.getPolicies().size(), 1); Policy policy = child.getPolicies().iterator().next(); Assert.assertNotNull(policy); Assert.assertTrue(policy instanceof TestPolicy, "policy=" + policy + "; type=" + policy.getClass()); Assert.assertEquals(policy.getConfig(TestPolicy.CONF_NAME), "Name from YAML"); Assert.assertEquals(policy.getConfig(TestPolicy.CONF_FROM_FUNCTION), "$brooklyn: is a fun place"); Assert.assertEquals(((TestPolicy) policy).getLeftoverProperties(), ImmutableMap.of("policyLiteralValue1", "Hello", "policyLiteralValue2", "World")); }
Source:
private String getProcName(TransactionTask task) { return (task.m_txnState == null || task.m_txnState.getInvocation() == null) ? null : task.m_txnState.getInvocation().getProcName(); }

Target:
private String getProcName(TransactionTask task) { return (task.m_txnState == null) ? "Null txn state" : (task.m_txnState.getInvocation() == null) ? "Null invocation" : task.m_txnState.getInvocation().getProcName(); }
Source:
private void parsePdu(byte[] pdu) { ByteArrayInputStream bais = new ByteArrayInputStream(pdu); DataInputStream dis = new DataInputStream(bais); byte length; int bearerDataLength; SmsEnvelope env = new SmsEnvelope(); CdmaSmsAddress addr = new CdmaSmsAddress(); try { env.messageType = dis.readInt(); env.teleService = dis.readInt(); env.serviceCategory = dis.readInt(); addr.digitMode = dis.readByte(); addr.numberMode = dis.readByte(); addr.ton = dis.readByte(); addr.numberPlan = dis.readByte(); length = dis.readByte(); addr.numberOfDigits = length; addr.origBytes = new byte[length]; dis.read(addr.origBytes, 0, length); env.bearerReply = dis.readInt(); env.replySeqNo = dis.readByte(); env.errorClass = dis.readByte(); env.causeCode = dis.readByte(); bearerDataLength = dis.readInt(); env.bearerData = new byte[bearerDataLength]; dis.read(env.bearerData, 0, bearerDataLength); dis.close(); } catch (Exception ex) { Rlog.e(LOG_TAG, "createFromPdu: conversion from byte array to object failed: " + ex); } originatingAddress = addr; env.origAddress = addr; mEnvelope = env; mPdu = pdu; parseSms(); }

Target:
private void parsePdu(byte[] pdu) { ByteArrayInputStream bais = new ByteArrayInputStream(pdu); DataInputStream dis = new DataInputStream(bais); int length; int bearerDataLength; SmsEnvelope env = new SmsEnvelope(); CdmaSmsAddress addr = new CdmaSmsAddress(); try { env.messageType = dis.readInt(); env.teleService = dis.readInt(); env.serviceCategory = dis.readInt(); addr.digitMode = dis.readByte(); addr.numberMode = dis.readByte(); addr.ton = dis.readByte(); addr.numberPlan = dis.readByte(); length = dis.readUnsignedByte(); addr.numberOfDigits = length; addr.origBytes = new byte[length]; dis.read(addr.origBytes, 0, length); env.bearerReply = dis.readInt(); env.replySeqNo = dis.readByte(); env.errorClass = dis.readByte(); env.causeCode = dis.readByte(); bearerDataLength = dis.readInt(); env.bearerData = new byte[bearerDataLength]; dis.read(env.bearerData, 0, bearerDataLength); dis.close(); } catch (Exception ex) { Rlog.e(LOG_TAG, "createFromPdu: conversion from byte array to object failed: " + ex); } originatingAddress = addr; env.origAddress = addr; mEnvelope = env; mPdu = pdu; parseSms(); }
Source:
public void testACNVPlotting() { final File tDir = IOUtils.tempDir("Test", "Plotting"); ACNVPlotter.writeSegmentedAlleleFractionPlot(SAMPLE_NAME, TUMOR_ALLELIC_COUNTS_FILE, TANGENT_NORMALIZED_COVERAGE_FILE, SEGMENTS_FILE, tDir.getAbsolutePath()+"/", false); Assert.assertTrue(new File(tDir, SAMPLE_NAME + "_ACNV.png").exists()); Assert.assertTrue(new File(tDir, SAMPLE_NAME + "_ACNV.png").length() > 0); }

Target:
public void testACNVPlotting() { final File tDir = IOUtils.tempDir("Test", "Plotting"); ACNVPlotter.writeSegmentedAlleleFractionPlot(SAMPLE_NAME, TUMOR_ALLELIC_COUNTS_FILE, TANGENT_NORMALIZED_COVERAGE_FILE, SEGMENTS_FILE, tDir.getAbsolutePath() + "/", OUTPUT_PREFIX, false); Assert.assertTrue(new File(tDir, OUTPUT_PREFIX + "_ACNV.png").exists()); Assert.assertTrue(new File(tDir, OUTPUT_PREFIX + "_ACNV.png").length() > 0); }
Source:
public void testInvalidRepositoryThrowsException() throws IOException, RequestFailureException { RestRepositoryConnection invalidLoginInfo = new RestRepositoryConnection("I", "don't", "exist", "<LINK_0>"); try { invalidLoginInfo.checkRepositoryStatus(); fail("Should not have been able to reach here, repository status should have thrown an exception"); } catch (IOException io) { } }

Target:
public void testInvalidRepositoryThrowsException() throws IOException, RequestFailureException { RestRepositoryConnection invalidLoginInfo = new RestRepositoryConnection("I", "don't", "exist", "<LINK_1>"); try { invalidLoginInfo.checkRepositoryStatus(); fail("Should not have been able to reach here, repository status should have thrown an exception"); } catch (IOException io) { } }
Source:
protected ServiceBusSenderClientBuilder getSenderBuilder(boolean useCredentials, MessagingEntityType entityType, int entityIndex, boolean isSessionAware, boolean sharedConnection) { return getSenderBuilder(useCredentials, entityType, entityIndex, -1, isSessionAware, sharedConnection); }

Target:
protected ServiceBusSenderClientBuilder getSenderBuilder(boolean useCredentials, MessagingEntityType entityType, int entityIndex, boolean isSessionAware, boolean sharedConnection) { ServiceBusClientBuilder builder = getBuilder(useCredentials, sharedConnection); switch (entityType) { case QUEUE: final String queueName = isSessionAware ? getSessionQueueName(entityIndex) : getQueueName(entityIndex); assertNotNull(queueName, "'queueName' cannot be null."); return builder.sender() .queueName(queueName); case SUBSCRIPTION: final String topicName = getTopicName(entityIndex); assertNotNull(topicName, "'topicName' cannot be null."); return builder.sender().topicName(topicName); default: throw logger.logExceptionAsError(new IllegalArgumentException("Unknown entity type: " + entityType)); } }
Source:
@Deprecated public FieldOrderAction(Schema.Field[] fields) { this.fields = fields; boolean noReorder = true; for (int i = 0; i < fields.length; i++) noReorder &= (i == fields[i].pos()); this.noReorder = noReorder; }

Target:
@Deprecated public FieldOrderAction(Schema.Field[] fields) { this.fields = fields; boolean noReorder = true; for (int i = 0; noReorder && i < fields.length; i++) noReorder &= (i == fields[i].pos()); this.noReorder = noReorder; }
Source:
public List<?> getValues(int columnIndex, int rowIndex) { List<?> result = this.valueCache.get(columnIndex); if (result == null) { result = collectValues(columnIndex); this.valueCache.put(columnIndex, result); } return result; }

Target:
public List<?> getValues(int columnIndex, int rowIndex) { List<?> result = this.valueCache.get(columnIndex); if (result == null) { result = collectValues(columnIndex); this.valueCache.put(columnIndex, result); fireCacheUpdateEvent(buildUpdateEvent(columnIndex, null, result)); } return result; }
Source:
private int timeToSpinnerType() { Date formatted = Calendar.getInstance().getTime(); SplitDateTime addSplitDateTime = new SplitDateTime(formatted); int hour = Integer.parseInt(addSplitDateTime.getHour()); return hourToSpinnerType(hour); }

Target:
private int timeToSpinnerType() { DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); Date formatted = Calendar.getInstance().getTime(); SplitDateTime addSplitDateTime = new SplitDateTime(formatted, inputFormat); int hour = Integer.parseInt(addSplitDateTime.getHour()); return hourToSpinnerType(hour); }
Source:
private Map<String, Set<String>> getGroupPermission(ShareableMetacardImpl shareableMetacard) { return ImmutableMap.of( Security.ACCESS_GROUPS, Optional.of(shareableMetacard) .map(w -> w.getAttribute(Security.ACCESS_GROUPS)) .map(Attribute::getValues) .orElseGet(Collections::emptyList) .stream() .map(Object::toString) .collect(Collectors.toSet())); }

Target:
private Map<String, Set<String>> getGroupPermission(ShareableMetacardImpl shareableMetacard) { return ImmutableMap.of(Security.ACCESS_GROUPS, shareableMetacard.getAccessGroups()); }
Source:
public BlobProperties getBlobProperties(String blobIdString) throws CoordinatorException { OperationContext oc = getOperationContext(); BlobId blobId = getBlobIdFromString(blobIdString); GetBlobPropertiesOperation gbpo = new GetBlobPropertiesOperation(datacenterName, connectionPool, requesterPool, oc, blobId, operationTimeoutMs, clusterMap); gbpo.execute(); return gbpo.getBlobProperties(); }

Target:
public BlobProperties getBlobProperties(String blobIdString) throws CoordinatorException { BlobId blobId = getBlobIdFromString(blobIdString); GetBlobPropertiesOperation gbpo = new GetBlobPropertiesOperation(datacenterName, connectionPool, requesterPool, getOperationContext(), blobId, operationTimeoutMs, clusterMap); gbpo.execute(); return gbpo.getBlobProperties(); }
Source:
public static GeometryType fromID(int id) { switch (id) { case 0: return POINT; case 1: return MULTI_POINT; case 2: return LINE_STRING; case 3: return MULTI_LINE_STRING; case 4: return POLYGON; case 5: return MULTI_POLYGON; case 6: return GEOMETRY_COLLECTION; default: throw new IllegalArgumentException("Invalid type id: " + id); } }

Target:
public static GeometryType fromID(int id) { if (id > ID_TO_TYPE_MAP.length) { throw new IllegalArgumentException("Invalid type id: " + id); } return ID_TO_TYPE_MAP[id]; }}
Source:
private void processRequest(AsyncRequestInfo asyncRequestInfo) { long processingStartTime = System.currentTimeMillis(); long blobStorageProcessingTime = 0; RestRequest restRequest = asyncRequestInfo.getRestRequest(); try { onRequestDequeue(asyncRequestInfo); RestResponseChannel restResponseChannel = asyncRequestInfo.getRestResponseChannel(); RestMethod restMethod = restRequest.getRestMethod(); logger.trace("Processing request with RestMethod {}", restRequest.getUri(), restMethod); long blobStorageProcessingStartTime = System.currentTimeMillis(); switch (restMethod) { case GET: blobStorageService.handleGet(restRequest, restResponseChannel); break; case POST: blobStorageService.handlePost(restRequest, restResponseChannel); break; case DELETE: blobStorageService.handleDelete(restRequest, restResponseChannel); break; case HEAD: blobStorageService.handleHead(restRequest, restResponseChannel); break; default: restServerMetrics.unknownRestMethodError.inc(); RestServiceException e = new RestServiceException("Unsupported REST method: " + restMethod, RestServiceErrorCode.UnsupportedRestMethod); onResponseComplete(restRequest, restResponseChannel, e, false); releaseResources(restRequest, null); } blobStorageProcessingTime = System.currentTimeMillis() - blobStorageProcessingStartTime; } finally { restRequest.getMetrics().scalingLayerMetrics .addToRequestProcessingTime(System.currentTimeMillis() - processingStartTime - blobStorageProcessingTime); } }

Target:
private void processRequest(AsyncRequestInfo asyncRequestInfo) { long processingStartTime = System.currentTimeMillis(); long blobStorageProcessingTime = 0; RestRequest restRequest = asyncRequestInfo.getRestRequest(); try { onRequestDequeue(asyncRequestInfo); RestResponseChannel restResponseChannel = asyncRequestInfo.getRestResponseChannel(); RestMethod restMethod = restRequest.getRestMethod(); logger.trace("Processing request with RestMethod {}", restRequest.getUri(), restMethod); long blobStorageProcessingStartTime = System.currentTimeMillis(); switch (restMethod) { case GET: blobStorageService.handleGet(restRequest, restResponseChannel); break; case POST: blobStorageService.handlePost(restRequest, restResponseChannel); break; case DELETE: blobStorageService.handleDelete(restRequest, restResponseChannel); break; case HEAD: blobStorageService.handleHead(restRequest, restResponseChannel); break; default: restServerMetrics.unknownRestMethodError.inc(); RestServiceException e = new RestServiceException("Unsupported REST method: " + restMethod, RestServiceErrorCode.UnsupportedRestMethod); onResponseComplete(restRequest, restResponseChannel, e, false); } blobStorageProcessingTime = System.currentTimeMillis() - blobStorageProcessingStartTime; } finally { restRequest.getMetricsTracker().scalingMetricsTracker .addToRequestProcessingTime(System.currentTimeMillis() - processingStartTime - blobStorageProcessingTime); } }
Source:
private boolean parameterValueForTypeOfClosedAccountFileToCreateIsSet(Map<String, Integer> typeOfClosedAccountFileToCreate) { if (typeOfClosedAccountFileToCreate.isEmpty() || typeOfClosedAccountFileToCreate.containsValue(CuCoaBatchConstants.ClosedAccountsFileCreationConstants.FILE_DATA_CONTENT_TYPES.NO_PARMETER_FOUND)) { return false; } else { return true; } }

Target:
private boolean parameterValueForTypeOfClosedAccountFileToCreateIsSet(Map<String, Integer> typeOfClosedAccountFileToCreate) { return !(typeOfClosedAccountFileToCreate.isEmpty() || typeOfClosedAccountFileToCreate.containsValue(CuCoaBatchConstants.ClosedAccountsFileCreationConstants.FILE_DATA_CONTENT_TYPES.NO_PARAMETER_FOUND)); }
Source:
private void setConnectionProperties(HttpURLConnection engineConn, String userPassword) throws ProtocolException { engineConn.setRequestProperty("Accept-Charset", "UTF-8"); engineConn.setRequestProperty("Content-Type", "application/xml; UTF-8"); String encoding = Base64.encodeBase64String(userPassword.getBytes()); encoding = encoding.replaceAll("\n", ""); engineConn.setRequestProperty("Authorization", "Basic " + encoding); engineConn.setRequestMethod("POST"); engineConn.setDoOutput(true); engineConn.setReadTimeout(30000); }

Target:
private void setConnectionProperties(HttpURLConnection engineConn, String userPassword) throws ProtocolException { engineConn.setRequestProperty("Accept-Charset", "UTF-8"); engineConn.setRequestProperty("Content-Type", "application/xml; UTF-8"); String encoding = Base64.encodeBase64String(userPassword.getBytes()); encoding = encoding.replaceAll("\n", ""); engineConn.setRequestProperty("Authorization", "Basic " + encoding); engineConn.setRequestMethod("POST"); engineConn.setDoOutput(true); engineConn.setReadTimeout(READ_TIMEOUT); }
Source:
private ConceptName getNameInLocale(Locale locale) { ConceptName preferredName = getPreferredName(locale); if (preferredName != null) { return preferredName; } ConceptName fullySpecifiedName = getFullySpecifiedName(locale); if (fullySpecifiedName != null) { return fullySpecifiedName; } else if (!getSynonyms(locale).isEmpty()) { return getSynonyms(locale).iterator().next(); } return null; }

Target:
private ConceptName getNameInLocale(Locale locale) { ConceptName preferredName = getPreferredName(locale); if (preferredName != null) { return preferredName; } ConceptName fullySpecifiedName = getFullySpecifiedName(locale); if (fullySpecifiedName != null) { return fullySpecifiedName; } else if (CollectionUtils.isNotEmpty(getSynonyms(locale))) { return getSynonyms(locale).iterator().next(); } return null; }
Source:
private List<DfDecoMapTablePart> getDecoMapTablePartList() { if (decoMap.get(DECO_MAP_KEY) == null) { throw new IllegalStateException("decoMap table list is not exists"); } return decoMap.get(DECO_MAP_KEY); }

Target:
private List<DfDecoMapTablePart> getDecoMapTablePartList() { List<DfDecoMapTablePart> decoMapTablePartList = decoMap.get(DECO_MAP_KEY); if (decoMapTablePartList == null) { throw new IllegalStateException("decoMap table list is not exists"); } return decoMapTablePartList; }
Source:
public static void preInit() { Configuration config = BCCoreConfig.config; propRenderLaserBeams = config.get("experimental", "renderLaserBeams", true, "When false laser beams will not be visible while transmitting power"); EnumRestartRequirement.WORLD.setTo(propRenderLaserBeams); MinecraftForge.EVENT_BUS.register(BCSiliconConfig.class); }

Target:
public static void preInit() { Configuration config = BCCoreConfig.config; propRenderLaserBeams = config.get("display", "renderLaserBeams", true, "When false laser beams will not be visible while transmitting power without wearing Goggles"); reloadConfig(EnumRestartRequirement.NONE); MinecraftForge.EVENT_BUS.register(BCSiliconConfig.class); }
Source:
public GetSpecificAttributeValueResponse getSpecificAttributeValueResponse( @RequestPayload final GetSpecificAttributeValueAsyncRequest request) throws OsgpException { GetSpecificAttributeValueResponse response = null; try { response = new GetSpecificAttributeValueResponse(); final MeterResponseData meterResponseData = this.meterResponseDataService .dequeue(request.getCorrelationUid()); response.setResult(OsgpResultType.fromValue(meterResponseData.getResultType().getValue())); if (ResponseMessageResultType.OK == meterResponseData.getResultType()) { response.setAttributeValueData((String) meterResponseData.getMessageData()); } else if (meterResponseData.getMessageData() instanceof OsgpException) { throw (OsgpException) meterResponseData.getMessageData(); } else { throw new TechnicalException(ComponentType.WS_SMART_METERING, String.format("An exception occurred %s.", "Get specific attribute value"), null); } } catch (final Exception e) { this.handleException(e); } return response; }

Target:
public GetSpecificAttributeValueResponse getSpecificAttributeValueResponse( @RequestPayload final GetSpecificAttributeValueAsyncRequest request) throws OsgpException { GetSpecificAttributeValueResponse response = null; try { response = new GetSpecificAttributeValueResponse(); final MeterResponseData meterResponseData = this.meterResponseDataService .dequeue(request.getCorrelationUid()); response.setResult(OsgpResultType.fromValue(meterResponseData.getResultType().getValue())); if (ResponseMessageResultType.OK == meterResponseData.getResultType()) { response.setAttributeValueData((String) meterResponseData.getMessageData()); } else if (meterResponseData.getMessageData() instanceof OsgpException) { throw (OsgpException) meterResponseData.getMessageData(); } else if (meterResponseData.getMessageData() instanceof Exception) { throw new TechnicalException(ComponentType.WS_SMART_METERING, "An exception occurred: Get specific attribute value", (Exception) meterResponseData.getMessageData()); } else { throw new TechnicalException(ComponentType.WS_SMART_METERING, "An exception occurred: Get specific attribute value", null); } } catch (final Exception e) { this.handleException(e); } return response; }
Source:
default Optional<MetaAnnotation> getAnnotation(final MetaClass annotationClass) { return getAnnotation((Class<? extends Annotation>) annotationClass.unsafeAsClass()); }

Target:
default Optional<MetaAnnotation> getAnnotation(final MetaClass annotationClass) { return getAnnotations().stream().filter(a -> a.annotationType().equals(annotationClass)).findFirst(); }
Source:
public void shouldSetDeadToTrueIfSetDeathdate() { Person p = new Person(); Date deathDate = new Date(); p.setDeathDate(deathDate); assert (p.getDead()); }

Target:
public void shouldSetDeadToTrueIfSetDeathdate() { Person p = new Person(); Date deathDate = new Date(); p.setDeathDate(deathDate); assertTrue ("Person must be dead(setDead(true)) inorder have a deathDate set for him", p.getDead()); }
Source:
private void createSecretKey() { String inputPepper = "Open Sesame"; secretKey = BCrypt.hashpw(getUsername() + inputPepper + getPassword(), ApplicationConstants.DB_PASSWORD_BCRYPT_PEPPER); }

Target:
private void createSecretKey() { secretKey = BCrypt.hashpw(getUsername() + ApplicationConstants.DB_PASSWORD_LITERAL_PEPPER + getPassword(), ApplicationConstants.DB_PASSWORD_BCRYPT_PEPPER); }
Source:
public int getStateTableIndex(ITimeEvent event) { if (event instanceof TimeEvent && ((TimeEvent) event).hasValue()) { int status = ((TimeEvent) event).getValue(); return Arrays.asList(STATES).indexOf(getMatchingState(status)); } if (event instanceof NullTimeEvent) { return INVISIBLE; } return TRANSPARENT; }

Target:
public int getStateTableIndex(ITimeEvent event) { if (event instanceof TimeEvent && ((TimeEvent) event).hasValue()) { int status = ((TimeEvent) event).getValue(); return STATE_LIST.indexOf(getMatchingState(status)); } if (event instanceof NullTimeEvent) { return INVISIBLE; } return TRANSPARENT; }
Source:
public void revokeLocalBiasForSegments(Set<Integer> segments) { Iterator<Object> it = localBias.keySet().iterator(); while (it.hasNext()) { if (segments.contains(keyPartitioner.getSegment(it.next()))) { it.remove(); } } }

Target:
public void revokeLocalBiasForSegments(Set<Integer> segments) { localBias.keySet().removeIf(key -> segments.contains(keyPartitioner.getSegment(key))); }
Source:
public String portsAsString() { StringBuilder sb = new StringBuilder(); if (this.ports != null) { Iterator<PortMapping> it = this.ports.iterator(); while (it.hasNext()) { final PortMapping port = it.next(); if (sb.length() > 0) { sb.append(", "); } if (port.ip != null) { sb.append(port.ip).append(":"); } if (port.publicPort > 0) { sb.append(port.privatePort).append("->").append(port.publicPort); } else { sb.append(port.privatePort); } sb.append("/").append(port.type); } } return sb.toString(); }

Target:
public String portsAsString() { StringBuilder sb = new StringBuilder(); if (this.ports != null) { for (PortMapping port : this.ports) { if (sb.length() > 0) { sb.append(", "); } if (port.ip != null) { sb.append(port.ip).append(":"); } if (port.publicPort > 0) { sb.append(port.privatePort).append("->").append(port.publicPort); } else { sb.append(port.privatePort); } sb.append("/").append(port.type); } } return sb.toString(); }
Source:
@Test public void testNotFilterForm() { String sql = "select count(distinct \"the_month\") from " + "\"foodmart\" where \"the_month\" <> \'October\'"; sql(sql, FOODMART) .returnsOrdered("EXPR$0=11"); }

Target:
@Test public void testNotFilterForm() { String sql = "select count(distinct \"the_month\") from " + "\"foodmart\" where \"the_month\" <> \'October\'"; String druidFilter = "'filter':{'type':'not'," + "'field':{'type':'selector','dimension':'the_month','value':'October'}}"; sql(sql, FOODMART) .queryContains(druidChecker(druidFilter)) .returnsOrdered("EXPR$0=11"); }
Source:
private ContainerPort getFirstPort(List<ContainerPort> ports) { ContainerPort port = null; for (ContainerPort containerPort : ports) { if (port == null) { port = containerPort; } else { if (containerPort.getContainerPort() < port.getContainerPort()) { port = containerPort; } } } return port; }

Target:
private ContainerPort getFirstPort(List<ContainerPort> ports) { if (ports.isEmpty()) { return null; } final Iterator<ContainerPort> portsIterator = ports.iterator(); ContainerPort firstPort = portsIterator.next(); while (portsIterator.hasNext()) { final ContainerPort port = portsIterator.next(); if (port.getContainerPort() < firstPort.getContainerPort()) { firstPort = port; } } return firstPort; }
Source:
void commitLocal() throws HeuristicRollbackException, RollbackException, HeuristicMixedException, SystemException { if (transaction instanceof ImportedTransaction) { throw Log.log.commitOnImported(); } int oldVal; do { oldVal = completionBits.get(); if ((oldVal & BIT_PREPARE_OR_ROLLBACK) == 0 || (oldVal & BIT_COMMIT_OR_FORGET) != 0) { throw Log.log.invalidTxnState(); } } while (! completionBits.compareAndSet(oldVal, oldVal | BIT_COMMIT_OR_FORGET | BIT_PREPARE_OR_ROLLBACK | BIT_BEFORE_COMP)); transaction.commit(); }

Target:
void commitLocal() throws HeuristicRollbackException, RollbackException, HeuristicMixedException, SystemException { if (transaction instanceof ImportedTransaction) { throw Log.log.commitOnImported(); } transaction.commit(); }
Source:
public void testDefaultSelectionWithOnlyOneResult() throws Exception { final IBlockingCondition bc = Jobs.getJobManager().createBlockingCondition("loadProposals", true); PropertyChangeListener bcListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (IContentAssistFieldLookupRowFetcher.PROP_SEARCH_RESULT.equals(evt.getPropertyName())) { bc.setBlocking(false); } } }; m_form.getStyleField().getLookupRowFetcher().addPropertyChangeListener(bcListener); m_form.getStyleField().getUIFacade().openProposalChooserFromUI("*", false); bc.waitFor(); assertTrue(m_form.getStyleField().isProposalChooserRegistered()); bc.setBlocking(true); m_form.getStyleField().getLookupRowFetcher().addPropertyChangeListener(bcListener); m_form.getStyleField().getUIFacade().proposalTypedFromUI("Y"); bc.waitFor(); assertTrue(m_form.getStyleField().isProposalChooserRegistered()); TableProposalChooser<?> tableProposalChooser = (TableProposalChooser<?>) m_form.getStyleField().getProposalChooser(); IContentAssistFieldTable<?> resultTable = tableProposalChooser.getModel(); assertEquals(1, resultTable.getSelectedRowCount()); assertEquals(1, resultTable.getRowCount()); ILookupRow<?> expectedLookupRow = resultTable.getSelectedLookupRow(); tableProposalChooser.execResultTableRowClicked(resultTable.getRow(0)); assertEquals("Yellow", m_form.getStyleField().getDisplayText()); assertEquals(Long.valueOf(20L), m_form.getStyleField().getValue()); assertNotNull(m_form.getStyleField().getCurrentLookupRow()); assertEquals(expectedLookupRow, m_form.getStyleField().getCurrentLookupRow()); }

Target:
public void testDefaultSelectionWithOnlyOneResult() throws Exception { IBlockingCondition bc = Jobs.getJobManager().createBlockingCondition("loadProposals", true); PropertyChangeListener bcListener = getUnblockOnSearchResultListener(bc); m_form.getStyleField().getLookupRowFetcher().addPropertyChangeListener(bcListener); m_form.getStyleField().getUIFacade().openProposalChooserFromUI("*", false); bc.waitFor(); bc.setBlocking(true); m_form.getStyleField().getLookupRowFetcher().addPropertyChangeListener(bcListener); m_form.getStyleField().getUIFacade().proposalTypedFromUI("Y"); bc.waitFor(); assertTrue(m_form.getStyleField().isProposalChooserRegistered()); TableProposalChooser<?> tableProposalChooser = (TableProposalChooser<?>) m_form.getStyleField().getProposalChooser(); IContentAssistFieldTable<?> resultTable = tableProposalChooser.getModel(); assertEquals(1, resultTable.getSelectedRowCount()); assertEquals(1, resultTable.getRowCount()); ILookupRow<?> expectedLookupRow = resultTable.getSelectedLookupRow(); tableProposalChooser.execResultTableRowClicked(resultTable.getRow(0)); assertEquals("Yellow", m_form.getStyleField().getDisplayText()); assertEquals(Long.valueOf(20L), m_form.getStyleField().getValue()); assertNotNull(m_form.getStyleField().getCurrentLookupRow()); assertEquals(expectedLookupRow, m_form.getStyleField().getCurrentLookupRow()); }
Source:
public CompositeCodec(Map<Class<?>, Codec> delegates, Codec defaultCodec) { Assert.notNull(defaultCodec, "'defaultCodec' cannot be null"); this.defaultCodec = defaultCodec; this.delegates = delegates; }

Target:
public CompositeCodec(Map<Class<?>, Codec> delegates, Codec defaultCodec) { Assert.notNull(defaultCodec, "'defaultCodec' cannot be null"); this.defaultCodec = defaultCodec; this.delegates = new HashMap<Class<?>, Codec>(delegates); }
Source:
public static List<String> PdhEnumObjectItemCounters(String szDataSource, String szMachineName, String szObjectName, int dwDetailLevel) { List<String> counters = new ArrayList<String>(); DWORDByReference pcchCounterListLength = new DWORDByReference(new DWORD(0)); DWORDByReference pcchInstanceListLength = new DWORDByReference(new DWORD(0)); Pdh.INSTANCE.PdhEnumObjectItems(szDataSource, szMachineName, szObjectName, null, pcchCounterListLength, null, pcchInstanceListLength, dwDetailLevel, 0); if (pcchCounterListLength.getValue().intValue() < 1 || pcchInstanceListLength.getValue().intValue() < 1) { return counters; } Memory mszCounterList = new Memory(pcchCounterListLength.getValue().intValue() * CHAR_TO_BYTES); Memory mszInstanceList = new Memory(pcchInstanceListLength.getValue().intValue() * CHAR_TO_BYTES); Pdh.INSTANCE.PdhEnumObjectItems(szDataSource, szMachineName, szObjectName, mszCounterList, pcchCounterListLength, mszInstanceList, pcchInstanceListLength, dwDetailLevel, 0); int offset = 0; while (offset < mszCounterList.size()) { String s = null; if (CHAR_TO_BYTES == 1) { s = mszCounterList.getString(offset); } else { s = mszCounterList.getWideString(offset); } if (s.isEmpty()) { break; } counters.add(s); offset += (s.length() + 1) * CHAR_TO_BYTES; } return counters; }

Target:
public static List<String> PdhEnumObjectItemCounters(String szDataSource, String szMachineName, String szObjectName, int dwDetailLevel) { List<String> counters = new ArrayList<String>(); DWORDByReference pcchCounterListLength = new DWORDByReference(new DWORD(0)); DWORDByReference pcchInstanceListLength = new DWORDByReference(new DWORD(0)); Pdh.INSTANCE.PdhEnumObjectItems(szDataSource, szMachineName, szObjectName, null, pcchCounterListLength, null, pcchInstanceListLength, dwDetailLevel, 0); if (pcchCounterListLength.getValue().intValue() < 1) { return counters; } Memory mszCounterList = new Memory(pcchCounterListLength.getValue().intValue() * CHAR_TO_BYTES); pcchInstanceListLength.getValue().setValue(0); Pdh.INSTANCE.PdhEnumObjectItems(szDataSource, szMachineName, szObjectName, mszCounterList, pcchCounterListLength, null, pcchInstanceListLength, dwDetailLevel, 0); int offset = 0; while (offset < mszCounterList.size()) { String s = null; if (CHAR_TO_BYTES == 1) { s = mszCounterList.getString(offset); } else { s = mszCounterList.getWideString(offset); } if (s.isEmpty()) { break; } counters.add(s); offset += (s.length() + 1) * CHAR_TO_BYTES; } return counters; }