auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected Object readSimpleValue(@Nullable Object value, TypeInformation<?> targetType) { if (value == null) { return null; } if (ClassTypeInformation.OBJECT.equals(targetType) || (targetType != null && value.getClass().equals(targetType.getActualType()))) { return value; } if (conversionService.canConvert(value.getClass(), targetType.getType())) { return conversionService.convert(value, targetType.getType()); } <START> throw new MappingException( <END> String.format("Unable to map %s of type %s to %s", value, value.getClass(), targetType.getType())); }</code><technical_language>Do want add Enum handling well</technical_language>

Target:
private Object readSimpleValue(@Nullable Object value, TypeInformation<?> targetType) { Class<?> target = targetType.getType(); if (value == null || target == null || ClassUtils.isAssignableValue(target, value)) { return value; } if (conversions.hasCustomReadTarget(value.getClass(), target)) { return conversionService.convert(value, target); } if (Enum.class.isAssignableFrom(target)) { return Enum.valueOf((Class<Enum>) target, value.toString()); } return conversionService.convert(value, target); }
Source:
<code>public void hook(ExtensionHook extensionHook) { super.hook(extensionHook); JWTI18n.init(); try { extensionHook.addOptionsParamSet(getJWTConfiguration()); extensionHook.getHookView().addOptionPanel(new JWTOptionsPanel()); <START> LOGGER.info("JWT Extension loaded successfully"); <END> } catch (Exception e) { LOGGER.error("JWT Extension can't be loaded. Configuration not found or invalid", e); } }</code><technical_language>Move debug</technical_language>

Target:
public void hook(ExtensionHook extensionHook) { super.hook(extensionHook); JWTI18n.init(); try { extensionHook.addOptionsParamSet(getJWTConfiguration()); extensionHook.getHookView().addOptionPanel(new JWTOptionsPanel()); LOGGER.debug("JWT Extension loaded successfully"); } catch (Exception e) { LOGGER.error("JWT Extension can't be loaded. Configuration not found or invalid", e); } }
Source:
<code>public boolean checkFileExistsInGlobalSpace(Session session, String pathname) throws NotConnectedException, PermissionException { try { return fileSystem(session).resolveFileInGlobalspace(pathname).exists(); <START> } catch (FileSystemException e) { <END> return false; } }</code><technical_language>log debug, in case</technical_language>

Target:
public boolean checkFileExistsInGlobalSpace(Session session, String pathname) throws NotConnectedException, PermissionException { try { return fileSystem(session).resolveFileInGlobalspace(pathname).exists(); } catch (FileSystemException e) { logger.debug(String.format("Can't parse the file name [%s] in the global space.", pathname), e); return false; } }
Source:
<code>public void updateProfiles(ModelQueryLookup querySet, Vector<PredicateProfile> profiles) { <START> profiles.removeElementAt(0); <END> }</code><technical_language>This is implementation of this interface call: profiles.remove(querySet); Is reason for that? implementation (as I tell) acts member of profiles, this update() call standardized added super class</technical_language>

Target:
public void updateProfiles(ModelQueryLookup querySet, Vector<PredicateProfile> profiles) { profiles.remove(querySet); }
Source:
<code>protected Method getServiceMethod(Message message) { Message inMessage = message.getExchange().getInMessage(); Method method = null; if (inMessage != null) { <START> method = MessageUtils.getTargetMethod(inMessage, null); <END> } if (method == null) { method = message.getExchange().get(Method.class); } return method; }</code><technical_language>Minor, introducing overloaded method MessageUtils.getTargetMethod(inMessage) (which calls original null supplier) a bit more cleaner, need guess argument is. Alternatively, Optional<Method> caller raise exceptions get null. do think</technical_language>

Target:
protected Method getServiceMethod(Message message) { Message inMessage = message.getExchange().getInMessage(); Method method = null; if (inMessage != null) { method = MessageUtils.getTargetMethod(inMessage).orElse(null); } if (method == null) { method = message.getExchange().get(Method.class); } return method; }
Source:
<code>public void sysErrAvailable(final byte[] data) { if (this.sysErrStream == null) { try { this.sysErrFilePath = Files.createTempFile(null, "syserr"); this.sysErrFilePath.toFile().deleteOnExit(); <START> this.sysErrStream = Files.newOutputStream(this.sysOutFilePath); <END> } catch (IOException e) { handleException(e); return; } } try { this.sysErrStream.write(data); } catch (IOException e) { handleException(e); return; } }</code><technical_language>copy-paste error, want sysErrFilePath :-)</technical_language>

Target:
public void sysErrAvailable(final byte[] data) { if (this.sysErrStore == null) { this.sysErrStore = new SysOutErrContentStore(false); } try { this.sysErrStore.store(data); } catch (IOException e) { handleException(e); return; } }
Source:
<code>public void dispose() { if (fOverlayStore != null) { fOverlayStore.stop(); fOverlayStore= null; } for (Image image : colorPreviewImages) { image.dispose(); <START> } <END> super.dispose(); }</code><technical_language>I suggest reset colorPreviewImages null that</technical_language>

Target:
public void dispose() { if (fOverlayStore != null) { fOverlayStore.stop(); fOverlayStore= null; } for (Image image : colorPreviewImages) { image.dispose(); } colorPreviewImages= null; super.dispose(); }
Source:
<code>CompletableFuture<?> addToQueue(InternalHiveSplit split) { if (throwable.get() == null) { if (estimatedSplitSizeInBytes.addAndGet(split.getEstimatedSizeInBytes()) > maxOutstandingSplitsBytes) { throw new PrestoException(GENERIC_INTERNAL_ERROR, format( <START> "Split buffering for %s.%s takes too much memory (%s bytes limit). %s splits are buffered.", <END> databaseName, tableName, maxOutstandingSplitsBytes, getOutstandingSplitCount())); } return queue.offer(split); } return completedFuture(null); }</code><technical_language>java format( "Split buffering for %s.%s exceeded memory limit (%s). %s splits buffered.", ..., succinctBytes(maxOutstandingSplitsBytes), ...)</technical_language>

