auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testEnableDataGridMinWidth() throws Exception { final int PAGE_SIZE = 10; Element mockElement =mock(Element.class); final int minWidth = 800; PagedTable pagedTable = new PagedTable(PAGE_SIZE, null, null, false, false, false); ColumnPicker columnPickerMock = mock(ColumnPicker.class); when(pagedTable.dataGridContainer.getElement()).thenReturn(mockElement); when(columnPickerMock.getDataGridMinWidth()).thenReturn(minWidth); pagedTable.setColumnPicker(columnPickerMock); <START> pagedTable.enableDataGridMinWidth(true);; <END> pagedTable.setTableHeight(); verify(columnPickerMock,never()).setDefaultColumnWidthSize(anyInt()); verify(mockElement).setAttribute("style", "min-width:" + minWidth + Style.Unit.PX.getType()); }</code><technical_language>extra semi-colon</technical_language>

Target:
public void testEnableDataGridMinWidth() throws Exception { final int PAGE_SIZE = 10; Element mockElement = mock(Element.class); final int minWidth = 800; PagedTable pagedTable = new PagedTable(PAGE_SIZE, null, null, false, false, false); ColumnPicker columnPickerMock = mock(ColumnPicker.class); when(pagedTable.dataGridContainer.getElement()).thenReturn(mockElement); when(columnPickerMock.getDataGridMinWidth()).thenReturn(minWidth); pagedTable.setColumnPicker(columnPickerMock); pagedTable.enableDataGridMinWidth(true); pagedTable.setTableHeight(); verify(columnPickerMock, never()).setDefaultColumnWidthSize(anyInt()); verify(mockElement).setAttribute("style", "min-width:" + minWidth + Style.Unit.PX.getType()); }
Source:
<code>public T getCredentials(String credentialsName, String type) { if (StringUtils.isEmpty(credentialsName)) { throw new IllegalArgumentException("Credentials name must be supplied"); } CredentialsRepository<? extends T> repository = allRepositories.get(type); if (repository == null) { throw new UnknownCredentialsTypeException("No credentials of type '" + type + "' found"); } T creds = repository.getOne(credentialsName); if (creds == null) { <START> throw new IllegalArgumentException( <END> "Credentials '" + credentialsName + "' of type '" + type + "' cannot be found"); } return creds; }</code><technical_language>useful move SpinnakerException family for exceptions. a number of places in PR need change this point. happy explain this (or doc if I haven't) beneficial do so</technical_language>

Target:
public T getCredentials(String credentialsName, String type) { CredentialsRepository<? extends T> repository = allRepositories.get(type); if (repository == null) { throw new UnknownCredentialsTypeException("No credentials of type '" + type + "' found"); } T creds = repository.getOne(credentialsName); if (creds == null) { throw new MissingCredentialsException( "Credentials '" + credentialsName + "' of type '" + type + "' cannot be found"); } return creds; }
Source:
<code>private List<Object> assertResult(List<MapOrList> parentResults, Object result) { result = convertPossibleArray(result); if (result != null && !(result instanceof Iterable)) { throw new BatchAssertionFailed(String.format("BatchedDataFetcher provided an invalid result: Iterable expected but got '%s'. Affected fields are set to null.", result.getClass().getName())); } @SuppressWarnings("unchecked") Iterable<Object> iterableResult = (Iterable<Object>) result; if (iterableResult == null) { throw new BatchAssertionFailed("BatchedDataFetcher provided a null Iterable of result values. Affected fields are set to null."); } <START> long size = iterableResult.spliterator().estimateSize(); <END> if (size != parentResults.size()) { throw new BatchAssertionFailed(String.format("BatchedDataFetcher provided invalid number of result values, expected %d but got %d. Affected fields are set to null.", parentResults.size(), size)); } List<Object> resultList = new ArrayList<>(); iterableResult.forEach(resultList::add); return resultList; }</code><technical_language>This is safe, estimateSize() return Long.MAX_VALUE in cases. values copied a new list lines this, check copying</technical_language>

Target:
private List<Object> assertResult(List<MapOrList> parentResults, Object result) { result = convertPossibleArray(result); if (result != null && !(result instanceof Iterable)) { throw new BatchAssertionFailed(String.format("BatchedDataFetcher provided an invalid result: Iterable expected but got '%s'. Affected fields are set to null.", result.getClass().getName())); } @SuppressWarnings("unchecked") Iterable<Object> iterableResult = (Iterable<Object>) result; if (iterableResult == null) { throw new BatchAssertionFailed("BatchedDataFetcher provided a null Iterable of result values. Affected fields are set to null."); } List<Object> resultList = new ArrayList<>(); iterableResult.forEach(resultList::add); long size = resultList.size(); if (size != parentResults.size()) { throw new BatchAssertionFailed(String.format("BatchedDataFetcher provided invalid number of result values, expected %d but got %d. Affected fields are set to null.", parentResults.size(), size)); } return resultList; }
Source:
<code>public void commit() throws IOException { close(); if(destFile.exists() && !destFile.delete()) throw new IOException("Unable to delete "+destFile); <START> boolean success = tmpFile.renameTo(destFile); <END> if (!success) { throw new IOException("Unable to rename: " + destFile); } }</code><technical_language>Files</technical_language>

Target:
public void commit() throws IOException { close(); Path destFilePath = destFile.toPath(); if (Files.exists(destFilePath)) { Files.delete(destFilePath); } Files.move(tmpFile.toPath(), destFilePath); }
Source:
<code>public String readLine() throws IOException { <START> final String line = readLine(mFp,this.longestLineLength); <END> if (line != null) { this.longestLineLength = Math.max(this.longestLineLength, line.length()); } return line; }</code><technical_language>space pull }</technical_language>

