auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void tearDown() throws Exception { uninstallShimApexIfNecessary(); <START> getDevice().deleteFile(SYSTEM_TRIGGER_WATCHDOG_RC); getDevice().deleteFile(SYSTEM_TRIGGER_WATCHDOG_SH); <END> }</code><technical_language>I need call getDevice().remountSystemWritable() deleting</technical_language>

Target:
public void tearDown() throws Exception { uninstallShimApexIfNecessary(); ITestDevice device = getDevice(); if (device.doesFileExist(SYSTEM_TRIGGER_WATCHDOG_RC) || device.doesFileExist(SYSTEM_TRIGGER_WATCHDOG_SH)) { device.remountSystemWritable(); device.deleteFile(SYSTEM_TRIGGER_WATCHDOG_RC); device.deleteFile(SYSTEM_TRIGGER_WATCHDOG_SH); } }
Source:
<code>public synchronized Collection<MetaAnnotation> getAnnotations() { final Annotation[] array; if (_annotationsCache != null) { array = _annotationsCache; } else { <START> array = _annotationsCache = getEnclosedMetaObject().getAnnotations(); <END> } return Arrays.stream(array).map(JavaReflectionAnnotation::new).collect(Collectors.toList()); }</code><technical_language>I get rid of this cache cache entire result (i.e. collection of MetaAnnotations, array of Java annotations)</technical_language>

Target:
public synchronized Collection<MetaAnnotation> getAnnotations() { return Arrays.stream(getEnclosedMetaObject().getAnnotations()).map(JavaReflectionAnnotation::new).collect(toList()); }
Source:
<code>List<Message> validateConditions() throws IOException, WorkbookParserException { final List<Message> messageList = new ArrayList<>(); final Workbook wb = this.etlService.retrieveCurrentWorkbook(this.userSelection); if (wb.getNumberOfSheets() > 1) { final Sheet sheet1 = wb.getSheetAt(ETLServiceImpl.DESCRIPTION_SHEET); <START> if (sheet1 != null && "Description".equalsIgnoreCase(sheet1.getSheetName())) { <END> final org.generationcp.middleware.domain.etl.Workbook referenceWorkbook = this.dataImportService .parseWorkbookDescriptionSheet(wb, this.contextUtil.getCurrentIbdbUserId()); final List<String> variableWithWrongPSM = new ArrayList<>(); for(MeasurementVariable measurementVariable: referenceWorkbook.getConditions()) { final Term term = this.termDataManager.getTermByNameAndCvId(measurementVariable.getName(), CvId.VARIABLES.getId()); if(term != null) { Variable variable = this.ontologyVariableDataManager.getVariable(this.contextUtil.getCurrentProgramUUID(), term.getId(), true); if (variable != null && this.variableHasWrongPSM(measurementVariable, variable)) { variableWithWrongPSM.add(measurementVariable.getName()); } } } if(!variableWithWrongPSM.isEmpty()) { messageList.add(new Message("error.variable.wrong.psm", StringUtils.join(variableWithWrongPSM, ", "))); } } } return messageList; }</code><technical_language>Extract "Description" constant</technical_language>