Target:
CompletableFuture<?> addToQueue(InternalHiveSplit split) { if (throwable.get() == null) { if (estimatedSplitSizeInBytes.addAndGet(split.getEstimatedSizeInBytes()) > maxOutstandingSplitsBytes) { throw new PrestoException(GENERIC_INTERNAL_ERROR, format( "Split buffering for %s.%s exceeded memory limit (%s). %s splits are buffered.", databaseName, tableName, succinctBytes(maxOutstandingSplitsBytes), getOutstandingSplitCount())); } return queue.offer(split); } return completedFuture(null); }
Source:
<code>public void deleteTagByRemoveButton(String tagName) { seleniumWebDriverHelper.moveCursorToAndClick( By.xpath( format( <START> " END> tagName))); }</code><technical_language>//div[text()='%s']/parent::md-chip-template/div[@class='stack-library-filter-tag-btn']/i a constant locators, IMHO</technical_language>

Target:
public void deleteTagByRemoveButton(String tagName) { String removeButtonXpath = format( FILTERS_INPUT_TAG_XPATH_TEMPLATE + "/parent::md-chip-template/div[@class='stack-library-filter-tag-btn']/i", tagName); seleniumWebDriverHelper.moveCursorToAndClick(By.xpath(removeButtonXpath)); }
Source:
<code>public void onVisible(IObservableValue serviceObservable, DataBindingContext dbc) { Object value = serviceObservable.getValue(); if (!(value instanceof IService)) { return; } IService service = (IService) value; nameText.setText(service.getName()); namespaceText.setText(service.getNamespace()); String labels = org.jboss.tools.openshift.common.core.utils.StringUtils.toString(service.getLabels()); if(labels != null) { labelsText.setText(labels); <START> } <END> String selectors = org.jboss.tools.openshift.common.core.utils.StringUtils.toString(service.getSelector()); if(selectors != null) { selectorsText.setText(selectors); } ipText.setText( org.apache.commons.lang.StringUtils.join(new String[] { service.getPortalIP(), StringUtils.toStringOrNull(service.getTargetPort()) }, ':')); portText.setText(StringUtils.toStringOrNull(service.getPort())); }</code><technical_language>if is null? text get reseted display value? shouldnt reset in this case? Btw. org.apache.commons.lang.StringUtils.defaultString(string) returns empty string if input is null</technical_language>

Target:
public void onVisible(IObservableValue serviceObservable, DataBindingContext dbc) { Object value = serviceObservable.getValue(); if (!(value instanceof IService)) { return; } IService service = (IService) value; nameText.setText(service.getName()); namespaceText.setText(service.getNamespace()); String labels = org.jboss.tools.openshift.common.core.utils.StringUtils.toString(service.getLabels()); labels = org.apache.commons.lang.StringUtils.defaultString(labels); labelsText.setText(labels); String selectors = org.jboss.tools.openshift.common.core.utils.StringUtils.toString(service.getSelector()); selectors = org.apache.commons.lang.StringUtils.defaultString(selectors); selectorsText.setText(selectors); ipText.setText( org.apache.commons.lang.StringUtils.join(new String[] { service.getPortalIP(), StringUtils.toStringOrNull(service.getTargetPort()) }, ':')); portText.setText(StringUtils.toStringOrNull(service.getPort())); }
Source:
<code>static String createJAASConfigFile(String fileName, String password) { String ret = null; try { File tmpDir = createTmpDir(); File jaasFile = new File(tmpDir, fileName); FileWriter fwriter = new FileWriter(jaasFile); fwriter.write("" <START> + "Server {\n" <END> + " " + digestLoginModule + " required\n" + " user_super=\"test\";\n" + "};\n" + "Client {\n" + " " + digestLoginModule + " required\n" + " username=\"super\"\n" + " password=\"" + password + "\";\n" + "};" + "\n"); fwriter.close(); ret = jaasFile.getAbsolutePath(); } catch (IOException e) { Assert.fail("Unable to create JaaS configuration file!"); } return ret; }</code><technical_language>revert this string</technical_language>

Target:
static String createJAASConfigFile(String fileName, String password) { String ret = null; try { File tmpDir = createTmpDir(); File jaasFile = new File(tmpDir, fileName); FileWriter fwriter = new FileWriter(jaasFile); fwriter.write("" + "Server {\n" + " " + digestLoginModule + " required\n" + " user_super=\"test\";\n" + "};\n" + "Client {\n" + " " + digestLoginModule + " required\n" + " username=\"super\"\n" + " password=\"" + password + "\";\n" + "};" + "\n"); fwriter.close(); ret = jaasFile.getAbsolutePath(); } catch (IOException e) { fail("Unable to create JaaS configuration file!"); } return ret; }
Source:
<code>public boolean isSubtype(final AnnotationMirror subAnno, final AnnotationMirror superAnno) { if (AnnotationUtils.areSame(subAnno, BOTTOM)) { return true; } if (AnnotationUtils.areSame(superAnno, BOTTOM)) { return false; } <START> if (AnnotationUtils.areSame(superAnno, TOP)) { <END> return true; } if (AnnotationUtils.areSame(subAnno, TOP)) { return false; } List<String> subVal = ValueCheckerUtils.getValueOfAnnotationWithStringArgument(subAnno); List<String> superVal = ValueCheckerUtils.getValueOfAnnotationWithStringArgument(superAnno); return subVal.containsAll(superVal); }</code><technical_language>This a test for top !AnnotationUtils.hasElementValue(a1, "value") above. Abstract out a method call, throughout</technical_language>

Target:
public boolean isSubtype(final AnnotationMirror subAnno, final AnnotationMirror superAnno) { if (AnnotationUtils.areSame(subAnno, bottom)) { return true; } else if (AnnotationUtils.areSame(superAnno, bottom)) { return false; } List<String> subVal = getAccumulatedValues(subAnno); List<String> superVal = getAccumulatedValues(superAnno); return subVal.containsAll(superVal); }
Source:
<code>public boolean contains(T value) { Node node = head.currentFlagAndNext.getReference(); <START> while (node.currentFlagAndNext.getReference() != null && node.value.compareTo(value) < 0) { <END> node = node.currentFlagAndNext.getReference(); } return node.value.compareTo(value) == 0 && !node.currentFlagAndNext.isMarked(); }</code><technical_language>= Iteration 2 / 10 = Actors thread: [get(1), put(1), remove(4)] [remove(5), put(2), get(4), put(3), put(3), put(1)] [put(5), get(1), remove(5)] Exception in thread "main" java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException com.devexperts.dxlab.lincheck.LinChecker.lambda$check$0(LinChecker.java:84) ... Caused by: java.lang.NullPointerException LockFreeSetImpl$Node.access$100(LockFreeSetImpl.java:4) LockFreeSetImpl.contains(LockFreeSetImpl.java:65) com.hpcourse.ees.linCheckTester.LockFreeSetCheck.get(LockFreeSetCheck.java:32) ... 36 more</technical_language>

Target:
public boolean contains(T value) { Node node = head.currentFlagAndNext.getReference(); if (node == null) { return false; } while (node.currentFlagAndNext.getReference() != null && node.value.compareTo(value) < 0) { node = node.currentFlagAndNext.getReference(); } return node.value.compareTo(value) == 0 && !node.currentFlagAndNext.isMarked(); }
Source:
<code><START> public int hashCode() { <END> final int prime = 31; int result = 1; result = prime * result + ((entityId == null) ? 0 : entityId.hashCode()); result = prime * result + ((jobId == null) ? 0 : jobId.hashCode()); return result; }</code><technical_language>return Objects.hash(entityId, jobId);</technical_language>

Target:
public int hashCode() { return Objects.hash(entityId, jobId); }
Source:
<code>private ITypedElement getHeadTypedElement(final IFile baseFile) { final RepositoryMapping mapping = RepositoryMapping.getMapping(baseFile .getProject()); final Repository repository = mapping.getRepository(); String gitPath = mapping.getRepoRelativePath(baseFile); try { GitIndex index = repository.getIndex(); if (index.getEntry(gitPath) == null) { return new GitCompareFileRevisionEditorInput.EmptyTypedElement( NLS.bind(UIText.CompareWithIndexAction_FileNotInIndex, baseFile.getName())); } <START> } catch (IOException e) { <END> return new GitCompareFileRevisionEditorInput.EmptyTypedElement( NLS.bind(UIText.CompareWithIndexAction_FileNotInIndex, baseFile.getName())); } IFileRevision nextFile = GitFileRevision.inIndex(repository, gitPath); final EditableRevision next = new EditableRevision(nextFile); IContentChangeListener listener = new IContentChangeListener() { public void contentChanged(IContentChangeNotifier source) { final byte[] newContent = next.getModifiedContent(); try { final GitIndex index = repository.getIndex(); final File file = new File(baseFile.getLocation() .toString()); index.add(mapping.getWorkDir(), file, newContent); index.write(); } catch (IOException e) { handle(new TeamException( UIText.CompareWithIndexAction_errorOnAddToIndex, e), UIText.CompareWithIndexAction_errorOnAddToIndex, UIText.CompareWithIndexAction_errorOnAddToIndex); return; } } }; next.addContentChangeListener(listener); return next; }</code><technical_language>exception logged</technical_language>

Target:
private ITypedElement getHeadTypedElement(final IFile baseFile) throws InvocationTargetException { final RepositoryMapping mapping = RepositoryMapping.getMapping(baseFile .getProject()); final Repository repository = mapping.getRepository(); String gitPath = mapping.getRepoRelativePath(baseFile); try { GitIndex index = repository.getIndex(); if (index.getEntry(gitPath) == null) { return new GitCompareFileRevisionEditorInput.EmptyTypedElement( NLS.bind(UIText.CompareWithIndexAction_FileNotInIndex, baseFile.getName())); } } catch (IOException e) { throw new InvocationTargetException(e); } IFileRevision nextFile = GitFileRevision.inIndex(repository, gitPath); final EditableRevision next = new EditableRevision(nextFile); IContentChangeListener listener = new IContentChangeListener() { public void contentChanged(IContentChangeNotifier source) { final byte[] newContent = next.getModifiedContent(); try { final GitIndex index = repository.getIndex(); final File file = new File(baseFile.getLocation().toString()); index.add(mapping.getWorkDir(), file, newContent); index.write(); } catch (IOException e) { handle( new TeamException( UIText.CompareWithIndexAction_errorOnAddToIndex, e), UIText.CompareWithIndexAction_errorOnAddToIndex, UIText.CompareWithIndexAction_errorOnAddToIndex); return; } } }; next.addContentChangeListener(listener); return next; }
Source:
<code>void poll(RequestRegistrationCallback<DeleteOperation> requestRegistrationCallback) { try { cleanupExpiredInflightRequests(); checkAndMaybeComplete(); if (!isOperationComplete()) { fetchRequests(requestRegistrationCallback); } } catch (Exception e) { <START> logger.error("Unexpected error in DeleteBlobOperation poll; operation cancelled.", e); <END> routerMetrics.unexpectedErrorCount.inc(); setOperationException(new RouterException("DeleteOperation poll encountered unexpected error", e, RouterErrorCode.UnexpectedInternalError)); } }</code><technical_language>a general rule of thumb follow i log exception is swallowed is destination of exception. In this case, exception is set passed else log eventually. If log exception is swallowed, double logging pollution of log</technical_language>

Target:
void poll(RequestRegistrationCallback<DeleteOperation> requestRegistrationCallback) { cleanupExpiredInflightRequests(); checkAndMaybeComplete(); if (!isOperationComplete()) { fetchRequests(requestRegistrationCallback); } }
Source:
<code><START> public String getTableDataDir() { return _tableDataDir; } <END></code><technical_language>try formatting this? in line</technical_language>

Target:
public File getTableDataDir() { return _indexDir; }
Source:
<code>public IConnectionWrapper getConnection() throws CoreException { <START> HashMap<String,String> map = new HashMap<String,String>(); <END> map.put(DefaultConnectionProvider.ID, name); map.put(DefaultConnectionProvider.URL, url); map.put(DefaultConnectionProvider.USERNAME, userName); map.put(DefaultConnectionProvider.PASSWORD, password); IConnectionProvider provider = ExtensionManager.getProvider(DefaultConnectionProvider.PROVIDER_ID); return provider.createConnection(map); }</code><technical_language>Optional: written in a more compact way: Map<String,String> map = new HashMap<>();</technical_language>

Target:
public IConnectionWrapper getConnection() throws CoreException { Map<String,String> map = new HashMap<>(); map.put(DefaultConnectionProvider.ID, name); map.put(DefaultConnectionProvider.URL, url); map.put(DefaultConnectionProvider.USERNAME, userName); map.put(DefaultConnectionProvider.PASSWORD, password); IConnectionProvider provider = ExtensionManager.getProvider(DefaultConnectionProvider.PROVIDER_ID); return provider.createConnection(map); }
Source:
<code>public FormValidation doCheckLabelString(@QueryParameter String value, @QueryParameter Node.Mode mode) { <START> if (mode == Node.Mode.EXCLUSIVE && (value == null || value.trim() == "")) { <END> return FormValidation.warning("Probably you should assign labels" + " when usage is 'Leave this machine for tied jobs only'" + " because this slave cannot be tied jobs without labels"); } return FormValidation.ok(); }</code><technical_language>want assign labels this node; marked run jobs exclusively tied a label</technical_language>

Target:
public FormValidation doCheckLabelString(@QueryParameter String value, @QueryParameter Node.Mode mode) { if (mode == Node.Mode.EXCLUSIVE && (value == null || value.trim() == "")) { return FormValidation.warning("You may want to assign labels to this node;" + " it's marked to only run jobs that are exclusively tied to itself or a label."); } return FormValidation.ok(); }
Source:
<code>public AccountingXmlDocumentAccountingLine createAccountingXmlDocumentAccountingLine(GroupLevel costCenterGroupLevel, DefaultKfsAccountForAws defaultKfsAccountForAws) { <START> LOG.info("createAccountingXmlDocumentAccountingLine for " + costCenterGroupLevel.getGroupName()); <END> String costCenterGroupValue = costCenterGroupLevel.getGroupValue(); AccountingXmlDocumentAccountingLine xmlAccountingLine = getEmptyAccountingXmlDocumentAccountingLine(); if (StringUtils.countMatches(costCenterGroupValue, "*") == 6) { xmlAccountingLine = parseCostCenterGroupLevel(costCenterGroupLevel.getGroupValue()); } else if (StringUtils.countMatches(costCenterGroupValue, "-") == 1) { xmlAccountingLine.setAccountNumber(StringUtils.split(costCenterGroupValue, "-")[0]); xmlAccountingLine.setSubAccountNumber(StringUtils.split(costCenterGroupValue, "-")[1]); } else { xmlAccountingLine.setAccountNumber(costCenterGroupValue); } xmlAccountingLine = fixAccountFieldReferences(xmlAccountingLine, defaultKfsAccountForAws.getKfsDefaultAccount()); xmlAccountingLine.setAmount(costCenterGroupLevel.getCost()); return xmlAccountingLine; }</code><technical_language>this a debug statement I</technical_language>

Target:
public AccountingXmlDocumentAccountingLine createAccountingXmlDocumentAccountingLine(GroupLevel costCenterGroupLevel, DefaultKfsAccountForAws defaultKfsAccountForAws) throws IllegalArgumentException { LOG.debug("createAccountingXmlDocumentAccountingLine for " + costCenterGroupLevel.getGroupName()); if (!costCenterGroupLevel.isCostCenterGroupLevel()) { throw new IllegalArgumentException(configurationService.getPropertyValueAsString(CuFPKeyConstants.ERROR_INVALID_GROUP_LEVEL_TYPE)); } String costCenterGroupValue = costCenterGroupLevel.getGroupValue(); AccountingXmlDocumentAccountingLine xmlAccountingLine = getEmptyAccountingXmlDocumentAccountingLine(); if (StringUtils.countMatches(costCenterGroupValue, "*") == 6) { xmlAccountingLine = parseCostCenterGroupLevel(costCenterGroupLevel.getGroupValue()); } else if (StringUtils.countMatches(costCenterGroupValue, "-") == 1) { xmlAccountingLine.setAccountNumber(StringUtils.split(costCenterGroupValue, "-")[0]); xmlAccountingLine.setSubAccountNumber(StringUtils.split(costCenterGroupValue, "-")[1]); } else { xmlAccountingLine.setAccountNumber(costCenterGroupValue); } xmlAccountingLine = fixAccountFieldReferences(xmlAccountingLine, defaultKfsAccountForAws.getKfsDefaultAccount()); xmlAccountingLine.setAmount(costCenterGroupLevel.getCost()); return xmlAccountingLine; }
Source:
<code>public static ObjectFactory loadObjectFactory(ClassFinder classFinder, String objectFactoryClassName) { ObjectFactory objectFactory; try { final Reflections reflections = new Reflections(classFinder); final ServiceLoader<io.cucumber.core.backend.ObjectFactory> loader = ServiceLoader.load(io.cucumber.core.backend.ObjectFactory.class); if (objectFactoryClassName == null) { <START> objectFactory = new ObjectFactoryAdapter(loadSingleObjectFactory(reflections, loader)); <END> } else { objectFactory = new ObjectFactoryAdapter(loadSelectedObjectFactory(reflections, loader, classFinder, objectFactoryClassName)); } } catch (TooManyInstancesException e) { LOG.warn(e.getMessage()); LOG.warn(getMultipleObjectFactoryLogMessage()); objectFactory = new DefaultJavaObjectFactory(); } catch (NoInstancesException e) { objectFactory = new DefaultJavaObjectFactory(); } catch (ClassNotFoundException e) { throw new CucumberException("Couldn't instantiate custom ObjectFactory", e); } return objectFactory; }</code><technical_language>Adapters applied needed. push this point needed? for below</technical_language>

Target:
public static ObjectFactory loadObjectFactory(ClassFinder classFinder, String objectFactoryClassName) { try { final Reflections reflections = new Reflections(classFinder); if (objectFactoryClassName == null) { return loadSingleObjectFactory(reflections); } else { return loadSelectedObjectFactory(reflections, classFinder, objectFactoryClassName); } } catch (TooManyInstancesException e) { LOG.warn(e.getMessage()); LOG.warn(getMultipleObjectFactoryLogMessage()); return new DefaultJavaObjectFactory(); } catch (NoInstancesException e) { return new DefaultJavaObjectFactory(); } catch (ClassNotFoundException e) { throw new CucumberException("Couldn't instantiate custom ObjectFactory", e); } }
Source:
<code>public ReplicaSet updateImage(String image) { ReplicaSet oldRC = get(); if (oldRC == null) { throw new KubernetesClientException("Existing replication controller doesn't exist"); } if (oldRC.getSpec().getTemplate().getSpec().getContainers().size() > 1) { throw new KubernetesClientException("Image update is not supported for multicontainer pods"); } if (oldRC.getSpec().getTemplate().getSpec().getContainers().isEmpty()) { throw new KubernetesClientException("Pod has no containers!"); } <START> Container container = oldRC.getSpec().getTemplate().getSpec().getContainers().get(0); <END> return updateImage(Collections.singletonMap(container.getName(), image)); }</code><technical_language>nit: retrieving item of a collection, in general do suggestion Container container = oldRC.getSpec().getTemplate().getSpec().getContainers().iterator().next(); This affected performance issues for specific collection implementations (imagine containers some sort of LinkedList access index heavily penalized)</technical_language>

Target:
public ReplicaSet updateImage(String image) { ReplicaSet oldRC = get(); if (oldRC == null) { throw new KubernetesClientException("Existing replication controller doesn't exist"); } if (oldRC.getSpec().getTemplate().getSpec().getContainers().size() > 1) { throw new KubernetesClientException("Image update is not supported for multicontainer pods"); } if (oldRC.getSpec().getTemplate().getSpec().getContainers().isEmpty()) { throw new KubernetesClientException("Pod has no containers!"); } Container container = oldRC.getSpec().getTemplate().getSpec().getContainers().iterator().next(); return updateImage(Collections.singletonMap(container.getName(), image)); }
Source:
<code>public String apply(String bytea, String format) { switch (Format.valueOf(format.toUpperCase(Locale.ROOT))) { case BASE64: final byte[] text; if (Hex.isHexFormat(bytea)) { text = Hex.decodeHex(Hex.stripHexFormatFlag(bytea)); } else { text = Octal.decode(bytea); } return Base64.getEncoder().encodeToString(text); case HEX: if (Hex.isHexFormat(bytea)) { return Hex.validateHex(Hex.stripHexFormatFlag(bytea)); } return Hex.encodeHexString(Octal.decode(bytea)); case ESCAPE: if (Hex.isHexFormat(bytea)) { return Octal.encode(Hex.decodeHex(Hex.stripHexFormatFlag(bytea))); } return Octal.encode(bytea.getBytes(StandardCharsets.UTF_8)); default: <START> throw new RuntimeException(); <END> } }</code><technical_language>defining a encode decode function Format enum itself, this switch statement eliminated improves performance. error handling improved, e.g. catching not-found enum.valueOf exception turn a user friendly "Format 'foo' supported" exception</technical_language>

Target:
public String apply(String bytea, String format) { final Format fmt; try { fmt = Format.valueOf(format.toUpperCase(Locale.ROOT)); } catch (IllegalArgumentException e) { throw new IllegalArgumentException( String.format(Locale.ENGLISH, "Encoding format '%s' is not supported", format) ); } return fmt.encode(bytea); }
Source:
<code>public RadiologyReport saveRadiologyReport(RadiologyReport radiologyReport) throws IllegalArgumentException { if (radiologyReport == null) { throw new IllegalArgumentException("radiologyReport cannot be null"); } if (radiologyReport.getRadiologyReportStatus() == null) { <START> throw new IllegalArgumentException("radiologyReportStatus is required"); <END> } if (isReportModifiable(radiologyReport)) { return radiologyReportDAO.saveRadiologyReport(radiologyReport); } else { throw new IllegalArgumentException("radiologyReport is not modifiable"); } }</code><technical_language>language "cannot null". dont express in ways user. consistent</technical_language>

Target:
public RadiologyReport saveRadiologyReport(RadiologyReport radiologyReport) throws IllegalArgumentException, UnsupportedOperationException { if (radiologyReport == null) { throw new IllegalArgumentException("radiologyReport cannot be null"); } if (radiologyReport.getReportStatus() == null) { throw new IllegalArgumentException("radiologyReportStatus cannot be null"); } if (radiologyReport.getReportStatus() == RadiologyReportStatus.DISCONTINUED) { throw new UnsupportedOperationException("a discontinued radiologyReport cannot be saved"); } if (radiologyReport.getReportStatus() == RadiologyReportStatus.COMPLETED) { throw new UnsupportedOperationException("a completed radiologyReport cannot be saved"); } return radiologyReportDAO.saveRadiologyReport(radiologyReport); }
Source:
<code>protected void run(Server server, User user, String commandLabel, String[] args) throws Exception { ItemStack item = user.getBase().getItemInHand(); if (item.getType().name().contains("AIR")) { <START> user.sendMessage(tl("itemloreInvalidItem")); return; <END> } if (args.length == 0) { throw new NotEnoughArgumentsException(); } ItemMeta im = item.getItemMeta(); if (args[0].equalsIgnoreCase("add") && args.length > 1) { String line = FormatUtil.formatString(user, "essentials.itemlore", getFinalArg(args, 1)).trim(); List<String> lore = im.hasLore() ? im.getLore() : new ArrayList<>(); lore.add(line); im.setLore(lore); item.setItemMeta(im); user.sendMessage(tl("itemloreSuccess", line)); } else if (args[0].equalsIgnoreCase("clear")) { im.setLore(new ArrayList<>()); item.setItemMeta(im); user.sendMessage(tl("itemloreClear")); } else if (args[0].equalsIgnoreCase("set") && args.length > 2 && NumberUtil.isInt(args[1])) { if (!im.hasLore()) { throw new Exception(tl("itemloreNoLore")); } int line = Integer.parseInt(args[1]); String newLine = FormatUtil.formatString(user, "essentials.itemlore", getFinalArg(args, 2)).trim(); List<String> lore = im.getLore(); try { lore.set(line - 1, newLine); } catch (Exception e) { throw new Exception(tl("itemloreNoLine", line), e); } im.setLore(lore); item.setItemMeta(im); user.sendMessage(tl("itemloreSuccessLore", line, newLine)); } else { throw new NotEnoughArgumentsException(); } }</code><technical_language>suggestion throw new Exception(tl("itemloreInvalidItem")); This is better, remain consistent handling errors in other parts of this command</technical_language>

Target:
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception { ItemStack item = user.getBase().getItemInHand(); if (item.getType().name().contains("AIR")) { throw new Exception(tl("itemloreInvalidItem")); } if (args.length == 0) { throw new NotEnoughArgumentsException(); } ItemMeta im = item.getItemMeta(); if (args[0].equalsIgnoreCase("add") && args.length > 1) { String line = FormatUtil.formatString(user, "essentials.itemlore", getFinalArg(args, 1)).trim(); List<String> lore = im.hasLore() ? im.getLore() : new ArrayList<>(); lore.add(line); im.setLore(lore); item.setItemMeta(im); user.sendMessage(tl("itemloreSuccess", line)); } else if (args[0].equalsIgnoreCase("clear")) { im.setLore(new ArrayList<>()); item.setItemMeta(im); user.sendMessage(tl("itemloreClear")); } else if (args[0].equalsIgnoreCase("set") && args.length > 2 && NumberUtil.isInt(args[1])) { if (!im.hasLore()) { throw new Exception(tl("itemloreNoLore")); } int line = Integer.parseInt(args[1]); String newLine = FormatUtil.formatString(user, "essentials.itemlore", getFinalArg(args, 2)).trim(); List<String> lore = im.getLore(); try { lore.set(line - 1, newLine); } catch (Exception e) { throw new Exception(tl("itemloreNoLine", line), e); } im.setLore(lore); item.setItemMeta(im); user.sendMessage(tl("itemloreSuccessLore", line, newLine)); } else { throw new NotEnoughArgumentsException(); } }
Source:
<code>public boolean implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException { if (offering.isSystemOnly()) { return false; } final Map<VirtualMachineProfile.Param, Object> params = new HashMap<VirtualMachineProfile.Param, Object>(1); params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true); final RouterDeploymentDefinition routerDeploymentDefinition = routerDeploymentDefinitionBuilder.create() .setGuestNetwork(network) .setDeployDestination(dest) .setAccountOwner(_accountMgr.getAccount(network.getAccountId())) .setParams(params) .build(); final List<DomainRouterVO> routers = routerDeploymentDefinition.deployVirtualRouter(); int routerCounts = 1; <START> if (offering.getRedundantRouter() || network.isRollingRestart()) { <END> routerCounts = 2; } if (routers == null || routers.size() < routerCounts) { List<DomainRouterVO> current_routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (current_routers.size() < 2) { updateToFailedState(network); throw new ResourceUnavailableException("Can't find all necessary running routers!", DataCenter.class, network.getDataCenterId()); } } return true; }</code><technical_language>neat solution</technical_language>

Target:
public boolean implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException { if (offering.isSystemOnly()) { return false; } final Map<VirtualMachineProfile.Param, Object> params = new HashMap<VirtualMachineProfile.Param, Object>(1); params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true); final RouterDeploymentDefinition routerDeploymentDefinition = routerDeploymentDefinitionBuilder.create() .setGuestNetwork(network) .setDeployDestination(dest) .setAccountOwner(_accountMgr.getAccount(network.getAccountId())) .setParams(params) .build(); final List<DomainRouterVO> routers = routerDeploymentDefinition.deployVirtualRouter(); int expectedRouters = 1; if (offering.getRedundantRouter() || network.isRollingRestart()) { expectedRouters = 2; } if (routers == null || routers.size() < expectedRouters) { List<DomainRouterVO> current_routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER); if (current_routers.size() < 2) { updateToFailedState(network); throw new ResourceUnavailableException("Can't find all necessary running routers!", DataCenter.class, network.getDataCenterId()); } } return true; }
Source:
<code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); if (view == null) { view = inflater.inflate(R.layout.fragment_random_item, container, false); ButterKnife.bind(this, view); imageView.setLegacyVisibilityHandlingEnabled(true); setContents(null); errorView.setBackClickListener(v -> getActivity().finish()); errorView.setVisibility(View.GONE); <START> new RandomSummaryClient().request(WikipediaApp.getInstance().getWikiSite(), new RandomSummaryClient.Callback() { <END> @Override public void onSuccess(@NonNull Call<RbPageSummary> call, @NonNull RbPageSummary pageSummary) { if (!isAdded()) { return; } setContents(pageSummary); } @Override public void onError(@NonNull Call<RbPageSummary> call, @NonNull Throwable t) { if (!isAdded()) { return; } setErrorState(t); } }); } return view; }</code><technical_language>errorView expects set a Retry listener, called Retry button is clicked. (With this patch Retry button nothing) pull out RandomSummaryClient request a separate method, call Retry listener, here. (and hide ErrorView successful response)</technical_language>

