auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected boolean validateInputs() { <START> boolean result = super.validateInputs(); <END> if (result) { VdcQueryReturnValue returnValue = getQueryReturnValue(); returnValue.setExceptionString(""); try { String hostName = getParameters().getVdsHostName(); if (StringUtils.isBlank(hostName)) { returnValue.setExceptionString("Cannot register Host - no Hostname address specified."); result = false; } else { List<VDS> vdssByUniqueId = getVdssByUniqueId(); if (vdssByUniqueId.size() > 1) { returnValue.setExceptionString("Cannot register Host - unique id is ambigious."); result = false; } else if (vdssByUniqueId.size() == 1) { VDS vds = vdssByUniqueId.get(0); if (!VdsHandler.isPendingOvirt(vds)) { returnValue.setExceptionString(VdcBllMessages.VDS_STATUS_NOT_VALID_FOR_UPDATE.name()); result = false; } else { Long otp = getParameters().getOtp(); if (otp != null && !isValidOtp(vds, otp)) { returnValue.setExceptionString(String.format("Invalid OTP for host %s", hostName)); result = false; } } } } } catch (RuntimeException ex) { log.error("RegisterVdsQuery::CanDoAction: An exception has been thrown.", ex); returnValue.setExceptionString(String.format("Cannot register Host - An exception has been thrown: %1$s", ex.getMessage())); result = false; } } return result; }</code><technical_language>return early move entire function left</technical_language>

Target:
protected boolean validateInputs() { if (!super.validateInputs()) { return false; } VdcQueryReturnValue returnValue = getQueryReturnValue(); returnValue.setExceptionString(""); try { String hostName = getParameters().getVdsHostName(); if (StringUtils.isBlank(hostName)) { returnValue.setExceptionString("Cannot register Host - no Hostname address specified."); return false; } List<VDS> vdssByUniqueId = getVdssByUniqueId(); if (vdssByUniqueId.size() > 1) { returnValue.setExceptionString("Cannot register Host - unique id is ambigious."); return false; } if (vdssByUniqueId.size() == 1) { VDS vds = vdssByUniqueId.get(0); if (!VdsHandler.isPendingOvirt(vds)) { returnValue.setExceptionString(VdcBllMessages.VDS_STATUS_NOT_VALID_FOR_UPDATE.name()); return false; } Long otp = getParameters().getOtp(); if (otp != null && !isValidOtp(vds, otp)) { returnValue.setExceptionString(String.format("Invalid OTP for host %s", hostName)); return false; } } } catch (RuntimeException ex) { log.error("RegisterVdsQuery::CanDoAction: An exception has been thrown.", ex); returnValue.setExceptionString(String.format("Cannot register Host - An exception has been thrown: %1$s", ex.getMessage())); return false; } return true; }
Source:
<code>public void addSmap(SmapFile smap) { if (!smap.getGeneratedFile().equals(path)) { <START> throw new IllegalStateException("Invalid smap " + smap + " for this generated file " + path); <END> } smapFiles.add(smap); }</code><technical_language>if this throws a runtime exception, able recover it? case interrupt process, ultimately interrupting analysis. is working failfast policy? I a test recovering it, some test checking thrown exception</technical_language>

Target:
public void addSmap(SmapFile smap) { if (!smap.getGeneratedFile().equals(path)) { LOG.warn("Invalid smap for {}.", smap, path); return; } smapFiles.add(smap); }
Source:
<code>private TreeItem thisOrFirstItem(TreeItem item) { <START> return item != null ? item : getFirstItemInTree(); <END> }</code><technical_language>I checkstyle is disabled for this project (not actually), EMF Compare checkstyle config discourages ternary expressions, replace this a common if statement here</technical_language>

Target:
private TreeItem thisOrFirstItem(TreeItem item) { if (item != null) { return item; } return getFirstItemInTree(); }
Source:
<code>private Map<String, Element> getMetaPropertyField( TypeElement classElement, PropertyMetaTypes type ) { final Messager messager = processingEnv.getMessager(); Map<String, Element> result = new LinkedHashMap<>(); while ( !classElement.toString().equals( Object.class.getName() ) ) { List<VariableElement> variableElements = ElementFilter.fieldsIn( classElement.getEnclosedElements() ); for ( VariableElement variableElement : variableElements ) { final Property metaProperty = variableElement.getAnnotation( Property.class ); if ( null != metaProperty ) { final TypeMirror fieldReturnType = variableElement.asType(); final TypeElement t = ( TypeElement ) ( ( DeclaredType ) fieldReturnType ).asElement(); final String fieldName = variableElement.getSimpleName().toString(); result.put( fieldName, t ); <START> messager.printMessage( Diagnostic.Kind.WARNING, "Discovered meta property value " + <END> "for class [" + classElement.getSimpleName() + "] " + "at field [" + fieldName + "] " + "of return type [" + fieldReturnType + "]" ); } } classElement = getParent( classElement ); } return result; }</code><technical_language>NOTE WARNING</technical_language>

Target:
private Map<String, Element> getMetaPropertyField( TypeElement classElement, PropertyMetaTypes type ) { final Messager messager = processingEnv.getMessager(); Map<String, Element> result = new LinkedHashMap<>(); while ( !classElement.toString().equals( Object.class.getName() ) ) { List<VariableElement> variableElements = ElementFilter.fieldsIn( classElement.getEnclosedElements() ); for ( VariableElement variableElement : variableElements ) { final Property metaProperty = variableElement.getAnnotation( Property.class ); if ( null != metaProperty ) { final TypeMirror fieldReturnType = variableElement.asType(); final TypeElement t = ( TypeElement ) ( ( DeclaredType ) fieldReturnType ).asElement(); final String fieldName = variableElement.getSimpleName().toString(); result.put( fieldName, t ); messager.printMessage( Diagnostic.Kind.NOTE, "Discovered meta property value " + "for class [" + classElement.getSimpleName() + "] " + "at field [" + fieldName + "] " + "of return type [" + fieldReturnType + "]" ); } } classElement = getParent( classElement ); } return result; }
Source:
<code>public Filter toFilter() { ExtractionFn extractionFn = getExtractionFn(); String dimension = getDimension(); String value = getValue(); if (extractionFn == null) { return new NoBitmapSelectorFilter(dimension, value); } else { <START> final String valueOrNull = StringUtils.emptyToNullNonDruidDataString(value); <END> final DruidPredicateFactory predicateFactory = new DruidPredicateFactory() { @Override public Predicate<String> makeStringPredicate() { return input -> Objects.equals(valueOrNull, input); } @Override public DruidLongPredicate makeLongPredicate() { return input -> Objects.equals(valueOrNull, String.valueOf(input)); } @Override public DruidFloatPredicate makeFloatPredicate() { return input -> Objects.equals(valueOrNull, String.valueOf(input)); } @Override public DruidDoublePredicate makeDoublePredicate() { return input -> Objects.equals(valueOrNull, String.valueOf(input)); } }; return new NoBitmapDimensionPredicateFilter(dimension, predicateFactory, extractionFn); } }</code><technical_language>question. is annotated @Nullable</technical_language>

