auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void finishPendingCleanup() { final long start = System.currentTimeMillis(); try { try { barrier.lock(); while (!projectsUnderDeletion.isEmpty()) { <START> emptyQCond.await(1, TimeUnit.SECONDS); <END> } } finally { barrier.unlock(); } log.info("Took ms to complete ongoing cache cleanup.", (System.currentTimeMillis() - start)); } catch (InterruptedException e) { e.printStackTrace(); } }</code><technical_language>Please add a long line time code enters while loop</technical_language>

Target:
void finishPendingCleanup() { final long start = System.currentTimeMillis(); try { this.barrier.lock(); while (!projectsUnderDeletion.isEmpty()) { log.info("{} entries left in the cache directory deletion Q. Waiting for the cleanup to finish", this.projectsUnderDeletion.size()); this.emptyQCond.await(10, TimeUnit.SECONDS); } log.info("Took ms to complete ongoing cache cleanup.", (System.currentTimeMillis() - start)); } catch (InterruptedException e) { e.printStackTrace(); } finally { this.barrier.unlock(); } }
Source:
<code>public boolean execute(CommandSender sender, String label, String[] args) { final World world = CommandUtils.getWorld(sender); if (world == null) { <START> sender.sendMessage(ChatColor.RED + "Can not get the world"); <END> return false; } else { sender.sendMessage("Seed: " + world.getSeed()); } return true; }</code><technical_language>need send this error, return false. happen a block/entity/console</technical_language>

Target:
public boolean execute(CommandSender sender, String label, String[] args) { if (!testPermission(sender)) return false; final World world = CommandUtils.getWorld(sender); if (world == null) { return false; } else { sender.sendMessage("Seed: " + world.getSeed()); } return true; }
Source:
<code>private static String readAppUrl() { ApiProxy.Environment serverEnvironment = ApiProxy.getCurrentEnvironment(); if (serverEnvironment == null) { return null; } String hostname = (String) serverEnvironment.getAttributes() .get("com.google.appengine.runtime.default_version_hostname"); if (hostname == null) { return null; } if (isDevServer()) { return "http://" + hostname; } <START> return "https://" + hostname; <END> }</code><technical_language>save a lines making this block: java return (isDevServer() ? "http://" : "https://") + hostname;</technical_language>

Target:
private static String readAppUrl() { ApiProxy.Environment serverEnvironment = ApiProxy.getCurrentEnvironment(); if (serverEnvironment == null) { return null; } String hostname = (String) serverEnvironment.getAttributes() .get("com.google.appengine.runtime.default_version_hostname"); if (hostname == null) { return null; } return (isDevServer() ? "http://" : "https://") + hostname; }
Source:
<code>protected SmbSession createSession() throws IOException { Properties props = new Properties(); props.setProperty("jcifs.smb.client.minVersion", this.getSmbMinVer().name()); <START> props.setProperty("jcifs.smb.client.maxVersion", this.getSmbMaxVer().name()); <END> SmbShare smbShare = new SmbShare(this, props); smbShare.setReplaceFile(isReplaceFile()); smbShare.setUseTempFile(isUseTempFile()); if (logger.isInfoEnabled()) { logger.info(String.format("SMB share init: %s/%s", getHostPort(), getShareAndDir())); } smbShare.init(); logger.debug("SMB share initialized."); return new SmbSession(smbShare); }</code><technical_language>constants for keys</technical_language>

Target:
protected SmbSession createSession() throws IOException { Properties props = new Properties(); props.setProperty("jcifs.smb.client.minVersion", this.getSmbMinVersion().name()); props.setProperty("jcifs.smb.client.maxVersion", this.getSmbMaxVersion().name()); SmbShare smbShare = new SmbShare(this, props); smbShare.setReplaceFile(isReplaceFile()); smbShare.setUseTempFile(isUseTempFile()); if (logger.isInfoEnabled()) { logger.info(String.format("SMB share init: %s/%s", getHostPort(), getShareAndDir())); } smbShare.init(); logger.debug("SMB share initialized."); return new SmbSession(smbShare); }
Source:
<code>public ExtendedSymbolKindType(int _v) { try { <START> SymbolKind s = SymbolKind.forValue(_v); <END> value = _v; isProtocolSymbol = true; } catch (IllegalArgumentException e) { try { CquerySymbolKind c = CquerySymbolKind.forValue(_v); value = _v; isProtocolSymbol = false; } catch (IllegalArgumentException y) { throw new IllegalArgumentException("Illegal value for SymbolKind"); } } }</code><technical_language>variable 's' is used. If this for bounds check, do 'SymbolKind.forValue(_v)' discard return value. (Does IDE show a warning for unused variable? If not, want turn on. In general, please try avoid introducing new warnings if avoided. (Sometimes, avoided; for example, Server2ClientProtocolExtension derives LanguageClientImpl is technically public API, API tooling a warning that, do suppress it.))</technical_language>

Target:
public ExtendedSymbolKindType(int _v) { try { SymbolKind.forValue(_v); value = _v; isProtocolSymbol = true; } catch (IllegalArgumentException e) { try { CquerySymbolKind.forValue(_v); value = _v; isProtocolSymbol = false; } catch (IllegalArgumentException y) { throw new IllegalArgumentException("Illegal value for SymbolKind"); } } }
Source:
<code>private String getUniqueNameFor(String seriesName) { Integer quark = fQuarkToString.inverse().get(seriesName); int index = 0; String newName = seriesName; while (quark != null) <START> { newName = seriesName + '(' + index + ')'; quark = fQuarkToString.inverse().get(newName); <END> } return newName; }</code><technical_language>need increment index avoid infinite looping? do avoid seriesName, seriesName(0)</technical_language>

Target:
private String getUniqueNameFor(String seriesName) { Integer quark = fQuarkToString.inverse().get(seriesName); int index = 1; String newName = seriesName; while (quark != null) { newName = seriesName + '(' + index + ')'; quark = fQuarkToString.inverse().get(newName); index++; } return newName; }
Source:
<code><START> public static int levenDistance(String a, String b) { <END> a = a.toLowerCase(); b = b.toLowerCase(); int[] costs = new int [b.length() + 1]; for (int j = 0; j < costs.length; j++) costs[j] = j; for (int i = 1; i <= a.length(); i++) { costs[0] = i; int nw = i - 1; for (int j = 1; j <= b.length(); j++) { int cj = Math.min(1 + Math.min(costs[j], costs[j - 1]), a.charAt(i - 1) == b.charAt(j - 1) ? nw : nw + 1); nw = costs[j]; costs[j] = cj; } } return costs[b.length()]; }</code><technical_language>needed spark version</technical_language>

