auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public String getETag(RevisionResource rsrc) { if (submitWholeTopicEnabled(config) <START> && rsrc.getChange().getTopic() != null && !rsrc.getChange().getTopic().equals("")) { <END> String topic = rsrc.getChange().getTopic(); Hasher h = Hashing.md5().newHasher(); try { for (ChangeData c : queryProvider.get().byTopicOpen(topic)) { new ChangeResource(c.changeControl()).prepareEtag(h, rsrc.getUser()); } } catch (OrmException e){ throw new OrmRuntimeException(e); } return h.hash().toString(); } else { return rsrc.getETag(); } }</code><technical_language>about: String topic = rsrc.getChange().getTopic(); if (submitWholeTopicEnabled(config) && !Strings.isNullOrEmpty(topic)) {</technical_language>

Target:
public String getETag(RevisionResource rsrc) { String topic = rsrc.getChange().getTopic(); if (!Submit.wholeTopicEnabled(config) || Strings.isNullOrEmpty(topic)) { return rsrc.getETag(); } Hasher h = Hashing.md5().newHasher(); try { for (ChangeData c : queryProvider.get().byTopicOpen(topic)) { new ChangeResource(c.changeControl()).prepareETag(h, rsrc.getUser()); } } catch (OrmException e){ throw new OrmRuntimeException(e); } return h.hash().toString(); }
Source:
<code>private String getSenderEmailId(MimeMessage message) throws MessagingException { InternetAddress sender = (InternetAddress) message.getSender(); if (sender == null) { InternetAddress[] fromAddresses = (InternetAddress[]) message.getFrom(); <START> sender = fromAddresses[0]; <END> } return (sender.getAddress()); }</code><technical_language>"message" null checked this point? Also, is a guarantee fromAddresses length greater 0</technical_language>

Target:
private String getSenderEmailId(MimeMessage message) throws MessagingException { InternetAddress sender = null; sender = (InternetAddress) message.getSender(); if (sender == null) { InternetAddress[] fromAddresses = (InternetAddress[]) message.getFrom(); if (fromAddresses.length > 0) { sender = fromAddresses[0]; } } return ((sender == null) ? null : sender.getAddress()); }
Source:
<code>private static String getFailureLog(TaskCompletionEvent event) { LOG.info("Getting errors for attempt " + event.getTaskAttemptId()); String exception = ""; try { String fullLog = retrieveTaskLogs(event.getTaskAttemptId(), event.getTaskTrackerHttp()); Pattern pattern = Pattern.compile("Caused by.*?more", Pattern.DOTALL); Matcher matcher = pattern.matcher(fullLog); matcher.find(); exception = matcher.group(); <START> } catch (Exception e) { <END> LOG.info("Regex Error!", e); } return "\nFailure log:\n" + exception; }</code><technical_language>catching exceptions here</technical_language>

Target:
private static String getFailureLog(TaskCompletionEvent event) { LOG.info("Getting errors for attempt " + event.getTaskAttemptId()); String exception = ""; try { String fullLog = retrieveTaskLogs(event.getTaskAttemptId(), event.getTaskTrackerHttp()); Matcher matcher = LOG_ERROR_PATTERN.matcher(fullLog); matcher.find(); exception = matcher.group(); } catch (IOException e) { LOG.info("Regex Error!", e); } return "\nCluster Log Exception:\n" + exception; }
Source:
<code>public void theStoredEventsAreRetrieved(final String deviceIdentification, final Map<String, String> expectedResponse) throws Throwable { final List<Event> events = this.retrieveStoredEvents(deviceIdentification); for (final Event e : events) { Assert.assertEquals(getString(expectedResponse, Keys.EVENT_TYPE), e.getEventType().toString()); Assert.assertEquals(getString(expectedResponse, Keys.KEY_DESCRIPTION), e.getDescription().toString()); Assert.assertEquals((int) getInteger(expectedResponse, Keys.KEY_INDEX), (int) e.getIndex()); <START> <END> } }</code><technical_language>Remove empty lines</technical_language>

Target:
public void theStoredEventsAreRetrieved(final String deviceIdentification, final Map<String, String> expectedResponse) throws Throwable { final List<Event> events = this.retrieveStoredEvents(deviceIdentification); for (final Event e : events) { Assert.assertEquals(getEnum(expectedResponse, Keys.EVENT_TYPE, EventType.class), e.getEventType()); Assert.assertEquals(getString(expectedResponse, Keys.KEY_DESCRIPTION), e.getDescription().toString()); Assert.assertEquals((int) getInteger(expectedResponse, Keys.KEY_INDEX, Defaults.DEFAULT_INDEX), (int) e.getIndex()); } }
Source:
<code>protected CollectionRest put(Context context, HttpServletRequest request, String apiCategory, String model, UUID id, JsonNode jsonNode) throws RepositoryMethodNotImplementedException, SQLException, AuthorizeException { CollectionRest collectionRest = null; try { collectionRest = new ObjectMapper().readValue(jsonNode.toString(), CollectionRest.class); } catch (IOException e) { <START> log.error(e.getMessage(), e); <END> } Collection collection = cs.find(context, id); if (collection == null) { throw new ResourceNotFoundException(apiCategory + "." + model + " with id: " + id + " not found"); } if (StringUtils.equals(id.toString(), collectionRest.getId())) { List<MetadataEntryRest> metadataEntryRestList = collectionRest.getMetadata(); collection = (Collection) dspaceObjectUtils.replaceMetadataValues(context, collection, metadataEntryRestList); } else { throw new IllegalArgumentException("The UUID in the Json and the UUID in the url do not match: " + id + ", " + collectionRest.getId()); } return converter.fromModel(collection); }</code><technical_language>Again, log a more useful message here</technical_language>

Target:
protected CollectionRest put(Context context, HttpServletRequest request, String apiCategory, String model, UUID id, JsonNode jsonNode) throws RepositoryMethodNotImplementedException, SQLException, AuthorizeException { CollectionRest collectionRest = null; try { collectionRest = new ObjectMapper().readValue(jsonNode.toString(), CollectionRest.class); } catch (IOException e) { throw new UnprocessableEntityException("error parsing the body ..." + e.getMessage()); } Collection collection = cs.find(context, id); if (collection == null) { throw new ResourceNotFoundException(apiCategory + "." + model + " with id: " + id + " not found"); } CollectionRest originalCollectionRest = converter.fromModel(collection); if (collectionRestEqualityUtils.isCollectionRestEqualWithoutMetadata(originalCollectionRest, collectionRest)) { List<MetadataEntryRest> metadataEntryRestList = collectionRest.getMetadata(); collection = (Collection) dspaceObjectUtils.replaceMetadataValues(context, collection, metadataEntryRestList); } else { throw new IllegalArgumentException("The UUID in the Json and the UUID in the url do not match: " + id + ", " + collectionRest.getId()); } return converter.fromModel(collection); }
Source:
<code>private void unloadRegions(ServerName server, List<ServerName> regionServers, List<RegionInfo> movedRegions) throws Exception { while (true) { List<RegionInfo> regionsToMove = admin.getRegions(server); regionsToMove.removeAll(movedRegions); if (regionsToMove.isEmpty()) { LOG.info("No Regions to move....Quitting now"); break; } int counter = 0; LOG.info("Moving " + regionsToMove.size() + " regions from " + this.hostname + " to " + regionServers.size() + " servers using " + this.maxthreads + " threads .Ack Mode:" + ack); ExecutorService moveRegionsPool = Executors.newFixedThreadPool(this.maxthreads); List<Future<Boolean>> taskList = new ArrayList<>(); int serverIndex = 0; <START> while (counter < regionsToMove.size()) { <END> if (ack) { Future<Boolean> task = moveRegionsPool.submit( new MoveWithAck(conn, regionsToMove.get(counter), server, regionServers.get(serverIndex), movedRegions)); taskList.add(task); } else { Future<Boolean> task = moveRegionsPool.submit( new MoveWithoutAck(admin, regionsToMove.get(counter), server, regionServers.get(serverIndex), movedRegions)); taskList.add(task); } counter++; serverIndex = (serverIndex + 1) % regionServers.size(); } moveRegionsPool.shutdown(); long timeoutInSeconds = regionsToMove.size() * admin.getConfiguration() .getLong(MOVE_WAIT_MAX_KEY, DEFAULT_MOVE_WAIT_MAX); waitMoveTasksToFinish(moveRegionsPool, taskList, timeoutInSeconds); } }</code><technical_language>nit: this a for loop regionsToMove list</technical_language>

Target:
private void unloadRegions(ServerName server, List<ServerName> regionServers, List<RegionInfo> movedRegions) throws Exception { while (true) { List<RegionInfo> regionsToMove = admin.getRegions(server); regionsToMove.removeAll(movedRegions); if (regionsToMove.isEmpty()) { LOG.info("No Regions to move....Quitting now"); break; } LOG.info("Moving regions from to servers using threads .Ack Mode: {}", regionsToMove.size(), this.hostname, regionServers.size(), this.maxthreads, ack); final ExecutorService moveRegionsPool = Executors.newFixedThreadPool(this.maxthreads); List<Future<Boolean>> taskList = new ArrayList<>(); int serverIndex = 0; for (RegionInfo regionToMove : regionsToMove) { if (ack) { Future<Boolean> task = moveRegionsPool.submit( new MoveWithAck(conn, regionToMove, server, regionServers.get(serverIndex), movedRegions)); taskList.add(task); } else { Future<Boolean> task = moveRegionsPool.submit( new MoveWithoutAck(admin, regionToMove, server, regionServers.get(serverIndex), movedRegions)); taskList.add(task); } serverIndex = (serverIndex + 1) % regionServers.size(); } moveRegionsPool.shutdown(); long timeoutInSeconds = regionsToMove.size() * admin.getConfiguration() .getLong(MOVE_WAIT_MAX_KEY, DEFAULT_MOVE_WAIT_MAX); waitMoveTasksToFinish(moveRegionsPool, taskList, timeoutInSeconds); } }
Source:
<code>public RadiatingLightning(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{R}"); this.getSpellAbility().addEffect(new DamageTargetEffect(3)); <START> this.getSpellAbility().addEffect(new DamageAllControlledTargetEffect(1, new FilterCreaturePermanent())); <END> this.getSpellAbility().addTarget(new TargetPlayer()); }</code><technical_language>want .setText("and 1 damage creature player controls") here</technical_language>

Target:
public RadiatingLightning(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{R}"); this.getSpellAbility().addEffect(new DamageTargetEffect(3)); this.getSpellAbility().addEffect(new DamageAllControlledTargetEffect(1, new FilterCreaturePermanent()).setText("and 1 damage to each creature that player controls")); this.getSpellAbility().addTarget(new TargetPlayer()); }
Source:
<code>public void aggregate(int length, AggregationResultHolder aggregationResultHolder, Map<TransformExpressionTree, BlockValSet> blockValSetMap) { int numBlockValSets = blockValSetMap.size(); int numExpressions = _inputExpressions.size(); Preconditions .checkState(numBlockValSets == numExpressions, "Size mismatch: numBlockValSets = %s, numExpressions = %s", numBlockValSets, numExpressions); BlockValSet[] blockValSets = new BlockValSet[numExpressions]; for (int i = 0; i < numExpressions; i++) { blockValSets[i] = blockValSetMap.get(_inputExpressions.get(i)); } DistinctTable distinctTable = aggregationResultHolder.getResult(); if (distinctTable == null) { ColumnDataType[] columnDataTypes = new ColumnDataType[numExpressions]; for (int i = 0; i < numExpressions; i++) { columnDataTypes[i] = ColumnDataType.fromDataTypeSV(blockValSetMap.get(_inputExpressions.get(i)).getValueType()); } DataSchema dataSchema = new DataSchema(_columns, columnDataTypes); distinctTable = new DistinctTable(dataSchema, _orderBy, _limit); aggregationResultHolder.setValue(distinctTable); } else if (distinctTable.shouldNotAddMore()) { return; } RowBasedBlockValueFetcher blockValueFetcher = new RowBasedBlockValueFetcher(blockValSets); for (int i = 0; i < length; i++) { <START> if (!distinctTable.add(new Record(blockValueFetcher.getRow(i)))) { <END> return; } } }</code><technical_language>I this for loop written separately for order order by. For order by, is early termination if check avoided return true. For order, adding record, check return if limit reached terminate early loop</technical_language>

Target:
public void aggregate(int length, AggregationResultHolder aggregationResultHolder, Map<TransformExpressionTree, BlockValSet> blockValSetMap) { int numBlockValSets = blockValSetMap.size(); int numExpressions = _inputExpressions.size(); Preconditions .checkState(numBlockValSets == numExpressions, "Size mismatch: numBlockValSets = %s, numExpressions = %s", numBlockValSets, numExpressions); BlockValSet[] blockValSets = new BlockValSet[numExpressions]; for (int i = 0; i < numExpressions; i++) { blockValSets[i] = blockValSetMap.get(_inputExpressions.get(i)); } DistinctTable distinctTable = aggregationResultHolder.getResult(); if (distinctTable == null) { ColumnDataType[] columnDataTypes = new ColumnDataType[numExpressions]; for (int i = 0; i < numExpressions; i++) { columnDataTypes[i] = ColumnDataType.fromDataTypeSV(blockValSetMap.get(_inputExpressions.get(i)).getValueType()); } DataSchema dataSchema = new DataSchema(_columns, columnDataTypes); distinctTable = new DistinctTable(dataSchema, _orderBy, _limit); aggregationResultHolder.setValue(distinctTable); } if (distinctTable.hasOrderBy()) { RowBasedBlockValueFetcher blockValueFetcher = new RowBasedBlockValueFetcher(blockValSets); for (int i = 0; i < length; i++) { distinctTable.addWithOrderBy(new Record(blockValueFetcher.getRow(i))); } } else { if (distinctTable.isSatisfied()) { return; } RowBasedBlockValueFetcher blockValueFetcher = new RowBasedBlockValueFetcher(blockValSets); for (int i = 0; i < length; i++) { if (distinctTable.addWithoutOrderBy(new Record(blockValueFetcher.getRow(i)))) { return; } } } }
Source:
<code>public static void validateLicenseIdMatch(License license) throws SW360Exception { if (license.isSetId() && license.isSetShortname()) { <START> String message = "license short name must be equal with license id"; <END> assertEquals(license.getId(), license.getShortname(), message); } }</code><technical_language>I "equal to" is grammatically correct phrase</technical_language>

Target:
private static void validateLicenseIdMatch(License license) throws SW360Exception { String message = "license short name must be equal to license id"; assertEquals(license.getId(), license.getShortname(), message); }
Source:
<code>private void initializeErrorReport() { reportWriterService.setFileNamePrefix(configurationService.getPropertyValueAsString(CUPdpKeyConstants.PDP_SEND_ACH_NOTIFICATION_ERROR_REPORT_PREFIX)); reportWriterService.setTitle(configurationService.getPropertyValueAsString(CUPdpKeyConstants.PDP_SEND_ACH_NOTIFICATION_ERROR_REPORT_TITLE)); reportWriterService.initialize(); reportWriterService.writeNewLines(2); String rowFormat = configurationService.getPropertyValueAsString(CUPdpKeyConstants.PDP_SEND_ACH_NOTIFICATION_ERROR_REPORT_FORMAT); reportWriterService.writeFormattedMessageLine(rowFormat, "PAYEE ID", "PAYMENT GROUP", "DISBURSEMENT NUMBER", "EMAIL ADDRESS"); String hyphens25 = buildHyphenString(20); <START> String hyphens200 = buildHyphenString(50); <END> reportWriterService.writeFormattedMessageLine(rowFormat, hyphens25, hyphens25, hyphens25, hyphens200); }</code><technical_language>Is hyphens200 correct variable name? hyphens50</technical_language>

Target:
private void initializeErrorReport() { reportWriterService.setFileNamePrefix(configurationService.getPropertyValueAsString(CUPdpKeyConstants.PDP_SEND_ACH_NOTIFICATION_ERROR_REPORT_PREFIX)); reportWriterService.setTitle(configurationService.getPropertyValueAsString(CUPdpKeyConstants.PDP_SEND_ACH_NOTIFICATION_ERROR_REPORT_TITLE)); reportWriterService.initialize(); reportWriterService.writeNewLines(2); String rowFormat = configurationService.getPropertyValueAsString(CUPdpKeyConstants.PDP_SEND_ACH_NOTIFICATION_ERROR_REPORT_FORMAT); reportWriterService.writeFormattedMessageLine(rowFormat, "PAYEE ID", "PAYMENT GROUP", "DISBURSEMENT NUMBER", "EMAIL ADDRESS"); String hyphens25 = buildHyphenString(20); String hyphens50 = buildHyphenString(50); reportWriterService.writeFormattedMessageLine(rowFormat, hyphens25, hyphens25, hyphens25, hyphens50); }
Source:
<code>public static MigrationOptions map(HasMigrationOptions entity, MigrationOptions template) { if (template == null) { template = new MigrationOptions(); } template.setAutoConverge(mapToInheritableBoolean(entity.getAutoConverge())); template.setCompressed(mapToInheritableBoolean(entity.getMigrateCompressed())); if (entity.getMigrationPolicyId() != null) { MigrationPolicy policy = template.getPolicy(); if (policy == null) { policy = new MigrationPolicy(); template.setPolicy(policy); } policy.setId(entity.getMigrationPolicyId().toString()); <START> template.setPolicy(policy); <END> } return template; }</code><technical_language>This ^ line is duplicated</technical_language>

Target:
public static MigrationOptions map(HasMigrationOptions entity, MigrationOptions template) { if (template == null) { template = new MigrationOptions(); } template.setAutoConverge(mapToInheritableBoolean(entity.getAutoConverge())); template.setCompressed(mapToInheritableBoolean(entity.getMigrateCompressed())); if (entity.getMigrationPolicyId() != null) { MigrationPolicy policy = template.getPolicy(); if (policy == null) { policy = new MigrationPolicy(); template.setPolicy(policy); } policy.setId(entity.getMigrationPolicyId().toString()); } return template; }
Source:
<code>public void propagate(int evtmask) throws ContradictionException { if (iv.isInstantiated()) { set.addToKernel(iv.getValue(), aCause); setPassive(); return; } int ub = iv.getUB(); for (int i = iv.getLB(); i <= ub; i++) { if (!set.envelopeContains(i)) { <START> iv.removeValue(i, this); <END> } } if (iv.isInstantiated()) { set.addToKernel(iv.getValue(), aCause); setPassive(); } }</code><technical_language>iv.removeValue(i, this) iv.removeValue(i, aCause)</technical_language>

Target:
public void propagate(int evtmask) throws ContradictionException { if (iv.isInstantiated()) { set.addToKernel(iv.getValue(), aCause); setPassive(); return; } int ub = iv.getUB(); for (int i = iv.getLB(); i <= ub; iv.nextValue(i)) { if (!set.envelopeContains(i)) { iv.removeValue(i, aCause); } } if (iv.isInstantiated()) { set.addToKernel(iv.getValue(), aCause); setPassive(); } sdm.unfreeze(); }
Source:
<code><START> public Storage getStorage(final String id) { <END> final Optional<Storage> storage; try { storage = storageDbRepository.getStorage(id); } catch (RepositoryProblemException e) { LOG.error("DB error occurred when fetching storage", e); throw new InternalNakadiException(e.getMessage()); } if (storage.isPresent()) { return storage.get(); } else { throw new NoSuchStorageException("No storage with id " + id); } }</code><technical_language>declare throws please</technical_language>

Target:
public Storage getStorage(final String id) throws NoSuchStorageException, InternalNakadiException { final Optional<Storage> storage; try { storage = storageDbRepository.getStorage(id); } catch (RepositoryProblemException e) { LOG.error("DB error occurred when fetching storage", e); throw new InternalNakadiException(e.getMessage()); } if (storage.isPresent()) { return storage.get(); } else { throw new NoSuchStorageException("No storage with id " + id); } }
Source:
<code>public boolean onCreateOptionsMenu(Menu menu) { getSupportMenuInflater().inflate(R.menu.guide_view_menu, menu); MenuItem item = menu.findItem(R.id.comments); item.getActionView().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mGuide != null) { ArrayList<Comment> comments; int stepIndex = getStepIndex(), contextid; String title, context; if (stepIndex < 0) { comments = mGuide.getComments(); title = getString(R.string.guide_comments); context = "guide"; contextid = mGuide.getGuideid(); } else { comments = mGuide.getStep(stepIndex).getComments(); contextid = mGuide.getStep(stepIndex).getStepid(); context = "step"; title = getString(R.string.step_number_comments, stepIndex + 1); } startActivityForResult(CommentsActivity.viewComments(getApplicationContext(), comments, title, context, contextid), COMMENT_REQUEST); } } <START> }); <END> return super.onCreateOptionsMenu(menu); }</code><technical_language>this is duplicated in onOptionsItemSelected. in favor of removing this proxying method if default method. Also, setEnabled($mGuide != null) avoid mGuide != null check here</technical_language>