Target:
public Filter toFilter() { ExtractionFn extractionFn = getExtractionFn(); String dimension = getDimension(); String value = getValue(); if (extractionFn == null) { return new NoBitmapSelectorFilter(dimension, value); } else { final String valueOrNull = NullHandling.emptyToNullIfNeeded(value); final DruidPredicateFactory predicateFactory = new DruidPredicateFactory() { @Override public Predicate<String> makeStringPredicate() { return input -> Objects.equals(valueOrNull, input); } @Override public DruidLongPredicate makeLongPredicate() { return input -> Objects.equals(valueOrNull, String.valueOf(input)); } @Override public DruidFloatPredicate makeFloatPredicate() { return input -> Objects.equals(valueOrNull, String.valueOf(input)); } @Override public DruidDoublePredicate makeDoublePredicate() { return input -> Objects.equals(valueOrNull, String.valueOf(input)); } }; return new NoBitmapDimensionPredicateFilter(dimension, predicateFactory, extractionFn); } }
Source:
<code>public String findTitle() { <START> List<WebElement> elements = post.findElements(By.className("post-content__body")); <END> return elements.isEmpty() ? "" : elements.get(0).getText(); }</code><technical_language>post-content__title</technical_language>

Target:
public String findTitle() { List<WebElement> elements = post.findElements(By.className("post-content__title")); return elements.isEmpty() ? "" : elements.get(0).getText(); }
Source:
<code>protected Optional<ExampleProjectError> getError(OrganizationalUnit ou, ImportProject importProject) { if (this.projectImportService.exist(ou, importProject)) { <START> String errorPattern = "Already exist project <{1}> in space <{0}> "; <END> String errorMessage = MessageFormat.format(errorPattern, ou.getSpace().getName(), importProject.getName()); return Optional.of(new ExampleProjectError(NameAlreadyExistValidator.class.getCanonicalName(), errorMessage)); } else { return Optional.empty(); } }</code><technical_language>Minor fix: "Project <{1}> exists in space <{0}>"</technical_language>

Target:
protected Optional<ExampleProjectError> getError(OrganizationalUnit ou, ImportProject importProject) { if (this.projectImportService.exist(ou, importProject)) { String errorPattern = "Project <{1}> already exists in space <{0}>"; return Optional.of(new ExampleProjectError(NameAlreadyExistValidator.class.getCanonicalName(), errorPattern, ou.getSpace().getName(), importProject.getName())); } else { return Optional.empty(); } }
Source:
<code>public boolean processInvalidUrl(final WebView view, String url) { <START> final String methodName = ".processInvalidUrl"; <END> if (isBrokerRequest(getIntent()) && url.startsWith(AuthenticationConstants.Broker.REDIRECT_PREFIX)) { Logger.e(TAG + methodName, String.format( "The RedirectUri is not as expected. Received %s and expected %s", url, mRedirectUrl), "", ADALError.DEVELOPER_REDIRECTURI_INVALID); returnError(ADALError.DEVELOPER_REDIRECTURI_INVALID, String.format( "The RedirectUri is not as expected. Received %s and expected %s", url, mRedirectUrl)); view.stopLoading(); return true; } if(!url.toLowerCase(Locale.US).startsWith(AuthenticationConstants.Broker.REDIRECT_SSL_PREFIX)) { Logger.e(TAG + methodName, "The webview was redirected to an unsafe URL.", "", ADALError.WEBVIEW_REDIRECTURL_NOT_SSL_PROTECTED); returnError(ADALError.WEBVIEW_REDIRECTURL_NOT_SSL_PROTECTED, "The webview was redirected to an unsafe URL."); view.stopLoading(); return true; } return false; }</code><technical_language>nitpick: change . :? code I :, consistent. If want change later, file changes</technical_language>

Target:
public boolean processInvalidUrl(final WebView view, String url) { final String methodName = ":processInvalidUrl"; if (isBrokerRequest(getIntent()) && url.startsWith(AuthenticationConstants.Broker.REDIRECT_PREFIX)) { Logger.e(TAG + methodName, String.format( "The RedirectUri is not as expected. Received %s and expected %s", url, mRedirectUrl), "", ADALError.DEVELOPER_REDIRECTURI_INVALID); returnError(ADALError.DEVELOPER_REDIRECTURI_INVALID, String.format( "The RedirectUri is not as expected. Received %s and expected %s", url, mRedirectUrl)); view.stopLoading(); return true; } if(!url.toLowerCase(Locale.US).startsWith(AuthenticationConstants.Broker.REDIRECT_SSL_PREFIX)) { Logger.e(TAG + methodName, "The webview was redirected to an unsafe URL.", "", ADALError.WEBVIEW_REDIRECTURL_NOT_SSL_PROTECTED); returnError(ADALError.WEBVIEW_REDIRECTURL_NOT_SSL_PROTECTED, "The webview was redirected to an unsafe URL."); view.stopLoading(); return true; } return false; }
Source:
<code>public List<List<WebElement>> getColumns() { List<WebElement> firstRow = getWrappedElement().findElements( <START> By.cssSelector("tr:nth-of-type(1) > td")); <END> return IntStream.range(0, firstRow.size()) .mapToObj(i -> getWrappedElement().findElements( By.cssSelector("tr > td:nth-of-type(" + i + ")"))) .collect(toList()); }</code><technical_language>working prefetched columns faster (and more stable) findElements time</technical_language>