Target:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); if (view == null) { view = inflater.inflate(R.layout.fragment_random_item, container, false); ButterKnife.bind(this, view); imageView.setLegacyVisibilityHandlingEnabled(true); setContents(null); errorView.setBackClickListener(v -> getActivity().finish()); errorView.setRetryClickListener(v -> { progressBar.setVisibility(View.VISIBLE); getRandomPage(); }); getRandomPage(); } return view; }
Source:
<code>public void migration_must_set_analysis_uuid() throws SQLException { <START> String ceTaskUuid = RandomStringUtils.randomAlphanumeric(40); <END> String analysisUuid = RandomStringUtils.randomAlphanumeric(40); String webhookDeliveryUuid = RandomStringUtils.randomAlphanumeric(40); insertWebhookDelivery(webhookDeliveryUuid,null, ceTaskUuid); insertCeActivity(ceTaskUuid, analysisUuid); assertThat(db.countRowsOfTable(TABLE_WEBHOOK_DELIVERY)).isEqualTo(1); assertThat(db.countRowsOfTable(TABLE_CE_ACTIVITIY)).isEqualTo(1); underTest.execute(); List<Map<String, Object>> maps = selectAllWebhookDeliveries(); assertThat(maps).hasSize(1); assertThat(maps.get(0)).containsExactly( entry("ANALYSIS_UUID", analysisUuid), entry("UUID", webhookDeliveryUuid), entry("CE_TASK_UUID", ceTaskUuid)); }</code><technical_language>statically import randomAlphanumeric</technical_language>