Target:
public static int levenDistance(String a, String b) { a = a.toLowerCase(Locale.ENGLISH); b = b.toLowerCase(Locale.ENGLISH); int[] costs = new int[b.length() + 1]; for (int j = 0; j < costs.length; j++) costs[j] = j; for (int i = 1; i <= a.length(); i++) { costs[0] = i; int nw = i - 1; for (int j = 1; j <= b.length(); j++) { int cj = Math.min(1 + Math.min(costs[j], costs[j - 1]), a.charAt(i - 1) == b.charAt(j - 1) ? nw : nw + 1); nw = costs[j]; costs[j] = cj; } } return costs[b.length()]; }
Source:
<code>public String conceptSearchHandler(@PathVariable("collection_id") String collection_id, HttpServletRequest req, ModelMap model) throws QuadrigaStorageException, QuadrigaAccessException { try { ConceptpowerReply conReply = conceptControllerManager.search(req.getParameter("name"), req.getParameter("pos")); if (conReply != null) { List<ConceptEntry> lists = conReply.getConceptEntry(); lists.sort(new Comparator<ConceptEntry>() { @Override public int compare(ConceptEntry o1, ConceptEntry o2) { return o1.getLemma().toLowerCase().compareTo(o2.getLemma().toLowerCase()); } }); model.addAttribute("result", conReply.getConceptEntry()); } } catch (HttpMessageNotReadableException hex) { logger.error("error:", hex); <START> return "auth/storageissue"; <END> } model.addAttribute("collectionid", collection_id); return "auth/searchitems"; }</code><technical_language>if throw a Quadriga exception general exception handler care of displaying it. this sense if do in response it</technical_language>

Target:
public String conceptSearchHandler(@PathVariable("collection_id") String collection_id, HttpServletRequest req, ModelMap model) throws QuadrigaStorageException, QuadrigaAccessException, QuadrigaException { try { ConceptpowerReply conReply = conceptControllerManager.search(req.getParameter("name"), req.getParameter("pos")); if (conReply != null) { List<ConceptEntry> lists = conReply.getConceptEntry(); lists.sort(new Comparator<ConceptEntry>() { @Override public int compare(ConceptEntry o1, ConceptEntry o2) { return o1.getLemma().toLowerCase().compareTo(o2.getLemma().toLowerCase()); } }); model.addAttribute("result", conReply.getConceptEntry()); } } catch (HttpMessageNotReadableException hex) { throw new QuadrigaException(hex); } model.addAttribute("collectionid", collection_id); return "auth/searchitems"; }
Source:
<code>public <T extends BusinessObject> T findByPrimaryKey(Class<T> clazz, Map<String, ?> primaryKeys) { <START> return (T)FavoriteAccountFixture.FAVORITE_ACCOUNT_1.createFavoriteAccount(); <END> }</code><technical_language>I suggest updating this analyze primary keys map, verify IDs in returning result</technical_language>

Target:
public <T extends BusinessObject> T findByPrimaryKey(Class<T> clazz, Map<String, ?> primaryKeys) { Integer accountLineIdentifier = (Integer) primaryKeys.get("accountLineIdentifier"); if (accountLineIdentifier.equals(13)) { return (T) FavoriteAccountFixture.FAVORITE_ACCOUNT_1.createFavoriteAccount(); } else { return null; } }
Source:
<code>public String asShortTime(Instant instant) { Locale set=locale; switch(preferencesService.getPreferences().getChat().getUkTime()) { case("yes"): set= new Locale("en", "UK"); break; case ("no"): set= new Locale("de", "DE"); break; } <START> return DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT).withLocale(set).format( <END> ZonedDateTime.ofInstant(instant, TimeZone.getDefault().toZoneId()) ); }</code><technical_language>locale set. Also, time formats; user choose time format a locale (see operating system do that, for instance)</technical_language>