Target:
List<Message> validateConditions() throws IOException, WorkbookParserException { final List<Message> messageList = new ArrayList<>(); final Workbook wb = this.etlService.retrieveCurrentWorkbook(this.userSelection); if (wb.getNumberOfSheets() > 1) { final Sheet sheet1 = wb.getSheetAt(ETLServiceImpl.DESCRIPTION_SHEET); if (AngularSelectSheetController.DESCRIPTION.equalsIgnoreCase(sheet1.getSheetName())) { final org.generationcp.middleware.domain.etl.Workbook referenceWorkbook = this.dataImportService .parseWorkbookDescriptionSheet(wb, this.contextUtil.getCurrentIbdbUserId()); final List<String> variablesWithWrongPSM = new ArrayList<>(); for(MeasurementVariable measurementVariable: referenceWorkbook.getConditions()) { Set<StandardVariable> standardVariables = this.ontologyDataManager.findStandardVariablesByNameOrSynonym(measurementVariable.getName(), this.contextUtil.getCurrentProgramUUID()); if(!CollectionUtils.isEmpty(standardVariables) && this.variableHasWrongPSM(measurementVariable, standardVariables)) { variablesWithWrongPSM.add(measurementVariable.getName()); } } if(!variablesWithWrongPSM.isEmpty()) { messageList.add(new Message("error.variable.wrong.psm", StringUtils.join(variablesWithWrongPSM, ", "))); } } } return messageList; }
Source:
<code>private String getDerivedOriginalFileName() { FileMetadata fm = getFileMetadata(); String filename = fm.getLabel(); String originalExtension = FileUtil.generateOriginalExtension(getOriginalFileFormat()); String extensionToRemove = StringUtil.substringIncludingLast(filename, "."); if (StringUtil.nonEmpty(extensionToRemove)) { String newFileName = filename.replace(extensionToRemove, originalExtension); return newFileName; <START> } <END> return filename; }</code><technical_language>@sekmiller I reading this correctly - if current filename extension ("foo"), this code return "foo"? - return "foo.<ORIG_EXT>"? (although this happen - ingested files ".tab" extension) (also, checked for this "no extension" case before. OCD though, if call .replace(".tab", ".dta") exotic "datafile.tabular.tab" return "datafile.dtaular.dta". code in StoredOriginalFile.java - I regex version of replace there: .replaceAll(".tab$", ".dta"), replacing end part</technical_language>

Target:
private String getDerivedOriginalFileName() { FileMetadata fm = getFileMetadata(); String filename = fm.getLabel(); String originalExtension = FileUtil.generateOriginalExtension(getOriginalFileFormat()); String extensionToRemove = StringUtil.substringIncludingLast(filename, "."); if (StringUtil.nonEmpty(extensionToRemove)) { return filename.replaceAll(extensionToRemove + "$", originalExtension); } else{ return filename + originalExtension ; } }
Source:
<code>private void transactionInfo(GridClient client, VisorTxTaskArg arg) throws GridClientException { IgniteProductVersion ver = FetchNearXidVersionTask.TX_INFO_SINCE_VER; validateProductVersion(client, ver); GridCacheVersion nearXidVer = executeTask(client, FetchNearXidVersionTask.class, arg.txInfoArgument()); boolean histMode = false; if (nearXidVer != null) { log("Resolved transaction near XID version: " + nearXidVer); arg.txInfoArgument(new TxVerboseId(null, nearXidVer)); } else { log("Active transactions not found."); if (arg.txInfoArgument().gridCacheVersion() != null) { log("Will try to peek history to find out whether transaction was committed / rolled back."); histMode = true; } else { log("You can specify transaction in GridCacheVersion format in order to peek history " + "to find out whether transaction was committed / rolled back."); return; } } Map<ClusterNode, VisorTxTaskResult> res = executeTask(client, VisorTxTask.class, arg); lastOperationRes = res; if (histMode) printTxInfoHistoricalResult(res); else printTxInfoResult(res); <START> <END> }</code><technical_language>Extra lines</technical_language>

Target:
private void transactionInfo(GridClient client, VisorTxTaskArg arg) throws GridClientException { checkFeatureSupportedByCluster(client, IgniteFeatures.TX_INFO_COMMAND, true); GridCacheVersion nearXidVer = executeTask(client, FetchNearXidVersionTask.class, arg.txInfoArgument()); boolean histMode = false; if (nearXidVer != null) { log("Resolved transaction near XID version: " + nearXidVer); arg.txInfoArgument(new TxVerboseId(null, nearXidVer)); } else { log("Active transactions not found."); if (arg.txInfoArgument().gridCacheVersion() != null) { log("Will try to peek history to find out whether transaction was committed / rolled back."); histMode = true; } else { log("You can specify transaction in GridCacheVersion format in order to peek history " + "to find out whether transaction was committed / rolled back."); return; } } Map<ClusterNode, VisorTxTaskResult> res = executeTask(client, VisorTxTask.class, arg); lastOperationRes = res; if (histMode) printTxInfoHistoricalResult(res); else printTxInfoResult(res); }
Source:
<code>public String getLocalName() { String hostName = exchange.getDestinationAddress().getHostName(); <START> if (hostName == null) { <END> return exchange.getDestinationAddress().getHostString(); } return hostName; }</code><technical_language>@tmiyargi @fl4via and/or @stuartwdouglas a final this one. a lurker in this project. that, I compatiblity of this play a role here, this bug fix is fixing a wrong retuned, this change</technical_language>

Target:
public String getLocalName() { return exchange.getDestinationAddress().getHostName(); }
Source:
<code>public MBObjectStops(MBLayer layer) { try { <START> if(getStops(layer.getPaint()) || getStops(layer.getPaint())){ <END> stops = getStopLevels(layer); layersForStop = getLayerStyleForStops(layer, stops); ranges = getStopLevelRanges(stops); } } catch (ParseException e) { System.out.println(e.getLocalizedMessage()); } }</code><technical_language>need null checks, else getStops throw NPE if paint layout present (which is perfectly valid for some layers)</technical_language>

Target:
public MBObjectStops(MBLayer layer) { try { if (layer.getPaint() != null) { hasStops = getStops(layer.getPaint()); } if (layer.getLayout() != null) { hasStops = getStops(layer.getLayout()); } if (hasStops) { stops = getStopLevels(layer); layersForStop = getLayerStyleForStops(layer, stops); ranges = getStopLevelRanges(stops); } } catch (ParseException e) { System.out.println(e.getLocalizedMessage()); } }
Source:
<code>public JSONArray getTargetedSequencingTypes(Long libraryPrepKitId) throws IOException { Collection<TargetedSequencing> targetedSequencings = getNonArchivedTargetedSequencing( requestManager.listAllTargetedSequencing()); JSONArray fullTargetedSequencingCollection = new JSONArray(); JSONArray targetedSequencingByKit = new JSONArray(); for (TargetedSequencing targetedSequencing : targetedSequencings) { Map<String, Object> targetedSequencingMap = Maps.newHashMap(); targetedSequencingMap.put("targetedSequencingId", targetedSequencing.getId()); targetedSequencingMap.put("alias", targetedSequencing.getAlias()); for (KitDescriptor kitDescriptor : targetedSequencing.getKitDescriptors()) { targetedSequencingMap.put("kitDescriptorId", kitDescriptor.getId()); fullTargetedSequencingCollection.add(targetedSequencingMap); if (libraryPrepKitId != null && libraryPrepKitId.equals(kitDescriptor.getId())) { targetedSequencingByKit.add(targetedSequencingMap); <START> } <END> } } if (libraryPrepKitId != null) { return targetedSequencingByKit; } else { return fullTargetedSequencingCollection; } }</code><technical_language>This method greatly simplified - fetch kitDescriptor id get targetedSequencings instead of this</technical_language>

Target:
public JSONArray getTargetedSequencingTypes(Long libraryPrepKitId) throws IOException { JSONArray targetedSequencingByKit = new JSONArray(); for (TargetedSequencing targetedSequencing : getNonArchivedTargetedSequencing( kitService.getKitDescriptorById(libraryPrepKitId).getTargetedSequencing())) { Map<String, Object> targetedSequencingMap = Maps.newHashMap(); targetedSequencingMap.put("targetedSequencingId", targetedSequencing.getId()); targetedSequencingMap.put("alias", targetedSequencing.getAlias()); targetedSequencingMap.put("kitDescriptorId", libraryPrepKitId); targetedSequencingByKit.add(targetedSequencingMap); } return targetedSequencingByKit; }
Source:
<code>public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { if (e.getMessage() instanceof ThriftMessage) { ThriftMessage message = (ThriftMessage) e.getMessage(); <START> if (taskTimeoutMillis > 0 || queueTimeoutMillis > 0) { <END> message.setProcessStartTimeMillis(System.currentTimeMillis()); } checkResponseOrderingRequirements(ctx, message); TNiftyTransport messageTransport = new TNiftyTransport(ctx.getChannel(), message); TTransportPair transportPair = TTransportPair.fromSingleTransport(messageTransport); TProtocolPair protocolPair = duplexProtocolFactory.getProtocolPair(transportPair); TProtocol inProtocol = protocolPair.getInputProtocol(); TProtocol outProtocol = protocolPair.getOutputProtocol(); processRequest(ctx, message, messageTransport, inProtocol, outProtocol); } else { ctx.sendUpstream(e); } }</code><technical_language>unconditionally</technical_language>

Target:
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { if (e.getMessage() instanceof ThriftMessage) { ThriftMessage message = (ThriftMessage) e.getMessage(); message.setProcessStartTimeMillis(System.currentTimeMillis()); checkResponseOrderingRequirements(ctx, message); TNiftyTransport messageTransport = new TNiftyTransport(ctx.getChannel(), message); TTransportPair transportPair = TTransportPair.fromSingleTransport(messageTransport); TProtocolPair protocolPair = duplexProtocolFactory.getProtocolPair(transportPair); TProtocol inProtocol = protocolPair.getInputProtocol(); TProtocol outProtocol = protocolPair.getOutputProtocol(); processRequest(ctx, message, messageTransport, inProtocol, outProtocol); } else { ctx.sendUpstream(e); } }
Source:
<code>private CodecConfigurationException setError(final Exception cause) { <START> return new CodecConfigurationException(format("Unable to get value for property '%s' in %s", propertyMetadata.getName(), <END> propertyMetadata.getTypeData().getType()), cause); }</code><technical_language>read "Unable set..."</technical_language>

Target:
private CodecConfigurationException setError(final Exception cause) { return new CodecConfigurationException(format("Unable to set value for property '%s' in %s", propertyMetadata.getName(), propertyMetadata.getDeclaringClassName()), cause); }
Source:
<code>private Object readProperty(Node otherNode, String targetColumnName) { Object value = null; <START> otherNode.getAllProperties(); <END> if ( otherNode.hasProperty( targetColumnName ) ) { value = otherNode.getProperty( targetColumnName ); } return value; }</code><technical_language>returned is used</technical_language>

Target:
private Object readProperty(Node otherNode, String targetColumnName) { Object value = null; if ( otherNode.hasProperty( targetColumnName ) ) { value = otherNode.getProperty( targetColumnName ); } return value; }
Source:
<code>public TryCastFunction() <START> { <END> super(new Signature( "TRY_CAST", FunctionKind.SCALAR, ImmutableList.of(typeVariable("F"), typeVariable("T")), ImmutableList.of(), parseTypeSignature("T"), ImmutableList.of(parseTypeSignature("F")), false)); }</code><technical_language>TRY_CAST_NAME in constructor</technical_language>

Target:
public TryCastFunction() { super(new Signature( TRY_CAST_NAME, FunctionKind.SCALAR, ImmutableList.of(typeVariable("F"), typeVariable("T")), ImmutableList.of(), parseTypeSignature("T"), ImmutableList.of(parseTypeSignature("F")), false)); }
Source:
<code>public boolean canAccessAll(Collection targets, SubResource subResource, Access access) { if (targets == null || targets.isEmpty()) { log.debug( "{} principal checking for access to sub-resource: {}." + " Access to null or resource tried", this.getClass().getName(), access, subResource); return canAccess(null, subResource, access); <START> } <END> log.debug("{} principal checking for access to targets: sub-resource: {}", this.getClass() .getName(), access, Arrays.toString(targets.toArray()), subResource); if (hasFullAccess()) { return true; } for (Object target : targets) { if (!canAccess(target, subResource, access)) { return false; } } return true; }</code><technical_language>is case for targets requiring subs resource access</technical_language>

Target:
public boolean canAccessAll(Collection targets, SubResource subResource, Access access) { if (CollectionUtils.isEmpty(targets)) { log.debug( "{} principal checking for access to sub-resource: {}." + " Access to null or resource tried", this.getClass().getName(), access, subResource); return canAccess(null, subResource, access); } log.debug("{} principal checking for access to targets: sub-resource: {}", this.getClass() .getName(), access, Arrays.toString(targets.toArray()), subResource); if (hasFullAccess()) { return true; } for (Object target : targets) { if (!canAccess(target, subResource, access)) { return false; } } return true; }
Source:
<code>public ValidationResult isUsingScsiReservationValid(VM vm, LunDisk lunDisk) { <START> if (vm == null && lunDisk.isUsingScsiReservation() != null && lunDisk.isUsingScsiReservation()) { <END> return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_SCSI_RESERVATION_NOT_VALID_FOR_FLOATING_DISK); } if (lunDisk.isUsingScsiReservation() != null && lunDisk.isUsingScsiReservation() && lunDisk.getSgio() == ScsiGenericIO.FILTERED) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_SGIO_IS_FILTERED); } return ValidationResult.VALID; }</code><technical_language>replace lunDisk.isUsingScsiReservation() != null && lunDisk.isUsingScsiReservation() Boolean.TRUE.equals(lunDisk.isUsingScsiReservation())</technical_language>