Target:
public void migration_must_set_analysis_uuid() throws SQLException { String ceTaskUuid = randomAlphanumeric(40); String analysisUuid = randomAlphanumeric(40); String webhookDeliveryUuid = randomAlphanumeric(40); insertWebhookDelivery(webhookDeliveryUuid,null, ceTaskUuid); insertCeActivity(ceTaskUuid, analysisUuid); assertThat(db.countRowsOfTable(TABLE_WEBHOOK_DELIVERY)).isEqualTo(1); assertThat(db.countRowsOfTable(TABLE_CE_ACTIVITIY)).isEqualTo(1); underTest.execute(); List<Map<String, Object>> maps = selectAllWebhookDeliveries(); assertThat(maps).hasSize(1); assertThat(maps.get(0)).containsExactly( entry("ANALYSIS_UUID", analysisUuid), entry("UUID", webhookDeliveryUuid), entry("CE_TASK_UUID", ceTaskUuid)); }
Source:
<code>public void configure(Binder binder) { JsonConfigProvider.bind(binder, "druid.discovery.curator", CuratorDiscoveryConfig.class); binder.bind(CuratorServiceAnnouncer.class).in(LazySingleton.class); DruidBinders.discoveryAnnouncementBinder(binder); binder.bind(ServiceAnnouncer.class) .to(Key.get(CuratorServiceAnnouncer.class, Names.named(NAME))) .in(LazySingleton.class); <START> DruidDiscoveryModule.createBindingChoices(binder, CURATOR_KEY); <END> PolyBind.optionBinder(binder, Key.get(DruidNodeDiscoveryProvider.class)) .addBinding(CURATOR_KEY) .to(CuratorDruidNodeDiscoveryProvider.class) .in(LazySingleton.class); PolyBind.optionBinder(binder, Key.get(DruidNodeAnnouncer.class)) .addBinding(CURATOR_KEY) .to(CuratorDruidNodeAnnouncer.class) .in(LazySingleton.class); }</code><technical_language>create this new method in this new class call here? able setup PolyBinds here</technical_language>