Target:
public String asShortTime(Instant instant) { return DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT).withLocale(getCurrentTimeLocale()).format( ZonedDateTime.ofInstant(instant, TimeZone.getDefault().toZoneId()) ); }
Source:
<code>public void should_not_remove_tag_iframe_from_sound_cloud() { String html = "<ol><li><iframe width=\"100%\" height=\"166\" scrolling=\"no\" frameborder=\"no\" src=\"<LINK_1>\"></iframe></li><li>ctrl</li></ol>"; <START> String htmlSanitized = "<ol><li><iframe width=\"100%\" height=\"166\" scrolling=\"no\" frameborder=\"no\" src=\"<LINK_0>;https%3A END> String sanitized = htmlSanitizer.sanitize(html); assertEquals(htmlSanitized, sanitized); }</code><technical_language>sanitized html worked? I sanitizer escaped query string src of iframe (this link worked I accessed in browser): src="<LINK_0>;https%3A//api.soundcloud.com/tracks/119929315" While input was: src="<LINK_1>"</technical_language>

Target:
public void should_not_remove_tag_iframe_from_sound_cloud() { String html = "<ol><li><iframe width=\"100%\" height=\"166\" scrolling=\"no\" frameborder=\"no\" src=\"<LINK_1>\"></iframe></li><li>ctrl</li></ol>"; String htmlSanitized = "<ol><li><iframe width=\"100%\" height=\"166\" scrolling=\"no\" frameborder=\"no\" src=\"<LINK_0>;https%3A String sanitized = htmlSanitizer.sanitize(html).getText(); assertEquals(htmlSanitized, sanitized); }
Source:
<code>public void testNoRetry() { <START> Random random = mock(Random.class); <END> ExponentialBackoff backoff = new ExponentialBackoff(0, ONE_SECOND, random::nextDouble); assertThat(backoff.nextBackoff()).isEmpty(); }</code><technical_language>a weird mock Random passing a supplier</technical_language>

Target:
public void testNoRetry() { AtomicDouble random = new AtomicDouble(); ExponentialBackoff backoff = new ExponentialBackoff(0, ONE_SECOND, random::get); assertThat(backoff.nextBackoff()).isEmpty(); }
Source:
<code>public DimFilter optimize() { <START> return new InDimFilter(dimension, Arrays.asList(value), extractionFn).optimize(); <END> }</code><technical_language>Collections.singletonList()</technical_language>

Target:
public DimFilter optimize() { return new InDimFilter(dimension, Collections.singletonList(value), extractionFn).optimize(); }
Source:
<code>private void setWatchAction(UserFeed feed) { actionIcon.setImageResource(Action.WATCH.getDrawableId()); int pluralsId = feed.getGender() == Gender.FEMALE ? R.plurals.f_watch_series : R.plurals.m_watch_series; int seriesNumber = feed.getEpisodes(); String showName = feed.getShow(); String episodeName = "[" + feed.getEpisode() + "]"; <START> String actionText = itemView.getContext().getResources().getQuantityString(pluralsId, seriesNumber, seriesNumber, showName, episodeName); <END> setShowActionText(actionText, feed); }</code><technical_language>getContext().getResources() -> getResources()</technical_language>

Target:
private void setWatchAction(UserFeed feed) { actionIcon.setImageResource(Action.WATCH.getDrawableId()); int pluralsId = feed.getGender() == Gender.FEMALE ? R.plurals.f_watch_series : R.plurals.m_watch_series; int seriesNumber = feed.getEpisodes(); String showName = feed.getShow(); String episodeName = "[" + feed.getEpisode() + "]"; String actionText = itemView.getResources().getQuantityString(pluralsId, seriesNumber, seriesNumber, showName, episodeName); setShowActionText(actionText, feed); }
Source:
<code>protected void createTableViewer() { ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.BORDER); scrolledComposite.setExpandHorizontal(true); scrolledComposite.setExpandVertical(true); tableViewer = <START> viewerFactory.createTableViewer(scrolledComposite, <END> SWT.BORDER | SWT.FULL_SELECTION, getEClass()); Table table = tableViewer.getTable(); scrolledComposite.setContent(table); scrolledComposite.setMinSize(table .computeSize(SWT.DEFAULT, SWT.DEFAULT)); }</code><technical_language>this tableViewerFactory</technical_language>

Target:
protected void createTableViewer() { ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.BORDER); scrolledComposite.setExpandHorizontal(true); scrolledComposite.setExpandVertical(true); tableViewer = tableViewerFactory.createTableViewer(scrolledComposite, SWT.BORDER | SWT.FULL_SELECTION, getEClass()); Table table = tableViewer.getTable(); scrolledComposite.setContent(table); scrolledComposite.setMinSize(table .computeSize(SWT.DEFAULT, SWT.DEFAULT)); }
Source:
<code>public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { M_log.debug("doFilter: Called"); HttpServletRequest useRequest = (HttpServletRequest) request; HttpServletResponse useResponse=(HttpServletResponse)response; if ( BASIC_LTI_LAUNCH_REQUEST.equals(request.getParameter(LTI_MESSAGE_TYPE))) { M_log.debug("new launch so invalidate any existing session"); if (useRequest.getSession() != null) { M_log.info("session id to invalidate: " + useRequest.getSession().getId()); useRequest.getSession().invalidate(); } } HttpSession session= useRequest.getSession(true); M_log.debug("session id: " + session.getId()); setLaunchType(request, session); M_log.debug("Launch Type: " + session.getAttribute(LAUNCH_TYPE)); M_log.debug("Path Info: " + useRequest.getPathInfo() ); if (session.getAttribute(LAUNCH_TYPE).equals("lti")){ if( useRequest.getPathInfo() != null && useRequest.getPathInfo().equals(SC_PAGE)){ useRequest.getSession().invalidate(); useResponse.sendError(403); return; } chain.doFilter(useRequest, response); } else if(session.getAttribute(LAUNCH_TYPE).equals("sc")){ <START> if(!useRequest.getPathInfo().equals(STATUS_PAGE) && !useRequest.getPathInfo().equals(PING_PAGE)){ <END> if(!checkForAuthorization(useRequest)) { useResponse.sendError(403); return; } } chain.doFilter(useRequest, response); } }</code><technical_language>Check URL starts /status check for exact URLs. problem exact URLS is more work add new urls payoff for work</technical_language>

Target:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { M_log.debug("doFilter: Called"); HttpServletRequest useRequest = (HttpServletRequest) request; HttpServletResponse useResponse=(HttpServletResponse)response; if ( BASIC_LTI_LAUNCH_REQUEST.equals(request.getParameter(LTI_MESSAGE_TYPE))) { M_log.debug("new launch so invalidate any existing session"); if (useRequest.getSession() != null) { M_log.info("session id to invalidate: " + useRequest.getSession().getId()); useRequest.getSession().invalidate(); } } HttpSession session= useRequest.getSession(true); M_log.debug("session id: " + session.getId()); setLaunchType(request, session); M_log.debug("Launch Type: " + session.getAttribute(LAUNCH_TYPE)); M_log.debug("Path Info: " + useRequest.getPathInfo() ); if (session.getAttribute(LAUNCH_TYPE).equals("lti")){ if( useRequest.getPathInfo() != null && useRequest.getPathInfo().equals(SC_PAGE)){ useRequest.getSession().invalidate(); useResponse.sendError(403); return; } chain.doFilter(useRequest, response); } else if(session.getAttribute(LAUNCH_TYPE).equals("sc")){ if(useRequest.getPathInfo() != null && !useRequest.getPathInfo().startsWith(STATUS_PAGE) && !useRequest.getPathInfo().equals(BOOTSTRAP) && !checkForAuthorization(useRequest)){ useResponse.sendError(403); return; } chain.doFilter(useRequest, response); } }
Source:
<code>private boolean shouldRemoveCommand(AsyncTask asyncTask) { if (asyncTask == null || Guid.isNullOrEmpty(asyncTask.getCommandId())) { return false; } CommandEntity cmdEntity = coco.getCommandEntity(asyncTask.getCommandId()); <START> CommandEntity rootEntity = coco.getCommandEntity(asyncTask.getRootCommandId()); <END> CommandEntity parentEntity = null; if (cmdEntity != null) { parentEntity = coco.getCommandEntity(cmdEntity.getParentCommandId()); } return (cmdEntity != null && !cmdEntity.isCallbackEnabled() && (rootEntity == null || !rootEntity.isCallbackEnabled()) && (parentEntity == null || !parentEntity.isCallbackEnabled())); }</code><technical_language>this change rootEntity relevant here, check parent only</technical_language>