Target:
public ValidationResult isUsingScsiReservationValid(VM vm, LunDisk lunDisk) { if (vm == null && Boolean.TRUE.equals(lunDisk.isUsingScsiReservation())) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_SCSI_RESERVATION_NOT_VALID_FOR_FLOATING_DISK); } if (lunDisk.isUsingScsiReservation() != null && lunDisk.isUsingScsiReservation() && lunDisk.getSgio() == ScsiGenericIO.FILTERED) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_SGIO_IS_FILTERED); } return ValidationResult.VALID; }
Source:
<code>public void testSanitizeForSaving() { AccountAttributes actualAccount = createAccountAttributesToSanitize(); <START> AccountAttributes expectedAccount = actualAccount.getCopy(); <END> actualAccount.sanitizeForSaving(); assertEquals(SanitizationHelper.sanitizeForHtml(expectedAccount.googleId), actualAccount.googleId); assertEquals(SanitizationHelper.sanitizeForHtml(expectedAccount.name), actualAccount.name); assertEquals(SanitizationHelper.sanitizeForHtml(expectedAccount.email), actualAccount.email); assertEquals(SanitizationHelper.sanitizeForHtml(expectedAccount.institute), actualAccount.institute); expectedAccount.studentProfile.sanitizeForSaving(); assertEquals(expectedAccount.studentProfile.toString(), actualAccount.studentProfile.toString()); }</code><technical_language>Unrelated change</technical_language>