Target:
public List<List<WebElement>> getColumns() { List<List<WebElement>> columns = new ArrayList<>(); List<List<WebElement>> rows = getRows(); if (rows.isEmpty()) { return columns; } int columnCount = rows.get(0).size(); for (int i = 0; i < columnCount; i++) { List<WebElement> column = new ArrayList<>(); for (List<WebElement> row : rows) { column.add(row.get(i)); } columns.add(column); } return columns; }
Source:
<code><START> public DevicesResource<WatchDog, WatchDogs> getWatchdogsResource() { <END> return inject(new BackendWatchdogsResource(guid, VdcQueryType.GetWatchdog, new IdQueryParameters(guid))); }</code><technical_language>added dedicated interface "WatchdogsResource" method extensions/overrides, - please (in signature)</technical_language>

Target:
public WatchdogsResource getWatchdogsResource() { return inject(new BackendWatchdogsResource(guid, VdcQueryType.GetWatchdog, new IdQueryParameters(guid))); }
Source:
<code>public void onComplete() { <START> T v = value; <END> value = null; if (v != null) { actual.onSuccess(v); } else { actual.onComplete(); } }</code><technical_language>check done</technical_language>

Target:
public void onComplete() { if (done) { return; } done = true; T v = value; value = null; if (v != null) { actual.onSuccess(v); } else { actual.onComplete(); } }
Source:
<code>WildFlyLogContextSelectorImpl(final LogContextSelector defaultLogContextSelector) { final LogContextSelector dft; <START> if (defaultLogContextSelector instanceof WildFlyLogContextSelector) { <END> dft = ((WildFlyLogContextSelectorImpl) defaultLogContextSelector).defaultLogContextSelector; } else { dft = defaultLogContextSelector; } this.defaultLogContextSelector = dft; counter = new AtomicInteger(0); contextSelector = new ClassLoaderLogContextSelector(dft, true); threadLocalContextSelector = new ThreadLocalLogContextSelector(contextSelector); }</code><technical_language>Nit: check for instanceof interface cast concrete impl</technical_language>

Target:
WildFlyLogContextSelectorImpl(final LogContextSelector defaultLogContextSelector) { final LogContextSelector dft; if (defaultLogContextSelector instanceof WildFlyLogContextSelectorImpl) { dft = ((WildFlyLogContextSelectorImpl) defaultLogContextSelector).defaultLogContextSelector; } else { dft = defaultLogContextSelector; } this.defaultLogContextSelector = dft; counter = new AtomicInteger(0); contextSelector = new ClassLoaderLogContextSelector(dft, true); threadLocalContextSelector = new ThreadLocalLogContextSelector(contextSelector); }
Source:
<code>private List<Record> getRecordsForXLS(InputStream xls) throws IOException { List<Record> records = new ArrayList<>(); HSSFWorkbook wb = new HSSFWorkbook(xls); HSSFSheet sheet = wb.getSheetAt(0); for (int j = 0; j <= sheet.getLastRowNum(); j++) { HSSFRow row = sheet.getRow(j); if (row != null) { for (int i = 0; i < row.getLastCellNum(); i++) { HSSFCell cell = row.getCell(i); <START> if (cell != null) { <END> cell.setCellType(HSSFCell.CELL_TYPE_STRING); Record record = changeCellTypeToString(cell, i, j); if (record != null) { records.add(record); } } } } } return records; }</code><technical_language>a Objects.nonNull(cell) other places changes</technical_language>

Target:
private List<Record> getRecordsForXLS(InputStream xls) throws IOException { List<Record> records = new ArrayList<>(); HSSFWorkbook wb = new HSSFWorkbook(xls); HSSFSheet sheet = wb.getSheetAt(0); for (int j = 0; j <= sheet.getLastRowNum(); j++) { HSSFRow row = sheet.getRow(j); if (Objects.nonNull(row)) { for (int i = 0; i < row.getLastCellNum(); i++) { HSSFCell cell = row.getCell(i); if (Objects.nonNull(cell)) { cell.setCellType(HSSFCell.CELL_TYPE_STRING); Record record = changeCellTypeToString(cell, i, j); if (Objects.nonNull(record)) { records.add(record); } } } } } return records; }
Source:
<code>public KObjectMarshaller(String typeName) { this.typeName = typeName; <START> this.mainAttributes = Arrays.asList(MetaObject.META_OBJECT_ID, <END> MetaObject.META_OBJECT_TYPE, CLUSTER_ID, SEGMENT_ID, MetaObject.META_OBJECT_KEY, MetaObject.META_OBJECT_FULL_TEXT); }</code><technical_language>private static final unmodifiable too.</technical_language>

Target:
public KObjectMarshaller(String typeName) { this.typeName = typeName; }
Source:
<code>void setUp() { <START> Locale.setDefault(Locale.ENGLISH); <END> }</code><technical_language>I played get work LocaleResolver. mitigates concerns a bit this: java @BeforeEach void setUp() { LocaleContextHolder.setLocale(Locale.ENGLISH); } @AfterEach void tearDown() { LocaleContextHolder.resetLocaleContext(); }</technical_language>

Target:
void setUp() { LocaleContextHolder.setLocale(Locale.ENGLISH); }
Source:
<code>private ContentEquivalenceUpdatingWorker( EquivalenceGraphStore graphStore, DirectAndExplicitEquivalenceMigrator equivMigrator, String metricPrefix, MetricRegistry metricRegistry ) { this.graphStore = checkNotNull(graphStore); this.equivMigrator = checkNotNull(equivMigrator); this.metricRegistry = metricRegistry; this.executionTimer = metricRegistry.timer(metricPrefix + "timer.execution"); this.messageReceivedMeter = metricRegistry.meter(metricPrefix + "meter.received"); this.failureMeter = metricRegistry.meter(metricPrefix + "meter.failure"); <START> this.latencyTimer = metricRegistry.timer(metricPrefix + "latency.meter"); <END> this.publisherMeterName = metricPrefix + "%s.meter.received"; }</code><technical_language>Follow convention "meter.latency"? this for other reasons</technical_language>