Target:
public String readLine() throws IOException { return readLine(mFp, DEFAULT_BUFFER_SIZE); }
Source:
<code>public void testChronologize(){ <START> Map<Long, Set<TObject>> map = Maps.newLinkedHashMap(); <END> Set<TObject> set = Sets.newLinkedHashSet(); long recordId = TestData.getLong(); for (long i = 30; i <= 50; i++) { TObject tObject = Convert.javaToThrift("foo" + i); add("name", tObject, recordId); } long start = Time.now(); for (long i = 51; i <= 70; i++) { set = Sets.newLinkedHashSet(set); TObject tObject = Convert.javaToThrift("foo" + i); add("name", tObject, recordId); set.add(tObject); map.put(i, set); } long end = Time.now(); for (long i = 71; i <= 90; i++) { TObject tObject = Convert.javaToThrift("foo" + i); add("name", tObject, recordId); } Map<Long, Set<TObject>> newMap = store.chronologize("name", recordId, start, end); long key = 51; for(Entry<Long, Set<TObject>> e : newMap.entrySet()){ Set<TObject> result = e.getValue(); Assert.assertEquals(map.get(key), result); key++; } }</code><technical_language>Call this variable expected</technical_language>

Target:
public void testChronologize() { Map<Long, Set<TObject>> expected = Maps.newLinkedHashMap(); Set<TObject> set = Sets.newLinkedHashSet(); Set<TObject> allValues = Sets.newLinkedHashSet(); long recordId = TestData.getLong(); for (long i = 30; i <= 35; i++) { TObject tObject = null; while (tObject == null || !allValues.add(tObject)) { tObject = TestData.getTObject(); add("name", tObject, recordId); set.add(tObject); } } long start = Time.now(); for (long i = 36; i <= 45; i++) { set = Sets.newLinkedHashSet(set); TObject tObject = null; while (tObject == null || !allValues.add(tObject)) { tObject = TestData.getTObject(); add("name", tObject, recordId); } set.add(tObject); expected.put(i, set); } for (long i = 46; i <= 50; i++) { set = Sets.newLinkedHashSet(set); Iterator<TObject> it = allValues.iterator(); if(it.hasNext()) { TObject tObject = it.next(); if(i % 2 == 0) { remove("name", tObject, recordId); set.remove(tObject); } } expected.put(i, set); } long end = Time.now(); for (long i = 51; i <= 55; i++) { TObject tObject = null; while (tObject == null || !allValues.add(tObject)) { tObject = TestData.getTObject(); add("name", tObject, recordId); } } Map<Long, Set<TObject>> actual = store.chronologize("name", recordId, start, end); long key = 36; for (Entry<Long, Set<TObject>> e : actual.entrySet()) { Set<TObject> result = e.getValue(); Assert.assertEquals(expected.get(key), result); key++; } }
Source:
<code>public VmDevice(VmDevice vmDevice) { this.id = vmDevice.id; this.type = vmDevice.type; this.device = vmDevice.device; this.address = vmDevice.address; this.specParams = vmDevice.specParams; this.managed = vmDevice.managed; this.plugged = vmDevice.plugged; this.readOnly = vmDevice.readOnly; this.alias = vmDevice.alias; this.customProperties = vmDevice.customProperties; this.snapshotId = vmDevice.snapshotId; <START> this.logicalName = vmDevice.logicalName; <END> }</code><technical_language>I a approach this: this(vmDevice.id, vmDevice.type...)</technical_language>

Target:
public VmDevice(VmDevice vmDevice) { this( vmDevice.id, vmDevice.type, vmDevice.device, vmDevice.address, vmDevice.specParams, vmDevice.managed, vmDevice.plugged, vmDevice.readOnly, vmDevice.alias, vmDevice.customProperties, vmDevice.snapshotId, vmDevice.logicalName); }
Source:
<code>public SSHKeyPair createSSHKeyPair(final CreateSSHKeyPairCmd cmd) { final Account caller = getCaller(); final String accountName = cmd.getAccountName(); final Long domainId = cmd.getDomainId(); final Long projectId = cmd.getProjectId(); final Account owner = _accountMgr.finalizeOwner(caller, accountName, domainId, projectId); final SSHKeyPairVO s = _sshKeyPairDao.findByName(owner.getAccountId(), owner.getDomainId(), cmd.getName()); if (s != null) { throw new InvalidParameterValueException("A key pair with name '" + cmd.getName() + "' already exists."); } final SSHKeysHelper keys = new SSHKeysHelper(sshKeyLength.value()); final String name = cmd.getName(); <START> if (StringUtils.isBlank(name)) { throw new InvalidParameterValueException("Please specify a valid name for the key pair. The key name can't be empty"); } <END> final String publicKey = keys.getPublicKey(); final String fingerprint = keys.getPublicKeyFingerPrint(); final String privateKey = keys.getPrivateKey(); return createAndSaveSSHKeyPair(name, fingerprint, publicKey, privateKey, owner); }</code><technical_language>move this validation validation queries DB above</technical_language>

Target:
public SSHKeyPair createSSHKeyPair(final CreateSSHKeyPairCmd cmd) { final Account caller = getCaller(); final String accountName = cmd.getAccountName(); final Long domainId = cmd.getDomainId(); final Long projectId = cmd.getProjectId(); final String name = cmd.getName(); if (StringUtils.isBlank(name)) { throw new InvalidParameterValueException("Please specify a valid name for the key pair. The key name can't be empty"); } final Account owner = _accountMgr.finalizeOwner(caller, accountName, domainId, projectId); final SSHKeyPairVO s = _sshKeyPairDao.findByName(owner.getAccountId(), owner.getDomainId(), cmd.getName()); if (s != null) { throw new InvalidParameterValueException("A key pair with name '" + cmd.getName() + "' already exists."); } final SSHKeysHelper keys = new SSHKeysHelper(sshKeyLength.value()); final String publicKey = keys.getPublicKey(); final String fingerprint = keys.getPublicKeyFingerPrint(); final String privateKey = keys.getPrivateKey(); return createAndSaveSSHKeyPair(name, fingerprint, publicKey, privateKey, owner); }
Source:
<code>private RpslObjectWithReplacements replaceReferences(final RpslObject object, final Collection<RpslObject> references) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute rpslAttribute : object.getAttributes()) { <START> AttributeType rpsAttributeType = rpslAttribute.getType(); <END> if (rpsAttributeType != null) { for (final RpslObject reference : references) { if (rpslAttribute.getCleanValue().equals(reference.getKey()) && (rpsAttributeType.getReferences().contains(ObjectType.PERSON) || rpsAttributeType.getReferences().contains(ObjectType.ROLE))) { replacements.put(rpslAttribute, new RpslAttribute(rpsAttributeType, dummyRole)); } } } } if (replacements.isEmpty()) { return new RpslObjectWithReplacements(object, replacements); } final RpslObjectBuilder builder = new RpslObjectBuilder(object); builder.replaceAttributes(replacements); return new RpslObjectWithReplacements(builder.get(), replacements); }</code><technical_language>final keyword</technical_language>