Target:
public void testSanitizeForSaving() { AccountAttributes actualAccount = createAccountAttributesToSanitize(); AccountAttributes expectedAccount = createAccountAttributesToSanitize(); actualAccount.sanitizeForSaving(); assertEquals(SanitizationHelper.sanitizeForHtml(expectedAccount.googleId), actualAccount.googleId); assertEquals(SanitizationHelper.sanitizeForHtml(expectedAccount.name), actualAccount.name); assertEquals(SanitizationHelper.sanitizeForHtml(expectedAccount.email), actualAccount.email); assertEquals(SanitizationHelper.sanitizeForHtml(expectedAccount.institute), actualAccount.institute); expectedAccount.studentProfile.sanitizeForSaving(); assertEquals(expectedAccount.studentProfile.toString(), actualAccount.studentProfile.toString()); }
Source:
<code>public boolean rename(String oldLayerName, String newLayerName) throws StorageException; public String getLayerMetadata(String layerName, String key); public void putLayerMetadata(String layerName, String key, String value); public boolean layerExists(String layerName); Map<String,Optional<Map<String, String>>> getParametersMapping(String layerName); public default boolean purgeOrphans(TileLayer layer) throws StorageException { try{ final List<ParameterFilter> parameterFilters = layer.getParameterFilters(); return getParametersMapping(layer.getName()).entrySet().stream() .filter(parameterMapping -> { return parameterMapping.getValue() .map(parameters-> { return parameters.size() != parameterFilters.size() || parameterFilters.stream() .allMatch(pfilter -> { final String key = pfilter.getKey(); final String value = parameters.get(key); if(Objects.isNull(value)) { return true; } return !pfilter.isFilteredValue(value); }); }) .orElse(true); }) .map(Map.Entry::getKey) <START> .map(id->{ <END> try { return this.deleteByParametersId(layer.getName(), id); } catch (StorageException e) { throw new UncheckedIOException(e); } }) .reduce((x,y)->x||y) .orElse(false); } catch (UncheckedIOException ex) { if(ex.getCause() instanceof StorageException) { throw (StorageException) ex.getCause(); } else { throw ex; } } }</code><technical_language>formatting in places, lack of spaces exepct find some (compared gt/gs conventions), if GWC is rules though</technical_language>

Target:
public boolean rename(String oldLayerName, String newLayerName) throws StorageException; public String getLayerMetadata(String layerName, String key); public void putLayerMetadata(String layerName, String key, String value); public boolean layerExists(String layerName); Map<String,Optional<Map<String, String>>> getParametersMapping(String layerName); public default boolean purgeOrphans(TileLayer layer) throws StorageException { try{ final List<ParameterFilter> parameterFilters = layer.getParameterFilters(); final Function<Map<String,String>, Boolean> parametersNeedPurge = parameters-> { return parameters.size() != parameterFilters.size() || parameterFilters.stream() .allMatch(pfilter -> { final String key = pfilter.getKey(); final String value = parameters.get(key); if(Objects.isNull(value)) { return true; } return !pfilter.isFilteredValue(value); }); }; return getParametersMapping(layer.getName()).entrySet().stream() .filter(parameterMapping -> { return parameterMapping.getValue() .map(parametersNeedPurge) .orElse(true); }) .map(Map.Entry::getKey) .map(id->{ try { return this.deleteByParametersId(layer.getName(), id); } catch (StorageException e) { throw new UncheckedIOException(e); } }) .reduce((x,y)->x||y) .orElse(false); } catch (UncheckedIOException ex) { if(ex.getCause() instanceof StorageException) { throw (StorageException) ex.getCause(); } else { throw ex; } } }
Source:
<code>public void refreshLogs() { currentPage = 1; loadTaskLogs(); <START> displayVisibleLogs(); <END> }</code><technical_language>this executed in callback _getTaskEvents_</technical_language>

Target:
public void refreshLogs() { currentPage = 0; loadTaskLogs(); }
Source:
<code><START> public static boolean isNotEmpty(@Nullable String str) { <END> return str != null && !str.isEmpty(); }</code><technical_language>private for</technical_language>

Target:
private static boolean isNotEmpty(@Nullable String str) { return str != null && !str.isEmpty(); }
Source:
<code>private IBreakpoint breakpointAtLineNumber(Location location) { if (fBreakpoints == null || location == null || location == Location.UNKNOWN_LOCATION) { return null; } int lineNumber = fDebugState.getLineNumber(location); File locationFile = new File(fDebugState.getFileName(location)); for (IBreakpoint <START> fBreakpoint : <END> fBreakpoints) { ILineBreakpoint breakpoint = (ILineBreakpoint) fBreakpoint; int breakpointLineNumber; try { if (!breakpoint.isEnabled()) { continue; } breakpointLineNumber = breakpoint.getLineNumber(); } catch (CoreException e) { return null; } IFile resource = (IFile) breakpoint.getMarker().getResource(); if (breakpointLineNumber == lineNumber && resource.getLocation().toFile().equals(locationFile)) { return breakpoint; } } return null; }</code><technical_language>rename bp</technical_language>

Target:
private IBreakpoint breakpointAtLineNumber(Location location) { if (fBreakpoints == null || location == null || location == Location.UNKNOWN_LOCATION) { return null; } int lineNumber = fDebugState.getLineNumber(location); File locationFile = new File(fDebugState.getFileName(location)); for (IBreakpoint bp : fBreakpoints) { ILineBreakpoint breakpoint = (ILineBreakpoint) bp; int breakpointLineNumber; try { if (!breakpoint.isEnabled()) { continue; } breakpointLineNumber = breakpoint.getLineNumber(); } catch (CoreException e) { return null; } IFile resource = (IFile) breakpoint.getMarker().getResource(); if (breakpointLineNumber == lineNumber && resource.getLocation().toFile().equals(locationFile)) { return breakpoint; } } return null; }
Source:
<code>public InputContent parseInputStream( InputStream inputStream, Boolean strict ) throws IOException, <START> ReadException { <END> Description description = deserialize(new InputStreamReader(inputStream), strict); Content content = complexify(description); return new InputContent(content, description.getType()); }</code><technical_language>this doesnt need a line</technical_language>