Target:
private ContentEquivalenceUpdatingWorker( EquivalenceGraphStore graphStore, DirectAndExplicitEquivalenceMigrator equivMigrator, String metricPrefix, MetricRegistry metricRegistry ) { this.graphStore = checkNotNull(graphStore); this.equivMigrator = checkNotNull(equivMigrator); this.metricRegistry = metricRegistry; this.executionTimer = metricRegistry.timer(metricPrefix + "timer.execution"); this.messageReceivedMeter = metricRegistry.meter(metricPrefix + "meter.received"); this.failureMeter = metricRegistry.meter(metricPrefix + "meter.failure"); this.latencyTimer = metricRegistry.timer(metricPrefix + "timer.latency"); this.publisherMeterName = metricPrefix + "%s.meter.received"; }
Source:
<code>public void testCreateFeedbackResponse() { FeedbackQuestionAttributes fq = dataBundle.feedbackQuestions.get("qn1InSession1InCourse1"); StudentAttributes student = dataBundle.students.get("student3InCourse1"); fq = BackDoor.getFeedbackQuestion(fq.courseId, fq.feedbackSessionName, fq.questionNumber); FeedbackResponseAttributes fr = FeedbackResponseAttributes.builder() .withFeedbackResponseId(fq.getId() + "%" + student.email + "%" + student.email) .withFeedbackSessionName(fq.feedbackSessionName) .withCourseId(fq.courseId) .withFeedbackQuestionId(fq.getId()) .withFeedbackQuestionType(fq.questionType) .withGiver(student.email) .withGiverSection(student.section) .withRecipient(student.email) .withRecipientSection(student.section) <START> .withResponseMetaData(new Text("Student 3 self feedback")) <END> .build(); BackDoor.deleteFeedbackResponse(fr.feedbackQuestionId, fr.giver, fr.recipient); verifyAbsentInDatastore(fr); BackDoor.createFeedbackResponse(fr); verifyPresentInDatastore(fr); BackDoor.deleteFeedbackResponse(fr.feedbackQuestionId, fr.giver, fr.recipient); verifyAbsentInDatastore(fr); }</code><technical_language>if is more "dummy" instead of a magic (that out of nowhere)? more consistent created test dummy#attribute? I fine current a thought</technical_language>

Target:
public void testCreateFeedbackResponse() { FeedbackQuestionAttributes fq = dataBundle.feedbackQuestions.get("qn1InSession1InCourse1"); StudentAttributes student = dataBundle.students.get("student3InCourse1"); fq = BackDoor.getFeedbackQuestion(fq.courseId, fq.feedbackSessionName, fq.questionNumber); FeedbackResponseAttributes fr = FeedbackResponseAttributes.builder() .withFeedbackSessionName(fq.feedbackSessionName) .withCourseId(fq.courseId) .withFeedbackQuestionId(fq.getId()) .withFeedbackQuestionType(fq.questionType) .withGiver(student.email) .withGiverSection(student.section) .withRecipient(student.email) .withRecipientSection(student.section) .withResponseMetaData(new Text("Student 3 self feedback")) .build(); BackDoor.deleteFeedbackResponse(fr.feedbackQuestionId, fr.giver, fr.recipient); verifyAbsentInDatastore(fr); BackDoor.createFeedbackResponse(fr); verifyPresentInDatastore(fr); BackDoor.deleteFeedbackResponse(fr.feedbackQuestionId, fr.giver, fr.recipient); verifyAbsentInDatastore(fr); }
Source:
<code>private List<String> getAllLemmas(final String word, final String postag) { List<String> lemmasList = new ArrayList<>(); final List<String> keys = this.getDictKeys(word, postag); final List<String> keyValues = this.dictMap.get(keys); if (!keyValues.isEmpty()) { <START> for (String keyValue : keyValues) { <END> lemmasList.add(keyValue); } } else { lemmasList.add("O"); } return lemmasList; }</code><technical_language>lemmasList.addAll(keyValues) here</technical_language>

Target:
private List<String> getAllLemmas(final String word, final String postag) { List<String> lemmasList = new ArrayList<>(); final List<String> keys = this.getDictKeys(word, postag); final List<String> keyValues = this.dictMap.get(keys); if (!keyValues.isEmpty()) { lemmasList.addAll(keyValues); } else { lemmasList.add("O"); } return lemmasList; }
Source:
<code>public void sendInternalLarge(CoreMessage message, boolean direct) throws Exception { int headerSize = message.getHeadersAndPropertiesEncodeSize(); if (headerSize >= connection.getMinLargeMessageSize()) { throw BUNDLE.headerTooBig(); } StorageManager storageManager = ((ServerSessionImpl) session).getStorageManager(); long id = storageManager.generateID(); LargeServerMessage largeMessage = storageManager.createLargeMessage(id, message); <START> byte[] bytes = new byte[message.getBodyBuffer().readableBytes()]; <END> message.getBodyBuffer().readBytes(bytes); largeMessage.addBytes(bytes); largeMessage.releaseResources(); largeMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, bytes.length); session.send(largeMessage, direct); largeMessage = null; }</code><technical_language>getReadOnlyBuffer() ??? need cache bodyBuffer somewhere.. bodyBuffer = message.getReadONlyBuffer(); bodyBuffer</technical_language>

Target:
public void sendInternalLarge(CoreMessage message, boolean direct) throws Exception { int headerSize = message.getHeadersAndPropertiesEncodeSize(); if (headerSize >= connection.getMinLargeMessageSize()) { throw BUNDLE.headerTooBig(); } StorageManager storageManager = ((ServerSessionImpl) session).getStorageManager(); long id = storageManager.generateID(); LargeServerMessage largeMessage = storageManager.createLargeMessage(id, message); ActiveMQBuffer body = message.getReadOnlyBodyBuffer(); byte[] bytes = new byte[body.readableBytes()]; body.readBytes(bytes); largeMessage.addBytes(bytes); largeMessage.releaseResources(); largeMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, bytes.length); session.send(largeMessage, direct); largeMessage = null; }
Source:
<code>public void open() { String execType = getProperty("zeppelin.pig.execType"); if (execType == null) { execType = "mapreduce"; } String includeJobStats = getProperty("zeppelin.pig.includeJobStats"); if (includeJobStats != null) { this.includeJobStats = Boolean.parseBoolean(includeJobStats); } try { pigServer = new PigServer(execType); <START> } catch (IOException e) { <END> throw new RuntimeException("Fail to launch PigServer", e); } }</code><technical_language>LOGGER.error exception is rethrown? easier in log file</technical_language>