Target:
private RpslObjectWithReplacements replaceReferences(final RpslObject object, final Collection<RpslObject> references) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute rpslAttribute : object.getAttributes()) { final AttributeType attributeType = rpslAttribute.getType(); if (attributeType != null) { for (final RpslObject reference : references) { if (rpslAttribute.getCleanValue().equals(reference.getKey()) && (attributeType.getReferences().contains(ObjectType.PERSON) || attributeType.getReferences().contains(ObjectType.ROLE))) { replacements.put(rpslAttribute, new RpslAttribute(attributeType, dummyRole)); } } } } if (replacements.isEmpty()) { return new RpslObjectWithReplacements(object, replacements); } final RpslObjectBuilder builder = new RpslObjectBuilder(object); builder.replaceAttributes(replacements); return new RpslObjectWithReplacements(builder.get(), replacements); }
Source:
<code>protected void handleError(final Exception e, final String correlationUid, final String organisationIdentification, final String deviceIdentification, final String messageType) { LOGGER.error("Handling error for message type: " + messageType, e); OsgpException osgpException = null; if (e instanceof OsgpException) { osgpException = (OsgpException) e; } else { osgpException = new TechnicalException(ComponentType.DOMAIN_TARIFF_SWITCHING, "An unknown error occurred", e); } <START> this.webServiceResponseMessageSender.send(ResponseMessage.newResponseMessageBuilder() <END> .withCorrelationUid(correlationUid).withOrganisationIdentification(organisationIdentification) .withDeviceIdentification(deviceIdentification).withResult(ResponseMessageResultType.NOT_OK) .withOsgpException(osgpException).withDataObject(e).build()); }</code><technical_language>Extract building of ResponseMessage variable (in eclipse, select text, right-click > refactor > extract local variable / select code + shift+alt+L). This code a bit more readable, especially passing in other besides ResponseMessage</technical_language>

Target:
protected void handleError(final Exception e, final String correlationUid, final String organisationIdentification, final String deviceIdentification, final String messageType) { LOGGER.error("Handling error for message type: " + messageType, e); OsgpException osgpException = null; if (e instanceof OsgpException) { osgpException = (OsgpException) e; } else { osgpException = new TechnicalException(ComponentType.DOMAIN_TARIFF_SWITCHING, "An unknown error occurred", e); } ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder() .withCorrelationUid(correlationUid).withOrganisationIdentification(organisationIdentification) .withDeviceIdentification(deviceIdentification).withResult(ResponseMessageResultType.NOT_OK) .withOsgpException(osgpException).withDataObject(e).build(); this.webServiceResponseMessageSender.send(responseMessage); }
Source:
<code>public long getNumberOfPayloads() { try { return jsonPayloadGenerator.getNumberOfPayloads(); <START> } catch (Exception e) { <END> LOGGER.warn("Failed to obtain number of payloads", e); } return PayloadGenerator.UNKNOWN_NUMBER_OF_PAYLOADS; }</code><technical_language>This removed here</technical_language>

Target:
public long getNumberOfPayloads() { return jsonPayloadGenerator.getNumberOfPayloads(); }
Source:
<code>private void addPrefixes(Map<ObjectId, String> nonCommits, FIFORevQueue pending) throws IOException { if (!prefixes.isEmpty()) { for (String prefix : prefixes) addPrefix(prefix, nonCommits, pending); <START> } else <END> addPrefix(Constants.R_REFS, nonCommits, pending); }</code><technical_language>If prefixes is empty refs is becuase caller invoked addAnnotatedTags(), do want add other reference</technical_language>

Target:
private void addPrefixes(Map<ObjectId, String> nonCommits, FIFORevQueue pending) throws IOException { if (!prefixes.isEmpty()) { for (String prefix : prefixes) addPrefix(prefix, nonCommits, pending); } else if (refs.isEmpty()) addPrefix(Constants.R_REFS, nonCommits, pending); }
Source:
<code><START> protected synchronized void setLocaleAndBundle(String locale, Bundle bundle, Map<String, ResourceBundle> resourceBundleMap) { <END> this.locale = locale; this.bundle = bundle; this.resourceBundleMap = resourceBundleMap; }</code><technical_language>change param name resourceBundleCache</technical_language>

Target:
protected synchronized void setLocaleAndBundle(String locale, Bundle bundle, Map<String, ResourceBundle> resourceBundleMap) { this.locale = locale; this.bundle = bundle; this.resourceBundleCache = resourceBundleMap; }
Source:
<code>protected SootMethod tryResolve(final StringBuilder trace) { SootMethod resolved = Scene.v() <START> .getOrMakeFastHierarchy() <END> .resolveMethod(declaringClass, declaringClass, name, parameterTypes, returnType, true); if (resolved != null) { checkStatic(resolved); return resolved; } if (Scene.v().allowsPhantomRefs() && Options.v().ignore_resolution_errors()) { SootClass classToAddTo = declaringClass; while (classToAddTo != null && !classToAddTo.isPhantom()) { classToAddTo = classToAddTo.getSuperclassUnsafe(); } if (classToAddTo == null) { classToAddTo = declaringClass; } SootMethod method = Scene.v() .makeSootMethod(name, parameterTypes, returnType, isStatic() ? Modifier.STATIC : 0); method.setPhantom(true); method = classToAddTo.getOrAddMethod(method); checkStatic(method); return method; } return null; }</code><technical_language>explain some examples this a difference? implement phantom behavior optionally for call 'SootMethodRefImpl' if solves problem</technical_language>

