auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void seekOffset() throws IOException, DataParserException { int count = 0; while (count < offset) { if (count < recordCount) { Object rows[] = sasFileReader.readNext(); count++; <START> } else { <END> break; } } }</code><technical_language>this else block avoided line 88 while (count < offset count < recordCount)</technical_language>

Target:
private void seekOffset() throws IOException, DataParserException { int count = 0; while (count < offset && count < recordCount) { Object rows[] = sasFileReader.readNext(); count++; } }
Source:
<code>public TopicRepositoryHolder(@Qualifier("kafka") final TopicRepositoryCreator kafkaRepository) { this.readWriteLock = new ReentrantReadWriteLock(); this.storageTopicRepository = new HashMap<>(); this.repositoryCreators = new HashMap<>(); <START> this.repositoryCreators.put(Storage.Type.KAFKA, kafkaRepository); <END> }</code><technical_language>I prefer method getSupportedStorageType() in TopicRepositoryCreator</technical_language>

Target:
public TopicRepositoryHolder(@Qualifier("kafka") final TopicRepositoryCreator kafkaRepository) { this.readWriteLock = new ReentrantReadWriteLock(); this.storageTopicRepository = new HashMap<>(); this.repositoryCreators = new HashMap<>(); this.repositoryCreators.put(kafkaRepository.getSupportedStorageType(), kafkaRepository); }
Source:
<code>NElementSet(T... data) { T[] table = data.clone(); Arrays.fill(table, null); for (T element : data) { Objects.requireNonNull(element); int suggestedIndex = Math.abs(element.hashCode()) % data.length; int index = suggestedIndex; <START> while (index < suggestedIndex + data.length) { <END> T existingElement = table[index % data.length]; if (existingElement == null) { break; } if (existingElement.equals(element)) { throw new IllegalArgumentException("Duplicate element " + element); } index++; } table[index % data.length] = element; } this.data = table; }</code><technical_language>purpose of this change</technical_language>

Target:
NElementSet(T... data) { T[] table = data.clone(); Arrays.fill(table, null); for (T element : data) { Objects.requireNonNull(element); int suggestedIndex = Math.abs(element.hashCode()) % data.length; int index = suggestedIndex; boolean found = false; while (index < data.length) { T existingElement = table[index]; if (existingElement == null) { found = true; break; } else if (existingElement.equals(element)) { throw new IllegalArgumentException(); } ++index; } if (!found) { index = 0; while (index < suggestedIndex) { T existingElement = table[index]; if (existingElement == null) { break; } else if (existingElement.equals(element)) { throw new IllegalArgumentException(); } ++index; } } table[index] = element; } this.data = table; }
Source:
<code>private boolean isMessageMatch(AuditEvent event) { final boolean match; if (eventMessageRegexp == null) { match = true; <START> } <END> else { final Matcher messageMatcher = eventMessageRegexp.matcher(event.getMessage()); match = messageMatcher.find(); } return match; }</code><technical_language>Please boolean match = true; test eventMessageRegexp != null</technical_language>

Target:
private boolean isMessageMatch(AuditEvent event) { boolean match = true; if (eventMessageRegexp != null) { final Matcher messageMatcher = eventMessageRegexp.matcher(event.getMessage()); match = messageMatcher.find(); } return match; }
Source:
<code>public synchronized List<ITmfStateInterval> queryFullState(long t) throws TimeRangeException, StateSystemDisposedException { if (isDisposed) { throw new StateSystemDisposedException(); } final int nbAttr = getNbAttributes(); List<ITmfStateInterval> stateInfo = new ArrayList<>(nbAttr); <START> for (int i = 0; i < getNbAttributes(); i++) { <END> stateInfo.add(null); } if (transState.isActive()) { transState.doQuery(stateInfo, t); } backend.doQuery(stateInfo, t); for (ITmfStateInterval interval : stateInfo) { if (interval == null) { throw new IllegalStateException("Incoherent interval storage"); } } return stateInfo; }</code><technical_language>I guess want nbAttr saved a local variable above</technical_language>

Target:
public synchronized List<ITmfStateInterval> queryFullState(long t) throws TimeRangeException, StateSystemDisposedException { if (isDisposed) { throw new StateSystemDisposedException(); } final int nbAttr = getNbAttributes(); List<ITmfStateInterval> stateInfo = new ArrayList<>(nbAttr); for (int i = 0; i < nbAttr; i++) { stateInfo.add(null); } if (transState.isActive()) { transState.doQuery(stateInfo, t); } backend.doQuery(stateInfo, t); for (ITmfStateInterval interval : stateInfo) { if (interval == null) { throw new IllegalStateException("Incoherent interval storage"); } } return stateInfo; }
Source:
<code>public String toString() { return "Group{" + "Description='" + Description + '\'' + ", Name='" + Name + '\'' + ", Users=" + Arrays.toString(Users) + <START> '}'; <END> }</code><technical_language>this toString() generated tags field added :P</technical_language>

Target:
public String toString() { return "Group{" + "Description='" + Description + '\'' + ", Name='" + Name + '\'' + ", Users=" + Arrays.toString(Users) + ", Tags=" + Arrays.toString(Tags) + "} " + super.toString(); }
Source:
<code>private void setModelRunMinNewOccurrences(DiseaseGroup diseaseGroup, Boolean newOccurrenceCountOverThreshold) { <START> Integer n; <END> if (newOccurrenceCountOverThreshold == null) { n = null; } else { int thresholdAdjustment = newOccurrenceCountOverThreshold ? -1 : +1; n = (int) diseaseService.getNewOccurrencesCountByDiseaseGroup(diseaseGroup.getId()) + thresholdAdjustment; } diseaseGroup.setModelRunMinNewOccurrences(n); }</code><technical_language>A tiny optimisation be: Integer n = null; if (newOccurrenceCountOverThreshold != null) { int thresholdAdjustment = ... }</technical_language>