Target:
public boolean onCreateOptionsMenu(Menu menu) { getSupportMenuInflater().inflate(R.menu.guide_view_menu, menu); MenuItem item = menu.findItem(R.id.comments); item.getActionView().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mGuide != null) { ArrayList<Comment> comments; int stepIndex = getStepIndex(), contextid; String title, context; if (stepIndex < 0) { comments = mGuide.getComments(); title = getString(R.string.guide_comments); context = "guide"; contextid = mGuide.getGuideid(); } else { comments = mGuide.getStep(stepIndex).getComments(); contextid = mGuide.getStep(stepIndex).getStepid(); context = "step"; title = getString(R.string.step_number_comments, stepIndex + 1); } startActivityForResult(CommentsActivity.viewGuideComments(getApplicationContext(), comments, title, context, contextid, mGuide.getGuideid()), COMMENT_REQUEST); } } }); CheatSheet.setup(item.getActionView(), R.string.view_comments); return super.onCreateOptionsMenu(menu); }
Source:
<code>void refreshTree() { try { tree.refresh(); <START> } catch (Exception e) <END> }</code><technical_language>logging here? Why</technical_language>

Target:
void refreshTree() { if(tree.getControl() != null && !tree.getControl().isDisposed()) { tree.refresh(); } }
Source:
<code><START> public String getCatalogUrl() { <END> String catalogUrl = properties.get(CATALOG_URL); if (catalogUrl == null) { catalogUrl = ""; } return catalogUrl; }</code><technical_language>letting return null check if url is null this method client? clean code a bit</technical_language>