Target:
protected SootMethod tryResolve(final StringBuilder trace) { SootMethod resolved = Scene.v() .getOrMakeFastHierarchy() .resolveMethod(declaringClass, declaringClass, name, parameterTypes, returnType, true); if (resolved != null) { checkStatic(resolved); return resolved; } else if(Scene.v().allowsPhantomRefs()) { SootClass selectedClass = declaringClass; while (selectedClass != null) { if (selectedClass.isPhantom()) { SootMethod phantomMethod = Scene.v().makeSootMethod(name, parameterTypes, returnType, isStatic() ? Modifier.STATIC : 0); phantomMethod.setPhantom(true); phantomMethod = selectedClass.getOrAddMethod(phantomMethod); checkStatic(phantomMethod); return phantomMethod; } selectedClass = selectedClass.getSuperclassUnsafe(); } } if (Scene.v().allowsPhantomRefs() && Options.v().ignore_resolution_errors()) { SootClass classToAddTo = declaringClass; while (classToAddTo != null && !classToAddTo.isPhantom()) { classToAddTo = classToAddTo.getSuperclassUnsafe(); } if (classToAddTo == null) { classToAddTo = declaringClass; } SootMethod method = Scene.v() .makeSootMethod(name, parameterTypes, returnType, isStatic() ? Modifier.STATIC : 0); method.setPhantom(true); method = classToAddTo.getOrAddMethod(method); checkStatic(method); return method; } return null; }
Source:
<code>private CertificateDTO addCertByAlias(List<CertificateDTO> toList, List<CertificateDTO> fromList, String alias){ for(CertificateDTO cert : fromList){ <START> if(StringUtils.isNotEmpty(cert.getAlias()) && StringUtils.isNotEmpty(alias) && cert.getAlias().compareTo(alias)==0){ <END> toList.add(cert); fromList.remove(cert); return cert; } } return null; }</code><technical_language>equals() instead of .compareTo</technical_language>

Target:
private CertificateDTO addCertByAlias(List<CertificateDTO> toList, List<CertificateDTO> fromList, String alias){ for(CertificateDTO cert : fromList){ if (StringUtils.isNotEmpty(cert.getAlias()) && StringUtils.isNotEmpty(alias) && cert.getAlias().equals(alias)) { toList.add(0, cert); fromList.remove(cert); return cert; } } return null; }
Source:
<code>public TaskJobEvent(ITask originalTask, ITask task) { <START> this.originalTask = originalTask; <END> this.task = task; }</code><technical_language>This invoke other constructor taskData marked final</technical_language>

Target:
public TaskJobEvent(ITask originalTask, ITask task) { this(originalTask, task, null); }
Source:
<code>private void doByteBufferWrite(String cipherClass, boolean withChannel) throws Exception { <START> CounterCryptoOutputStream out = getCryptoOutputStream(cipherClass, defaultBufferSize, withChannel); <END> ByteBuffer buf = ByteBuffer.allocateDirect(dataLen / 2); buf.put(data, 0, dataLen / 2); buf.flip(); int n1 = out.write(buf); buf.clear(); buf.put(data, n1, dataLen / 3); buf.flip(); int n2 = out.write(buf); buf.clear(); buf.put(data, n1 + n2, dataLen - n1 - n2); buf.flip(); int n3 = out.write(buf); Assert.assertEquals(dataLen, n1 + n2 + n3); out.flush(); encData = baos.toByteArray(); InputStream in = getCryptoInputStream(cipherClass, defaultBufferSize, withChannel); buf = ByteBuffer.allocate(dataLen + 100); byteBufferReadCheck(in, buf, 0); in.close(); }</code><technical_language>While tests CounterCryptoInputStream/CounterCryptoInputStream class, great rename this class CounterCryptoStreamTest.java</technical_language>

Target:
private void doByteBufferWrite(String cipherClass, boolean withChannel) throws Exception { CTRCryptoOutputStream out = getCryptoOutputStream(cipherClass, defaultBufferSize, withChannel); ByteBuffer buf = ByteBuffer.allocateDirect(dataLen / 2); buf.put(data, 0, dataLen / 2); buf.flip(); int n1 = out.write(buf); buf.clear(); buf.put(data, n1, dataLen / 3); buf.flip(); int n2 = out.write(buf); buf.clear(); buf.put(data, n1 + n2, dataLen - n1 - n2); buf.flip(); int n3 = out.write(buf); Assert.assertEquals(dataLen, n1 + n2 + n3); out.flush(); encData = baos.toByteArray(); InputStream in = getCryptoInputStream(cipherClass, defaultBufferSize, withChannel); buf = ByteBuffer.allocate(dataLen + 100); byteBufferReadCheck(in, buf, 0); in.close(); }
Source:
<code>public void setMessage(String message) { super.setMessage(message); if (message != null && message.length() > 0) { table.setVisible(false); } if (message != null) { <START> messageLabel.setText(message); <END> } }</code><technical_language>push this previous if? I a point in setting text of empty string visible</technical_language>

Target:
public void setMessage(String message) { super.setMessage(message); if (message != null && message.length() > 0) { table.setVisible(false); messageLabel.setText(message); } }
Source:
<code>public void assertRequest(RecordedRequest request, String method, String path, String resourceLocation) { assertRequest(request, method, path); assertJsonRequest(request); JsonParser parser = new JsonParser(); <START> JsonElement requestJson = null, resourceJson; END> try { requestJson = parser.parse(new String(request.getBody(), "UTF-8")); } catch (Exception e) { Throwables.propagate(e); } resourceJson = parser.parse(stringFromResource(resourceLocation)); assertEquals(requestJson, resourceJson); }</code><technical_language>Please write this lines</technical_language>

Target:
public void assertRequest(RecordedRequest request, String method, String path, String resourceLocation) { assertRequest(request, method, path); assertContentTypeIsJSON(request); JsonParser parser = new JsonParser(); JsonElement requestJson = null; JsonElement resourceJson; try { requestJson = parser.parse(new String(request.getBody(), "UTF-8")); } catch (Exception e) { Throwables.propagate(e); } resourceJson = parser.parse(stringFromResource(resourceLocation)); assertEquals(requestJson, resourceJson); }
Source:
<code>public HandlerMappingConfiguration(Map<String, Map<String, ?>> handlerMapping, SiteSet siteSet) { this.handlerMapping = handlerMapping; this.siteKeys = ImmutableSet.<String>builder() <START> .addAll(Preconditions.checkNotNull(siteSet).getSiteKeys()) <END> .add(VALUE_NULLSITE) .build(); }</code><technical_language>checkNotNull is unnecessary here, siteSet.getSiteKeys() for free (i.e., throw NPE if null)</technical_language>