Target:
public void configure(Binder binder) { JsonConfigProvider.bind(binder, "druid.discovery.curator", CuratorDiscoveryConfig.class); binder.bind(CuratorServiceAnnouncer.class).in(LazySingleton.class); DruidBinders.discoveryAnnouncementBinder(binder); binder.bind(ServiceAnnouncer.class) .to(Key.get(CuratorServiceAnnouncer.class, Names.named(NAME))) .in(LazySingleton.class); PolyBind.createChoiceWithDefault( binder, INTERNAL_DISCOVERY_PROP, Key.get(DruidNodeAnnouncer.class), CURATOR_KEY ); PolyBind.createChoiceWithDefault( binder, INTERNAL_DISCOVERY_PROP, Key.get(DruidNodeDiscoveryProvider.class), CURATOR_KEY ); PolyBind.optionBinder(binder, Key.get(DruidNodeDiscoveryProvider.class)) .addBinding(CURATOR_KEY) .to(CuratorDruidNodeDiscoveryProvider.class) .in(LazySingleton.class); PolyBind.optionBinder(binder, Key.get(DruidNodeAnnouncer.class)) .addBinding(CURATOR_KEY) .to(CuratorDruidNodeAnnouncer.class) .in(LazySingleton.class); }
Source:
<code>@Override public WebElement findElement(SearchContext context) throws WebDriverException, IllegalArgumentException { Class<?> contextClass = context.getClass(); if (FindsByAndroidViewTag.class.isAssignableFrom(contextClass)) { return FindsByAndroidViewTag.class.cast(context) .findElementByAndroidViewTag(getLocatorString()); } if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) { return super.findElement(context); } <START> throw formIllegalArgumentException(contextClass, FindsByAccessibilityId.class, <END> FindsByFluentSelector.class); }</code><technical_language>FindsByAndroidViewTag</technical_language>