Target:
public String getCatalogUrl() { return properties.get(CATALOG_URL); }
Source:
<code>public void resetKernelCmdlineCheckboxes() { final CpuVendor cpuVendor = getCurrentCpuVendor(); if (cpuVendor == null) { return; } switch (cpuVendor) { case INTEL: case AMD: case IBMS390: setKernelCmdlineCheckboxesValue(false); break; case IBM: <START> setKernelCmdlineCheckboxesValue(true); <END> if (getKernelCmdlineFips().getIsChangable()) { getKernelCmdlineFips().setEntity(false); } if (getKernelCmdlineSmtDisabled().getIsChangable()) { getKernelCmdlineSmtDisabled().setEntity(false); } break; default: throw new RuntimeException("Unknown CpuVendor type: " + cpuVendor); } updateKernelCmdlineCheckboxesChangeability(); }</code><technical_language>this is misleading a remnant of original iommu. supposed reflect fact need special parameter enable iommu power. While true respective checkbox checked, I for others wrong misleading. E.g. nesting is supported all, default (unchangeable) state off. for iommu workarounds...they're relevant "off" sounds a fit</technical_language>

Target:
public void resetKernelCmdlineCheckboxes() { final CpuVendor cpuVendor = getCurrentCpuVendor(); if (cpuVendor == null) { return; } switch (cpuVendor) { case INTEL: case AMD: case IBMS390: setKernelCmdlineCheckboxesValue(false); break; case IBM: setKernelCmdlineCheckboxesValuePpc(false); break; default: throw new RuntimeException("Unknown CpuVendor type: " + cpuVendor); } updateKernelCmdlineCheckboxesChangeability(); }
Source:
<code><START> public void userTypeChanged(UserOrGroup newType, boolean setRadioValue) { <END> switch (newType) { case User: searchItems.ensureColumnVisible(firstNameColumn, constants.firstNamePermissionsPopup(), true, MAX_COL_WIDTH); searchItems.ensureColumnVisible(groupNameColumn, constants.groupNamePermissionsPopup(), false, MAX_COL_WIDTH); searchItems.ensureColumnVisible(lastNameColumn, constants.lastNamePermissionsPopup(), true, MAX_COL_WIDTH); searchItems.ensureColumnVisible(userNameColumn, constants.userNamePermissionsPopup(), true, MAX_COL_WIDTH); searchItems.ensureColumnVisible(displayNameColumn, constants.displayNamePermissionsPopup(), false, MAX_COL_WIDTH); if (setRadioValue) { specificUserRadio.setValue(true, false); } break; case Group: searchItems.ensureColumnVisible(firstNameColumn, constants.firstNamePermissionsPopup(), false, MAX_COL_WIDTH); searchItems.ensureColumnVisible(groupNameColumn, constants.groupNamePermissionsPopup(), true, MAX_COL_WIDTH); searchItems.ensureColumnVisible(lastNameColumn, constants.lastNamePermissionsPopup(), false, MAX_COL_WIDTH); searchItems.ensureColumnVisible(userNameColumn, constants.userNamePermissionsPopup(), false, MAX_COL_WIDTH); searchItems.ensureColumnVisible(displayNameColumn, constants.displayNamePermissionsPopup(), true, MAX_COL_WIDTH); if (setRadioValue) { specificGroupRadio.setValue(true, false); } break; } }</code><technical_language>avoid code duplication, consider extracting variation (boolean in this case) a variable: boolean userActive = (newType == User) ? true : false; searchItems.ensureColumnVisible(firstNameColumn, constants.firstNamePermissionsPopup(), userActive, MAX_COL_WIDTH); searchItems.ensureColumnVisible(groupNameColumn, constants.groupNamePermissionsPopup(), !userActive, MAX_COL_WIDTH); searchItems.ensureColumnVisible(lastNameColumn, constants.lastNamePermissionsPopup(), userActive, MAX_COL_WIDTH); searchItems.ensureColumnVisible(userNameColumn, constants.userNamePermissionsPopup(), userActive, MAX_COL_WIDTH); searchItems.ensureColumnVisible(displayNameColumn, constants.displayNamePermissionsPopup(), !userActive, MAX_COL_WIDTH); if (setRadioValue) { specificUserRadio.setValue(true, false); }</technical_language>