Target:
public HandlerMappingConfiguration(Map<String, Map<String, ?>> handlerMapping, SiteSet siteSet) { this.handlerMapping = handlerMapping != null ? handlerMapping : ImmutableMap.<String, Map<String, ?>>of("", ImmutableMap.<String, Object>of()); this.siteKeys = ImmutableSet.<String>builder() .addAll(siteSet.getSiteKeys()) .add(VALUE_NULLSITE) .build(); }
Source:
<code>public String deleteFromClient() { <START> int clientId = Integer.parseInt(Helper.getRequestParameter("ID")); <END> try { Client client = serviceManager.getClientService().getById(clientId); this.userObject.getClients().remove(client); } catch (DAOException e) { Helper.setErrorMessage(ERROR_DATABASE_READING, new Object[] {Helper.getTranslation("client"), clientId }, logger, e); return null; } return null; }</code><technical_language>Integer.parseInt get numeric ID value. In method addToClient Integer.valueOf. change other? - methods throwing a NumberFormatException this code is in frontend classes, handle this</technical_language>

Target:
public String deleteFromClient() { int clientId = 0; try { clientId = Integer.parseInt(Helper.getRequestParameter("ID")); Client client = serviceManager.getClientService().getById(clientId); this.userObject.getClients().remove(client); } catch (DAOException e) { Helper.setErrorMessage(ERROR_DATABASE_READING, new Object[] {Helper.getTranslation("client"), clientId }, logger, e); return null; } catch (NumberFormatException e) { Helper.setErrorMessage(e.getLocalizedMessage(), logger, e); } return null; }
Source:
<code>public void removeNode(final RMNodeData rmNodeData) { if (nodeRecoveryDisabled()) { return; } if (rmdbManagerBuffer.canOperateDatabaseSynchronouslyWithNode(rmNodeData)) { try { <START> logger.info("Remove node " + rmNodeData.getName() + " in database"); <END> executeReadWriteTransaction(new SessionWork<Void>() { @Override public Void doInTransaction(Session session) { session.delete(rmNodeData); return null; } }); } catch (RuntimeException e) { throw new RuntimeException("Exception occurred while removing node " + rmNodeData.getName(), e); } } else { logger.info("Request " + RMDBManagerBuffer.class.getSimpleName() + " to remove node " + rmNodeData.getName() + " in database"); rmdbManagerBuffer.addRemoveNodeToPendingDatabaseOperations(rmNodeData); } }</code><technical_language>put this in debug</technical_language>

Target:
public void removeNode(final RMNodeData rmNodeData) { if (nodeRecoveryDisabled()) { return; } if (rmdbManagerBuffer.canOperateDatabaseSynchronouslyWithNode(rmNodeData)) { try { logger.info("Remove node " + rmNodeData.getName() + IN_DATABASE_STRING); executeReadWriteTransaction(new SessionWork<Void>() { @Override public Void doInTransaction(Session session) { session.delete(rmNodeData); return null; } }); } catch (RuntimeException e) { throw new RuntimeException("Exception occurred while removing node " + rmNodeData.getName(), e); } } else { logger.debug(REQUEST_BUFFER_STRING + "remove node " + rmNodeData.getName() + IN_DATABASE_STRING); rmdbManagerBuffer.addRemoveNodeToPendingDatabaseOperations(rmNodeData); } }
Source:
<code>public void configurePipeline(PipelineConfigurer pipelineConfigurer) throws IllegalArgumentException { super.configurePipeline(pipelineConfigurer); if (!S3_LOG.equals(config.logFormat) && !CLF_LOG.equals(config.logFormat) && !CLOUDFRONT_LOG.equals(config.logFormat)) { LOG.error("Log format not currently supported."); throw new IllegalStateException("Unsupported log format: " + config.logFormat); } Schema inputSchema = pipelineConfigurer.getStageConfigurer().getInputSchema(); if (inputSchema != null) { if (!inputSchema.getType().equals(Schema.Type.RECORD)) { throw new IllegalArgumentException("Only Input Schema of type Schema.Type.RECORD is supported"); } Schema.Field inputNameSchema = inputSchema.getField(config.inputName); try { if (inputNameSchema == null) { throw new IllegalArgumentException( <START> "Invalid inputName, no known inputField matches given input of " + config.inputName); <END> } else if (inputNameSchema.getSchema() == null) { throw new IllegalArgumentException( "Schema for the field" + inputNameSchema.getName() + "is null in inputSchema"); } else { validateInputSchemaType(inputNameSchema.getSchema().getType()); } } catch (IllegalArgumentException e) { LOG.error(e.getMessage()); throw Throwables.propagate(e); } } pipelineConfigurer.getStageConfigurer().setOutputSchema(LOG_SCHEMA); }</code><technical_language>this is a confusing message. other "Field " + config.field + " is present in input schema" more clear</technical_language>

Target:
public void configurePipeline(PipelineConfigurer pipelineConfigurer) throws IllegalArgumentException { super.configurePipeline(pipelineConfigurer); if (!S3_LOG.equals(config.logFormat) && !CLF_LOG.equals(config.logFormat) && !CLOUDFRONT_LOG.equals(config.logFormat)) { LOG.error("Log format not currently supported."); throw new IllegalStateException("Unsupported log format: " + config.logFormat); } Schema inputSchema = pipelineConfigurer.getStageConfigurer().getInputSchema(); if (inputSchema != null) { if (!inputSchema.getType().equals(Schema.Type.RECORD)) { throw new IllegalArgumentException("Only Input Schema of type Schema.Type.RECORD is supported"); } Schema.Field inputNameSchema = inputSchema.getField(config.inputName); if (inputNameSchema == null) { throw new IllegalArgumentException("Field " + config.inputName + " is not present in the input schema"); } else { validateInputSchemaType(inputNameSchema.getSchema().getType()); } } pipelineConfigurer.getStageConfigurer().setOutputSchema(LOG_SCHEMA); }
Source:
<code>private void handleMetadataRequest(CorfuMsg msg, ChannelHandlerContext ctx, IServerRouter r) { log.info("Log Replication Metadata Request received by Server."); if (isLeader(msg, r)) { LogReplicationMetadataManager metadataMgr = sinkManager.getLogReplicationMetadataManager(); LogReplicationMetadataResponse response = new LogReplicationMetadataResponse( metadataMgr.getTopologyConfigId(), metadataMgr.getVersion(), metadataMgr.getLastStartedSnapshotTimestamp(), metadataMgr.getLastTransferredSnapshotTimestamp(), metadataMgr.getLastAppliedSnapshotTimestamp(), metadataMgr.getLastProcessedLogEntryTimestamp()); <START> log.info("Send Negotiation response"); <END> sinkManager.reset(); r.sendResponse(msg, CorfuMsgType.LOG_REPLICATION_METADATA_RESPONSE.payloadMsg(response)); } else { log.warn("Dropping metadata request as this node is not the leader."); } }</code><technical_language>Negotiation -> metadata</technical_language>