Target:
public InputContent parseInputStream( InputStream inputStream, Boolean strict ) throws IOException, ReadException { Description description = deserialize(new InputStreamReader(inputStream), strict); Content content = complexify(description); return InputContent.create(content, description.getType()); }
Source:
<code>public IdentifierHolder signUp(Study study, StudyParticipant participant) { checkNotNull(study); checkNotNull(participant); if (BridgeUtils.isExternalIdAccount(participant) && !study.isExternalIdValidationEnabled()) { throw new UnauthorizedException("External ID management is not enabled for this study"); } try { return participantService.createParticipant(study, NO_CALLER_ROLES, participant, true); } catch(EntityAlreadyExistsException e) { AccountId accountId = null; if (e.getEntityKeys().get("email") != null) { accountId = AccountId.forEmail(study.getIdentifier(), participant.getEmail()); } else if (e.getEntityKeys().get("phone") != null) { accountId = AccountId.forPhone(study.getIdentifier(), participant.getPhone()); } else if (e.getEntityKeys().get("externalId") != null) { accountId = AccountId.forExternalId(study.getIdentifier(), participant.getExternalId()); } if (accountId != null) { accountWorkflowService.notifyAccountExists(study, accountId); <START> LOG.info("Sign up attempt for existing credential '"+accountId+"'"); <END> } else { LOG.error("Sign up attempt for existing credential, but could not create AccountId: '"+study.getIdentifier()+"'"); } } return null; }</code><technical_language>Similarly, this logs personal identifying info</technical_language>

Target:
public IdentifierHolder signUp(Study study, StudyParticipant participant) { checkNotNull(study); checkNotNull(participant); if (BridgeUtils.isExternalIdAccount(participant) && !study.isExternalIdValidationEnabled()) { throw new UnauthorizedException("External ID management is not enabled for this study"); } try { return participantService.createParticipant(study, NO_CALLER_ROLES, participant, true); } catch(EntityAlreadyExistsException e) { LOG.info("Sign up attempt using credential that exists in account '"+e.getEntityKeys().get("userId")+"'"); AccountId accountId = AccountId.forId(study.getIdentifier(), (String)e.getEntityKeys().get("userId")); accountWorkflowService.notifyAccountExists(study, accountId); return null; } }
Source:
<code>public double[] getData() { RealAttribute field = new RealAttribute(fieldName); try { return ClassificationUtils.getSortedValues(layer.getDataSource(), field); } catch (Exception ex) { <START> Logger.getLogger(ChoroplethDataModel.class.getName()).log(Level.SEVERE, null, ex); <END> } return null; }</code><technical_language>java logger, Log4j. like: java Logger.getLogger(ChoroplethDataModel.class).warn(...); (this is Logger class, is log4j, is in dependencies) Question: if error is severe, is swallowed here? Shoudn't propagate it</technical_language>

Target:
public double[] getData() { RealAttribute field = new RealAttribute(fieldName); try { return ClassificationUtils.getSortedValues(layer.getDataSource(), field); } catch (DriverException ex) { LOGGER.error(I18N.tr("Unable to load the map data"), ex); } catch (ParameterException ex) { LOGGER.error(I18N.tr("Unable to load the map data"), ex); } return null; }
Source:
<code>public URI getURI() { Preconditions.checkNotNull(hostname, "Hostname is null!"); if (protocol.value == null){ protocol = HTTP; } <START> if (port == 80) { <END> return URI.create(format("%s://%s", protocol.value, hostname)); } return URI.create(format("%s://%s:%s", protocol.value, hostname, port)); }</code><technical_language>if port provided</technical_language>

Target:
public URI getURI() { Preconditions.checkNotNull(hostname, "Hostname is null!"); if (protocol == null) { protocol = HTTP; } return newInstance().scheme(protocol.name().toLowerCase()).host(hostname).port(port).build().toUri(); }
Source:
<code>public static String[] getStringValuesFromDatabase(Connection dbConnection, String sqlStmt, Object... params) throws UserStoreException { String[] values = new String[0]; 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) { prepStmt.setString(i + 1, null); } 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() ) { List<String> lst = new ArrayList<String>(); while (rs.next()) { String name = rs.getString(1); lst.add(name); } if (lst.size() > 0) { values = lst.toArray(new String[lst.size()]); } return values; } } catch (SQLException e) { String errorMessage = "Using sql : " + sqlStmt + " " + e.getMessage(); if (log.isDebugEnabled()) { log.debug(errorMessage, e); } throw new UserStoreException(errorMessage, e); } finally { <START> close(dbConnection); <END> } }</code><technical_language>connection passed a parameter this method, close connection this method. Need close connection in original place originally (create )close dbConnection</technical_language>

Target:
public static String[] getStringValuesFromDatabase(Connection dbConnection, String sqlStmt, Object... params) throws UserStoreException { String[] values = new String[0]; 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) { prepStmt.setString(i + 1, null); } 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() ) { List<String> lst = new ArrayList<String>(); while (rs.next()) { String name = rs.getString(1); lst.add(name); } if (lst.size() > 0) { values = lst.toArray(new String[lst.size()]); } return values; } } catch (SQLException e) { String errorMessage = "Using sql : " + sqlStmt + " " + e.getMessage(); if (log.isDebugEnabled()) { log.debug(errorMessage, e); } throw new UserStoreException(errorMessage, e); } }
Source:
<code>public void onRestoreInstanceState(Bundle savedInstanceStateBundle) { mStableIdMap = (HashMap<Integer, Boolean>) savedInstanceStateBundle.getSerializable(STABLE_ID_MAP); int i = 0; while (i < mItemList.size()) { if (mItemList.get(i) instanceof ParentObject) { ParentObject parentObject = (ParentObject) mItemList.get(i); if (mStableIdMap.containsKey(parentObject.getStableID())) { <START> parentObject.setExpanded(mStableIdMap.get(parentObject.getStableID())); <END> if (parentObject.isExpanded()) { i++; mItemList.add(i, parentObject.getChildObject()); } } else { parentObject.setExpanded(false); } } i++; } notifyDataSetChanged(); }</code><technical_language>biggest fan of isExpanded/setExpanded live in model object, is a change a part of <LINK_0></technical_language>