Target:
private void setModelRunMinNewOccurrences(DiseaseGroup diseaseGroup, Boolean newOccurrenceCountOverThreshold) { Integer n = null; if (newOccurrenceCountOverThreshold != null) { int thresholdAdjustment = newOccurrenceCountOverThreshold ? -1 : +1; n = (int) diseaseService.getNewOccurrencesCountByDiseaseGroup(diseaseGroup.getId()) + thresholdAdjustment; } diseaseGroup.setModelRunMinNewOccurrences(n); }
Source:
<code>private void waitAndConnectToScheduler() throws Exception { SchedulerAuthenticationInterface authentication; boolean firstException = true; int trialsNumber = 0; while (scheduler == null && trialsNumber <= nodeSourceRecoveryTrialsNumber) { trialsNumber++; try { authentication = SchedulerConnection.join(schedulerUrl); Credentials creds = Credentials.getCredentialsBase64(credentials); scheduler = authentication.login(creds); <START> Thread.sleep(nodeSourceRecoveryTimeout); <END> } catch (Throwable t) { if (firstException) { logger.warn("Could not contact scheduler at url " + schedulerUrl + " this is normal if the scheduler has just been restarted", t); firstException = false; } else { logger.debug("Could not contact scheduler", t); } } if (trialsNumber > nodeSourceRecoveryTrialsNumber) throw new ConnectionException("Number of trials exceeded and could not contact scheduler"); } }</code><technical_language>In end, nodeSourceRecoveryTimeout is more a delay a timeout. If I correct, timeout is nodeSourceRecoveryTrialsNumber * nodeSourceRecoveryTimeout. rename nodeSourceRecoveryTimeout variable</technical_language>

Target:
private void waitAndConnectToScheduler() throws Exception { SchedulerAuthenticationInterface authentication; boolean firstException = true; int trialsNumber = 0; while (scheduler == null && trialsNumber <= schedulerAwarePolicyNodeSourceRecoveryTrialsNumber) { trialsNumber++; try { authentication = SchedulerConnection.join(schedulerUrl); Credentials creds = Credentials.getCredentialsBase64(credentials); scheduler = authentication.login(creds); Thread.sleep(schedulerAwarePolicyNodeSourceRecoveryDelay); } catch (Throwable t) { if (firstException) { logger.warn("Could not contact scheduler at url " + schedulerUrl + " this is normal if the scheduler has just been restarted", t); firstException = false; } else { logger.debug("Could not contact scheduler", t); } } if (trialsNumber > schedulerAwarePolicyNodeSourceRecoveryTrialsNumber) throw new ConnectionException("Number of trials exceeded and could not contact scheduler"); } }
Source:
<code>private List<String> getPermissionsInSession(DocumentModel doc, CoreSession session) { Principal principal = session.getPrincipal(); PermissionProvider permissionProvider = Framework.getService(PermissionProvider.class); Set<String> permissions = permissionProvider.getUserVisiblePermissionDescriptors(doc.getType()).stream().map( UserVisiblePermission::getId).collect(Collectors.toSet()); permissions.addAll(availablePermissions); <START> return session.filterGrantedPermissions(principal, doc.getRef(), new ArrayList<>(permissions)); <END> }</code><technical_language>I need new ArrayList called method change permissions</technical_language>

Target:
private Collection<String> getPermissionsInSession(DocumentModel doc, CoreSession session) { Principal principal = session.getPrincipal(); PermissionProvider permissionProvider = Framework.getService(PermissionProvider.class); Set<String> permissions = permissionProvider.getUserVisiblePermissionDescriptors(doc.getType()).stream().map( UserVisiblePermission::getId).collect(Collectors.toSet()); permissions.addAll(availablePermissions); return session.filterGrantedPermissions(principal, doc.getRef(), permissions); }
Source:
<code>public void finish() { if (new FinishButton().isEnabled()) { new FinishButton().click(); new WaitWhile(new JobIsRunning(), TimePeriod.VERY_LONG); } else { <START> fail("Image cannot be run! (Duplicate name?)"); <END> } }</code><technical_language>failing plugin level is OK. If in test plugin abstraction for manipulation docker I consider ok. plugin level I do it. @rhopp thougts</technical_language>

Target:
public void finish() { if (new FinishButton().isEnabled()) { new FinishButton().click(); new WaitWhile(new JobIsRunning(), TimePeriod.VERY_LONG); } else { throw new RuntimeException("Image cannot be run! (Duplicate name?)"); } }
Source:
<code>public void receiveReduceData(final int iteration, final List<IndexedVector> data) { Collections.sort(data, new Comparator<IndexedVector>() { @Override public int compare(final IndexedVector o1, final IndexedVector o2) { if (o1.getIndex() > o2.getIndex()) { return 1; <START> } else if (o1.getIndex() < o2.getIndex()) { <END> return -1; } return 0; } }); try (final DataOutputStream daos = outputStreamProvider.create("result")) { if (data.size() == 0) { daos.writeBytes(String.format("No data")); return; } final int numColumns = data.size(); final int numRows = data.get(0).getVector().size(); for (int i = 0; i < numRows; i++) { daos.writeBytes(String.format("%d", i)); for (int j = 0; j < numColumns; j++) { daos.writeBytes(String.format(" ")); daos.writeBytes(String.format("%f", data.get(j).getVector().get(i))); } daos.writeBytes(String.format("%n")); } } catch (final IOException e) { throw new RuntimeException(e); } }</code><technical_language>o1.getIndex() - o2.getIndex()</technical_language>