Target:
private void handleMetadataRequest(CorfuMsg msg, ChannelHandlerContext ctx, IServerRouter r) { log.info("Log Replication Metadata Request received by Server."); if (isLeader(msg, r)) { LogReplicationMetadataManager metadataMgr = sinkManager.getLogReplicationMetadataManager(); LogReplicationMetadataResponse response = new LogReplicationMetadataResponse( metadataMgr.getTopologyConfigId(), metadataMgr.getVersion(), metadataMgr.getLastStartedSnapshotTimestamp(), metadataMgr.getLastTransferredSnapshotTimestamp(), metadataMgr.getLastAppliedSnapshotTimestamp(), metadataMgr.getLastProcessedLogEntryTimestamp()); log.info("Send Metadata response :: {}", response); r.sendResponse(msg, CorfuMsgType.LOG_REPLICATION_METADATA_RESPONSE.payloadMsg(response)); } else { log.warn("Dropping metadata request as this node is not the leader."); } }
Source:
<code>public void testConditionHasDefaultTypeMapping() throws NoSuchFieldException, IllegalAccessException { <START> Field conditionToTypeField = XMPPError.class.getDeclaredField("CONDITION_TO_TYPE"); <END> conditionToTypeField.setAccessible(true); @SuppressWarnings("unchecked") Map<Condition, Type> conditionToTypeMap = (Map<Condition, Type>) conditionToTypeField.get(null); assertEquals("CONDITION_TO_TYPE map is likely out of sync with Condition enum", Condition.values().length, conditionToTypeMap.size()); }</code><technical_language>making CONDITION_TO_TYPE field package protected avoid reflection</technical_language>

Target:
public void testConditionHasDefaultTypeMapping() throws NoSuchFieldException, IllegalAccessException { Map<Condition, Type> conditionToTypeMap = XMPPError.CONDITION_TO_TYPE; assertEquals("CONDITION_TO_TYPE map is likely out of sync with Condition enum", Condition.values().length, conditionToTypeMap.size()); }
Source:
<code>public static void main(String[] args) { ZipkinTraceExporter.createAndRegister("http://localhost:9411/api/v2/spans", "tracing-to-zipkin-service"); TraceConfig traceConfig = Tracing.getTraceConfig(); TraceParams activeTraceParams = traceConfig.getActiveTraceParams(); traceConfig.updateActiveTraceParams(activeTraceParams.toBuilder().setSampler(Samplers.alwaysSample()).build()); Tracer tracer = Tracing.getTracer(); Scope scope = tracer.spanBuilder("user-parent-span").startScopedSpan(); try { QueueClient queueClient = new QueueClientBuilder() .endpoint(String.format("<LINK_0>", ACCOUNT_NAME, QUEUE_NAME, SAS_TOKEN)) .buildClient(); Context tracingContext = new Context(OPENCENSUS_SPAN_KEY, tracer.getCurrentSpan()); queueClient.createWithResponse(null, null, tracingContext); queueClient.enqueueMessageWithResponse("This is message 1", null, null, null, tracingContext); queueClient.enqueueMessageWithResponse("This is message 2", null, null, null, tracingContext); System.out.println("Enqueuing of messages has completed!"); } finally { scope.close(); } <START> Tracing.getExportComponent().shutdown(); <END> }</code><technical_language>this in finally block? If exception occurs, this get hit</technical_language>

Target:
public static void main(String[] args) { ZipkinTraceExporter.createAndRegister("http://localhost:9411/api/v2/spans", "tracing-to-zipkin-service"); TraceConfig traceConfig = Tracing.getTraceConfig(); TraceParams activeTraceParams = traceConfig.getActiveTraceParams(); traceConfig.updateActiveTraceParams(activeTraceParams.toBuilder().setSampler(Samplers.alwaysSample()).build()); Tracer tracer = Tracing.getTracer(); Scope scope = tracer.spanBuilder("user-parent-span").startScopedSpan(); try { QueueClient queueClient = new QueueClientBuilder() .endpoint(String.format("<LINK_0>", ACCOUNT_NAME, QUEUE_NAME, "<GENERATED_SAS_TOKEN>")) .buildClient(); Context tracingContext = new Context(OPENCENSUS_SPAN_KEY, tracer.getCurrentSpan()); queueClient.createWithResponse(null, null, tracingContext); queueClient.enqueueMessageWithResponse("This is message 1", null, null, null, tracingContext); queueClient.enqueueMessageWithResponse("This is message 2", null, null, null, tracingContext); System.out.println("Enqueuing of messages has completed!"); } finally { scope.close(); Tracing.getExportComponent().shutdown(); } }
Source:
<code>public void configure(Map configurationValues) { <START> OptionsService optionsService = serviceRegistry.getService( OptionsService.class ); <END> ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); ConfigurationPropertyReader propertyReader = new ConfigurationPropertyReader( configurationValues, classLoaderService ); try { this.config = new RedisConfiguration( propertyReader ); } catch (Exception e) { throw log.unableToConfigureDatastoreProvider( e ); } this.config.initConfiguration( configurationValues ); }</code><technical_language>used</technical_language>