Target:
public void onRestoreInstanceState(Bundle savedInstanceStateBundle) { if (savedInstanceStateBundle == null) { return; } if (!savedInstanceStateBundle.containsKey(STABLE_ID_MAP)) { return; } mStableIdMap = (HashMap<Integer, Boolean>) savedInstanceStateBundle.getSerializable(STABLE_ID_MAP); int i = 0; while (i < mItemList.size()) { if (mItemList.get(i) instanceof ParentObject) { ParentObject parentObject = (ParentObject) mItemList.get(i); if (mStableIdMap.containsKey(parentObject.getStableID())) { parentObject.setExpanded(mStableIdMap.get(parentObject.getStableID())); if (parentObject.isExpanded()) { i++; mItemList.add(i, parentObject.getChildObject()); } } else { parentObject.setExpanded(false); } } i++; } notifyDataSetChanged(); }
Source:
<code>private static Method normalizedValueOf(final String method) { <START> return Method.valueOf(Objects.requireNonNull(method, "method").toUpperCase(Locale.ROOT)); <END> }</code><technical_language>@garydgregory Please Args.notNull for consistency rest of code base</technical_language>

Target:
private static Method normalizedValueOf(final String method) { return Method.valueOf(Args.notNull(method, "method").toUpperCase(Locale.ROOT)); }
Source:
<code>public RX64Packet(XBee64BitAddress sourceAddress, int rssi, int receiveOptions, byte[] receivedData) { super(XBeeAPIType.RX_64); <START> this.sourceAddress = sourceAddress; <END> this.rssi = rssi; this.receiveOptions = receiveOptions; this.receivedData = receivedData; }</code><technical_language>Check if address is null</technical_language>

Target:
public RX64Packet(XBee64BitAddress sourceAddress, int rssi, int receiveOptions, byte[] receivedData) { super(APIFrameType.RX_64); if (sourceAddress == null) throw new NullPointerException("Source address cannot be null."); if (rssi < 0 || rssi > 100) throw new IllegalArgumentException("RSSI value must be between 0 and 100."); if (receiveOptions < 0 || receiveOptions > 255) throw new IllegalArgumentException("Receive options value must be between 0 and 255."); this.sourceAddress = sourceAddress; this.rssi = rssi; this.receiveOptions = receiveOptions; this.receivedData = receivedData; }
Source:
<code>private static boolean isTupleDeclaration(Tree tree) { return tree.ancestors().stream() .anyMatch(t -> t.is(Kind.TUPLE) || (t.is(Kind.EXPRESSION_LIST) && ((PyExpressionListTree) t).expressions().size() > 1) <START> || t.is(Kind.FOR_STMT) && ((PyForStatementTree) t).expressions().size() > 1 && ((PyForStatementTree) t).expressions().contains(tree)); <END> }</code><technical_language>tuples in cases</technical_language>

Target:
private static boolean isTupleDeclaration(Tree tree) { return tree.ancestors().stream() .anyMatch(t -> t.is(Kind.TUPLE) || (t.is(Kind.EXPRESSION_LIST) && ((PyExpressionListTree) t).expressions().size() > 1) || (t.is(Kind.FOR_STMT) && ((PyForStatementTree) t).expressions().size() > 1 && ((PyForStatementTree) t).expressions().contains(tree))); }
Source:
<code>public DnsServerAddressStreamProvider getNameServerProvider() { if (Strings.isNullOrEmpty(nameservers)) { return DnsServerAddressStreamProviders.platformDefault(); } final String servers[] = nameservers.split(","); return new SequentialDnsServerAddressStreamProvider(Arrays.stream(servers) .map(s -> { String parts[] = s.split(":"); if (parts.length > 1) { <START> return SocketUtils.socketAddress(parts[0], Integer.parseInt(parts[1])); <END> } else { return SocketUtils.socketAddress(parts[0],53); } }) .toArray(InetSocketAddress[]::new)); }</code><technical_language>parts[0].trim() parts[1].trim()</technical_language>

Target:
public DnsServerAddressStreamProvider getNameServerProvider() { if (Strings.isNullOrEmpty(nameservers)) { return DnsServerAddressStreamProviders.platformDefault(); } return new SequentialDnsServerAddressStreamProvider(toSocketAddresses(nameservers).toArray(new InetSocketAddress[]{})); }
Source:
<code>public void test_MergingUpdater_failure() throws IOException, RDFHandlerException { final AbstractTripleStore store = getStore(); boolean ok = false; final String resource = "data-bad.ttl"; try { final MergingUpdater original = doMergingUpdate(store, resource); final String baseURL = new File(resource).toURI().toString(); ok = true; } catch (RDFParseException t) { log.info("Expected error {}", t.getMessage()); } finally { store.__tearDownUnitTest(); } <START> if (ok) fail("Error should have been reported for " + resource); <END> }</code><technical_language>Tagging test @Test(expected = RDFParseException.class) is more readable this custom logic check for exception</technical_language>

Target:
public void test_MergingUpdater_failure() throws IOException, RDFHandlerException, RDFParseException { final AbstractTripleStore store = getStore(); final String resource = "data-bad.ttl"; try { final MergingUpdaterResult original = doMergingUpdate(store, resource); final String baseURL = new File(resource).toURI().toString(); } finally { store.__tearDownUnitTest(); } }
Source:
<code>protected void doPoll(SourcePollingChannelAdapter adapter) { try { Method method = AbstractPollingEndpoint.class.getDeclaredMethod("doPoll"); method.setAccessible(true); method.invoke(adapter); } catch (Exception e) { <START> e.printStackTrace(); <END> fail("Failed to invoke doPoll(): " + e.toString()); } }</code><technical_language>e.printStackTrace(), please, all. provide info pollutes logs CI builds</technical_language>