Target:
private boolean shouldRemoveCommand(AsyncTask asyncTask) { if (asyncTask == null || Guid.isNullOrEmpty(asyncTask.getCommandId())) { return false; } CommandEntity cmdEntity = coco.getCommandEntity(asyncTask.getCommandId()); CommandEntity parentEntity = null; if (cmdEntity != null) { parentEntity = coco.getCommandEntity(cmdEntity.getParentCommandId()); } return (cmdEntity != null && !cmdEntity.isCallbackEnabled() && (parentEntity == null || !parentEntity.isCallbackEnabled())); }
Source:
<code>public void visitField(Field field) { final CtField<Object> ctField = factory.Core().createField(); ctField.setSimpleName(field.getName()); setModifier(ctField, field.getModifiers(), field.getDeclaringClass()); try { Set<ModifierKind> modifiers = RtHelper.getModifiers(field.getModifiers()); if (modifiers.contains(ModifierKind.STATIC) && modifiers.contains(ModifierKind.PUBLIC) && (field.getType().isPrimitive() || String.class.isAssignableFrom(field.getType())) ) { CtLiteral<Object> defaultExpression = factory.createLiteral(field.get(null)); ctField.setDefaultExpression(defaultExpression); } <START> } catch (Throwable e) { <END> } enter(new VariableRuntimeBuilderContext(ctField)); super.visitField(field); exit(); contexts.peek().addField(ctField); }</code><technical_language>catching "IllegalAccessException | ExceptionInInitializerError"? Thanks a lot for changes</technical_language>

Target:
public void visitField(Field field) { final CtField<Object> ctField = factory.Core().createField(); ctField.setSimpleName(field.getName()); setModifier(ctField, field.getModifiers(), field.getDeclaringClass()); try { Set<ModifierKind> modifiers = RtHelper.getModifiers(field.getModifiers()); if (modifiers.contains(ModifierKind.STATIC) && modifiers.contains(ModifierKind.PUBLIC) && (field.getType().isPrimitive() || String.class.isAssignableFrom(field.getType())) ) { CtLiteral<Object> defaultExpression = factory.createLiteral(field.get(null)); ctField.setDefaultExpression(defaultExpression); } } catch (IllegalAccessException | ExceptionInInitializerError | UnsatisfiedLinkError e) { } enter(new VariableRuntimeBuilderContext(ctField)); super.visitField(field); exit(); contexts.peek().addField(ctField); }
Source:
<code>public void close() throws StorageContainerException { writeLock(); try { updateContainerData(containerData::closeContainer); } finally { writeUnlock(); } compactDB(); <START> flushAndSyncDB(); <END> }</code><technical_language>updateContainerData takes care revert state of container in case of failure. a problem flushDB? If flush fails, want container remain Open? Also, related question : relative order - sync change state close, writeLock held question applies quasiClose well</technical_language>

Target:
public void close() throws StorageContainerException { flushAndSyncDB(); writeLock(); try { flushAndSyncDB(); updateContainerData(containerData::closeContainer); } finally { writeUnlock(); } }
Source:
<code><START> protected void onCreateSessionSafe(Bundle savedInstanceState) { <END> super.onCreateSessionSafe(savedInstanceState); for(Suite s: CommCareApplication._().getCurrentApp().getCommCarePlatform().getInstalledSuites()){ allAlerts.addAll(s.getAlerts()); } launchService(allAlerts); loadInstanceState(savedInstanceState); ACRAUtil.registerAppData(); uiController.setupUI(); sessionNavigator = new SessionNavigator(this); formAndDataSyncer = new FormAndDataSyncer(); processFromExternalLaunch(savedInstanceState); processFromShortcutLaunch(); processFromLoginLaunch(); }</code><technical_language>super familiar this entry point, is lifecycle cleanly bound notion of a user login/logout event in a is reliable? a bit surprised firing v. in CommCareSessionService tied user navigation</technical_language>

Target:
protected void onCreateSessionSafe(Bundle savedInstanceState) { super.onCreateSessionSafe(savedInstanceState); loadInstanceState(savedInstanceState); ACRAUtil.registerAppData(); uiController.setupUI(); sessionNavigator = new SessionNavigator(this); formAndDataSyncer = new FormAndDataSyncer(); processFromExternalLaunch(savedInstanceState); processFromShortcutLaunch(); processFromLoginLaunch(); }
Source:
<code>private void initDataSource() throws HumanTaskServerException { database = new Database(serverConfig); database.setTransactionManager(tnxManager); try { database.start(); } catch (Exception e) { String errMsg = "Humantask Database Initialization failed."; <START> log.error(errMsg); <END> throw new HumanTaskServerException(errMsg, e); } }</code><technical_language>Need log exception here</technical_language>

Target:
private void initDataSource() throws HumanTaskServerException { database = new Database(serverConfig); database.setTransactionManager(tnxManager); try { database.start(); } catch (Exception e) { String errMsg = "Humantask Database Initialization failed."; log.error(errMsg, e); throw new HumanTaskServerException(errMsg, e); } }
Source:
<code>private void validateProperties(ProcessingEnvironment env, Map<String, ExecutableElement> properties) { Types typeUtils = env.getTypeUtils(); Elements elementUtils = env.getElementUtils(); TypeMirror collection = typeUtils.getDeclaredType( <START> elementUtils.getTypeElement(Collection.class.getName()), <END> typeUtils.getWildcardType(null, null) ); TypeMirror parcelable = env.getElementUtils().getTypeElement("android.os.Parcelable").asType(); TypeMirror serializable = TypeSimplifier.typeFromClass(env.getTypeUtils(), env.getElementUtils(), Serializable.class); for (ExecutableElement name : properties.values()) { TypeMirror type = name.getReturnType(); if (type.getKind() == TypeKind.DECLARED && typeUtils.isSubtype(type, collection)) { DeclaredType dType = (DeclaredType) type; List<? extends TypeMirror> types = dType.getTypeArguments(); if (!types.isEmpty()) { type = types.get(0); } } if (!TypeName.get(type).isPrimitive() && !TypeSimplifier.isClassOfType(env.getTypeUtils(), parcelable, type) && !TypeSimplifier.isClassOfType(env.getTypeUtils(), serializable, type)) { env.getMessager().printMessage(Diagnostic.Kind.ERROR, "AutoValue property " + name.getSimpleName() + " is not primitive, Parcelable, or Serializable.", name); throw new AutoValueParcelException(); } } }</code><technical_language>I specifically check for List instead of Collection. Parcel special cases List writeList() method. Collections other hand parcelable if type parameter is serializable. Check out implementation of Parcel#writeValue(). a lot of special cases</technical_language>