Target:
public void userTypeChanged(UserOrGroup newType, boolean setRadioValue) { boolean isUser = newType == UserOrGroup.User; searchItems.ensureColumnVisible(firstNameColumn, constants.firstNamePermissionsPopup(), isUser, MAX_COL_WIDTH); searchItems.ensureColumnVisible(groupNameColumn, constants.groupNamePermissionsPopup(), !isUser, MAX_COL_WIDTH); searchItems.ensureColumnVisible(lastNameColumn, constants.lastNamePermissionsPopup(), isUser, MAX_COL_WIDTH); searchItems.ensureColumnVisible(userNameColumn, constants.userNamePermissionsPopup(), isUser, MAX_COL_WIDTH); searchItems.ensureColumnVisible(displayNameColumn, constants.displayNamePermissionsPopup(), !isUser, MAX_COL_WIDTH); if (setRadioValue) { if (isUser) { specificUserRadio.setValue(true, false); } else { specificGroupRadio.setValue(true, false); } } }
Source:
<code>private static Details getDetails(DetailAST ast) { final Details details; switch (ast.getType()) { case TokenTypes.LITERAL_TRY: case TokenTypes.LITERAL_CATCH: case TokenTypes.LITERAL_FINALLY: details = getDetailsForTryCatchFinally(ast); break; case TokenTypes.LITERAL_IF: case TokenTypes.LITERAL_ELSE: details = getDetailsForIfElse(ast); break; case TokenTypes.LITERAL_DO: case TokenTypes.LITERAL_WHILE: case TokenTypes.LITERAL_FOR: details = getDetailsForLoops(ast); break; default: <START> details = getDetailsForDefs(ast); <END> break; } return details; }</code><technical_language>of DEFs. call this 'Other' 'Misc'</technical_language>