Target:
public void open() { String execType = getProperty("zeppelin.pig.execType"); if (execType == null) { execType = "mapreduce"; } String includeJobStats = getProperty("zeppelin.pig.includeJobStats"); if (includeJobStats != null) { this.includeJobStats = Boolean.parseBoolean(includeJobStats); } try { pigServer = new PigServer(execType); } catch (IOException e) { LOGGER.error("Fail to initialize PigServer", e); throw new RuntimeException("Fail to initialize PigServer", e); } }
Source:
<code>private void testGetForDeletedBlobWithoutIncludeDeleteOption(List<BlobId> blobIds) { try { store.get(blobIds, EnumSet.noneOf(StoreGetOptions.class)); <START> assertTrue( <END> "get should fail for a deleted blob, if StoreGetOptions.Store_Include_Deleted is not set in get options", false); } catch (StoreException e) { assertTrue( "get for deleted blob with with Store_Include_Deleted not set in get options should throw exception with " + StoreErrorCodes.ID_Deleted + " error code.", e.getErrorCode().equals(StoreErrorCodes.ID_Deleted)); } }</code><technical_language>fail</technical_language>

Target:
private void testGetForDeletedBlobWithoutIncludeDeleteOption(List<BlobId> blobIds) { try { store.get(blobIds, EnumSet.noneOf(StoreGetOptions.class)); fail("get should fail for a deleted blob, if StoreGetOptions.Store_Include_Deleted is not set in get options"); } catch (StoreException e) { assertEquals( "get for deleted blob with with Store_Include_Deleted not set in get options should throw exception with " + StoreErrorCodes.ID_Deleted + " error code.", e.getErrorCode(), StoreErrorCodes.ID_Deleted); } }
Source:
<code>public String getMessage(FormApiException exception) { if (exception.getType() == FormApiException.Type.UNKNOWN_HOST) { <START> return resources.getString(R.string.unknown_host_error, exception.getServerUrl()); <END> } return resources.getString(R.string.generic_network_error); }</code><technical_language>In this case want include "if happening, talk person asked collect data" message. I concatenating a space fine (and concat right LTR languages, I believe)</technical_language>

Target:
public String getMessage(FormApiException exception) { if (exception.getType() == FormApiException.Type.UNKNOWN_HOST) { return resources.getString(R.string.unknown_host_error, exception.getServerUrl()) + " " + resources.getString(R.string.report_to_project_lead); } return resources.getString(R.string.report_to_project_lead); }
Source:
<code>public void run() { HTInterval currentInterval = intervalQueue.blockingPeek(); while (currentInterval.getStartTime() != -1) { getSHT().insertInterval(currentInterval); intervalQueue.take(); currentInterval = intervalQueue.blockingPeek(); } if (currentInterval.getAttribute() != -1) { throw new IllegalStateException(); } getSHT().closeTree(currentInterval.getEndTime()); <START> return; <END> }</code><technical_language>is this line useless</technical_language>

Target:
public void run() { HTInterval currentInterval = intervalQueue.blockingPeek(); while (currentInterval.getStartTime() != -1) { getSHT().insertInterval(currentInterval); intervalQueue.take(); currentInterval = intervalQueue.blockingPeek(); } if (currentInterval.getAttribute() != -1) { throw new IllegalStateException(); } getSHT().closeTree(currentInterval.getEndTime()); }
Source:
<code>public static int getIntegerValueFromDatabase(Connection dbConnection, String sqlStmt, Object... params) throws UserStoreException { int value = -1; try (PreparedStatement prepStmt = dbConnection.prepareStatement(sqlStmt)){ if (params != null && params.length > 0) { for (int i = 0; i < params.length; i++) { Object param = params[i]; if (param == null) { throw new UserStoreException("Null data provided."); } else if (param instanceof String) { prepStmt.setString(i + 1, (String) param); } else if (param instanceof Integer) { prepStmt.setInt(i + 1, (Integer) param); } } } try(ResultSet rs = prepStmt.executeQuery()) { if (rs.next()) { <START> value = rs.getInt(1); <END> } return value; } } catch (SQLException e) { String errorMessage = "Using sql : " + sqlStmt + " " + e.getMessage(); if (log.isDebugEnabled()) { log.debug(errorMessage, e); } throw new UserStoreException(errorMessage, e); } }</code><technical_language>try-with-resource pattern automatically handles ResultSet PreparedStatement objects, Connection, "dbConnection" in this scope, needs closed "DatabaseUtil.closeAllConnections(dbConnection);"</technical_language>

Target:
public static int getIntegerValueFromDatabase(Connection dbConnection, String sqlStmt, Object... params) throws UserStoreException { int value = -1; try (PreparedStatement prepStmt = dbConnection.prepareStatement(sqlStmt)){ if (params != null && params.length > 0) { for (int i = 0; i < params.length; i++) { Object param = params[i]; if (param == null) { throw new UserStoreException("Null data provided."); } else if (param instanceof String) { prepStmt.setString(i + 1, (String) param); } else if (param instanceof Integer) { prepStmt.setInt(i + 1, (Integer) param); } } } try(ResultSet rs = prepStmt.executeQuery()) { if (rs.next()) { value = rs.getInt(1); } return value; } } catch (SQLException e) { String errorMessage = "Using sql : " + sqlStmt + " " + e.getMessage(); if (log.isDebugEnabled()) { log.debug(errorMessage, e); } throw new UserStoreException(errorMessage, e); }finally { close(dbConnection); } }
Source:
<code>protected void updateData(long start, long end, int nb, @Nullable IProgressMonitor monitor) { double x[] = getXAxis(start, end, nb); setXAxis(x); final double y[] = new double[nb]; final long yLong[] = new <START> long[nb]; Arrays.fill(y, 0.0); <END> for (ITmfTrace trace : TmfTraceManager.getTraceSet(getTrace())) { final TmfStatisticsModule statsMod = TmfTraceUtils.getAnalysisModuleOfClass(trace, TmfStatisticsModule.class, TmfStatisticsModule.ID); if (statsMod == null) { continue; } statsMod.waitForInitialization(); final ITmfStatistics stats = Objects.requireNonNull(statsMod.getStatistics()); List<Long> values = stats.histogramQuery(start, end, nb); for (int i = 0; i < nb; i++) { yLong[i] += values.get(i); } } for (int i = 0; i < nb; i++) { y[i] += yLong[i]; } setSeries("Number of events", y); updateDisplay(); }</code><technical_language>double arrays 0.0 default</technical_language>