Target:
private void validateProperties(ProcessingEnvironment env, Map<String, ExecutableElement> properties) { Types typeUtils = env.getTypeUtils(); Elements elementUtils = env.getElementUtils(); TypeMirror list = typeUtils.getDeclaredType( elementUtils.getTypeElement(List.class.getName()), typeUtils.getWildcardType(null, null) ); TypeMirror parcelable = env.getElementUtils().getTypeElement("android.os.Parcelable").asType(); TypeMirror serializable = TypeSimplifier.typeFromClass(env.getTypeUtils(), env.getElementUtils(), Serializable.class); for (ExecutableElement name : properties.values()) { TypeMirror type = name.getReturnType(); if (type.getKind() == TypeKind.DECLARED && typeUtils.isSubtype(type, list)) { DeclaredType dType = (DeclaredType) type; List<? extends TypeMirror> types = dType.getTypeArguments(); if (!types.isEmpty()) { type = types.get(0); } } else if (type.getKind() == TypeKind.ARRAY) { ArrayType aType = (ArrayType) type; type = aType.getComponentType(); } if (!TypeName.get(type).isPrimitive() && !TypeSimplifier.isClassOfType(env.getTypeUtils(), parcelable, type) && !TypeSimplifier.isClassOfType(env.getTypeUtils(), serializable, type)) { env.getMessager().printMessage(Diagnostic.Kind.ERROR, "AutoValue property " + name.getSimpleName() + " is not primitive, Parcelable, or Serializable.", name); throw new AutoValueParcelException(); } } }
Source:
<code>private void refreshAssetList() { final Images images = Ode.getImageBundle(); OdeLog.log("AssetList: refreshing for project " + projectId); assetList.clear(); if (assetsFolder != null) { for (ProjectNode node : assetsFolder.getChildren()) { String nodeName = node.getName(); if (nodeName.length() > 20) nodeName = nodeName.substring(0, 8) + "..." + nodeName.substring(nodeName.length() - 9, nodeName.length()); String fileSuffix = node.getProjectId() + "/" + node.getFileId(); String treeItemText = "<span style='cursor: pointer'>"; <START> Image mediaIcon = null; <END> if (StorageUtil.isImageFile(fileSuffix)) { mediaIcon = new Image(images.mediaIconImg()); } else if (StorageUtil.isAudioFile(fileSuffix )) { mediaIcon = new Image(images.mediaIconAudio()); } else if (StorageUtil.isVideoFile(fileSuffix )) { mediaIcon = new Image(images.mediaIconVideo()); } if (mediaIcon != null){ treeItemText += mediaIcon; } treeItemText += nodeName + "</span>"; TreeItem treeItem = new TreeItem(new HTML(treeItemText)); treeItem.setUserObject(node); assetList.addItem(treeItem); } } }</code><technical_language>Alternatively, instead of setting checking variable, if-else blocks treeItemText += new Image(...); path taken</technical_language>

Target:
private void refreshAssetList() { final Images images = Ode.getImageBundle(); OdeLog.log("AssetList: refreshing for project " + projectId); assetList.clear(); if (assetsFolder != null) { for (ProjectNode node : assetsFolder.getChildren()) { String nodeName = node.getName(); if (nodeName.length() > 20) nodeName = nodeName.substring(0, 8) + "..." + nodeName.substring(nodeName.length() - 9, nodeName.length()); String fileSuffix = node.getProjectId() + "/" + node.getFileId(); String treeItemText = "<span style='cursor: pointer'>"; if (StorageUtil.isImageFile(fileSuffix)) { treeItemText += new Image(images.mediaIconImg()); } else if (StorageUtil.isAudioFile(fileSuffix )) { treeItemText += new Image(images.mediaIconAudio()); } else if (StorageUtil.isVideoFile(fileSuffix )) { treeItemText += new Image(images.mediaIconVideo()); } treeItemText += nodeName + "</span>"; TreeItem treeItem = new TreeItem(new HTML(treeItemText)); treeItem.setUserObject(node); assetList.addItem(treeItem); } } }
Source:
<code>private TimeoutDuration getTimeoutDuration(EhcacheOperationMessage message) { <START> TimeoutDuration timeLimit = timeouts.getMutativeOperationTimeout(); <END> if (GET_STORE_OPS.contains(message.getMessageType())) { timeLimit = timeouts.getReadOperationTimeout(); } return timeLimit; }</code><technical_language>a if/else</technical_language>

Target:
private TimeoutDuration getTimeoutDuration(EhcacheOperationMessage message) { if (GET_STORE_OPS.contains(message.getMessageType())) { return timeouts.getReadOperationTimeout(); } else { return timeouts.getMutativeOperationTimeout(); } }
Source:
<code>protected boolean isDriverVersion( int majorVersion, int minorVersion ) { int driverMajorVersion; int driverMinorVersion; if ( getAccessType() == DatabaseMeta.TYPE_ACCESS_JNDI ) { PooledDatasourceHelper pooledDatasourceHelper = new PooledDatasourceHelper(); DataSource dataSource = null; try { dataSource = pooledDatasourceHelper.getJndiDataSource( this.getDatabaseName() ); } catch ( DBDatasourceServiceException e ) { <START> e.printStackTrace(); <END> } DatabaseMetaData meta = null; try { Connection connection = dataSource.getConnection(); meta = connection.getMetaData(); } catch ( SQLException e ) { e.printStackTrace(); } driverMajorVersion = meta.getDriverMajorVersion(); driverMinorVersion = meta.getDriverMinorVersion(); } else { String url = getURL( "localhost", "10000", "default" ); Driver driver = driverLocator.getDriver( url ); driverMajorVersion = driver.getMajorVersion(); driverMinorVersion = driver.getMinorVersion(); } return driverMajorVersion > majorVersion || ( driverMajorVersion == majorVersion && driverMinorVersion >= minorVersion ); }</code><technical_language>do e.printStackTrace() calls - regular logging</technical_language>