Target:
private static Details getDetails(DetailAST ast) { final Details details; switch (ast.getType()) { case TokenTypes.LITERAL_TRY: case TokenTypes.LITERAL_CATCH: case TokenTypes.LITERAL_FINALLY: details = getDetailsForTryCatchFinally(ast); break; case TokenTypes.LITERAL_IF: case TokenTypes.LITERAL_ELSE: details = getDetailsForIfElse(ast); break; case TokenTypes.LITERAL_DO: case TokenTypes.LITERAL_WHILE: case TokenTypes.LITERAL_FOR: details = getDetailsForLoops(ast); break; case TokenTypes.LAMBDA: details = getDetailsForLambda(ast); break; case TokenTypes.LITERAL_NEW: details = getDetailsForAnonClassOrArrInitOrObjInit(ast); break; default: details = getDetailsForOthers(ast); break; } return details; }
Source:
<code>private static double analyseBFB(BasicFBType fbType) { ECC ecc = fbType.getECC(); int nrstates = ecc.getECState().size(); int nrtransitions = ecc.getECTransition().size(); double ccfb = (nrtransitions - nrstates + 2); int saveIndex = 0; for (ECState state : ecc.getECState()) { for (ECAction action : state.getECAction()) { if (null != action.getAlgorithm()) { for (String cond : CONDITIONS) { int lastIndex = 0; while <START> (lastIndex != -1) { <END> if (cond.equals("REPEAT")) { saveIndex = action.getAlgorithm().toString().indexOf(cond + "\r\n", lastIndex); } else { saveIndex = action.getAlgorithm().toString().indexOf(cond + " ", lastIndex); } if (saveIndex != 0) { lastIndex = saveIndex; if (lastIndex != -1) { ccfb++; lastIndex += cond.length(); } } } } } } } return ccfb; }</code><technical_language>switched -1 != lastIndex</technical_language>

Target:
private static double analyseBFB(BasicFBType fbType) { ECC ecc = fbType.getECC(); int nrstates = ecc.getECState().size(); int nrtransitions = ecc.getECTransition().size(); double ccfb = (nrtransitions - nrstates + 2); int saveIndex = 0; for (ECState state : ecc.getECState()) { for (ECAction action : state.getECAction()) { if (null != action.getAlgorithm()) { for (String cond : CONDITIONS) { int lastIndex = 0; while (-1 != lastIndex) { if (cond.equals("REPEAT")) { saveIndex = action.getAlgorithm().toString().indexOf(cond + "\r\n", lastIndex); } else { saveIndex = action.getAlgorithm().toString().indexOf(cond + " ", lastIndex); } if (0 != saveIndex) { lastIndex = saveIndex; if (-1 != lastIndex) { ccfb++; lastIndex += cond.length(); } } } } } } } return ccfb; }
Source:
<code>protected void scrollAndClick(WebElement element) { scrollToElement(element); <START> waitForElementClickableByElement(element); <END> element.click(); }</code><technical_language>This is a default timeout, (thath is 30 sec) - 5sec is enough</technical_language>