Target:
public void receiveReduceData(final int iteration, final List<IndexedVector> data) { Collections.sort(data, new Comparator<IndexedVector>() { @Override public int compare(final IndexedVector o1, final IndexedVector o2) { return o1.getIndex() - o2.getIndex(); } }); try (final DataOutputStream daos = outputStreamProvider.create("result")) { if (data.size() == 0) { daos.writeBytes(String.format("No data")); return; } final int numColumns = data.size(); final int numRows = data.get(0).getVector().size(); for (int i = 0; i < numRows; i++) { daos.writeBytes(String.format("%d", i)); for (int j = 0; j < numColumns; j++) { daos.writeBytes(String.format(" ")); daos.writeBytes(String.format("%f", data.get(j).getVector().get(i))); } daos.writeBytes(String.format("%n")); } } catch (final IOException e) { throw new RuntimeException(e); } }
Source:
<code>private static String determineClassifier() { if (SystemUtils.IS_OS_LINUX) { return "linux"; } if (SystemUtils.IS_OS_WINDOWS) { return "windows"; } if (SystemUtils.IS_OS_MAC_OSX) { return "macosx"; } <START> return null; <END> }</code><technical_language>throw exception here, in case :)</technical_language>

Target:
private static String determineClassifier() { if (SystemUtils.IS_OS_LINUX) { return "linux"; } if (SystemUtils.IS_OS_WINDOWS) { return "windows"; } if (SystemUtils.IS_OS_MAC_OSX) { return "macosx"; } throw new IllegalStateException("Unsupported OS: only Linux, Windows and Mac OS X are supported"); }
Source:
<code>private ColumnType[] getColumnTypes(final Sheet sheet, final Row row) { final Iterator<Row> data = ExcelUtils.getRowIterator(sheet, _configuration, false); final int rowLength = row.getLastCellNum(); int eagerness = 1000; final ColumnType[] columnTypes = new ColumnType[rowLength]; while (data.hasNext() && eagerness-- > 0) { <START> Row currentRow = data.next(); <END> for (int index = 0; index < rowLength; index++) { if (currentRow.getLastCellNum() == 0) { continue; } if (currentRow.getCell(index) == null) { checkColumnType(ColumnType.STRING, columnTypes, index); } else { CellType cellType = currentRow.getCell(index).getCellType(); switch (cellType) { case NUMERIC: if (DateUtil.isCellDateFormatted(currentRow.getCell(index))) { checkColumnType(ColumnType.DATE, columnTypes, index); } else { checkColumnType((currentRow.getCell(index).getNumericCellValue() % 1 == 0) ? ColumnType.INTEGER : ColumnType.DOUBLE, columnTypes, index); } break; case BOOLEAN: checkColumnType(ColumnType.BOOLEAN, columnTypes, index); break; case ERROR: break; case _NONE: case STRING: case FORMULA: case BLANK: checkColumnType(ColumnType.STRING, columnTypes, index); break; } } } } return columnTypes; }</code><technical_language>this variable final</technical_language>

Target:
protected ColumnType[] getColumnTypes(final Sheet sheet, final Row row) { final Iterator<Row> data = ExcelUtils.getRowIterator(sheet, _configuration, false); final int rowLength = row.getLastCellNum(); final ColumnType[] columnTypes = new ColumnType[rowLength]; if (_configuration.isDetectColumnTypes()) { int numberOfLinesToScan = _configuration.getNumberOfLinesToScan(); while (data.hasNext() && numberOfLinesToScan-- > 0) { final Row currentRow = data.next(); if (currentRow.getRowNum() < _configuration.getColumnNameLineNumber()) { continue; } for (int index = 0; index < rowLength; index++) { if (currentRow.getLastCellNum() == 0) { continue; } final ColumnType columnType = columnTypes[index]; final ColumnType expectedColumnType = getColumnTypeFromRow(currentRow, index); if (columnType != null) { if (!columnType.equals(ColumnType.STRING) && !columnType.equals(expectedColumnType)) { columnTypes[index] = ColumnType.VARCHAR; } } else { columnTypes[index] = expectedColumnType; } } } } else { Arrays.fill(columnTypes, ColumnType.STRING); } return columnTypes; }
Source:
<code>private void checkCommentsInsideToken(DetailAST token) { final List<DetailAST> childNodes = new LinkedList<>(); DetailAST childNode = token.getLastChild(); while (childNode != null) { if (childNode.getType() == TokenTypes.MODIFIERS) { for (DetailAST node = token.getFirstChild().getLastChild(); node != null; node = node.getPreviousSibling()) { if (isCommentInBeginningOfLine(node)) { childNodes.add(node); } } } else if (isCommentInBeginningOfLine(childNode)) { childNodes.add(childNode); } childNode = childNode.getPreviousSibling(); } for (DetailAST node : childNodes) { if (hasEmptyLineBefore(node) && isPrePreviousLineEmpty(node)) { <START> log(node.getLineNo(), MSG_MULTIPLE_LINES, node.getText()); <END> } } }</code><technical_language>logs give AST</technical_language>

Target:
private void checkCommentsInsideToken(DetailAST token) { final List<DetailAST> childNodes = new LinkedList<>(); DetailAST childNode = token.getLastChild(); while (childNode != null) { if (childNode.getType() == TokenTypes.MODIFIERS) { for (DetailAST node = token.getFirstChild().getLastChild(); node != null; node = node.getPreviousSibling()) { if (isCommentInBeginningOfLine(node)) { childNodes.add(node); } } } else if (isCommentInBeginningOfLine(childNode)) { childNodes.add(childNode); } childNode = childNode.getPreviousSibling(); } for (DetailAST node : childNodes) { if (hasEmptyLineBefore(node) && isPrePreviousLineEmpty(node)) { log(node, MSG_MULTIPLE_LINES, node.getText()); } } }
Source:
<code>public static long writeHeader(final Version cramVersion, final OutputStream outStream, final SAMFileHeader samFileHeader, String cramID) { final CramHeader cramHeader = new CramHeader(cramVersion, cramID, samFileHeader); try { return CramIO.writeCramHeader(cramHeader, outStream); } catch (final IOException e) { <START> throw new RuntimeException(e); <END> } }</code><technical_language>RuntimeIOException</technical_language>