Target:
protected void updateData(long start, long end, int nb, @Nullable IProgressMonitor monitor) { double[] x = getXAxis(start, end, nb); setXAxis(x); final double[] y = new double[nb]; final long[] yLong = new long[nb]; for (ITmfTrace trace : TmfTraceManager.getTraceSet(getTrace())) { final TmfStatisticsModule statsMod = TmfTraceUtils.getAnalysisModuleOfClass(trace, TmfStatisticsModule.class, TmfStatisticsModule.ID); if (statsMod == null) { continue; } statsMod.waitForInitialization(); final ITmfStatistics stats = Objects.requireNonNull(statsMod.getStatistics()); List<Long> values = stats.histogramQuery(start, end, nb); for (int i = 0; i < nb; i++) { yLong[i] += values.get(i); } } for (int i = 0; i < nb; i++) { y[i] = yLong[i]; } setSeries("Number of events", y); updateDisplay(); }
Source:
<code>public void addProperty(String p_key, String p_value) { <START> logger.debug("addProperty Key : " + p_key + ", Value : " + p_value); <END> m_properties.put(p_key, p_value); }</code><technical_language>parameterized logging instead of string concatenation</technical_language>

Target:
public void addProperty(String p_key, String p_value) { logger.debug("addProperty Key : {}, Value : {}", p_key, p_value); m_properties.put(p_key, p_value); }
Source:
<code>private long parseValueAsLong() { try { return Long.parseLong(value.toString()); } catch (NumberFormatException ex) { throw new NumberFormatException(RedisConstants.ERROR_NOT_LONG); <END> } <START> }</code><technical_language>I understand thinking here. However, want match errors returned Redis, is returning integer error. a Java long instead of integer integer's storage capacity large enough, Redis [INCR docs](<LINK_0> string stored key is interpreted a base-10 64 bit signed integer</technical_language>

Target:
private long parseValueAsLong() { try { return Long.parseLong(value.toString()); } catch (NumberFormatException ex) { throw new NumberFormatException(RedisConstants.ERROR_NOT_INTEGER); } }
Source:
<code>public double asFloat() { boolean negative = false; int i = offset; if (bytes[i] == '-') { negative = true; i++; } long significand = 0; byte b = 0; while (i < offset + length) { b = bytes[i++]; if (b < '0' || b > '9') break; significand = 10 * significand + b - '0'; } if (b != '.' && i < offset + length) notFloat(); int exponent = 0; while (i < offset + length) { b = bytes[i++]; if (b < '0' || b > '9') notFloat(); significand = 10 * significand + b - '0'; exponent++; } <START> double x = exponent != 0 ? significand / POWERS_OF_TEN[exponent] : significand; <END> return negative ? -x : +x; }</code><technical_language>drop this conditional write POWERS_OF_TEN[0] == 1: double x = significand / POWERS_OF_TEN[exponent]; for benchmark decide</technical_language>

Target:
public double asFloat() { boolean negative = false; int i = offset; if (bytes[i] == '-') { negative = true; i++; } long significand = 0; byte b = 0; while (i < offset + length) { b = bytes[i++]; if (b < '0' || b > '9') break; significand = 10 * significand + b - '0'; } if (b != '.' && i < offset + length) notFloat(); int exponent = 0; while (i < offset + length) { b = bytes[i++]; if (b < '0' || b > '9') notFloat(); significand = 10 * significand + b - '0'; exponent++; } double x = significand / POWERS_OF_TEN[exponent]; return negative ? -x : +x; }
Source:
<code>public ProcessEditPage editProcess() throws Exception { if (isNotAt()) { goTo(); } <START> clickButtonAndWaitForRedirect(editProcessLink, Pages.getProjectEditPage().getUrl()); <END> return Pages.getProcessEditPage(); }</code><technical_language>Edit process project? ;-) click editProcess Link wait for redirect editProject page</technical_language>

Target:
public ProcessEditPage editProcess() throws Exception { if (isNotAt()) { goTo(); } clickButtonAndWaitForRedirect(editProcessLink, Pages.getProcessEditPage().getUrl()); return Pages.getProcessEditPage(); }
Source:
<code>private static void verifyInputFile(Map<String, List<String>> allTests, boolean skipFileNaming, String path, String fileName) { <START> if (!skipFileNaming) { <END> List<String> classes; int slash = path.lastIndexOf(File.separatorChar); String packge = path.substring(0, slash); boolean found = false; for (int depth = 0; depth < 4; depth++) { final String folderPath = packge; slash = packge.lastIndexOf(File.separatorChar); packge = path.substring(0, slash); classes = allTests.get(packge); if (classes != null && checkInputMatchCorrectFileStructure(classes, folderPath, skipFileNaming, fileName)) { found = true; break; } } assertTrue(found, "Resource must be named after a Test like 'InputMyCustomCase.java' " + "and be in the sub-package of the test like 'mycustom' " + "for test 'MyCustomCheckTest': " + path); } }</code><technical_language>please review PR more time, remove unrelated changes</technical_language>

Target:
private static void verifyInputFile(Map<String, List<String>> allTests, boolean skipFileNaming, String path, String fileName) { List<String> classes; int slash = path.lastIndexOf(File.separatorChar); String packge = path.substring(0, slash); boolean found = false; for (int depth = 0; depth < 4; depth++) { final String folderPath = packge; slash = packge.lastIndexOf(File.separatorChar); packge = path.substring(0, slash); classes = allTests.get(packge); if (classes != null && checkInputMatchCorrectFileStructure(classes, folderPath, skipFileNaming, fileName)) { found = true; break; } } assertTrue(found, "Resource must be named after a Test like 'InputMyCustomCase.java' " + "and be in the sub-package of the test like 'mycustom' " + "for test 'MyCustomCheckTest': " + path); }
Source:
<code>public List<String> getGroupsWithPermission(final Type type) { <START> final ArrayList<String> groups = new ArrayList<>(); <END> for (final Map.Entry<String, Permission> entry : this.groupPermissionMap.entrySet()) { final Permission perm = entry.getValue(); if (perm.isPermissionSet(type)) { groups.add(entry.getKey()); } } return groups; }</code><technical_language>" List<String>" instead of ArrayList<String> in declaration</technical_language>