Target:
protected void scrollAndClick(WebElement element) { scrollToElement(element); waitForElementClickableByElement(element, 5); element.click(); }
Source:
<code>public void testGetCompletionTimesSingleFragment() { Trace trace1 = new Trace(); trace1.setId("1"); trace1.setStartTime(System.currentTimeMillis() - 4000); Consumer c1 = new Consumer(); c1.setUri("testuri"); c1.setDuration(TimeUnit.NANOSECONDS.convert(1234, TimeUnit.MILLISECONDS)); trace1.getNodes().add(c1); List<Trace> traces = new ArrayList<Trace>(); traces.add(trace1); try { publisher.publish(null, traces); } catch (Exception e1) { <START> fail("Failed to store: " + e1); <END> } Wait.until(() -> service.searchFragments(null, new Criteria()).size() == 1); Wait.until(() -> analytics.getTraceCompletionTimes(null, new Criteria()).size() == 1); List<CompletionTime> times = analytics.getTraceCompletionTimes(null, new Criteria()); assertNotNull(times); assertEquals(1, times.size()); assertEquals(1234, times.get(0).getDuration()); }</code><technical_language>This a test error</technical_language>

Target:
public void testGetCompletionTimesSingleFragment() throws Exception { Trace trace1 = new Trace(); trace1.setId("1"); trace1.setStartTime(System.currentTimeMillis() - 4000); Consumer c1 = new Consumer(); c1.setUri("testuri"); c1.setDuration(TimeUnit.NANOSECONDS.convert(1234, TimeUnit.MILLISECONDS)); trace1.getNodes().add(c1); publisher.publish(null, Collections.singletonList(trace1)); Wait.until(() -> service.searchFragments(null, new Criteria()).size() == 1); Wait.until(() -> analytics.getTraceCompletionTimes(null, new Criteria()).size() == 1); List<CompletionTime> times = analytics.getTraceCompletionTimes(null, new Criteria()); assertNotNull(times); assertEquals(1, times.size()); assertEquals(1234, times.get(0).getDuration()); }
Source:
<code><START> @Override public double getMissRate(){ <END> double missRate = 0; for(ManagedCache<K, V> mc : managedCache){ missRate += mc.getMissRate(); } return missRate; }</code><technical_language>Incorrect</technical_language>

Target:
@Override public double getMissRate(){ double missRate = 0; for(ManagedCache<K, V> mc : managedCache){ missRate += mc.getMissRate(); } return missRate/managedCache.size(); }
Source:
<code>public SELF isPositive() { isNotNull(); final boolean negative = actual.isNegative(); final int days = actual.getDays(); final int months = actual.getMonths(); final int years = actual.getYears(); <START> if (negative || (days == 0 && months == 0 && years == 0)) { <END> throw Failures.instance().failure(info, shouldBePositive(actual)); } return myself; }</code><technical_language>I replace days == 0 && months == 0 && years == 0 Period.ZERO.equals(actual)</technical_language>