Target:
public static long writeHeader(final Version cramVersion, final OutputStream outStream, final SAMFileHeader samFileHeader, String cramID) { final CramHeader cramHeader = new CramHeader(cramVersion, cramID, samFileHeader); try { return CramIO.writeCramHeader(cramHeader, outStream); } catch (final IOException e) { throw new RuntimeIOException(e); } }
Source:
<code>private boolean inUsingDeclaration(CContentAssistInvocationContext context) { IDocument doc = context.getDocument(); int offset = context.getInvocationOffset(); try { IRegion completionLineRegion = doc.getLineInformationOfOffset(offset); String completionLine = doc.get(completionLineRegion.getOffset(), completionLineRegion.getLength()); <START> int completionLineNumber = doc.getLineOfOffset(offset); <END> int completionLineOffset = doc.getLineOffset(completionLineNumber); String completionLinePrefix = completionLine.substring(0, offset - completionLineOffset); int lastSemicolon = completionLinePrefix.lastIndexOf(';'); String completionStatement = lastSemicolon == -1 ? completionLinePrefix : completionLinePrefix.substring(lastSemicolon + 1); if (completionStatement.matches("\\s*using\\s*(\\w*::)+\\w*")) return true; } catch (BadLocationException exc) { } return false; }</code><technical_language>undesirable depend location of line breaks. code work for a weird case: f/*cursor*/ achieve is CHeuristicScanner CIndenter does</technical_language>

Target:
private boolean inUsingDeclaration(CContentAssistInvocationContext context) { IDocument doc = context.getDocument(); int offset = context.getInvocationOffset(); CHeuristicScanner.TokenStream tokenStream = new CHeuristicScanner.TokenStream(doc, offset); int token = tokenStream.previousToken(); if (token == Symbols.TokenIDENT) token = tokenStream.previousToken(); while (token == Symbols.TokenDOUBLECOLON) { token = tokenStream.previousToken(); if (token == Symbols.TokenUSING) { return true; } else if (token != Symbols.TokenIDENT) { return false; } else { token = tokenStream.previousToken(); } } return token == Symbols.TokenUSING; }
Source:
<code>public CourseCardViewHolder(View convertView) { this.courseTitle = (TextView) convertView .findViewById(R.id.course_name); this.courseDetails = (TextView) convertView .findViewById(R.id.course_details); this.courseImage = (ImageView) convertView .findViewById(R.id.course_image); this.newCourseContent = convertView .findViewById(R.id.new_course_content_layout); if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { convertView.findViewById(R.id.view_foreground_overlay).setVisibility(View.VISIBLE); } <END> <START> this.propContainer = (LinearLayout) convertView .findViewById(R.id.graded_content_layout); this.coursePropMsg = (TextView) convertView .findViewById(R.id.prop_msg); this.learnMore = (AppCompatButton) convertView .findViewById(R.id.btn_learn_more); }</code><technical_language>add type abbrevation 'll_graded_content_layout', tv_prop_msg</technical_language>

Target:
public CourseCardViewHolder(View convertView) { this.courseTitle = (TextView) convertView .findViewById(R.id.course_name); this.courseDetails = (TextView) convertView .findViewById(R.id.course_details); this.courseImage = (ImageView) convertView .findViewById(R.id.course_image); this.newCourseContent = convertView .findViewById(R.id.new_course_content_layout); if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { convertView.findViewById(R.id.view_foreground_overlay).setVisibility(View.VISIBLE); } this.propContainer = (LinearLayout) convertView .findViewById(R.id.ll_graded_content_layout); this.learnMore = (AppCompatButton) convertView .findViewById(R.id.btn_learn_more); }
Source:
<code>protected List<AttributeStatement> createResourceIdAttributeStatements(final CallbackProperties properties) { final List<AttributeStatement> statements = new ArrayList<>(); final String patientId = properties.getPatientID(); if (patientId != null) { <START> Attribute attribute = componentBuilder.createPatientIDAttribute(patientId); <END> statements.addAll(componentBuilder.createAttributeStatement(Arrays.asList(attribute))); } else { LOG.warn("Resource Id is missing"); } return statements; }</code><technical_language>rename method createResourceIdAttributeStatements</technical_language>

Target:
protected List<AttributeStatement> createResourceIdAttributeStatements(final CallbackProperties properties) { final List<AttributeStatement> statements = new ArrayList<>(); final String patientId = properties.getPatientID(); if (patientId != null) { Attribute attribute = componentBuilder.createResourceIDAttribute(patientId); statements.addAll(componentBuilder.createAttributeStatement(Arrays.asList(attribute))); } else { LOG.warn("Resource Id is missing"); } return statements; }
Source:
<code>public synchronized void loadSpiderIpAddresses() { if (table == null) { table = new IPTable(); String filePath = configurationService.getProperty("dspace.dir"); try { File spidersDir = new File(filePath, "config/spiders"); if (spidersDir.exists() && spidersDir.isDirectory()) { <START> for (File file : spidersDir.listFiles()) { <END> if (file.isFile() && !file.getName().matches(".+old$")) { for (String ip : readPatterns(file)) { log.debug("Loading {}", ip); if (!Character.isDigit(ip.charAt(0))) { try { ip = DnsLookup.forward(ip); log.debug("Resolved to {}", ip); } catch (IOException e) { log.warn("Not loading {}: {}", ip, e.getMessage()); continue; } } table.add(ip); } log.info("Loaded Spider IP file: " + file); } } } else { log.info("No spider file loaded"); } } catch (IOException | IPTable.IPFormatException e) { log.error("Error Loading Spiders:" + e.getMessage(), e); } } }</code><technical_language>is other place FileFilter implementation</technical_language>