Target:
public List<String> getGroupsWithPermission(final Type type) { final List<String> groups = new ArrayList<>(); for (final Map.Entry<String, Permission> entry : this.groupPermissionMap.entrySet()) { final Permission perm = entry.getValue(); if (perm.isPermissionSet(type)) { groups.add(entry.getKey()); } } return groups; }
Source:
<code>public static Location fromValue(String v) { try { return valueOf(v); } catch (IllegalArgumentException ex) { return UNRECOGNIZED; <START> } <END> }</code><technical_language>here. a consistent approach in enums</technical_language>

Target:
public static Location fromValue(String v) { return Enums .getIfPresent(Location.class, v) .or(UNRECOGNIZED); }
Source:
<code>public void notifyRefReplicated(String project, String ref, URIish uri, RefPushResult status) { pushProcessing.onOneNodeReplicated(project, ref, uri, status); countingLock.lock(); try { finishedPushCount++; if (!allScheduled) { return; } if (finishedPushCount < totalPushCount) { return; } } finally { countingLock.unlock(); } pushProcessing.onAllNodesReplicated(); <START> if (type == ReplicationType.COMMAND) { <END> allPushTasksFinished.countDown(); } }</code><technical_language>Agreed, Done</technical_language>

Target:
public void notifyRefReplicated(String project, String ref, URIish uri, RefPushResult status) { pushResultProcessing.onOneNodeReplicated(project, ref, uri, status); countingLock.lock(); try { finishedPushTasksCount++; if (!allScheduled) { return; } if (finishedPushTasksCount < totalPushTasksCount) { return; } } finally { countingLock.unlock(); } doAllPushTasksCompleted(); }
Source:
<code>public int remove(Filter filter) { LOGGER.info("removing statuses matching " + filter); int ret = 0; DefaultTransaction transaction = new DefaultTransaction("create"); try { SimpleFeatureSource source = statuses.getFeatureSource(STATUS); SimpleFeatureCollection features = source.getFeatures(filter); ret = features.size(); if (ret == 0) { return ret; } SimpleFeatureIterator itr = features.features(); itr.close(); <START> if (source instanceof SimpleFeatureStore) { <END> SimpleFeatureStore store = (SimpleFeatureStore) source; store.setTransaction(transaction); store.removeFeatures(filter); transaction.commit(); } } catch (IOException e) { e.printStackTrace(); try { transaction.rollback(); } catch (IOException e1) { } } finally { transaction.close(); } return ret; }</code><technical_language>inefficient, call removeFeatures(Filter)</technical_language>

Target:
public int remove(Filter filter) { LOGGER.fine("removing statuses matching " + filter); int ret = 0; DefaultTransaction transaction = new DefaultTransaction("create"); try { SimpleFeatureSource source = statuses.getFeatureSource(fixTableName(STATUS)); Filter fixedFilter = fixFilter(filter); SimpleFeatureCollection features = source.getFeatures(fixedFilter); ret = features.size(); if (ret == 0) { return ret; } if (source instanceof SimpleFeatureStore) { SimpleFeatureStore store = (SimpleFeatureStore) source; store.setTransaction(transaction); store.removeFeatures(fixedFilter); transaction.commit(); } else { LOGGER.info("Readonly status store found, probably not what you wanted"); } } catch (IOException e) { LOGGER.info("failed to remove WPS Status matching " + filter); LOGGER.log(Level.FINE,"failed to remove WPS Status matching " + filter,e); try { transaction.rollback(); } catch (IOException e1) { } } finally { transaction.close(); } return ret; }
Source:
<code><START> public void testgetSqlString() { <END> List<String> streams = Collections.singletonList("kafka_stream_1"); List<String> gbk = Collections.singletonList("a.b.c"); List<Projection> projections = Collections.singletonList(new Projection("f1.g.h", null, null, null)); String sql = streamCatalogService.getSqlString(streams, projections, "x = y", gbk); assertEquals("SELECT f1['g']['h'] FROM kafka_stream_1 WHERE x = y GROUP BY a['b']['c']", sql); projections = Collections.singletonList(new Projection(null, "foo", Arrays.asList("a.b", "kafka_stream_1.c.d"), "res")); sql = streamCatalogService.getSqlString(streams, projections, "x = y", gbk); assertEquals("SELECT foo(a['b'],kafka_stream_1.c['d']) AS \"res\" FROM kafka_stream_1 WHERE x = y GROUP BY a['b']['c']", sql); }</code><technical_language>show conversion is applied statement: changing x = y f1.a.b = kafka_stream_1.g.h</technical_language>