Target:
@Override public WebElement findElement(SearchContext context) throws WebDriverException, IllegalArgumentException { Class<?> contextClass = context.getClass(); if (FindsByAndroidViewTag.class.isAssignableFrom(contextClass)) { return FindsByAndroidViewTag.class.cast(context) .findElementByAndroidViewTag(getLocatorString()); } if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) { return super.findElement(context); } throw formIllegalArgumentException(contextClass, FindsByAndroidViewTag.class, FindsByFluentSelector.class); }
Source:
<code>String locate(String name, CompilerInput referrer) { URI base = isRelativeIdentifier(name) ? createUri(referrer) <START> : createUri(moduleRoot); <END> return convertSourceUriToModuleAddress(base.resolve(createUri(name))); }</code><technical_language>this moduleRootURI</technical_language>

Target:
String locate(String name, CompilerInput referrer) { URI base = isRelativeIdentifier(name) ? createUri(referrer) : moduleRootURI; return convertSourceUriToModuleAddress(base.resolve(createUri(name))); }
Source:
<code>public void historyNotification(OperationHistoryEvent event) { if (session != null && <START> SessionStatus.DIRTY.equals(session.getStatus())) <END> { if (marker == null) { marker = event.getOperation(); } } }</code><technical_language>equals() is usefull for enum, == is sufficient</technical_language>