Target:
public SELF isPositive() { isNotNull(); final boolean negative = actual.isNegative(); if (negative || Period.ZERO.equals(actual)) { throw Failures.instance().failure(info, shouldBePositive(actual)); } return myself; }
Source:
<code>@Override public void accept(List<Span> spans, Callback<Void> callback) { if (spans.isEmpty()) { callback.onSuccess(null); return; } Map<String, Set<Pair<String>>> indexToServiceSpans = new LinkedHashMap<>(); try { HttpBulkIndexer indexer = new HttpBulkIndexer("index-span", es); indexToServiceSpans = indexSpans(indexer, spans); if (!indexToServiceSpans.isEmpty()) { indexNames(indexer, indexToServiceSpans); } indexer.execute(callback); } catch (Throwable t) { propagateIfFatal(t); callback.onError(t); synchronized(indexToServiceSpansCache) { for (String index : indexToServiceSpans.keySet()) { Set<Pair<String>> serviceSpansEntry = indexToServiceSpans.get(index); <START> Set<Pair<String>> serviceSpansEntryCached = indexToServiceSpansCache.get(index); <END> serviceSpansEntryCached.removeAll(serviceSpansEntry); } } } }</code><technical_language>I write this.. outer synchronized .. java for (Map.Entry<String, Set<Pair<String>>> entry : indexToServiceSpans.entrySet()) { Set<Pair<String>> serviceSpansEntryCached = null; synchronized (indexToServiceSpansCache) { // lock cache serviceSpansEntryCached = indexToServiceSpansCache.get(entry.getKey()); } if (serviceSpansEntryCached == null || serviceSpansEntryCached.isEmpty()) continue; synchronized (serviceSpansEntryCached) { // lock cache for index serviceSpansEntryCached.removeAll(entry.getValue()); } }</technical_language>

Target:
@Override public void accept(List<Span> spans, Callback<Void> callback) { Callback<Void> callbackWrapper = new Callback<Void>() { @Override public void onSuccess(Void value) { callback.onSuccess(value); } @Override public void onError(Throwable t) { clearIndexToServiceSpansCache(indexToServiceSpans, indexToServiceSpansCache); callback.onError(t); } }; if (spans.isEmpty()) { callbackWrapper.onSuccess(null); return; } try { HttpBulkIndexer indexer = new HttpBulkIndexer("index-span", es); indexToServiceSpans = indexSpans(indexer, spans); for (Map.Entry<String, Set<Pair<String>>> entry : indexToServiceSpans.entrySet()) { Set<Pair<String>> serviceSpansEntryCached = null; synchronized(indexToServiceSpansCache) { serviceSpansEntryCached = indexToServiceSpansCache.get(entry.getKey()); } if (serviceSpansEntryCached == null) { synchronized(indexToServiceSpansCache) { indexToServiceSpansCache.put(entry.getKey(), serviceSpansEntryCached = Collections.newSetFromMap(new LinkedHashMap<Pair<String>, Boolean>() { @Override protected boolean removeEldestEntry(Map.Entry<Pair<String>, Boolean> eldest) { return size() > MAX_CACHE_ENTRIES; } })); } } Set<Pair<String>> serviceSpansEntry = entry.getValue(); synchronized(serviceSpansEntryCached) { serviceSpansEntry.removeAll(serviceSpansEntryCached); serviceSpansEntryCached.addAll(serviceSpansEntry); } } if (!indexToServiceSpans.isEmpty()) { indexNames(indexer, indexToServiceSpans); } indexer.execute(callbackWrapper); } catch (Throwable t) { propagateIfFatal(t); callbackWrapper.onError(t); } }
Source:
<code>public void onPearlDamage(PlayerTeleportEvent event) { Player player = event.getPlayer(); TeleportCause cause = event.getCause(); Location destination = event.getTo(); if (BattlePlayer.getBattlePlayer(player).isSpectator()) { <START> return; <END> } else { if (event.getPlayer().getLocation().getWorld().getName().equals(name)) { if (disablePearlDamage(true)) { if (cause == TeleportCause.ENDER_PEARL) { event.setCancelled(true); player.teleport(destination); } } } } }</code><technical_language>Kinda redundant, 'if (!BattlePlayer.getBattlePlayer(player).isSpectator()) { }'</technical_language>

Target:
public void onPearlDamage(PlayerTeleportEvent event) { Player player = event.getPlayer(); TeleportCause cause = event.getCause(); Location destination = event.getTo(); if (!BattlePlayer.getBattlePlayer(player).isSpectator()) { if (event.getPlayer().getLocation().getWorld().getName().equals(name)) { if (pearlDamage) { if (cause == TeleportCause.ENDER_PEARL) { player.teleport(destination); event.setCancelled(true); } } } } }
Source:
<code>public RuleResult validate(final PasswordData passwordData) { final RuleResult result = new RuleResult(true); String text = passwordData.getPassword(); if (text.length() > 1) { String matchingWord = doWordSearch(text); if (matchingWord != null) { result.setValid(false); result.getDetails().add(new RuleResultDetail(ERROR_CODE, createRuleResultDetailParameters(matchingWord))); } if (matchBackwards) { text = new StringBuilder(passwordData.getPassword()).reverse().toString(); matchingWord = doWordSearch(text); if (matchingWord != null) { result.setValid(false); result.getDetails().add( new RuleResultDetail(ERROR_CODE_REVERSED, createRuleResultDetailParameters(matchingWord))); <START> } <END> } } return result; }</code><technical_language>purpose of this change? unrelated task hand</technical_language>

Target:
public RuleResult validate(final PasswordData passwordData) { final RuleResult result = new RuleResult(true); String text = passwordData.getPassword(); String matchingWord = doWordSearch(text); if (matchingWord != null) { result.setValid(false); result.getDetails().add(new RuleResultDetail(ERROR_CODE, createRuleResultDetailParameters(matchingWord))); } if (matchBackwards && text.length() > 1) { text = new StringBuilder(passwordData.getPassword()).reverse().toString(); matchingWord = doWordSearch(text); if (matchingWord != null) { result.setValid(false); result.getDetails().add( new RuleResultDetail(ERROR_CODE_REVERSED, createRuleResultDetailParameters(matchingWord))); } } return result; }
Source:
<code>protected Method getSuperMethod(Method method, final Class<?> clazz) { Method[] methods = new Method[0]; try { if (System.getSecurityManager() == null) { methods = clazz.getDeclaredMethods(); } else { methods = AccessController.doPrivileged(new PrivilegedExceptionAction<Method[]>() { @Override public Method[] run() throws Exception { return clazz.getDeclaredMethods(); } }); } } catch (PrivilegedActionException pae) { <START> LogMessages.LOGGER.error(pae.getMessage()); <END> } for (int i = 0; i < methods.length; i++) { if (overrides(method, methods[i])) { return methods[i]; } } return null; }</code><technical_language>I throw exception instead of logging it</technical_language>

Target:
protected Method getSuperMethod(Method method, final Class<?> clazz) { Method[] methods = new Method[0]; try { if (System.getSecurityManager() == null) { methods = clazz.getDeclaredMethods(); } else { methods = AccessController.doPrivileged(new PrivilegedExceptionAction<Method[]>() { @Override public Method[] run() throws Exception { return clazz.getDeclaredMethods(); } }); } } catch (PrivilegedActionException pae) { throw new ResteasyViolationException(pae.getMessage()); } for (int i = 0; i < methods.length; i++) { if (overrides(method, methods[i])) { return methods[i]; } } return null; }
Source:
<code><START> public Matrix(String matrixAsString) { <END> String[] rows = newlinePattern.split(matrixAsString); matrix = new int[rows.length][]; for (int i = 0; i < rows.length; i++) { String[] columnValues = spacePattern.split(rows[i]); matrix[i] = new int[columnValues.length]; for (int j = 0; j < columnValues.length; j++) { matrix[i][j] = Integer.parseInt(columnValues[j]); } } }</code><technical_language>This package private :)</technical_language>

Target:
Matrix(String matrixAsString) { String[] rows = newlinePattern.split(matrixAsString); matrix = new int[rows.length][]; for (int i = 0; i < rows.length; i++) { String[] columnValues = spacePattern.split(rows[i]); matrix[i] = new int[columnValues.length]; for (int j = 0; j < columnValues.length; j++) { matrix[i][j] = Integer.parseInt(columnValues[j]); } } }
Source:
<code>public boolean areDeadServersInProgress() throws IOException { <START> return master.getMasterProcedureExecutor().getActiveProceduresNoCopy().stream() <END> .anyMatch(p -> p instanceof ServerCrashProcedure); }</code><technical_language>getActiveProceduresNoCopy is expected called initialization, is race</technical_language>

Target:
public boolean areDeadServersInProgress() throws IOException { return master.getProcedures().stream() .anyMatch(p -> !p.isFinished() && p instanceof ServerCrashProcedure); }
Source:
<code>public Object fromStorage(Object stored) { <START> checkConverters(); <END> if (stored == null) return null; return encoder.fromStorage(wrapper.unwrap(stored)); }</code><technical_language>I check if is null</technical_language>

Target:
public Object fromStorage(Object stored) { if (stored == null) return null; checkConverters(); return encoder.fromStorage(wrapper.unwrap(stored)); }
Source:
<code>public void testAdminAssignTicketOrder() { Map<String, Object> order = new HashMap<>(); List<String> options = Arrays.asList(CH_MEMBER, PICKUP_SERVICE); order.put("type", TEST_TICKET); order.put("options", options); User user = createUser(); User admin = createAdmin(); given(). header(getXAuthTokenHeaderForUser(admin)). when(). body(order).contentType(ContentType.JSON). post("/orders/ " + user.getId() + "/test/assigngiveaway"). then(). statusCode(HttpStatus.SC_CREATED). body("object.id", is(16)). body("object.tickets", hasSize(1)). body("object.tickets.type.name", hasItem(is(TEST_TICKET))). body("object.tickets.type.text", anything()). <START> body("object.amount",equalTo(30F)); <END> }</code><technical_language>extra check, validate user assigned order valid tickets. repositories for</technical_language>

Target:
public void testAdminAssignTicketOrder() { Map<String, Object> assignObject = new HashMap<>(); User user = createUser(); assignObject.put("userID", user.getId()); assignObject.put("ticketType", TEST_TICKET); User admin = createAdmin(); given(). header(getXAuthTokenHeaderForUser(admin)). when(). body(assignObject).contentType(ContentType.JSON). post("/orders/assigngiveaway"). then(). statusCode(HttpStatus.SC_CREATED). body("object.tickets", hasSize(1)). body("object.tickets.type.name", hasItem(is(TEST_TICKET))). body("object.tickets.type.text", anything()). body("object.amount",equalTo(30F)); }
Source:
<code>private void run_version(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { <START> if (!sender.isPlayer() && ess.getUserMap().getUser(sender.getPlayer().getName()).isAuthorized("essentials.version")) return; <END> boolean isMismatched = false; final PluginManager pm = server.getPluginManager(); sender.sendMessage("Server version: " + server.getBukkitVersion()); final String essVer = pm.getPlugin("Essentials").getDescription().getVersion(); sender.sendMessage("EssentialsX version: " + essVer); for (Plugin plugin : pm.getPlugins()) { final PluginDescriptionFile desc = plugin.getDescription(); if (desc.getName().startsWith("Essentials")) { String version = desc.getVersion(); if (!version.equalsIgnoreCase(essVer)) { version = "\u00a7c" + version; isMismatched = true; } sender.sendMessage(desc.getName().replace("Essentials", "EssentialsX") + " version: " + version); } } if (isMismatched) { sender.sendMessage("Version mismatch - make sure all EssentialsX plugins are the same version!"); } }</code><technical_language>This right</technical_language>

Target:
private void run_version(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.version")) return; boolean isMismatched = false; boolean isVaultInstalled = false; final PluginManager pm = server.getPluginManager(); final String essVer = pm.getPlugin("Essentials").getDescription().getVersion(); sender.sendMessage("Server version: " + server.getBukkitVersion() + " " + server.getVersion()); sender.sendMessage("EssentialsX version: " + essVer); for (Plugin plugin : pm.getPlugins()) { final PluginDescriptionFile desc = plugin.getDescription(); String name = desc.getName(); String version = desc.getVersion(); if (name.startsWith("Essentials") && !name.equalsIgnoreCase("Essentials")) { if (!version.equalsIgnoreCase(essVer)) { version = "\u00a7c" + version; isMismatched = true; } sender.sendMessage(name.replace("Essentials", "EssentialsX") + " version: " + version); } if (versionPlugins.contains(name)) { sender.sendMessage(name + " version: " + version); } if (name.equals("Vault")) isVaultInstalled = true; } if (isMismatched) { sender.sendMessage(tl("versionMismatchAll")); } if (!isVaultInstalled) { sender.sendMessage("Vault is not installed - chat and permissions may not work."); } }
Source:
<code>public void testExtendedModifiedSinceTermMatchException() { <START> final ExtendedModifiedSinceTerm extendedModifiedSinceTerm = new ExtendedModifiedSinceTerm(1L); <END> UnsupportedOperationException actual = null; try { extendedModifiedSinceTerm.match(null); } catch (final UnsupportedOperationException e) { actual = e; } Assert.assertNotNull(actual, "Should throw exception"); }</code><technical_language>If checking for exception, is a do it. @Test(expectedExceptions = UnsupportedOperationException.class) public void testExtendedModifiedSinceTermMatchException() { final ExtendedModifiedSinceTerm extendedModifiedSinceTerm = new ExtendedModifiedSinceTerm(1L); extendedModifiedSinceTerm.match(null); }</technical_language>

Target:
public void testExtendedModifiedSinceTermMatchException() { final ExtendedModifiedSinceTerm extendedModifiedSinceTerm = new ExtendedModifiedSinceTerm(1L); extendedModifiedSinceTerm.match(null); }
Source:
<code>public PluginContainer getPlugin() { Object base = this; if (this instanceof CarriedInventory) { Optional<?> carrier = ((CarriedInventory<?>) this).getCarrier(); if (carrier.isPresent()) { base = carrier.get(); } } if (base instanceof TileEntity) { String id = ((TileEntity) this).getBlock().getType().getId(); String pluginId = id.substring(0, id.indexOf(":")); return Sponge.getPluginManager().getPlugin(pluginId) .orElseThrow(() -> new AssertionError("Missing plugin " + pluginId + " for block " + id)); } if (base instanceof Entity) { String id = ((Entity) this).getType().getId(); String pluginId = id.substring(0, id.indexOf(":")); return Sponge.getPluginManager().getPlugin(pluginId) .orElseThrow(() -> new AssertionError("Missing plugin " + pluginId + " for entity " + id + " (" + getClass().getName() + ")")); } if (base instanceof SpongeUser) { return SpongeImpl.getMinecraftPlugin(); <START> } <END> SpongeImpl.getLogger().warn("Unknown plugin for " + this); return SpongeImpl.getMinecraftPlugin(); }</code><technical_language>I if this SpongeAPI plugin instead.</technical_language>

Target:
public PluginContainer getPlugin() { Object base = this; if (this instanceof CarriedInventory) { Optional<?> carrier = ((CarriedInventory<?>) this).getCarrier(); if (carrier.isPresent()) { base = carrier.get(); } } if (base instanceof TileEntity) { String id = ((TileEntity) base).getBlock().getType().getId(); String pluginId = id.substring(0, id.indexOf(":")); return Sponge.getPluginManager().getPlugin(pluginId) .orElseThrow(() -> new AssertionError("Missing plugin " + pluginId + " for block " + id)); } if (base instanceof Entity) { String id = ((Entity) base).getType().getId(); String pluginId = id.substring(0, id.indexOf(":")); return Sponge.getPluginManager().getPlugin(pluginId) .orElseThrow(() -> new AssertionError("Missing plugin " + pluginId + " for entity " + id + " (" + getClass().getName() + ")")); } if (base instanceof SpongeUser) { return SpongeImpl.getMinecraftPlugin(); } return Sponge.getPluginManager().getPlugin(SpongeImplHooks.getModIdFromClass(this.getClass())).orElseGet(() -> { SpongeImpl.getLogger().warn("Unknown plugin for " + this); return SpongeImpl.getMinecraftPlugin(); }); }