Target:
public synchronized void loadSpiderIpAddresses() { if (table == null) { table = new IPTable(); String filePath = configurationService.getProperty("dspace.dir"); try { File spidersDir = new File(filePath, "config/spiders"); if (spidersDir.exists() && spidersDir.isDirectory()) { for (File file : spidersDir.listFiles(new NoDotOldFilter())) { if (file.isFile()) { for (String ip : readPatterns(file)) { log.debug("Loading {}", ip); if (!Character.isDigit(ip.charAt(0))) { try { ip = DnsLookup.forward(ip); log.debug("Resolved to {}", ip); } catch (IOException e) { log.warn("Not loading {}: {}", ip, e.getMessage()); continue; } } table.add(ip); } log.info("Loaded Spider IP file: " + file); } } } else { log.info("No spider file loaded"); } } catch (IOException | IPTable.IPFormatException e) { log.error("Error Loading Spiders:" + e.getMessage(), e); } } }
Source:
<code>public void setDefaultSystem(SystemDescriptor<?> defaultSystemDescriptor) { Preconditions.checkNotNull(defaultSystemDescriptor, "Provided defaultSystemDescriptor must not be null."); String defaultSystemName = defaultSystemDescriptor.getSystemName(); Preconditions.checkState(inputOperators.isEmpty() && outputStreams.isEmpty(), "Default system must be set before creating any input or output streams."); <START> Preconditions.checkState(!systemDescriptors.containsKey(defaultSystemName) || <END> systemDescriptors.get(defaultSystemName) == defaultSystemDescriptor, "Must not use different system descriptor instances for the same system name: " + defaultSystemName); systemDescriptors.put(defaultSystemName, defaultSystemDescriptor); this.defaultSystemDescriptorOptional = Optional.of(defaultSystemDescriptor); }</code><technical_language>Minor: do this check for default/input/output. extract a shared method</technical_language>

Target:
public void setDefaultSystem(SystemDescriptor<?> defaultSystemDescriptor) { Preconditions.checkNotNull(defaultSystemDescriptor, "Provided defaultSystemDescriptor must not be null."); String defaultSystemName = defaultSystemDescriptor.getSystemName(); Preconditions.checkState(inputOperators.isEmpty() && outputStreams.isEmpty(), "Default system must be set before creating any input or output streams."); checkSystemDescriptorUniqueness(defaultSystemDescriptor, defaultSystemName); systemDescriptors.put(defaultSystemName, defaultSystemDescriptor); this.defaultSystemDescriptorOptional = Optional.of(defaultSystemDescriptor); }
Source:
<code>protected void setFrameFocus(final IFrameDMContext newFrame, RequestMonitor rm) { <START> if (newFrame == null) { <END> GdbPlugin.logErrorMessage("GdbSynchronizer unable to resolve frame context for the selected element"); rm.done(); return; } if (isThreadSuspended(getThreadFromFrame(newFrame))) { ICommand<MIInfo> command = fCommandFactory.createMIStackSelectFrame(getThreadFromFrame(newFrame), newFrame.getLevel()); fCommandControl.queueCommand(command, new ImmediateDataRequestMonitor<MIInfo>(rm) {}); } else { rm.done(); } }</code><technical_language>I set error in RM instead</technical_language>

Target:
protected void setFrameFocus(final IFrameDMContext newFrame, RequestMonitor rm) { if (newFrame == null) { rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "GdbSynchronizer unable to resolve frame context for the selected element", null)); return; } if (isThreadSuspended(getThreadFromFrame(newFrame))) { ICommand<MIInfo> command = fCommandFactory.createMIStackSelectFrame(getThreadFromFrame(newFrame), newFrame.getLevel()); fGdbcontrol.queueCommand(command, new ImmediateDataRequestMonitor<MIInfo>(rm) {}); } else { rm.done(); } }
Source:
<code>private KieModuleModel getKieModuleModelWithAlphaNetworkCompiler() { KieModuleModel kproj = KieServices.get().newKieModuleModel(); <START> kproj.setConfigurationProperty( "drools.alphaNetworkCompiler", "true" ); <END> return kproj; }</code><technical_language>If extracted a constant, reused here</technical_language>

Target:
private KieModuleModel getKieModuleModelWithAlphaNetworkCompiler() { KieModuleModel kproj = KieServices.get().newKieModuleModel(); kproj.setConfigurationProperty( org.drools.compiler.kie.builder.impl.KieContainerImpl.ALPHA_NETWORK_COMPILER_OPTION, "true" ); return kproj; }
Source:
<code>public static void setTickTupleFrequency(Map<String, Object> conf, int seconds) { <START> setTickTupleFrequency(conf, (long) (seconds * 1000)); <END> }</code><technical_language>name explicitly. setTickTupleFreqencySec Msec</technical_language>

Target:
public static void setTickTupleFrequency(Map<String, Object> conf, int seconds) { setTickTupleFrequencyMs(conf, (long) (seconds * 1000)); }
Source:
<code>public JsonElement serialize(JsonSerializationContext context) { JsonObject serialized = new JsonObject(); serialized.addProperty("doi", article.getDoi()); this.latestRevision.ifPresent(latestRevision -> { serialized.addProperty("revisionNumber", latestRevision.getRevisionNumber()); ArticleIngestion ingestion = latestRevision.getIngestion(); <START> serialized.add("journal", context.serialize(ingestion.getJournal())); <END> serialized.addProperty("ingestionNumber", ingestion.getIngestionNumber()); serialized.addProperty("title", ingestion.getTitle()); serialized.addProperty("publicationDate", ingestion.getPublicationDate().toLocalDate().toString()); serialized.addProperty("revisionDate", ingestion.getRevisionDate().toLocalDate().toString()); serialized.addProperty("articleType", ingestion.getArticleType()); }); return serialized; }</code><technical_language>Needs JournalOutputView, assuming want provide key something</technical_language>