Target:
protected void doPoll(SourcePollingChannelAdapter adapter) { try { Method method = AbstractPollingEndpoint.class.getDeclaredMethod("doPoll"); method.setAccessible(true); method.invoke(adapter); } catch (Exception e) { fail("Failed to invoke doPoll(): " + e.toString()); } }
Source:
<code>public List<Question> getQuestions( @Scope(OAuthScope.QUESTIONS_READ) final AccessToken accessToken, @QueryParam("date") final String date) { LOGGER.debug("Returning list of questions for account id = {}", accessToken.accountId); final Optional<Account> accountOptional = accountDAO.getById(accessToken.accountId); if(!accountOptional.isPresent()) { throw new WebApplicationException(404); } <START> int timeZoneOffset = - 26200000; <END> final Optional<TimeZoneHistory> tzHistory = this.tzHistoryDAO.getCurrentTimeZone(accessToken.accountId); if (tzHistory.isPresent()) { timeZoneOffset = tzHistory.get().offsetMillis; } final DateTime today = DateTime.now(DateTimeZone.UTC).plusMillis(timeZoneOffset).withTimeAtStartOfDay(); LOGGER.debug("today = {}", today); if(date != null && !date.equals(today.toString("yyyy-MM-dd"))) { return Collections.EMPTY_LIST; } final int accountAgeInDays = (int) ((DateTime.now(DateTimeZone.UTC).getMillis() - accountOptional.get().created.getMillis()) / DAY_IN_MILLIS); return this.questionProcessor.getQuestions(accessToken.accountId, accountAgeInDays, today, DEFAULT_NUM_QUESTIONS, true); }</code><technical_language>This is repeated multiple times, move a private method of QuestionsResource</technical_language>

Target:
public List<Question> getQuestions( @Scope(OAuthScope.QUESTIONS_READ) final AccessToken accessToken, @QueryParam("date") final String date) { LOGGER.debug("Returning list of questions for account id = {}", accessToken.accountId); final int accountAgeInDays = this.getAccountAgeInDays(accessToken.accountId); if (accountAgeInDays == -1) { LOGGER.warn("Fail to get account age for {}", accessToken.accountId); throw new WebApplicationException(404); } final int timeZoneOffset = this.getTimeZoneOffsetMillis(accessToken.accountId); final DateTime today = DateTime.now(DateTimeZone.UTC).plusMillis(timeZoneOffset).withTimeAtStartOfDay(); LOGGER.debug("today = {}", today); if(date != null && !date.equals(today.toString("yyyy-MM-dd"))) { return Collections.EMPTY_LIST; } return this.questionProcessor.getQuestions(accessToken.accountId, accountAgeInDays, today, DEFAULT_NUM_QUESTIONS, true); }
Source:
<code>@Override public int selectName(Options options) throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } if (p != PEEKED_DOUBLE_QUOTED_NAME) { return -1; } int result = source.select(options.doubleQuoteSuffix); if (result == -1) { String lastPathName = pathNames[stackSize - 1]; String nextName = nextName(); for (int i = 0, size = options.strings.length; i < size; i++) { if (nextName.equals(options.strings[i])) { result = i; peeked = PEEKED_NONE; pathNames[stackSize - 1] = nextName; break; } } if (result == -1) { peeked = PEEKED_BUFFERED_NAME; peekedString = nextName; <START> pathNames[stackSize - 1] = lastPathName; <END> } } else { peeked = PEEKED_NONE; pathNames[stackSize - 1] = options.strings[result]; } return result; }</code><technical_language>ooh, I missed this</technical_language>

Target:
@Override public int selectName(Options options) throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } if (p < PEEKED_SINGLE_QUOTED_NAME || p > PEEKED_BUFFERED_NAME) { return -1; } int result = source.select(options.doubleQuoteSuffix); if (result != -1) { peeked = PEEKED_NONE; pathNames[stackSize - 1] = options.strings[result]; return result; } String lastPathName = pathNames[stackSize - 1]; String nextName = nextName(); for (int i = 0, size = options.strings.length; i < size; i++) { if (nextName.equals(options.strings[i])) { peeked = PEEKED_NONE; pathNames[stackSize - 1] = nextName; return i; } } peeked = PEEKED_BUFFERED_NAME; peekedString = nextName; pathNames[stackSize - 1] = lastPathName; return -1; }
Source:
<code><START> public int getListValue() { <END> return intValue; }</code><technical_language>Getter return List<String> int</technical_language>

Target:
public List<String> getListValue() { return listValue; }
Source:
<code>private void checkSuperInvokedInAnyDerivedClassConstructor(MethodDeclarationTree method) { if (isConstructor(method) && !isInBaseClass(method) && !isInDummyDerivedClass(method)) { Set<SuperTreeImpl> superTrees = new SuperDetector().detectIn(method); <START> if (!superTrees.stream().anyMatch(s -> s.getParent().is(Kind.CALL_EXPRESSION))) { <END> addIssue(method.name(), MESSAGE_SUPER_REQUIRED_IN_ANY_DERIVED_CLASS_CONSTRUCTOR); } } }</code><technical_language>@ivandalbosco noneMatch</technical_language>

Target:
private void checkSuperInvokedInAnyDerivedClassConstructor(MethodDeclarationTree method) { if (isConstructor(method) && !isInBaseClass(method) && !isInDummyDerivedClass(method)) { Set<SuperTreeImpl> superTrees = new SuperDetector().detectIn(method); if (superTrees.stream().noneMatch(s -> s.getParent().is(Kind.CALL_EXPRESSION))) { addIssue(method.name(), MESSAGE_SUPER_REQUIRED_IN_ANY_DERIVED_CLASS_CONSTRUCTOR); } } }
Source:
<code>public void testEncryptionOverRename() throws Throwable { Path src = path(createFilename(1024)); byte[] data = dataset(1024, 'a', 'z'); S3AFileSystem fs = getFileSystem(); EncryptionSecrets secrets = fs.getEncryptionSecrets(); validateEncrytionSecrets(secrets); writeDataset(fs, src, data, data.length, 1024 * 1024, true); ContractTestUtils.verifyFileContents(fs, src, data); Path targetDir = path("target"); Path dest = new Path(targetDir, src.getName() + "-another"); byte[] dataTarget = dataset(1024, 'A', 'Z'); writeDataset(fs, dest, dataTarget, dataTarget.length, 1024*1024, true); ContractTestUtils.verifyFileContents(fs, dest, dataTarget); fs.rename(src, targetDir); Path renamedFile = new Path(targetDir, src.getName()); ContractTestUtils.verifyFileContents(fs, renamedFile, data); assertEncrypted(renamedFile); <START> } <END></code><technical_language>I this, understand is doing. Before: created a file src, renamed dest verified contents unchanged; dest encrypted. After: 1. src is created a dataset 1. new path targetDir created 1. file dest is created in a target/src+"-another" a dataset; contents verified 1. rename(src, targetDir) create file targetDir/src 1. is verified 1. dest file is completely change here? I need new test file, change is renaming a subdirectory exists a path of destination file. I need some clarification here. * change * encryption settings changed in copy, this new test fail</technical_language>