Target:
public void configure(Map configurationValues) { ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); ConfigurationPropertyReader propertyReader = new ConfigurationPropertyReader( configurationValues, classLoaderService ); try { this.config = new RedisConfiguration( propertyReader ); } catch (Exception e) { throw log.unableToConfigureDatastoreProvider( e ); } }
Source:
<code>static GeoIPCookie unmarshal(@Nullable String cookie) { <START> if (TextUtils.isEmpty(cookie)) { <END> return new GeoIPCookie(); } String[] components = cookie.split(":"); if (components.length < Component.values().length || !components[Component.VERSION.ordinal()].equals("v4")) { return new GeoIPCookie(); } Location location = new Location(""); try { location.setLatitude(Double.parseDouble(components[Component.LATITUDE.ordinal()])); location.setLongitude(Double.parseDouble(components[Component.LONGITUDE.ordinal()])); } catch (NumberFormatException e) { L.w(e); location = null; } return new GeoIPCookie(components[Component.COUNTRY.ordinal()], components[Component.REGION.ordinal()], components[Component.CITY.ordinal()], location); }</code><technical_language>reason throw Exception for exceptional cases (blank input, wrong missing version, location is present unparseable)? paths return a null object more traceable throw Exception client decide handle case</technical_language>

Target:
static GeoIPCookie unmarshal(@Nullable String cookie) throws IllegalArgumentException { if (TextUtils.isEmpty(cookie)) { throw new IllegalArgumentException("Cookie is empty."); } String[] components = cookie.split(":"); if (components.length < Component.values().length) { throw new IllegalArgumentException("Cookie is malformed."); } else if (!components[Component.VERSION.ordinal()].equals("v4")) { throw new IllegalArgumentException("Incorrect cookie version."); } Location location = null; if (!TextUtils.isEmpty(components[Component.LATITUDE.ordinal()]) && !TextUtils.isEmpty(components[Component.LONGITUDE.ordinal()])) { location = new Location(""); try { location.setLatitude(Double.parseDouble(components[Component.LATITUDE.ordinal()])); location.setLongitude(Double.parseDouble(components[Component.LONGITUDE.ordinal()])); } catch (NumberFormatException e) { throw new IllegalArgumentException("Location is malformed."); } } return new GeoIPCookie(components[Component.COUNTRY.ordinal()], components[Component.REGION.ordinal()], components[Component.CITY.ordinal()], location); }
Source:
<code>public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) { Log_OC.d(TAG, "Received result of operation in FileActivity - common behaviour for all the " + "FileActivities "); mFileOperationsHelper.setOpIdWaitingFor(Long.MAX_VALUE); dismissLoadingDialog(); if (!result.isSuccess() && ( result.getCode() == ResultCode.UNAUTHORIZED || (result.isException() && result.getException() instanceof AuthenticatorException) )) { requestCredentialsUpdate(); if (result.getCode() == ResultCode.UNAUTHORIZED) { showSnackMessage( ErrorMessageAdapter.Companion.getResultMessage(result, operation, getResources()) ); } } else if (!result.isSuccess() && ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(result.getCode())) { showUntrustedCertDialog(result); } else if (operation == null || operation instanceof SynchronizeFolderOperation ) { if (result.isSuccess()) { updateFileFromDB(); } else if (result.getCode() != ResultCode.CANCELLED) { showSnackMessage( ErrorMessageAdapter.Companion.getResultMessage(result, operation, getResources()) ); } } else if (operation instanceof SynchronizeFileOperation) { onSynchronizeFileOperationFinish((SynchronizeFileOperation) operation, result); } else if (operation instanceof RenameFileOperation && result.isSuccess()) { result.getData(); } <START> } <END></code><technical_language>Sure, great, this is kotlin</technical_language>

Target:
public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) { Timber.d("Received result of operation in FileActivity - common behaviour for all the FileActivities"); mFileOperationsHelper.setOpIdWaitingFor(Long.MAX_VALUE); dismissLoadingDialog(); if (!result.isSuccess() && ( result.getCode() == ResultCode.UNAUTHORIZED || (result.isException() && result.getException() instanceof AuthenticatorException) )) { requestCredentialsUpdate(); if (result.getCode() == ResultCode.UNAUTHORIZED) { showSnackMessage( ErrorMessageAdapter.Companion.getResultMessage(result, operation, getResources()) ); } } else if (!result.isSuccess() && ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(result.getCode())) { showUntrustedCertDialog(result); } else if (operation == null || operation instanceof SynchronizeFolderOperation ) { if (result.isSuccess()) { updateFileFromDB(); } else if (result.getCode() != ResultCode.CANCELLED) { showSnackMessage( ErrorMessageAdapter.Companion.getResultMessage(result, operation, getResources()) ); } } else if (operation instanceof SynchronizeFileOperation) { onSynchronizeFileOperationFinish((SynchronizeFileOperation) operation, result); } else if (operation instanceof RenameFileOperation && result.isSuccess()) { result.getData(); } }
Source:
<code>private void populateLabels() { EntityRef building = buildingUpgradeSystem.getBuildingToUpgrade(); ConstructedBuildingComponent buildingComponent = building.getComponent(ConstructedBuildingComponent.class); if (buildingComponent == null) { <START> logger.info("component null"); <END> return; } buildingName.setText(buildingComponent.buildingType.toString()); buildingLevel.setText("" + buildingComponent.currentLevel); }</code><technical_language>"ConstructedBuildingComponent null" is a message. Component null refer anything</technical_language>

Target:
private void populateLabels() { EntityRef building = buildingUpgradeSystem.getBuildingToUpgrade(); ConstructedBuildingComponent buildingComponent = building.getComponent(ConstructedBuildingComponent.class); if (buildingComponent == null) { logger.info("ConstructedBuildingComponent null"); return; } buildingName.setText(buildingComponent.buildingType.toString()); buildingLevel.setText("" + buildingComponent.currentLevel); }
Source:
<code>public boolean contains(Object o) { <START> boolean contains = super.contains(o); <END> if (!contains && o != null) { MarshalledEntry<K, V> me = persistenceManager.loadFromAllStores(o, true); contains = me != null; } return contains; }</code><technical_language>if o is null, return false</technical_language>