Target:
protected boolean isDriverVersion( int majorVersion, int minorVersion ) { int driverMajorVersion; int driverMinorVersion; if ( getAccessType() == DatabaseMeta.TYPE_ACCESS_JNDI ) { PooledDatasourceHelper pooledDatasourceHelper = new PooledDatasourceHelper(); DataSource dataSource = null; try { dataSource = pooledDatasourceHelper.getJndiDataSource( this.getDatabaseName() ); } catch ( DBDatasourceServiceException e ) { logger.error( e.getMessage(), e ); } DatabaseMetaData meta = null; try ( Connection connection = dataSource.getConnection() ) { meta = connection.getMetaData(); } catch ( SQLException e ) { logger.error( e.getMessage(), e ); } driverMajorVersion = meta.getDriverMajorVersion(); driverMinorVersion = meta.getDriverMinorVersion(); } else { String url = getURL( "localhost", "10000", "default" ); Driver driver = driverLocator.getDriver( url ); driverMajorVersion = driver.getMajorVersion(); driverMinorVersion = driver.getMinorVersion(); } return driverMajorVersion > majorVersion || ( driverMajorVersion == majorVersion && driverMinorVersion >= minorVersion ); }
Source:
<code>public SourceResponse query(QueryRequest request) throws UnsupportedQueryException { long startTime = System.currentTimeMillis(); SourceResponse result = source.query(request); long endTime = System.currentTimeMillis(); int elapsedTime = Math.toIntExact(endTime - startTime); <START> result.getProperties().put("metrics.source.elapsed." + source.getId(), elapsedTime); <END> LOGGER.trace("Source took {}ms to query.", source.getId(), elapsedTime); return result; }</code><technical_language>this magic string concatenation is a bit brittle. nice if a centralized place prefix lived, ideally methods like: 1. createSourceElapsedPropKey(String): String 2. isSourceElapsedPropKey(String): Boolean 3. getSourceFromKey(String): String needed here; in SourceMetricsImpl</technical_language>