Target:
public void testEncryptionOverRename() throws Throwable { Path src = path(createFilename(1024)); byte[] data = dataset(1024, 'a', 'z'); S3AFileSystem fs = getFileSystem(); EncryptionSecrets secrets = fs.getEncryptionSecrets(); validateEncrytionSecrets(secrets); writeDataset(fs, src, data, data.length, 1024 * 1024, true); ContractTestUtils.verifyFileContents(fs, src, data); assertEncrypted(src); Path targetDir = path("target"); mkdirs(targetDir); fs.rename(src, targetDir); Path renamedFile = new Path(targetDir, src.getName()); ContractTestUtils.verifyFileContents(fs, renamedFile, data); assertEncrypted(renamedFile); }
Source:
<code>protected RemoteCallback<Object> getExportCallBack() { return rawResult -> { final AnchorElement exportAnchorElement = view.getExportAnchorElement((String) rawResult, path.getFileName() + CSV.getExtension()); <START> final NativeEvent CLICK_EVENT = Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false); <END> exportAnchorElement.dispatchEvent(CLICK_EVENT); exportAnchorElement.removeFromParent(); }; }</code><technical_language>wondering. is this for</technical_language>

Target:
protected RemoteCallback<Object> getExportCallBack() { return rawResult -> { TextContent textContent = TextContent.create((String) rawResult); textFileExport.export(textContent, path.getFileName() + CSV.getExtension()); }; }
Source:
<code>public static boolean isFullyQualified(String address) { <START> List<String> split = Splitter.onPattern(SEPARATOR).splitToList(address); <END> return address != null && split.size() == 2 && !split.contains(""); }</code><technical_language>This method is a lot code-base including message routing (which is important performance). Therefore, garbage produces better. creating a List of String objects. I this implemented more simply String.indexOf instead. do think</technical_language>

Target:
public static boolean isFullyQualified(String address) { if (address == null) { return false; } if (address.length() < SEPARATOR_LENGTH + 2) { return false; } int index = address.indexOf(SEPARATOR, 1); return index != -1 && index != address.length() - SEPARATOR_LENGTH; }
Source:
<code><START> private boolean dontNeedEncoding(char ch) { <END> return ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch >= '0' && ch <= '9' || ch == '-' || ch == '_' || ch == '.' || ch == '*'; }</code><technical_language>static</technical_language>

Target:
private static boolean dontNeedEncoding(char ch) { return ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch >= '0' && ch <= '9' || ch == '-' || ch == '_' || ch == '.' || ch == '*'; }
Source:
<code>public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || this.getClass() != o.getClass()) { return false; } final SecurityKey compareKey = (SecurityKey) o; return Objects.equals(this.getDlmsDevice(), compareKey.getDlmsDevice()) && Objects.equals(this.getSecurityKeyType(), compareKey.getSecurityKeyType()) && Objects.equals(this.getId(), compareKey.getId()); <START> } <END></code><technical_language>Id is part of equals hashcode, dlmsDevice securityKeyType</technical_language>

Target:
public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || this.getClass() != o.getClass()) { return false; } final SecurityKey compareKey = (SecurityKey) o; return Objects.equals(this.getId(), compareKey.getId()); }
Source:
<code>@Test public void testPushAggragateOnTimeWithExtractDay() { <START> String sql = "select EXTRACT( day from \"timestamp\") as \"day\",\"product_id\" from \"foodmart\" where \"product_id\" = 1016 and " <END> + "\"timestamp\" < cast('1997-01-20' as timestamp) and \"timestamp\" > cast" + "('1997-01-01' as timestamp)" + " group by " + " EXTRACT( day from \"timestamp\"), \"product_id\" "; sql(sql).queryContains( druidChecker(",\"granularity\":\"all\"", "{\"type\":\"extraction\"," + "\"dimension\":\"__time\",\"outputName\":\"dayOfMonth\"," + "\"extractionFn\":{\"type\":\"timeFormat\",\"format\":\"dd\"," + "\"timeZone\":\"UTC\"}}")) .returnsUnordered("day=02; product_id=1016", "day=10; product_id=1016", "day=13; product_id=1016", "day=16; product_id=1016"); }</code><technical_language>need solve problem _extraction result column_ name mentioned previously. I renaming result of _extract_, enough. If do solve check this patch in, this result in incorrect results in cases, right</technical_language>

Target:
@Test public void testPushAggragateOnTimeWithExtractDay() { String sql = "select EXTRACT( day from \"timestamp\") as \"day\",\"product_id\" from \"foodmart\"" + " where \"product_id\" = 1016 and " + "\"timestamp\" < cast('1997-01-20' as timestamp) and \"timestamp\" > cast" + "('1997-01-01' as timestamp)" + " group by " + " EXTRACT( day from \"timestamp\"), \"product_id\" "; sql(sql).queryContains(druidChecker (",\"granularity\":\"all\"", "{\"type\":\"extraction\"," + "\"dimension\":\"__time\",\"outputName\":\"dayOfMonth\"," + "\"extractionFn\":{\"type\":\"timeFormat\",\"format\":\"dd\"," + "\"timeZone\":\"UTC\"}}" ) ).returnsUnordered("day=02; product_id=1016", "day=10; product_id=1016", "day=13; product_id=1016", "day=16; product_id=1016" ); }