Target:
public void historyNotification(OperationHistoryEvent event) { if (session != null && SessionStatus.DIRTY == session.getStatus()) { if (marker == null) { marker = event.getOperation(); } } }
Source:
<code>Mono<Response<KeyVaultKey>> createKeyWithResponse(CreateKeyOptions createKeyOptions, Context context) { Objects.requireNonNull(createKeyOptions, "The key create options parameter cannot be null."); context = context == null ? Context.NONE : context; KeyRequestParameters parameters = new KeyRequestParameters() .setKty(createKeyOptions.getKeyType()) .setKeyOps(createKeyOptions.getKeyOperations()) .setKeyAttributes(new KeyRequestAttributes(createKeyOptions)) <START> .setKeyReleasePolicy(createKeyOptions.getKeyReleasePolicy()); <END> return service.createKey(vaultUrl, createKeyOptions.getName(), apiVersion, ACCEPT_LANGUAGE, parameters, CONTENT_TYPE_HEADER_VALUE, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Creating key - {}", createKeyOptions.getName())) .doOnSuccess(response -> logger.info("Created key - {}", response.getValue().getName())) .doOnError(error -> logger.warning("Failed to create key - {}", createKeyOptions.getName(), error)); }</code><technical_language>swagger is "release_policy", I ReleasePolicy instead of KeyReleasePolicy. in original bug well</technical_language>

Target:
Mono<Response<KeyVaultKey>> createKeyWithResponse(CreateKeyOptions createKeyOptions, Context context) { Objects.requireNonNull(createKeyOptions, "The key create options parameter cannot be null."); context = context == null ? Context.NONE : context; KeyRequestParameters parameters = new KeyRequestParameters() .setKty(createKeyOptions.getKeyType()) .setKeyOps(createKeyOptions.getKeyOperations()) .setKeyAttributes(new KeyRequestAttributes(createKeyOptions)) .setReleasePolicy(createKeyOptions.getReleasePolicy()); return service.createKey(vaultUrl, createKeyOptions.getName(), apiVersion, ACCEPT_LANGUAGE, parameters, CONTENT_TYPE_HEADER_VALUE, context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) .doOnRequest(ignored -> logger.info("Creating key - {}", createKeyOptions.getName())) .doOnSuccess(response -> logger.info("Created key - {}", response.getValue().getName())) .doOnError(error -> logger.warning("Failed to create key - {}", createKeyOptions.getName(), error)); }
Source:
<code>public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; boolean persistentAuth = FiltersHelper.isPersistentAuth(req); <START> HttpSession session = req.getSession(); <END> if (persistentAuth) { try { int ttlValue = Integer.parseInt(req.getHeader("Session-TTL")) * SECONDS_IN_MINUTE; if (ttlValue >= MINIMAL_SESSION_TTL) { session.setMaxInactiveInterval(ttlValue); } session.setAttribute( SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY, req.getAttribute(SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY ) ); } catch (NumberFormatException ex) { log.error("Session-TTL header was not passed. Not setting TTL value"); } } chain.doFilter(request, response); try { if (!persistentAuth && FiltersHelper.isAuthenticated(req)) { InitialContext ctx = new InitialContext(); try { FiltersHelper.getBackend(ctx).runAction( VdcActionType.LogoutBySession, new VdcActionParametersBase( (String) req.getAttribute(SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY) ) ); req.getSession().invalidate(); } finally { ctx.close(); } } } catch (Exception ex) { log.error("Error in REST-API session management. ", ex); } }</code><technical_language>need this here^</technical_language>

Target:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; boolean persistentAuth = FiltersHelper.isPersistentAuth(req); if (persistentAuth) { HttpSession session = req.getSession(true); try { int ttlValue = Integer.parseInt(req.getHeader("Session-TTL")) * SECONDS_IN_MINUTE; if (ttlValue >= MINIMAL_SESSION_TTL) { session.setMaxInactiveInterval(ttlValue); } } catch (NumberFormatException ex) { log.error("Session-TTL header was not passed. Not setting TTL value"); } String engineSessionId = (String)req.getAttribute(SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY); if (engineSessionId != null) { session.setAttribute( SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY, engineSessionId ); } } chain.doFilter(request, response); try { if (!persistentAuth && FiltersHelper.isAuthenticated(req)) { InitialContext ctx = new InitialContext(); try { FiltersHelper.getBackend(ctx).runAction( VdcActionType.LogoutBySession, new VdcActionParametersBase( (String) req.getAttribute(SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY) ) ); req.getSession().invalidate(); } finally { ctx.close(); } } else { HttpSession session = req.getSession(false); if (session != null && session.isNew() && session.getAttribute("async") != null && !Boolean.valueOf((boolean)session.getAttribute("async"))) { ((HttpServletResponse)response).addHeader(FiltersHelper.Constants.JSESSIONID_COOKIE, session.getId()); } } } catch (Exception ex) { log.error("Error in REST-API session management. ", ex); } }