Target:
public JsonElement serialize(JsonSerializationContext context) { JsonObject serialized = new JsonObject(); serialized.addProperty("doi", article.getDoi()); this.latestRevision.ifPresent(latestRevision -> { serialized.addProperty("revisionNumber", latestRevision.getRevisionNumber()); ArticleIngestion ingestion = latestRevision.getIngestion(); JournalOutputView journalOutputView = journalOutputViewFactory.getView(ingestion.getJournal()); serialized.add("journal", context.serialize(journalOutputView)); serialized.addProperty("ingestionNumber", ingestion.getIngestionNumber()); serialized.addProperty("title", ingestion.getTitle()); serialized.addProperty("publicationDate", ingestion.getPublicationDate().toLocalDate().toString()); if (ingestion.getRevisionDate() != null) { serialized.addProperty("revisionDate", ingestion.getRevisionDate().toLocalDate().toString()); } serialized.addProperty("articleType", ingestion.getArticleType()); }); return serialized; }
Source:
<code>private boolean existsFile(URI uri) throws IOException { try { URI base = getBase(uri); String path = sanitizePath(base.relativize(uri).getPath()); HeadObjectRequest headObjectRequest = HeadObjectRequest.builder() .bucket(uri.getHost()) .key(path) .build(); s3Client.headObject(headObjectRequest); return true; <START> }catch(NoSuchKeyException e){ <END> return false; }catch(S3Exception e){ throw new IOException(e); } }</code><technical_language>Missing space } catch. Please format files codestyle config in <LINK_0></technical_language>

Target:
private boolean existsFile(URI uri) throws IOException { try { URI base = getBase(uri); String path = sanitizePath(base.relativize(uri).getPath()); HeadObjectRequest headObjectRequest = HeadObjectRequest.builder().bucket(uri.getHost()).key(path).build(); _s3Client.headObject(headObjectRequest); return true; } catch (NoSuchKeyException e) { return false; } catch (S3Exception e) { throw new IOException(e); } }
Source:
<code>public Response getAllComments( @PathParam("uuid") String uuid, @QueryParam("offset") int offSet, @ QueryParam("limit") int limit) { CommentsManager commentsManager = APIUtil.getCommentsManager(); List<Comment> comments = new ArrayList<>(); try { PaginationRequest request = new PaginationRequest(offSet, limit); if (uuid == null) { return Response.status(Response.Status.NOT_FOUND).entity("Comments not found").build(); } else if (request.validatePaginationRequest(offSet, limit)) { commentsManager.getAllComments(request, uuid); return Response.status(Response.Status.OK).entity(comments).build(); } } catch (CommentManagementException e) { String msg = "Error occurred while retrieving comments."; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(" Internal server error occurs") .build(); } <START> return null; <END> }</code><technical_language>@NishadiPrasangini send a correct HTTP response instead of returning null</technical_language>

Target:
public Response getAllComments( @PathParam("uuid") String uuid, @QueryParam("offset") int offSet, @ QueryParam("limit") int limit) { CommentsManager commentsManager = APIUtil.getCommentsManager(); List<Comment> comments = new ArrayList<>(); try { PaginationRequest request = new PaginationRequest(offSet, limit); if (uuid == null) { return Response.status(Response.Status.NOT_FOUND).entity("Comments not found").build(); } else if (request.validatePaginationRequest(offSet, limit)) { commentsManager.getAllComments(request, uuid); return Response.status(Response.Status.OK).entity(comments).build(); } } catch (CommentManagementException e) { String msg = "Error occurred while retrieving comments."; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg) .build(); } return Response.status(Response.Status.OK).entity(comments).build(); }
Source:
<code>protected void deleteAnchors() { <START> @SuppressWarnings("unchecked") <END> Collection<File> anchors = listFiles(appsDir, ANCHOR_FILTER, null); for (File anchor : anchors) { try { forceDelete(anchor); } catch (IOException e) { throw new MuleControllerException(String.format(ANCHOR_DELETE_ERROR, anchor), e); } } }</code><technical_language>is this needed</technical_language>