Target:
public boolean contains(Object o) { boolean contains = false; if (o != null) { contains = super.contains(o); if (!contains) { MarshalledEntry<K, V> me = persistenceManager.loadFromAllStores(o, true); contains = me != null; } } return contains; }
Source:
<code>public static void main(String[] args) throws Exception { Crypto crypto = Crypto.initJava(); NetworkAccess network = NetworkAccess.buildJava(new URL("<LINK_0>")).get(); List<String> usernames = network.coreNode.getUsernames("").get(); List<Summary> summaries = usernames.stream().parallel().flatMap(username -> { try { List<UserPublicKeyLink> chain = network.coreNode.getChain(username).get(); UserPublicKeyLink last = chain.get(chain.size() - 1); LocalDate expiry = last.claim.expiry; Set<PublicKeyHash> ownedKeysRecursive = WriterData.getOwnedKeysRecursive(username, network.coreNode, network.mutable, network.dhtClient); long total = 0; for (PublicKeyHash writer : ownedKeysRecursive) { MaybeMultihash target = network.mutable.getPointerTarget(writer, network.dhtClient).get(); if (target.isPresent()) total += network.dhtClient.getRecursiveBlockSize(target.get()).get(); } String summary = "User: " + username + ", expiry: " + expiry + " usage: " + total + "\n"; <START> LOG.info(summary); <END> return Stream.of(new Summary(username, expiry, total)); } catch (Exception e) { LOG.severe("Error for " + username); LOG.log(Level.WARNING, e.getMessage(), e); return Stream.empty(); } }).collect(Collectors.toList()); summaries.sort((a, b) -> (int) (b.usage - a.usage)); summaries.forEach(System.out::println); }</code><technical_language>cmd app</technical_language>

Target:
public static void main(String[] args) throws Exception { Crypto crypto = Crypto.initJava(); NetworkAccess network = NetworkAccess.buildJava(new URL("<LINK_0>")).get(); List<String> usernames = network.coreNode.getUsernames("").get(); List<Summary> summaries = usernames.stream().parallel().flatMap(username -> { try { List<UserPublicKeyLink> chain = network.coreNode.getChain(username).get(); UserPublicKeyLink last = chain.get(chain.size() - 1); LocalDate expiry = last.claim.expiry; Set<PublicKeyHash> ownedKeysRecursive = WriterData.getOwnedKeysRecursive(username, network.coreNode, network.mutable, network.dhtClient); long total = 0; for (PublicKeyHash writer : ownedKeysRecursive) { MaybeMultihash target = network.mutable.getPointerTarget(writer, network.dhtClient).get(); if (target.isPresent()) total += network.dhtClient.getRecursiveBlockSize(target.get()).get(); } String summary = "User: " + username + ", expiry: " + expiry + " usage: " + total + "\n"; System.out.println(summary); return Stream.of(new Summary(username, expiry, total)); } catch (Exception e) { System.err.println("Error for " + username); e.printStackTrace(); return Stream.empty(); } }).collect(Collectors.toList()); summaries.sort((a, b) -> (int) (b.usage - a.usage)); summaries.forEach(System.out::println); }
Source:
<code>public void testProcessNodeForUnchangedEntity(String key, Object base, Object update) { Owner owner = TestUtil.createOwner(); String id = TestUtil.randomString("test_id"); Content existing = this.createPopulatedExistingEntity(id, key, base); ContentInfo imported = this.createPopulatedImportedEntity(id, key, base); <START> MergeValidator<ContentInfo> validator = this.validators.get(key); <END> EntityNode<Content, ContentInfo> node = new ContentNode(owner, id) .setExistingEntity(existing) .setImportedEntity(imported); ContentNodeVisitor visitor = this.buildContentNodeVisitor(); assertFalse(node.visited()); assertFalse(node.changed()); assertNull(node.getMergedEntity()); visitor.processNode(this.mockNodeProcessor, this.mockNodeMapper, node); visitor.complete(); assertTrue(node.visited()); assertFalse(node.changed()); assertNull(node.getMergedEntity()); }</code><technical_language>this line is needed (the validator thereafter)</technical_language>

Target:
public void testProcessNodeForUnchangedEntity(String key, Object base, Object update) { Owner owner = TestUtil.createOwner(); String id = TestUtil.randomString("test_id"); Content existing = this.createPopulatedExistingEntity(id, key, base); ContentInfo imported = this.createPopulatedImportedEntity(id, key, base); EntityNode<Content, ContentInfo> node = new ContentNode(owner, id) .setExistingEntity(existing) .setImportedEntity(imported); ContentNodeVisitor visitor = this.buildContentNodeVisitor(); assertFalse(node.visited()); assertFalse(node.changed()); assertNull(node.getMergedEntity()); visitor.processNode(this.mockNodeProcessor, this.mockNodeMapper, node); visitor.complete(); assertFalse(node.changed()); assertNull(node.getMergedEntity()); verify(this.mockContentCurator, never()).saveOrUpdate(any(Content.class)); }
Source:
<code>public void addRemoteCatalog(String catalogFileURL, String description, boolean verify) { new PushButton(ADD_REMOTE_CATALOG).click(); new WaitUntil(new ShellWithTextIsAvailable(REMOTE_CATALOG_SHELL), TimePeriod.NORMAL); new DefaultCombo().setText(catalogFileURL); new LabeledText(CATALOG_DESCRIPTION).setText(description); if (verify) { <START> new PushButton(VERIFY_BUTTON).click(); <END> } new OkButton().click(); }</code><technical_language>purpose of this line? I difference if url is correct incorrect. clicks Verify button continues clicking OK. nice preserve verification result. For example return String result</technical_language>

Target:
public String addRemoteCatalog(String catalogFileURL, String description, boolean verify) { String verificationResult = ""; new PushButton(ADD_REMOTE_CATALOG).click(); new WaitUntil(new ShellWithTextIsAvailable(REMOTE_CATALOG_SHELL), TimePeriod.NORMAL); new DefaultCombo().setText(catalogFileURL); new LabeledText(CATALOG_DESCRIPTION).setText(description); if (verify) { verificationResult = verifyURL(); } log.info(verificationResult); new OkButton().click(); return verificationResult; }