Target:
public SourceResponse query(QueryRequest request) throws UnsupportedQueryException { long startTime = System.currentTimeMillis(); SourceResponse result = source.query(request); long endTime = System.currentTimeMillis(); int elapsedTime = Math.toIntExact(endTime - startTime); String sourceLatencyMetricKey = METRICS_SOURCE_ELAPSED_PREFIX_API + source.getId(); result.getProperties().put(sourceLatencyMetricKey, elapsedTime); LOGGER.trace("Query latency for source was {}ms.", source.getId(), elapsedTime); return result; }
Source:
<code>public void onApplicationEvent(AbstractAuthenticationEvent appEvent) { String currentUserName = extractUserName(appEvent); if (currentUserName == null || isLockMechanismDisabled()) { return; } <START> if (appEvent instanceof AuthenticationSuccessEvent) { <END> if (accessCounter.containsKey(currentUserName)) { if (accessCounter.get(currentUserName) < maxLoginFailures) { accessCounter.remove(currentUserName); lastFailedLogin.remove(currentUserName); } } } if (appEvent instanceof AuthenticationFailureBadCredentialsEvent) { if (accessCounter.containsKey(currentUserName)) { accessCounter.put(currentUserName, accessCounter.get(currentUserName) + 1); } else { accessCounter.put(currentUserName, 1); } lastFailedLogin.put(currentUserName, new Date()); } }</code><technical_language>change 1 if 2 && conditions. Easier read "normal" writing if (appEvent instanceof AuthenticationSuccessEvent && accessCounter.containsKey(currentUserName) && accessCounter.get(currentUserName) < maxLoginFailures) {</technical_language>

Target:
public void onApplicationEvent(AbstractAuthenticationEvent appEvent) { String currentUserName = extractUserName(appEvent); if (currentUserName == null || isLockMechanismDisabled()) { return; } if (appEvent instanceof AuthenticationSuccessEvent && accessCounter.containsKey(currentUserName) && accessCounter.get(currentUserName) < maxLoginFailures) { accessCounter.remove(currentUserName); lastFailedLogin.remove(currentUserName); } if (appEvent instanceof AuthenticationFailureBadCredentialsEvent) { if (accessCounter.containsKey(currentUserName)) { accessCounter.put(currentUserName, accessCounter.get(currentUserName) + 1); } else { accessCounter.put(currentUserName, 1); } lastFailedLogin.put(currentUserName, new Date()); } }
Source:
<code>public static double breakSize(PDFLine l2, PDFLine l1) { if(l2==null || l1==null) return 0.0; float h1 = getH(l1); float h2 = getH(l2); if(h1 < 0.0f) <START> log.info("negative height!!!!"); <END> return (getY(l2, true) - getY(l1, false))/Math.min(h1,h2); }</code><technical_language>abort processing a safe 0 height this happens</technical_language>

Target:
public static double breakSize(PDFLine l2, PDFLine l1) { if(l2==null || l1==null) return 0.0; float h1 = getH(l1); float h2 = getH(l2); return (getY(l2, true) - getY(l1, false)) / Math.min(h1,h2); }
Source:
<code>public void testMatchResults(final double pLoH) { final Fingerprint fpObserved = new Fingerprint("test", null, "noop"); final Fingerprint fpExpected = new Fingerprint("test", null, "noop"); final HaplotypeProbabilities hpHet = new HaplotypeProbabilitiesFromGenotype(snp, hb, 0.0001, 1.0, 0.0001); final HaplotypeProbabilities hpHomRef = new HaplotypeProbabilitiesFromGenotype(snp, hb, 1.0, 0.00001, 0.000000001); fpExpected.add(hpHet); fpObserved.add(hpHomRef); <START> MatchResults mr = FingerprintChecker.calculateMatchResults(fpObserved, fpExpected, 0.01, pLoH); <END> Assert.assertTrue(mr.getLodTN() > mr.getLOD() ); Assert.assertTrue(mr.getLOD() < 0); Assert.assertTrue(mr.getLodTN() > mr.getLodNT()); }</code><technical_language>final</technical_language>

Target:
public void testMatchResults(final double pLoH) { final Fingerprint fpObserved = new Fingerprint("test", null, "noop"); final Fingerprint fpExpected = new Fingerprint("test", null, "noop"); final HaplotypeProbabilities hpHet = new HaplotypeProbabilitiesFromGenotype(snp, hb, 0.0001, 1.0, 0.0001); final HaplotypeProbabilities hpHomRef = new HaplotypeProbabilitiesFromGenotype(snp, hb, 1.0, 0.00001, 0.000000001); fpExpected.add(hpHet); fpObserved.add(hpHomRef); final MatchResults mr = FingerprintChecker.calculateMatchResults(fpObserved, fpExpected, 0.01, pLoH); Assert.assertTrue(mr.getLodTN() > mr.getLOD()); Assert.assertTrue(mr.getLOD() < 0); Assert.assertTrue(mr.getLodTN() > mr.getLodNT()); }
Source:
<code>protected boolean validate() { if (!validateExternalVnicProfileMapping()) { return false; } initVmTemplate(); if <START> (!super.validate()) { <END> return false; } ArrayList<DiskImage> disks = new ArrayList(getVmTemplate().getDiskTemplateMap().values()); setImagesWithStoragePoolId(getStorageDomain().getStoragePoolId(), disks); getVmTemplate().setImages(disks); if (getParameters().isImagesExistOnTargetStorageDomain() && !validateUnregisteredEntity(vmTemplateFromConfiguration, ovfEntityData)) { return false; } return true; }</code><technical_language>note initialize imageToDestinationDomainMap. able send ValidateDiskNotAlreadyExistOnDB avoid filterInvalidDisksForImport in excecuteCommand. please try this change then: 1. create a template 2. detach SD template 3. register template disk 4. register template 5. try watch template disks (if wrong UI exception occurs) 6. Remove template verify disk remains in environment</technical_language>

Target:
protected boolean validate() { initVmTemplate(); if (!super.validate()) { return false; } if (!validateExternalVnicProfileMapping()) { return false; } ArrayList<DiskImage> disks = new ArrayList(getVmTemplate().getDiskTemplateMap().values()); setImagesWithStoragePoolId(getStorageDomain().getStoragePoolId(), disks); getVmTemplate().setImages(disks); if (getParameters().isImagesExistOnTargetStorageDomain() && !validateUnregisteredEntity(vmTemplateFromConfiguration, ovfEntityData)) { return false; } return true; }
Source:
<code>public void activate(Map<String, Object> config) { <START> final int port = config.containsKey(KEY_PORT) ? Integer.parseInt(config.get(KEY_PORT).toString()) <END> : DEFAULT_PORT; injector = Guice.createInjector(new RuntimeServerModule(scriptServiceUtil, scriptEngine)); new Thread(() -> { listen(port); }, "Language Server").start(); }</code><technical_language>catch a NumberFormatException here</technical_language>

Target:
public void activate(Map<String, Object> config) { int port = DEFAULT_PORT; try { port = config.containsKey(KEY_PORT) ? Integer.parseInt(config.get(KEY_PORT).toString()) : DEFAULT_PORT; } catch (NumberFormatException e) { logger.warn("Couldn't parse '{}', using default port '{}' for the Language Server instead", config.get(KEY_PORT), DEFAULT_PORT); } final int serverPort = port; injector = Guice.createInjector(new RuntimeServerModule(scriptServiceUtil, scriptEngine)); new Thread(() -> { listen(serverPort); }, "Language Server").start(); }
Source:
<code>public void confirmDelete() { <START> clickArticleDeleteConfirmationButton("MediaWiki:Wikia.css"); <END> }</code><technical_language>store in a const re-use in line 194? escape semicolon there: java verifyUrl("Special:Undelete?target=" + CSS_FILE.escape() ); a guess, I if Java allow :P</technical_language>

Target:
public void confirmDelete() { clickArticleDeleteConfirmationButton(URLsContent.mediaWikiCss); }
Source:
<code>private Resource loadFromClassLoader(Class<?> clazz, String path, ResourceSet resourceSet) throws IOException { final URL fileURL = clazz.getResource(path); final URI uri = URI.createURI(fileURL.toString()); <START> List<URI> urisToLoad = <END> Collections.singletonList(uri); for (IResourceSetHook hook : getMatchingHooks(urisToLoad)) { hook.preLoadingHook(resourceSet, urisToLoad); } final Resource existing = resourceSet.getResource(uri, false); if (existing != null) { return existing; } InputStream stream = null; Resource resource = null; try { resource = resourceSet.createResource(uri); stream = fileURL.openStream(); resource.load(stream, Collections.emptyMap()); } catch (IOException e) { } catch (WrappedException e) { } finally { if (stream != null) { try { stream.close(); } catch (IOException e) { } } } for (IResourceSetHook hook : getMatchingHooks(urisToLoad)) { hook.postLoadingHook(resourceSet, urisToLoad); } return resource; }</code><technical_language>final</technical_language>

Target:
private Resource loadFromClassLoader(Class<?> clazz, String path, ResourceSet resourceSet) throws IOException { final URL fileURL = clazz.getResource(path); final URI uri = URI.createURI(fileURL.toString()); final List<URI> urisToLoad = Collections.singletonList(uri); for (final IResourceSetHook hook : getMatchingHooks(urisToLoad)) { hook.preLoadingHook(resourceSet, urisToLoad); } final Resource existing = resourceSet.getResource(uri, false); if (existing != null) { return existing; } InputStream stream = null; Resource resource = null; try { resource = resourceSet.createResource(uri); stream = fileURL.openStream(); resource.load(stream, Collections.emptyMap()); } catch (final IOException e) { } catch (final WrappedException e) { } finally { if (stream != null) { try { stream.close(); } catch (final IOException e) { } } } for (final IResourceSetHook hook : getMatchingHooks(urisToLoad)) { hook.postLoadingHook(resourceSet, urisToLoad); } return resource; }
Source:
<code><START> protected AsyncCompletionWaitor insertBreakpoint( <END> final IBreakpointsTargetDMContext context, final Map<String, Object> attributes) throws InterruptedException { final AsyncCompletionWaitor waitor = new AsyncCompletionWaitor(); final DataRequestMonitor<IBreakpointDMContext> drm = new DataRequestMonitor<IBreakpointDMContext>(fBreakpointService.getExecutor(), null) { @Override protected void handleCompleted() { if (isSuccess()) { waitor.setReturnInfo(getData()); } waitor.waitFinished(getStatus()); } }; fBreakpointService.getExecutor().submit(new Runnable() { @Override public void run() { fBreakpointService.insertBreakpoint(context, attributes, drm); } }); waitor.waitUntilDone(TestsPlugin.massageTimeout(2000)); return waitor; }</code><technical_language>return IBreakpointDMContext a Query for</technical_language>

Target:
protected IBreakpointDMContext insertBreakpoint( final IBreakpointsTargetDMContext context, final Map<String, Object> attributes) throws InterruptedException, ExecutionException { Query<IBreakpointDMContext> query = new Query<IBreakpoints.IBreakpointDMContext>() { @Override protected void execute(DataRequestMonitor<IBreakpointDMContext> rm) { fBreakpointService.insertBreakpoint(context, attributes, rm); } }; fBreakpointService.getExecutor().submit(query); return query.get(); }
Source:
<code>public void testPublishWithBadTypeValue() { Response response = resource.publish(key, null, null, null, "Test", null, null); <START> assertEquals(response.getStatusInfo(), Response.Status.BAD_REQUEST); <END> }</code><technical_language>Similar this test. I return a BAD_REQUEST hits null username, testing bad type value</technical_language>

Target:
public void testPublishWithBadTypeValue() { Response response = resource.publish(key, "Test", null, null, "Test", null, null); assertEquals(response.getStatusInfo(), Response.Status.BAD_REQUEST); }
Source:
<code>public T createInstance() { <START> if (!isGenericRecord(type)) { <END> return InstantiationUtil.instantiate(type); } else { return (T) new GenericData.Record(schema.getAvroSchema()); } }</code><technical_language>do a slightly more unified approach? @Override @SuppressWarnings("unchecked") public T createInstance() { checkAvroInitialized(); return (T) avroData.newRecord(null, schema.getAvroSchema()); }</technical_language>

Target:
public T createInstance() { checkAvroInitialized(); return (T) avroData.newRecord(null, runtimeSchema); }
Source:
<code>public boolean visit(QualifiedName node) { node.getParent(); <START> IBinding b= node.resolveBinding(); <END> if (b instanceof IVariableBinding) { int modifiers= ((IVariableBinding)b).getModifiers(); if ((modifiers & IModifierConstants.ACC_FINAL) == IModifierConstants.ACC_FINAL) { if (((IVariableBinding) b).isField()) { throw new AbortSearchException(); } } } return true; }</code><technical_language>I suggest name "binding" instead of "b"</technical_language>

Target:
public boolean visit(QualifiedName node) { node.getParent(); IBinding binding= node.resolveBinding(); checkForUninitializedFinalReference(binding); return true; }
Source:
<code>public Iterator<SequencingParameters> iterator() { try { return getSequencingParameters().iterator(); } catch (IOException e) { <START> return Collections.emptyIterator(); <END> } }</code><technical_language>log this</technical_language>

Target:
public Iterator<SequencingParameters> iterator() { try { return getSequencingParameters().iterator(); } catch (IOException e) { log.error("Failed to get sequencing parameters", e); return Collections.emptyIterator(); } }
Source:
<code>public void createApplicationContextFrom_validBuilderContext_containingExtraComponent_shouldCreateAnApplicationContext() { <START> String name = "workers"; <END> ExecutorService workers = Executors.newFixedThreadPool(2); Map<Platform.ExtraComponentKey, Object> extraComponents = Maps.newHashMap(); extraComponents.put(new Platform.ExtraComponentKey(name, ExecutorService.class), workers); KasperPlatformConfiguration platformConfiguration = new KasperPlatformConfiguration(); final Platform.BuilderContext builderContext = new Platform.BuilderContext( platformConfiguration.configuration(), platformConfiguration.eventBus(), platformConfiguration.commandGateway(), platformConfiguration.queryGateway(), platformConfiguration.metricRegistry(), extraComponents ); ApplicationContext applicationContext = BuilderContextHelper.createApplicationContextFrom(builderContext); assertNotNull(applicationContext); assertEquals(workers, applicationContext.getBean(ExecutorService.class)); assertEquals(workers, applicationContext.getBean(name)); }</code><technical_language>name final</technical_language>

Target:
public void createApplicationContextFrom_validBuilderContext_containingExtraComponent_shouldCreateAnApplicationContext() { final String name = "workers"; final ExecutorService workers = Executors.newFixedThreadPool(2); final Map<Platform.ExtraComponentKey, Object> extraComponents = Maps.newHashMap(); extraComponents.put(new Platform.ExtraComponentKey(name, ExecutorService.class), workers); final KasperPlatformConfiguration platformConfiguration = new KasperPlatformConfiguration(); final Platform.BuilderContext builderContext = new Platform.BuilderContext( platformConfiguration.configuration(), platformConfiguration.eventBus(), platformConfiguration.commandGateway(), platformConfiguration.queryGateway(), platformConfiguration.metricRegistry(), extraComponents ); final ApplicationContext applicationContext = BuilderContextHelper.createApplicationContextFrom(builderContext); assertNotNull(applicationContext); assertEquals(workers, applicationContext.getBean(ExecutorService.class)); assertEquals(workers, applicationContext.getBean(name)); }
Source:
<code>public Void visit(UnlockEvent unlockEvent) { for (LockDescriptor descriptor : unlockEvent.lockDescriptors()) { <START> OptionalLong lastLocked = lockWatchState.getOrDefault(descriptor, LockWatchInfo.NOT_WATCHED).lastLocked(); <END> lockWatchState.put(descriptor, LockWatchInfo.of(LockWatchInfo.State.UNLOCKED, lastLocked)); } return null; }</code><technical_language>good explain this is NOT_WATCHED. discussed offline this plausible</technical_language>

Target:
public Void visit(UnlockEvent unlockEvent) { for (LockDescriptor descriptor : unlockEvent.lockDescriptors()) { OptionalLong lastLocked = lockWatchState.getOrDefault(descriptor, LockWatchInfo.UNKNOWN).lastLocked(); lockWatchState.put(descriptor, LockWatchInfo.of(LockWatchInfo.State.UNLOCKED, lastLocked)); } return null; }
Source:
<code>public static void insertPageProlog(StringBuilder buffer, int position) { StringBuilder pageProlog= new StringBuilder(60); pageProlog.append("<html>"); buffer.append("<head>"); appendStyleSheetWithBodyColorRules(pageProlog, FG_COLOR_RGB, BG_COLOR_RGB); <START> buffer.append("</head>"); END> buffer.insert(position, pageProlog.toString()); }</code><technical_language>this appended pageProlog</technical_language>

Target:
public static void insertPageProlog(StringBuilder buffer, int position) { StringBuilder pageProlog= new StringBuilder(60); pageProlog.append("<html>"); pageProlog.append("<head>"); appendStyleSheetWithBodyColorRules(pageProlog, FG_COLOR_RGB, BG_COLOR_RGB); pageProlog.append("</head>"); buffer.insert(position, pageProlog.toString()); }