Target:
protected void deleteAnchors() { Collection<File> anchors = listFiles(appsDir, ANCHOR_FILTER, null); for (File anchor : anchors) { try { forceDelete(anchor); } catch (IOException e) { throw new MuleControllerException(String.format(ANCHOR_DELETE_ERROR, anchor), e); } } }
Source:
<code>public IStatus runInUIThread(IProgressMonitor monitor) { String binaryPath = fProcessNameToBinaryMap.get(fProcName); if (binaryPath == null) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); <START> <END> if (shell != null) { FileDialog fd = new FileDialog(shell, SWT.NONE); fd.setText(fTitle); binaryPath = fd.open(); } } if (binaryPath == null) { fRm.done(); } else { final String finalBinaryPath = binaryPath; fExecutor.execute(new DsfRunnable() { @Override public void run() { IGDBProcesses procService = fTracker.getService(IGDBProcesses.class); ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); if (procService != null && commandControl != null) { IProcessDMContext procDmc = procService.createProcessContext(commandControl.getContext(), fPid); procService.attachDebuggerToProcess(procDmc, finalBinaryPath, new DataRequestMonitor<IDMContext>(fExecutor, fRm) { @Override protected void handleSuccess() { if (fProcName != null && !fProcName.isEmpty()) { fProcessNameToBinaryMap.put(fProcName, finalBinaryPath); } fRm.done(); }; }); } else { fRm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Cannot find services", null)); fRm.done(); } } }); } return Status.OK_STATUS; }</code><technical_language>I GdbUIPlugin.getShell() is in GdbDebugNewExecutableCommand</technical_language>

Target:
public IStatus runInUIThread(IProgressMonitor monitor) { String binaryPath = fProcessNameToBinaryMap.get(fProcName); if (binaryPath == null) { Shell shell = GdbUIPlugin.getShell(); if (shell != null) { FileDialog fd = new FileDialog(shell, SWT.NONE); fd.setText(fTitle); binaryPath = fd.open(); } } if (binaryPath == null) { fRm.done(); } else { final String finalBinaryPath = binaryPath; fExecutor.execute(new DsfRunnable() { @Override public void run() { IGDBProcesses procService = fTracker.getService(IGDBProcesses.class); ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); if (procService != null && commandControl != null) { IProcessDMContext procDmc = procService.createProcessContext(commandControl.getContext(), fPid); procService.attachDebuggerToProcess(procDmc, finalBinaryPath, new DataRequestMonitor<IDMContext>(fExecutor, fRm) { @Override protected void handleSuccess() { if (fProcName != null && !fProcName.isEmpty()) { fProcessNameToBinaryMap.put(fProcName, finalBinaryPath); } fRm.done(); }; }); } else { fRm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Cannot find services", null)); fRm.done(); } } }); } return Status.OK_STATUS; }
Source:
<code>private void <START> computeNullStatus(FlowInfo <END> flowInfo, FlowContext flowContext) { int status = 0; int combinedStatus = 0; for (Expression re : this.resultExpressions) { combinedStatus |= re.nullStatus(flowInfo, flowContext); } if ((combinedStatus & (FlowInfo.NULL|FlowInfo.POTENTIALLY_NULL)) != 0) status |= FlowInfo.POTENTIALLY_NULL; if ((combinedStatus & (FlowInfo.NON_NULL|FlowInfo.POTENTIALLY_NON_NULL)) != 0) status |= FlowInfo.POTENTIALLY_NON_NULL; if ((combinedStatus & (FlowInfo.UNKNOWN|FlowInfo.POTENTIALLY_UNKNOWN)) != 0) status |= FlowInfo.POTENTIALLY_UNKNOWN; if (status > 0) this.nullStatus = status; }</code><technical_language>15 lines of ConditionalExpression.computeNullStatus reflected here. argue needed here</technical_language>

Target:
private void computeNullStatus(FlowInfo flowInfo, FlowContext flowContext) { int status = this.resultExpressions.get(0).nullStatus(flowInfo, flowContext); int combinedStatus = status; boolean identicalStatus = true; for (int i = 1, l = this.resultExpressions.size(); i < l; ++i) { int tmp = this.resultExpressions.get(i).nullStatus(flowInfo, flowContext); identicalStatus &= status == tmp; combinedStatus |= tmp; } if (identicalStatus) { this.nullStatus = status; return; } status = Expression.computeNullStatus(0, combinedStatus); if (status > 0) this.nullStatus = status; }
Source:
<code><START> @Override public boolean equals(Object o) { <END> if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ValidationResult that = (ValidationResult) o; if (privateSuccess != that.privateSuccess) return false; if (!privateReasons.equals(that.privateReasons)) return false; return true; }</code><technical_language>Please annotations separate line :-) I suggest Java 7 utils for easier computation: if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ValidationResult = (ValidationResult) o; return Objects.equals(success, that.success) && Objects.equals(reasons, that.reasons);</technical_language>

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ValidationResult that = (ValidationResult) o; return Objects.equals(privateSuccess, that.privateSuccess) && Objects.equals(privateReasons, that.privateReasons); }
Source:
<code><START> public ExcludedPath(String path) { <END> this(); this.setPath(path); }</code><technical_language>this constructor , is benefit of default constructor setPath() method explicitly</technical_language>

Target:
public ExcludedPath(String path) { this.jsonSerializable = new JsonSerializable(); this.setPath(path); }
Source:
<code>public void leaderChangeClearsCaches() { eventCache.processStartTransactionsUpdate(TIMESTAMPS, SNAPSHOT); <START> eventCache.processStartTransactionsUpdate(TIMESTAMPS_2, <END> LockWatchStateUpdate.success(EVENT2_UUID, 4L, ImmutableList.of())); verifyStage(); }</code><technical_language>this throw? received a success update timelock snapshot is</technical_language>

Target:
public void leaderChangeClearsCaches() { setupInitialState(); eventCache.processStartTransactionsUpdate(TIMESTAMPS_2, LockWatchStateUpdate.success(EVENT2_UUID, 4L, ImmutableList.of())); verifyStage(); }
Source:
<code>static DMNRuntimeFluent create(CommandBasedExecutable executable) { try { <START> return (DMNRuntimeFluent) Class.forName("org.kie.dmn.core.fluent.DMNRuntimeFluentImpl") <END> .getConstructor(CommandBasedExecutable.class).newInstance(executable); } catch (Exception e) { throw new RuntimeException("Unable to instance DMNRuntimeFluent", e); } }</code><technical_language>I Class.forName is preferable org.kie.internal.utils.ClassLoaderUtil. I understand this is -api -internal need a bit of refactor reconciliate requirements</technical_language>

Target:
static DMNRuntimeFluent create(CommandBasedExecutable executable) { try { return (DMNRuntimeFluent) ClassLoaderUtil.getClassLoader(null, null, true) .loadClass("org.kie.dmn.core.fluent.DMNRuntimeFluentImpl") .getConstructor(CommandBasedExecutable.class).newInstance(executable); } catch (Exception e) { throw new RuntimeException("Unable to instance DMNRuntimeFluent", e); } }
Source:
<code>private void drainQueue() { if (isTerminated()) { return; } currentWork = workQueue.poll(); if (currentWork == null) { return; } <START> subscription.request(currentWork.getNumberOfEvents()); <END> timeoutOperation = Mono.delay(currentWork.getTimeout()) .subscribe(l -> { if (!currentWork.isTerminal()) { completeCurrentWork(currentWork); } }); }</code><technical_language>if requested 100 events, 30 showed in timeout period, next work item wants 10? This logic add another 10 credits (making 80 credits) need add more credits link</technical_language>

Target:
private void drainQueue() { if (isTerminated()) { return; } synchronized (currentWorkLock) { if (currentWork != null && currentWork.isTerminal()) { workQueue.remove(currentWork); if (currentTimeoutOperation != null && !currentTimeoutOperation.isDisposed()) { currentTimeoutOperation.dispose(); } currentTimeoutOperation = null; } while ((currentWork = workQueue.peek()) != null && (!currentWork.isProcessingStarted() || bufferMessages.size() > 0)) { if (currentWork.isTerminal()) { workQueue.remove(currentWork); if (currentTimeoutOperation != null && !currentTimeoutOperation.isDisposed()) { currentTimeoutOperation.dispose(); } continue; } if (!currentWork.isProcessingStarted()) { currentTimeoutOperation = getTimeoutOperation(currentWork); currentWork.startedProcessing(); } while (bufferMessages.size() > 0 && !currentWork.isTerminal()) { currentWork.next(bufferMessages.poll()); remaining.decrementAndGet(); } if (currentWork.isTerminal()) { if (currentWork.getError() == null) { currentWork.complete(); } workQueue.remove(currentWork); if (currentTimeoutOperation != null && !currentTimeoutOperation.isDisposed()) { currentTimeoutOperation.dispose(); } logger.verbose("The work is complete.", currentWork.getId()); } else { long creditToAdd = currentWork.getRemaining() - (remaining.get() + bufferMessages.size()); if (creditToAdd > 0) { remaining.addAndGet(creditToAdd); subscription.request(creditToAdd); logger.verbose("Requesting from upstream for work [{}].", creditToAdd, currentWork.getId()); } } } } }
Source:
<code>Connection createProxyConnection(final ProxyLeakTask leakTask, final long now) { ProxyConnection pc = ProxyFactory.getProxyConnection(this, connection, openStatements, leakTask, now); <START> hikariPool.initProxyConnection(pc); <END> return pc; }</code><technical_language>I suspect this is a performance hit, this is in hot path init() method in ProxyConnection introduces additional dereference method invocation. I initially this, eventually introduced additional stack parameter constructor reduce overhead</technical_language>

Target:
Connection createProxyConnection(final ProxyLeakTask leakTask, final long now) { return ProxyFactory.getProxyConnection(this, connection, openStatements, leakTask, now, hikariPool.getReadOnly(), hikariPool.getAutoCommit()); }
Source:
<code>public void waitHttpAsAction() { String server = String.format("http://localhost:%s", serverPort); httpServer.setPort(serverPort); start(httpServer); parallel().actions( sequential().actions( waitFor() .execution() <START> .action(send(http -> http.endpoint(server))) <END> ), sequential().actions( http(http -> http.server(httpServer).receive().post()), http(http -> http.server(httpServer).receive().post()), http(http -> http.server(httpServer).respond(HttpStatus.OK)) ) ); doFinally().actions(stop(httpServer)); }</code><technical_language>redundant test (already covered waitAction() below)</technical_language>

Target:
public void waitHttpAsAction() { String server = startHttpServerAndGetUrl(); parallel().actions( sequential().actions( waitFor() .execution() .action(send(http -> http.endpoint(server))) ), sequential().actions( http(http -> http.server(httpServer).receive().post()), http(http -> http.server(httpServer).receive().post()), http(http -> http.server(httpServer).respond(HttpStatus.OK)) ) ); doFinally().actions(stop(httpServer)); }
Source:
<code>private synchronized void doRefreshProgress(int id, int progress, boolean fromUser, boolean callBackToApp, boolean animate) { int range = mMax - mMin; final float scale = range > 0 ? (progress - mMin) / (float) range : 0; final boolean isPrimary = id == R.id.progress; if (isPrimary && animate) { final ObjectAnimator animator = ObjectAnimator.ofFloat(this, VISUAL_PROGRESS, scale); animator.setAutoCancel(true); animator.setDuration(PROGRESS_ANIM_DURATION); animator.setInterpolator(PROGRESS_ANIM_INTERPOLATOR); animator.start(); <START> mLastProgressAnimator = animator; <END> } else { if (isPrimary && mLastProgressAnimator != null) { mLastProgressAnimator.cancel(); mLastProgressAnimator = null; } setVisualProgress(id, scale); } if (isPrimary && callBackToApp) { onProgressRefresh(scale, fromUser, progress); } }</code><technical_language>Please add a listener clear this field animator ends</technical_language>

Target:
private synchronized void doRefreshProgress(int id, int progress, boolean fromUser, boolean callBackToApp, boolean animate) { int range = mMax - mMin; final float scale = range > 0 ? (progress - mMin) / (float) range : 0; final boolean isPrimary = id == R.id.progress; if (isPrimary && animate) { final ObjectAnimator animator = ObjectAnimator.ofFloat(this, VISUAL_PROGRESS, scale); animator.setAutoCancel(true); animator.setDuration(PROGRESS_ANIM_DURATION); animator.setInterpolator(PROGRESS_ANIM_INTERPOLATOR); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLastProgressAnimator = null; } }); animator.start(); mLastProgressAnimator = animator; } else { if (isPrimary && mLastProgressAnimator != null) { mLastProgressAnimator.cancel(); mLastProgressAnimator = null; } setVisualProgress(id, scale); } if (isPrimary && callBackToApp) { onProgressRefresh(scale, fromUser, progress); } }
Source:
<code>private void validateScheduleNameForPlatform(String type, String scheduleName) { <START> if(type.equals(KUBERNETES)) { <END> if(scheduleName.length() > MAX_SCHEDULE_NAME_LEN) { throw new IllegalArgumentException(String.format("the name specified " + "exceeds the maximum schedule name length of %s. A SCDF " + "schedule name is an aggregate of <task-definition-name>-%s" + "<schedule-name>. Consider using fewer characters for task definition" + "name or the schedule-name.", MAX_SCHEDULE_NAME_LEN, taskConfigurationProperties.getScheduleNamePrefix() )); } } }</code><technical_language>I thought planning convert case of schedule name case add case insensitive checks task definition names in other places involves task name references</technical_language>

Target:
private String validateScheduleNameForPlatform(String type, String scheduleName) { if(type.equals(TaskPlatformFactory.KUBERNETES_PLATFORM_TYPE)) { if(scheduleName.length() > MAX_SCHEDULE_NAME_LEN) { throw new IllegalArgumentException(String.format("the name specified " + "exceeds the maximum schedule name length of %s. A SCDF " + "schedule name is an aggregate of <task-definition-name>-%s" + "<schedule-name>. Consider using fewer characters for task definition" + "name or the schedule-name.", MAX_SCHEDULE_NAME_LEN, this.taskConfigurationProperties.getScheduleNamePrefix() )); } scheduleName = scheduleName.toLowerCase(); } return scheduleName; }