Target:
public void testgetSqlString() { List<String> streams = Collections.singletonList("kafka_stream_1"); List<String> gbk = Collections.singletonList("a.b.c"); List<Projection> projections = Collections.singletonList(new Projection("f1.g.h", null, null, null)); String sql = streamCatalogService.getSqlString(streams, projections, "f1.a.b = kafka_stream_1.g.h", gbk); assertEquals("SELECT f1['g']['h'] FROM kafka_stream_1 WHERE f1['a']['b'] = kafka_stream_1.g['h'] GROUP BY a['b']['c']", sql); projections = Collections.singletonList(new Projection(null, "foo", Arrays.asList("a.b", "kafka_stream_1.c.d"), "res")); sql = streamCatalogService.getSqlString(streams, projections, "f1.a.b = kafka_stream_1.g.h", gbk); assertEquals("SELECT foo(a['b'],kafka_stream_1.c['d']) AS \"res\" FROM kafka_stream_1 WHERE f1['a']['b'] = kafka_stream_1.g['h'] GROUP BY a['b']['c']", sql); }
Source:
<code>public void run() { final IRunnableWithProgress generateCodeRunnable = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Generating Code", IProgressMonitor.UNKNOWN); final ResourceSet resourceSet = (ResourceSet) currentObject; final GenModel genmodel = (GenModel) resourceSet.getResources().get(0).getContents().get(0); genmodel.reconcile(); genmodel.setCanGenerate(true); final Generator generator = GenModelUtil.createGenerator(genmodel); for (final Object type : types) { generator.generate(genmodel, type, new BasicMonitor.EclipseSubProgress(monitor, 1)); } } }; try { new ProgressMonitorDialog(Display.getCurrent().getActiveShell()).run(true, false, generateCodeRunnable); } catch (final InvocationTargetException e) { <START> e.printStackTrace(); <END> } catch (final InterruptedException e) { e.printStackTrace(); } }</code><technical_language>reportservice</technical_language>

Target:
public void run() { final IRunnableWithProgress generateCodeRunnable = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Generating Code", IProgressMonitor.UNKNOWN); final ResourceSet resourceSet = (ResourceSet) currentObject; final GenModel genmodel = (GenModel) resourceSet.getResources().get(0).getContents().get(0); genmodel.reconcile(); genmodel.setCanGenerate(true); final Generator generator = GenModelUtil.createGenerator(genmodel); for (final Object type : types) { generator.generate(genmodel, type, new BasicMonitor.EclipseSubProgress(monitor, 1)); } } }; try { new ProgressMonitorDialog(Display.getCurrent().getActiveShell()).run(true, false, generateCodeRunnable); } catch (final InvocationTargetException ex) { Activator.getDefault().getReportService().report( new StatusReport(new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex))); } catch (final InterruptedException ex) { Activator.getDefault().getReportService().report( new StatusReport(new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex))); } }
Source:
<code>public int getDurationInYears() { <START> return Float.valueOf(getDegreeStructure().getAcademicPeriod().getWeight()).intValue(); <END> }</code><technical_language>degreeStructure relation is required existing data contains DegreeCurricularPlans a CurricularPeriod. relation required existing data properly filled, done in next major. For now, accesses getDegreeStructure() safeguarded nulls duration returned degree type a fallback option</technical_language>

Target:
public int getDurationInYears() { final AcademicPeriod academicPeriod = getDegreeStructure() != null ? getDegreeStructure().getAcademicPeriod() : getDegreeType().getAcademicPeriod(); return Float.valueOf(academicPeriod.getWeight()).intValue(); }
Source:
<code>public MetadataResolutionResult addError( Exception e ) { if ( exceptions == null ) { exceptions = initList( exceptions ); } exceptions.add( e ); <START> return this; <END> }</code><technical_language>Please remove whitespace</technical_language>

Target:
public MetadataResolutionResult addError( Exception e ) { exceptions = initList( exceptions ); exceptions.add( e ); return this; }
Source:
<code>public void worldTick(TickEvent.WorldTickEvent event) { if (ENABLE && !event.world.isRemote ) { <START> if(ticks++ > 60) <END> { ticks = 0; World w = event.world; List<EntityLivingBase> list = w.getEntities(EntityLivingBase.class, new Predicate<EntityLivingBase>() { public boolean test(EntityLivingBase e) { return e.isAlive(); }; }); for(EntityLivingBase liv : list) { IAttributeInstance grav = liv.getAttribute(EntityLivingBase.ENTITY_GRAVITY); boolean inPlains = liv.world.getBiome(liv.getPosition()).getCategory() == Category.PLAINS; if(inPlains && !grav.hasModifier(REDUCED_GRAVITY)) { logger.info("Granted low gravity to Entity: {}", liv); grav.applyModifier(REDUCED_GRAVITY); } else if(!inPlains && grav.hasModifier(REDUCED_GRAVITY)) { logger.info("Removed low gravity from Entity: {}", liv); grav.removeModifier(REDUCED_GRAVITY); } } } } }</code><technical_language>Please fix formatting in this file. for example: suggestion if (ticks++ > 60)</technical_language>

Target:
public void worldTick(TickEvent.WorldTickEvent event) { if (ENABLE && !event.world.isRemote) { if (ticks++ > 60) { ticks = 0; World w = event.world; List<LivingEntity> list; if(w.isRemote) { ClientWorld cw = (ClientWorld) w; list = new ArrayList<>(100); for(Entity e : cw.func_217416_b()) { if(e.isAlive()) { if(e instanceof LivingEntity) { list.add((LivingEntity) e); } } } } else { ServerWorld sw = (ServerWorld) w; Stream<LivingEntity> s = sw.getEntities().filter(Entity::isAlive).filter(e -> e instanceof LivingEntity).map(e -> (LivingEntity)e); list = s.collect(Collectors.toList()); } for(LivingEntity liv : list) { IAttributeInstance grav = liv.getAttribute(LivingEntity.ENTITY_GRAVITY); boolean inPlains = liv.world.getBiome(liv.getPosition()).getCategory() == Category.PLAINS; if (inPlains && !grav.hasModifier(REDUCED_GRAVITY)) { logger.info("Granted low gravity to Entity: {}", liv); grav.applyModifier(REDUCED_GRAVITY); } else if (!inPlains && grav.hasModifier(REDUCED_GRAVITY)) { logger.info("Removed low gravity from Entity: {}", liv); grav.removeModifier(REDUCED_GRAVITY); } } } } }
Source:
<code>public void experimentUpdated(TmfExperimentUpdatedSignal signal) { TmfExperiment experiment = signal.getExperiment(); if (!experiment.equals(TmfExperiment.getCurrentExperiment())) { return; <START> } <END> requestData(experiment, experiment.getTimeRange()); }</code><technical_language>changes a check for number of events avoid sending of unnecessary requests (in TmfStatisticsView) /* * In normal case, statistics request is coalesced indexing * number of events same, is do. if * case, trigger a new request count new events. */ if (nbEvents < experiment.getNbEvents()) { requestData(experiment, experiment.getTimeRange()); } I debugged I in version requestData() is called this method. I need put this check back. This signal handler exoerimentUpdated() introduced fix bug 382438</technical_language>

Target:
public void experimentUpdated(TmfExperimentUpdatedSignal signal) { TmfExperiment experiment = signal.getExperiment(); if (!experiment.equals(TmfExperiment.getCurrentExperiment())) { return; } long nbEvents = 0; if (fRequest != null) { nbEvents = fRequest.getLastEventIndex(); } if (nbEvents < experiment.getNbEvents()) { requestData(experiment, experiment.getTimeRange()); } }
Source:
<code>private Iterable<Payload> doSlice(InputStream rawContent, ContentMetadata meta) { return new PayloadIterator(rawContent, meta); <START> } <END></code><technical_language>doSlice methods static? Also, protected overridden</technical_language>

Target:
protected Iterable<Payload> doSlice(InputStream rawContent, ContentMetadata meta) { return new PayloadIterator(rawContent, meta); }