auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void start() { eventService.subscribe(new EventSubscriber<WorkspaceCreatedEvent>() { @Override public void onEvent(WorkspaceCreatedEvent workspaceCreatedEvent) { try { sshManager.generatePair(EnvironmentContext.getCurrent().getSubject().getUserId(), "workspace", workspaceCreatedEvent.getWorkspace().getId()); } catch (ServerException | ConflictException e) { LOG.error(String.format("Unable to generate a default ssh pair for the workspace with ID %s", workspaceCreatedEvent.getWorkspace().getId()), e); } } }); eventService.subscribe(new EventSubscriber<WorkspaceRemovedEvent>() { @Override public void onEvent(WorkspaceRemovedEvent workspaceRemovedEvent) { try { sshManager.removePair(EnvironmentContext.getCurrent().getSubject().getUserId(), "workspace", workspaceRemovedEvent.getWorkspace().getId()); } catch (NotFoundException e) { <START> LOG.error(String.format("Do not remove default keypair from workspace %s as it is not existing (workspace ID %s)", <END> workspaceRemovedEvent.getWorkspace().getConfig().getName(), workspaceRemovedEvent.getWorkspace().getId())); } catch (ServerException e) { LOG.error(String.format( "Error when trying to remove default ssh pair for the workspace %s as it is not existing (workspace ID %s)", workspaceRemovedEvent.getWorkspace().getConfig().getName(), workspaceRemovedEvent.getWorkspace().getId())); } } }); }</code><technical_language>I log this case error</technical_language>

Target:
public void start() { eventService.subscribe(new EventSubscriber<WorkspaceCreatedEvent>() { @Override public void onEvent(WorkspaceCreatedEvent workspaceCreatedEvent) { try { sshManager.generatePair(EnvironmentContext.getCurrent().getSubject().getUserId(), "workspace", workspaceCreatedEvent.getWorkspace().getId()); } catch (ServerException | ConflictException e) { LOG.error("Unable to generate a default ssh pair for the workspace with ID {}", workspaceCreatedEvent.getWorkspace().getId(), e); } } }); eventService.subscribe(new EventSubscriber<WorkspaceRemovedEvent>() { @Override public void onEvent(WorkspaceRemovedEvent workspaceRemovedEvent) { try { sshManager.removePair(EnvironmentContext.getCurrent().getSubject().getUserId(), "workspace", workspaceRemovedEvent.getWorkspace().getId()); } catch (NotFoundException e) { LOG.debug("Do not remove default keypair from workspace as it is not existing (workspace ID {})", workspaceRemovedEvent.getWorkspace().getConfig().getName(), workspaceRemovedEvent.getWorkspace().getId()); } catch (ServerException e) { LOG.error("Error when trying to remove default ssh pair for the workspace (workspace ID {})", workspaceRemovedEvent.getWorkspace().getConfig().getName(), workspaceRemovedEvent.getWorkspace().getId()); } } }); }
Source:
<code>private boolean init(boolean firstAttempt) { close(); try { logger.info("Loading Record Manager from file : " + statusFile); recMan = RecordManagerFactory.createRecordManager(statusFile.getCanonicalPath()); persistedChannels = recMan.hashMap(STATUS_RECORD_NAME); logger.info("Content of persisted store : " + persistedChannels); for (Map.Entry<String, Channel> tempChannels : persistedChannels.entrySet()) ; recMan.commit(); if (!firstAttempt) { logger.info("Loading of job database successful after clean."); } } catch (Throwable e) { if (firstAttempt) { logger.error("Error occurred when loading channels database " + statusFile.getAbsolutePath() + ", now cleaning it and retrying.", e); <START> close(); <END> recMan = null; cleanDataBase(); init(false); } else { close(); throw new IllegalStateException("Error when loading database (even after cleaning it): " + statusFile.getAbsolutePath(), e); } } return true; }</code><technical_language>'Init' method calls 'close' method. This re-initialization messy</technical_language>

Target:
private void init(boolean firstAttempt) { close(); try { logger.info("Loading Record Manager from file : " + statusFile); recordManager = RecordManagerFactory.createRecordManager(statusFile.getCanonicalPath()); persistedChannels = recordManager.hashMap(STATUS_RECORD_NAME); logger.info("Content of persisted store : " + persistedChannels); recordManager.commit(); if (!firstAttempt) { logger.info("Loading of job database successful after clean."); } } catch (Throwable e) { if (firstAttempt) { logger.error("Error occurred when loading channels database " + statusFile.getAbsolutePath() + ", now cleaning it and retrying.", e); cleanDataBase(); init(false); } else { close(); throw new IllegalStateException("Error when loading database (even after cleaning it): " + statusFile.getAbsolutePath(), e); } } isStarted = true; }
Source:
<code>BridgeFile(VirtualFile file) { this.file = file; <START> this.parent = file.parent(); <END> }</code><technical_language>is needed</technical_language>

Target:
BridgeFile(VirtualFile file) { this.file = file; }
Source:
<code>private void electedTruncationLeader() throws Exception { loggingLog.info("This node was selected as the leader for snapshot truncation"); m_truncationSnapshotScanTask = m_es.scheduleWithFixedDelay(new Runnable() { @Override public void run() { try { scanTruncationSnapshots(); } catch (Exception e) { loggingLog.error("Error during scan and group of truncation snapshots"); } } <START> }, 0, 1, TimeUnit.MINUTES); <END> try { truncationRequestExistenceCheck(); userSnapshotRequestExistenceCheck(false); } catch (Exception e) { VoltDB.crashLocalVoltDB("Error while accepting snapshot daemon leadership", true, e); } }</code><technical_language>motivation this change</technical_language>

Target:
private void electedTruncationLeader() throws Exception { loggingLog.info("This node was selected as the leader for snapshot truncation"); m_truncationSnapshotScanTask = m_es.scheduleWithFixedDelay(new Runnable() { @Override public void run() { try { scanTruncationSnapshots(); } catch (Exception e) { loggingLog.error("Error during scan and group of truncation snapshots"); } } }, 0, 1, TimeUnit.HOURS); try { truncationRequestExistenceCheck(); userSnapshotRequestExistenceCheck(false); } catch (Exception e) { VoltDB.crashLocalVoltDB("Error while accepting snapshot daemon leadership", true, e); } }
Source:
<code>public MutableList<String> rsplit( String self, String sep, Object maxSplitO, Location loc, Environment env) throws EvalException { if (sep.isEmpty()) { throw new EvalException(loc, "Empty separator"); } int maxSplit = Integer.MAX_VALUE; if (maxSplitO != Runtime.NONE) { maxSplit = (Integer) maxSplitO; } ArrayDeque<String> res = new ArrayDeque<>(); int end = self.length() - 1; while (true) { int start = self.lastIndexOf(sep, end); if (start < 0 || maxSplit-- == 0) { res.addFirst(self.substring(0, Math.max(0, end + 1))); break; } res.addFirst(self.substring(start + sep.length(), end + 1)); end = start - 1; } <START> return MutableList.copyOf(env, res); <END> }</code><technical_language>here: a MutableList, simply reverse returning result</technical_language>

Target:
public MutableList<String> rsplit( String self, String sep, Object maxSplitO, Location loc, Environment env) throws EvalException { if (sep.isEmpty()) { throw new EvalException(loc, "Empty separator"); } int maxSplit = Integer.MAX_VALUE; if (maxSplitO != Runtime.NONE) { maxSplit = (Integer) maxSplitO; } ArrayList<String> res = new ArrayList<>(); int end = self.length(); while (true) { int start = self.lastIndexOf(sep, end - 1); if (start < 0 || maxSplit-- == 0) { res.add(self.substring(0, end)); break; } res.add(self.substring(start + sep.length(), end)); end = start; } Collections.reverse(res); return MutableList.wrapUnsafe(env, res); }
Source:
<code>public Waiter.Predicate<IOException> predicateTableEnabled(final TableName tableName) { return new ExplainingPredicate<IOException>() { @Override public String explainFailure() throws IOException { return explainTableState(tableName); } @Override public boolean evaluate() throws IOException { <START> boolean tableEnabled = false; try { tableEnabled = getHBaseAdmin().tableExists(tableName) && getHBaseAdmin().isTableEnabled(tableName); } catch (TableNotFoundException tnfe) { } return tableEnabled; <END> } }; }</code><technical_language>This public boolean evaluate() throws IOException { try { return getHBaseAdmin().tableExists(tableName) && getHBaseAdmin().isTableEnabled(tableName); } catch (TableNotFoundException tnfe) { return false; } }</technical_language>

Target:
public Waiter.Predicate<IOException> predicateTableEnabled(final TableName tableName) { return new ExplainingPredicate<IOException>() { @Override public String explainFailure() throws IOException { return explainTableState(tableName); } @Override public boolean evaluate() throws IOException { try { return getHBaseAdmin().tableExists(tableName) && getHBaseAdmin().isTableEnabled(tableName); } catch (TableNotFoundException tnfe) { return false; } } }; }
Source:
<code>protected void createDefaultEditPolicies() { installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy()); super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ActivityItemSemanticEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(EditPolicy.COMPONENT_ROLE, new RootComponentEditPolicy()); installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new ActivityCanonicalEditPolicy()); installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizeActivityEditPolicy()); <START> installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); <END> removeEditPolicy(EditPolicyRoles.CANONICAL_ROLE); }</code><technical_language>superclass installs one? is remove added in line 110</technical_language>

Target:
protected void createDefaultEditPolicies() { installEditPolicy(EditPolicyRoles.CREATION_ROLE, new PapyrusCreationEditPolicy()); super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ActivityItemSemanticEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(EditPolicy.COMPONENT_ROLE, new RootComponentEditPolicy()); installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizeActivityEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); }
Source:
<code>public SequencerServer(ServerContext serverContext) { this.serverContext = serverContext; this.executor = Executors.newSingleThreadExecutor( new ServerThreadFactory("sequencer-", new ServerThreadFactory.ExceptionHandler())); globalLogTail = 0; this.cache = new SequencerServerCache(serverContext.getConfiguration().getSequencerConflictWindowSize()); setUpTimerNameCache(); <START> } <END></code><technical_language>![Codacy](<LINK_0> Issue found: [Use explicit scoping instead of default package private level](<LINK_1></technical_language>

Target:
public SequencerServer(ServerContext serverContext) { this.serverContext = serverContext; this.executor = Executors.newSingleThreadExecutor( new ServerThreadFactory("sequencer-", new ServerThreadFactory.ExceptionHandler())); globalLogTail = Address.getMinAddress(); this.cache = new SequencerServerCache(serverContext .getConfiguration().getSequencerConflictWindowSize(), globalLogTail - 1); setUpTimerNameCache(); }
Source:
<code>public byte[] encode(final Identity identity) throws IOException { <START> final byte[] raw = this.origin.encode(identity); <END> return Base64.encodeBase64(raw); }</code><technical_language>@ikhvostenkov this variable inlined</technical_language>

Target:
public byte[] encode(final Identity identity) throws IOException { return this.origin.encode(identity); }
Source:
<code>public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if(!hasValidCSRFToken(request)) { respondCSRFError(response); return; } try { Project project = getProject(request); String columnName = request.getParameter("columnName"); String keyColumnName = request.getParameter("keyColumnName"); String separator = request.getParameter("separator"); String mode = request.getParameter("mode"); Boolean regex = Boolean.parseBoolean(request.getParameter("regex")); if ("separator".equals(mode)) { AbstractOperation op = new MultiValuedCellSplitOperation(columnName, keyColumnName, separator, regex); Process process = op.createProcess(project, new Properties()); performProcessAndRespond(request, response, project, process); } else if ("lengths".equals(mode)) { String s = request.getParameter("fieldLengths"); int[] fieldLengths = ParsingUtilities.mapper.readValue(s, new TypeReference<int[]>() {}); AbstractOperation op = new MultiValuedCellSplitOperation(columnName, keyColumnName, fieldLengths); Process process = op.createProcess(project, new Properties()); performProcessAndRespond(request, response, project, process); } else if ("cases".equals(mode)) { AbstractOperation op = new MultiValuedCellSplitOperation(columnName, keyColumnName, true); Process process = op.createProcess(project, new Properties()); <START> performProcessAndRespond(request, response, project, process); <END> } else if ("number".equals(mode)) { AbstractOperation op = new MultiValuedCellSplitOperation(columnName, keyColumnName, false); Process process = op.createProcess(project, new Properties()); performProcessAndRespond(request, response, project, process); } } catch (Exception e) { respondException(response, e); } }</code><technical_language>Instead of duplicating lines Process process = op.createProcess(project, new Properties()); performProcessAndRespond(request, response, project, process); in case of if/else block, move shared for blocks? (The original code duplication, feels more painful more cases)</technical_language>

Target:
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if(!hasValidCSRFToken(request)) { respondCSRFError(response); return; } try { Project project = getProject(request); String columnName = request.getParameter("columnName"); String keyColumnName = request.getParameter("keyColumnName"); String separator = request.getParameter("separator"); String mode = request.getParameter("mode"); Boolean regex = Boolean.parseBoolean(request.getParameter("regex")); AbstractOperation op; if ("lengths".equals(mode)) { String s = request.getParameter("fieldLengths"); int[] fieldLengths = ParsingUtilities.mapper.readValue(s, new TypeReference<int[]>() {}); op = new MultiValuedCellSplitOperation(columnName, keyColumnName, fieldLengths); } else { op = new MultiValuedCellSplitOperation(columnName, keyColumnName, separator, regex); } Process process = op.createProcess(project, new Properties()); performProcessAndRespond(request, response, project, process); } catch (Exception e) { respondException(response, e); } }
Source:
<code>public void testSetOther() { when(i18n.get("userInfo.tooltipFormat", "user", 1000)).thenReturn("user(1000)"); PlayerBuilder playerBuilder = PlayerBuilder.create("user") .defaultValues() .socialStatus(SocialStatus.OTHER); <START> Player player = playerBuilder.get(); <END> instance.setPlayer(player, 1000, Faction.NOMAD); assertThat(instance.factionIcon.isVisible(), is(false)); assertThat(instance.factionImage.getImage().getUrl(), is(new Image("/images/factions/random.png").getUrl())); assertThat(instance.factionImage.isVisible(), is(true)); assertThat(instance.foeIconText.isVisible(), is(false)); assertThat(instance.friendIconText.isVisible(), is(false)); assertThat(instance.playerInfo.getText(), is("user(1000)")); }</code><technical_language>Yea, this test</technical_language>

Target:
public void testSetOther() { when(i18n.get("userInfo.tooltipFormat", "user", 1000)).thenReturn("user(1000)"); PlayerBuilder playerBuilder = PlayerBuilder.create("user") .defaultValues() .socialStatus(SocialStatus.OTHER); Player player = playerBuilder.get(); instance.setPlayer(player, 1000, Faction.RANDOM); assertThat(instance.factionIcon.isVisible(), is(false)); assertThat(instance.factionImage.getImage().getUrl(), is(PlayerCardTooltipController.RANDOM_IMAGE.getUrl())); assertThat(instance.factionImage.isVisible(), is(true)); assertThat(instance.foeIconText.isVisible(), is(false)); assertThat(instance.friendIconText.isVisible(), is(false)); assertThat(instance.playerInfo.getText(), is("user(1000)")); }
Source:
<code>public RebaseResponse rebase(RebaseRequest request) throws ApiException { <START> GitConnection gitConnection = getGitConnection(); <END> try { return gitConnection.rebase(request); } finally { gitConnection.close(); } }</code><technical_language>try resources</technical_language>

Target:
public RebaseResponse rebase(RebaseRequest request) throws ApiException { try (GitConnection gitConnection = getGitConnection()) { return gitConnection.rebase(request); } }
Source:
<code>private void scheduleAppUpdate() { Constraints constraints = new Constraints.Builder() .setRequiredNetworkType(NetworkType.CONNECTED) .setRequiresBatteryNotLow(true) .build(); PeriodicWorkRequest updateRequest = <START> new PeriodicWorkRequest.Builder(UpdateWorker.class, PERIODICITY_FOR_UPDATE_IN_HOURS, TimeUnit.HOURS) <END> .addTag(getCurrentApp().getAppRecord().getApplicationId()) .setConstraints(constraints) .setBackoffCriteria( BackoffPolicy.EXPONENTIAL, BACKOFF_DELAY_FOR_UPDATE_RETRY, TimeUnit.MILLISECONDS) .build(); WorkManager.getInstance(this).enqueueUniquePeriodicWork( UpdateHelper.getUpdateRequestName(), ExistingPeriodicWorkPolicy.KEEP, updateRequest ); }</code><technical_language>this more takes a context retry auto update 2 hours, right? Server load-wise I if presuming contact server, succeeded, update</technical_language>

Target:
private void scheduleAppUpdate() { if(UpdateHelper.shouldAutoUpdate()) { Constraints constraints = new Constraints.Builder() .setRequiredNetworkType(NetworkType.CONNECTED) .setRequiresBatteryNotLow(true) .build(); PeriodicWorkRequest updateRequest = new PeriodicWorkRequest.Builder(UpdateWorker.class, UpdateHelper.getAutoUpdatePeriodicity(), TimeUnit.HOURS) .addTag(getCurrentApp().getAppRecord().getApplicationId()) .setConstraints(constraints) .setBackoffCriteria( BackoffPolicy.EXPONENTIAL, BACKOFF_DELAY_FOR_UPDATE_RETRY, TimeUnit.MILLISECONDS) .build(); WorkManager.getInstance(this).enqueueUniquePeriodicWork( UpdateHelper.getUpdateRequestName(), ExistingPeriodicWorkPolicy.KEEP, updateRequest ); } }
Source:
<code>public CTRCryptoInputStream( Input input, Cipher cipher, int bufferSize, byte[] key, byte[] iv, long streamOffset) throws IOException { super(input, cipher, bufferSize, key, iv); Utils.checkStreamCipher(cipher); this.streamOffset = streamOffset; <START> resetStreamOffset(streamOffset); <END> }</code><technical_language>construction, inBuffer outBuffer newly allocated. for other variables. Is if original initCipher method invoke initCipher in method resetStreamOffset</technical_language>

Target:
public CTRCryptoInputStream( Input input, Cipher cipher, int bufferSize, byte[] key, byte[] iv, long streamOffset) throws IOException { super(input, cipher, bufferSize, key, iv); Utils.checkStreamCipher(cipher); resetStreamOffset(streamOffset); }
Source:
<code>public Box getByAlias(String alias) throws IOException { Box o = boxStore.getBoxByAlias(alias); <START> if (authorizationManager.readCheck(o)) return o; <END> else throw new IOException("User " + authorizationManager.getCurrentUser().getFullName() + " cannot read Box " + alias); }</code><technical_language>authorizationManager.throwIfNotReadable</technical_language>

Target:
public Box getByAlias(String alias) throws IOException { Box o = boxStore.getBoxByAlias(alias); authorizationManager.throwIfNotReadable(o); return o; }
Source:
<code><START> public ReadOnlyArrayInterface getArray(String key) { <END> int index = indexForColumnName(key); return index >= 0 ? getArray(index) : null; }</code><technical_language>return ReadOnlyArray</technical_language>

Target:
public ReadOnlyArray getArray(String key) { int index = indexForColumnName(key); return index >= 0 ? getArray(index) : null; }
Source:
<code>public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { try { fConfigDir = null; SubMonitor subMonitor = SubMonitor.convert(monitor, 4); try { preLaunchCheck(configuration, launch, subMonitor.newChild(2)); } catch (CoreException e) { if (e.getStatus().getSeverity() == IStatus.CANCEL) { subMonitor.setCanceled(true); return; } throw e; } VMRunnerConfiguration runnerConfig = new VMRunnerConfiguration(getMainClass(), getClasspath(configuration)); runnerConfig.setVMArguments(getVMArguments(configuration)); runnerConfig.setProgramArguments(getProgramArguments(configuration)); runnerConfig.setWorkingDirectory(getWorkingDirectory(configuration).getAbsolutePath()); runnerConfig.setEnvironment(getEnvironment(configuration)); runnerConfig.setVMSpecificAttributesMap(getVMSpecificAttributesMap(configuration)); subMonitor.worked(1); setDefaultSourceLocator(configuration); manageLaunch(launch); IVMRunner runner = getVMRunner(configuration, mode); if (runner != null) <START> runner.run(runnerConfig, launch, subMonitor); <END> else subMonitor.setCanceled(true); } catch (final CoreException e) { throw e; } }</code><technical_language>subMonitor.newChild 1 tick</technical_language>

Target:
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { try { fConfigDir = null; SubMonitor subMonitor = SubMonitor.convert(monitor, 4); try { preLaunchCheck(configuration, launch, subMonitor.newChild(2)); } catch (CoreException e) { if (e.getStatus().getSeverity() == IStatus.CANCEL) { subMonitor.setCanceled(true); return; } throw e; } VMRunnerConfiguration runnerConfig = new VMRunnerConfiguration(getMainClass(), getClasspath(configuration)); runnerConfig.setVMArguments(getVMArguments(configuration)); runnerConfig.setProgramArguments(getProgramArguments(configuration)); runnerConfig.setWorkingDirectory(getWorkingDirectory(configuration).getAbsolutePath()); runnerConfig.setEnvironment(getEnvironment(configuration)); runnerConfig.setVMSpecificAttributesMap(getVMSpecificAttributesMap(configuration)); subMonitor.worked(1); setDefaultSourceLocator(configuration); manageLaunch(launch); IVMRunner runner = getVMRunner(configuration, mode); if (runner != null) runner.run(runnerConfig, launch, subMonitor.newChild(1)); else subMonitor.setCanceled(true); } catch (final CoreException e) { throw e; } }
Source:
<code>public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { <START> if (shouldUseJwtFilter(jwtFilter, filterChain, (HttpServletRequest) request, (HttpServletResponse) response)) { <END> LOG.useJwtFilter(); jwtFilter.doFilter(request, response, filterChain); } else { super.doFilter(request, response, filterChain); } }</code><technical_language>a client intent JWT sends expired token end a kerberos challenge here. I imagine argument for sides of this I want allow JWT validation failure reflected in response falling kerberos</technical_language>

Target:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { if (shouldUseJwtFilter(jwtFilter, (HttpServletRequest) request)) { LOG.useJwtFilter(); jwtFilter.doFilter(request, response, filterChain); } else { super.doFilter(request, response, filterChain); } }
Source:
<code>public void failAll(Throwable error) throws PromiseResolvedException { <START> PromiseResolvedException exception = null; <END> for (BatchEntry<T> entry: _map.values()) { try { entry.getPromise().fail(error); } catch (PromiseResolvedException e) { exception = e; } } if (exception != null) { throw exception; } }</code><technical_language>MultiException</technical_language>

Target:
public int failAll(Throwable error) { int alreadyResolved = 0; for (Entry<K, BatchEntry<T>> entry: _map.entrySet()) { try { entry.getValue().getPromise().fail(error); } catch (PromiseResolvedException e) { alreadyResolved++; } } return alreadyResolved; }
Source:
<code>public Target onboard( @NonNull String thingID, @NonNull String thingPassword, @Nullable OnboardWithThingIDOptions options) throws ThingIFException { <START> return thingIfApi.onboard(thingID, thingPassword, options); <END> }</code><technical_language>Adding this a field is good manner</technical_language>

Target:
public Target onboard( @NonNull String thingID, @NonNull String thingPassword, @Nullable OnboardWithThingIDOptions options) throws ThingIFException { return this.thingIfApi.onboard(thingID, thingPassword, options); }
Source:
<code>public S contains(String key, String value) { isNotNull(); assertThat(actual.getAll()) <START> .overridingErrorMessage("Expected <%s> to contain <%s> but it does not.", actual.getAll(), <END> stringOf(key, value)) .contains(MapEntry.entry(key, value)); return myself; }</code><technical_language>I passing entire map format string is a bit much. get "Expected preferences contain..."</technical_language>

Target:
public S contains(String key, String value) { isNotNull(); assertThat(actual.getAll()) .overridingErrorMessage("Expected preferences to contain <%s> but it does not.", stringOf(key, value)) .contains(MapEntry.entry(key, value)); return myself; }
Source:
<code>private Transmissions transmissions(SelectionKey key) { <START> if (key == null) { <END> throw new IllegalStateException("Attempt to get attachment from a null key"); } return (Transmissions) key.attachment(); }</code><technical_language>do need this check? argue statements in other methods</technical_language>

Target:
private Transmissions transmissions(SelectionKey key) { return (Transmissions) key.attachment(); }
Source:
<code>public static List<Service> addVectorLayer(InputStream is, String name) { List<Service> serviceList = new LinkedList<>(); try { String created = importUsingWPS(PROXY_WORKSPACE, PROXY_STORE, name, is); if (StringUtils.isNotBlank(created)) { serviceList.add(wfsService(created)); <START> serviceList.add(wmsService(created, PROXY_WORKSPACE)); <END> } } catch (FileNotFoundException ex) { log.error("Unable to publish shapefile", ex); } catch (IOException ex) { log.error("Error reading stream", ex); } return serviceList; }</code><technical_language>Jordan suggested workspaces need supported for now. unknown dependencies discovered removed prior converting workspace</technical_language>

Target:
public static List<Service> addVectorLayer(InputStream is, String name) { List<Service> serviceList = new LinkedList<>(); try { String created = importUsingWPS(PROXY_WORKSPACE, PROXY_STORE, name, is); if (StringUtils.isNotBlank(created)) { serviceList.add(wfsService(created)); serviceList.add(wmsService(created)); } } catch (FileNotFoundException ex) { log.error("Unable to publish shapefile", ex); } catch (IOException ex) { log.error("Error reading stream", ex); } return serviceList; }
Source:
<code>public PaginationWrapper<Subscription> listSubscriptions(@Nullable final String owningApplication, @Nullable final Set<String> eventTypes, final boolean showStatus, final int limit, final int offset) throws InvalidLimitException { if (limit < 1 || limit > 1000) { throw new InvalidLimitException("'limit' parameter should have value between 1 and 1000"); } if (offset < 0) { throw new InvalidLimitException("'offset' parameter can't be lower than 0"); } try { final Set<String> eventTypesFilter = eventTypes == null ? ImmutableSet.of() : eventTypes; final Optional<String> owningAppOption = Optional.ofNullable(owningApplication); final List<Subscription> subscriptions = subscriptionRepository.listSubscriptions(eventTypesFilter, owningAppOption, offset, limit); final PaginationLinks paginationLinks = SubscriptionsUriHelper.createSubscriptionPaginationLinks( owningAppOption, eventTypesFilter, offset, limit, showStatus, subscriptions.size()); final PaginationWrapper<Subscription> paginationWrapper = new PaginationWrapper<>(subscriptions, paginationLinks); if (showStatus) { final List<Subscription> items = paginationWrapper.getItems(); items.forEach(s -> s.setStatus(createSubscriptionStat(s, StatsMode.LIGHT))); } return paginationWrapper; } catch (final ServiceTemporarilyUnavailableException e) { LOG.error("Error occurred during listing of subscriptions", e); <START> throw e; <END> } }</code><technical_language>do need this catch block</technical_language>

Target:
public PaginationWrapper<Subscription> listSubscriptions(@Nullable final String owningApplication, @Nullable final Set<String> eventTypes, final boolean showStatus, final int limit, final int offset) throws InvalidLimitException, ServiceTemporarilyUnavailableException { if (limit < 1 || limit > 1000) { throw new InvalidLimitException("'limit' parameter should have value between 1 and 1000"); } if (offset < 0) { throw new InvalidLimitException("'offset' parameter can't be lower than 0"); } final Set<String> eventTypesFilter = eventTypes == null ? ImmutableSet.of() : eventTypes; final Optional<String> owningAppOption = Optional.ofNullable(owningApplication); final List<Subscription> subscriptions = subscriptionRepository.listSubscriptions(eventTypesFilter, owningAppOption, offset, limit); final PaginationLinks paginationLinks = SubscriptionsUriHelper.createSubscriptionPaginationLinks( owningAppOption, eventTypesFilter, offset, limit, showStatus, subscriptions.size()); final PaginationWrapper<Subscription> paginationWrapper = new PaginationWrapper<>(subscriptions, paginationLinks); if (showStatus) { final List<Subscription> items = paginationWrapper.getItems(); items.forEach(s -> s.setStatus(createSubscriptionStat(s, StatsMode.LIGHT))); } return paginationWrapper; }
Source:
<code><START> public HttpMessage createMessage() { <END> HttpMessage msg = new HttpMessage(); HttpRequestHeader requestHeader = new HttpRequestHeader(); try { requestHeader.setURI(new URI("<LINK_0>", false)); } catch (URIException | NullPointerException e) { } requestHeader.setMethod(HttpRequestHeader.GET); msg = new HttpMessage(); msg.setRequestHeader(requestHeader); msg.getResponseHeader().setStatusCode(HttpStatusCode.OK); return msg; }</code><technical_language>Some tests @Before others a method this, worth normalising that</technical_language>

Target:
public HttpMessage createMessage() { HttpMessage msg = new HttpMessage(); HttpRequestHeader requestHeader = new HttpRequestHeader(); try { requestHeader.setURI(new URI("<LINK_0>", false)); } catch (URIException | NullPointerException e) { } requestHeader.setMethod(HttpRequestHeader.GET); msg.setRequestHeader(requestHeader); msg.getResponseHeader().setStatusCode(HttpStatusCode.OK); return msg; }
Source:
<code>public TestSuite(List<TestCase> tests, KTestOptions options, FileUtil files) { this.tests = tests; this.options = options; <START> reportGen = options.getGenerateReport() ? new ReportGen(files.resolveWorkingDirectory("junit-reports")) : null; <END> }</code><technical_language>"junit-reports" a constant defined else. in case else want change in future</technical_language>

Target:
public TestSuite(List<TestCase> tests, KTestOptions options, FileUtil files) { this.tests = tests; this.options = options; reportGen = options.getGenerateReport() ? new ReportGen(files.resolveWorkingDirectory(REPORT_DIR)) : null; }
Source:
<code>protected Set<Event> handleAuthenticationTransactionAndGrantTicketGrantingTicket(final RequestContext context) { final HttpServletResponse response = WebUtils.getHttpServletResponseFromExternalWebflowContext(context); try { final Credential credential = getCredentialFromContext(context); AuthenticationResultBuilder builder = WebUtils.getAuthenticationResultBuilder(context); LOGGER.debug("Handling authentication transaction for credential [{}]", credential); final Service service = WebUtils.getService(context); <START> builder.getInitialAuthentication().get().addAttribute("providerId", context.getActiveFlow().getId()); <END> builder = this.authenticationSystemSupport.handleAuthenticationTransaction(service, builder, credential); LOGGER.debug("Issuing ticket-granting tickets for service [{}]", service); return CollectionUtils.wrapSet(grantTicketGrantingTicketToAuthenticationResult(context, builder, service)); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); final MessageContext messageContext = context.getMessageContext(); messageContext.addMessage(new MessageBuilder() .error() .code(DEFAULT_MESSAGE_BUNDLE_PREFIX.concat(e.getClass().getSimpleName())) .build()); response.setStatus(HttpStatus.UNAUTHORIZED.value()); return CollectionUtils.wrapSet(new EventFactorySupport().error(this)); } }</code><technical_language>this</technical_language>

Target:
protected Set<Event> handleAuthenticationTransactionAndGrantTicketGrantingTicket(final RequestContext context) { final HttpServletResponse response = WebUtils.getHttpServletResponseFromExternalWebflowContext(context); try { final Credential credential = getCredentialFromContext(context); AuthenticationResultBuilder builder = WebUtils.getAuthenticationResultBuilder(context); LOGGER.debug("Handling authentication transaction for credential [{}]", credential); final Service service = WebUtils.getService(context); builder = this.authenticationSystemSupport.handleAuthenticationTransaction(service, builder, credential); LOGGER.debug("Issuing ticket-granting tickets for service [{}]", service); return CollectionUtils.wrapSet(grantTicketGrantingTicketToAuthenticationResult(context, builder, service)); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); final MessageContext messageContext = context.getMessageContext(); messageContext.addMessage(new MessageBuilder() .error() .code(DEFAULT_MESSAGE_BUNDLE_PREFIX.concat(e.getClass().getSimpleName())) .build()); response.setStatus(HttpStatus.UNAUTHORIZED.value()); return CollectionUtils.wrapSet(new EventFactorySupport().error(this)); } }
Source:
<code>protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { decisionTable.getComponentWidths().add(uiColumnIndex, null); final int clauseIndex = getClauseIndex(); decisionTable.getAnnotations().add(clauseIndex, ruleAnnotationClause); ruleAnnotationClause.getName().setValue(getName()); decisionTable.getRule().forEach(rule -> { <START> final RuleAnnotationClauseText le = new RuleAnnotationClauseText(); <END> le.getText().setValue(DecisionTableDefaultValueUtilities.RULE_ANNOTATION_CLAUSE_EXPRESSION_TEXT); rule.getAnnotationEntry().add(clauseIndex, le); le.setParent(rule); }); ruleAnnotationClause.setParent(decisionTable); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { decisionTable.getComponentWidths().remove(uiColumnIndex); final int clauseIndex = decisionTable.getAnnotations().indexOf(ruleAnnotationClause); decisionTable.getRule().forEach(rule -> rule.getAnnotationEntry().remove(clauseIndex)); decisionTable.getAnnotations().remove(ruleAnnotationClause); return GraphCommandResultBuilder.SUCCESS; } }; }</code><technical_language>a le here.. a copy paste _artifact_</technical_language>

Target:
protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { decisionTable.getComponentWidths().add(uiColumnIndex, null); final int clauseIndex = getClauseIndex(); decisionTable.getAnnotations().add(clauseIndex, ruleAnnotationClause); ruleAnnotationClause.getName().setValue(getName()); decisionTable.getRule().forEach(rule -> { final RuleAnnotationClauseText ruleAnnotationClauseText = new RuleAnnotationClauseText(); ruleAnnotationClauseText.getText().setValue(DecisionTableDefaultValueUtilities.RULE_ANNOTATION_CLAUSE_EXPRESSION_TEXT); rule.getAnnotationEntry().add(clauseIndex, ruleAnnotationClauseText); ruleAnnotationClauseText.setParent(rule); }); ruleAnnotationClause.setParent(decisionTable); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { decisionTable.getComponentWidths().remove(uiColumnIndex); final int clauseIndex = decisionTable.getAnnotations().indexOf(ruleAnnotationClause); decisionTable.getRule().forEach(rule -> rule.getAnnotationEntry().remove(clauseIndex)); decisionTable.getAnnotations().remove(ruleAnnotationClause); return GraphCommandResultBuilder.SUCCESS; } }; }
Source:
<code>public void testThatCustomLauncherCanCustomizeTheClusteredOption() throws InterruptedException { AtomicBoolean asv = new AtomicBoolean(); <START> AtomicBoolean bsv = new AtomicBoolean(); <END> Launcher myLauncher = new Launcher() { @Override protected String getMainVerticle() { return HttpTestVerticle.class.getName(); } @Override public void afterStartingVertx(Vertx vertx) { LauncherExtensibilityTest.this.vertx = vertx; } @Override public void beforeStartingVertx(VertxOptions options) { options.setClustered(true); } @Override public void afterStoppingVertx() { asv.set(true); } @Override public void beforeStoppingVertx(Vertx vertx) { bsv.set(vertx != null); } }; myLauncher.dispatch(new String[0]); waitUntil(() -> { try { return RunCommandTest.getHttpCode() == 200; } catch (IOException e) { return false; } }); assertThat(this.vertx.isClustered()).isTrue(); BareCommand.getTerminationRunnable(vertx, LoggerFactory.getLogger("foo"), () -> { asv.set(true); }).run(); assertThat(asv.get()).isTrue(); vertx = null; }</code><technical_language>is bsv tested? updated</technical_language>

Target:
public void testThatCustomLauncherCanCustomizeTheClusteredOption() throws InterruptedException { AtomicBoolean asv = new AtomicBoolean(); AtomicBoolean bsv = new AtomicBoolean(); Launcher myLauncher = new Launcher() { @Override protected String getMainVerticle() { return HttpTestVerticle.class.getName(); } @Override public void afterStartingVertx(Vertx vertx) { LauncherExtensibilityTest.this.vertx = vertx; } @Override public void beforeStartingVertx(VertxOptions options) { options.setClustered(true); } @Override public void afterStoppingVertx() { asv.set(true); } @Override public void beforeStoppingVertx(Vertx vertx) { bsv.set(vertx != null); } }; myLauncher.dispatch(new String[0]); waitUntil(() -> { try { return RunCommandTest.getHttpCode() == 200; } catch (IOException e) { return false; } }); assertThat(this.vertx.isClustered()).isTrue(); BareCommand.getTerminationRunnable(vertx, LoggerFactory.getLogger("foo"), () -> asv.set(true)).run(); assertThat(bsv.get()).isTrue(); assertThat(asv.get()).isTrue(); vertx = null; }
Source:
<code>public Set<String> getDuplicateIndicesSequences() { <START> return duplicateIndicesSequences; <END> }</code><technical_language>If hasDuplicateIndices called yet, if indices changed was, calling this method duplicates if are. refactored * calling methods in order works expected * is method (hasDuplicateIndices() turns !getDuplicateIndicesSequences().isEmpty()) This save duplicates in jsp page load</technical_language>

Target:
public Set<String> getDuplicateIndicesSequences() { Set<String> indices = new HashSet<>(); Set<String> duplicateSequences = new HashSet<>(); for (PoolableElementView item : getPoolableElementViews()) { if (hasDuplicateIndices(indices, item)) { for (Index index : item.getIndices()) { duplicateSequences.add(index.getSequence()); } } } return duplicateSequences.isEmpty() ? Collections.emptySet() : duplicateSequences; }
Source:
<code>private Declaration getDeclarationCorrespondingToXpath( Pattern pattern, boolean isXPath, Constraint constraint ) { <START> Declaration declFromXpath = null; <END> if (!isXPath && pattern.hasXPath()) { Declaration xPathDecl = pattern.getXPathDeclaration(); if (xPathDecl != null) { for ( Declaration decl : constraint.getRequiredDeclarations() ) { if (xPathDecl.equals( decl )) { declFromXpath = decl; break; } } } } return declFromXpath; }</code><technical_language>.and change variable name declFromXpath declCorrXpath here</technical_language>

Target:
private Declaration getDeclarationCorrespondingToXpath( Pattern pattern, boolean isXPath, Constraint constraint ) { if (!isXPath && pattern.hasXPath()) { Declaration xPathDecl = pattern.getXPathDeclaration(); if (xPathDecl != null) { for ( Declaration decl : constraint.getRequiredDeclarations() ) { if (xPathDecl.equals( decl )) { return decl; } } } } return null; }
Source:
<code>public void controlCharacters() throws Exception { String htmlInput = "<p>\u0008</p>"; Document document = this.cleaner.clean(new StringReader(htmlInput)); String textContent = document.getElementsByTagName("p").item(0).getTextContent(); assertEquals(" ", textContent); assertHTML(" ", "\u0008"); htmlInput = "<p>&#8;</p>"; document = this.cleaner.clean(new StringReader(htmlInput)); textContent = document.getElementsByTagName("p").item(0).getTextContent(); assertEquals("&#8;", textContent); assertHTML("<p>&#8;</p>", "&#8;"); htmlInput = "<p foo=\"&#8;\">content</p>"; <START> document = this.cleaner.clean(new StringReader(htmlInput)); <END> textContent = document.getElementsByTagName("p").item(0).getAttributes().getNamedItem("foo").getTextContent(); assertEquals("&#8;", textContent); assertHTML("<p foo=\"&#8;\">content</p>", "<p foo=\"&#8;\">content</p>"); }</code><technical_language>I more explicit this behavior is insane a TODO issue HTMLCleanr side</technical_language>

Target:
void controlCharacters() throws Exception { String htmlInput = "<p>\u0008</p>"; Document document = this.cleaner.clean(new StringReader(htmlInput)); String textContent = document.getElementsByTagName("p").item(0).getTextContent(); assertEquals(" ", textContent); assertHTML(" ", "\u0008"); htmlInput = "<p>&#8;</p>"; document = this.cleaner.clean(new StringReader(htmlInput)); textContent = document.getElementsByTagName("p").item(0).getTextContent(); assertEquals("&#8;", textContent); assertHTML("<p>&#8;</p>", "&#8;"); htmlInput = "<p foo=\"&#8;\">content</p>"; document = this.cleaner.clean(new StringReader(htmlInput)); textContent = document.getElementsByTagName("p").item(0).getAttributes().getNamedItem("foo").getTextContent(); assertEquals("&#8;", textContent); assertHTML("<p foo=\"&#8;\">content</p>", "<p foo=\"&#8;\">content</p>"); }
Source:
<code>EventHubConsumer(EventHubAsyncConsumer consumer, Duration tryTimeout) { <START> Objects.requireNonNull(tryTimeout, "'getTryTimeout' cannot be null."); <END> this.consumer = Objects.requireNonNull(consumer, "'consumer' cannot be null."); this.timeout = tryTimeout; }</code><technical_language>Find / replace mistake</technical_language>

Target:
EventHubConsumer(EventHubAsyncConsumer consumer, Duration tryTimeout) { Objects.requireNonNull(tryTimeout, "'tryTimeout' cannot be null."); this.consumer = Objects.requireNonNull(consumer, "'consumer' cannot be null."); this.timeout = tryTimeout; }
Source:
<code>private static OseeServerInfo createOseeServerInfo(Log logger, ApplicationServerDataStore dataStore, String... defaultVersions) { <START> String serverAddress = ""; <END> if (System.getProperty("osee.application.server") != null) { serverAddress = System.getProperty("osee.application.server"); } else { try { serverAddress = InetAddress.getLocalHost().getCanonicalHostName(); } catch (UnknownHostException ex) { } } int port = OseeServerProperties.getOseeApplicationServerPort(); String scheme = OseeServerProperties.getOseeApplicationServerScheme(); URI uri = null; try { uri = new URI(scheme, null, serverAddress, port, null, null, null); } catch (URISyntaxException ex) { logger.error(ex, "Error generating application server uri"); } String checkSum = "-1"; try { String address = String.format("%s:%s", serverAddress, port); ByteArrayInputStream inputStream = new ByteArrayInputStream(address.getBytes("UTF-8")); checkSum = ChecksumUtil.createChecksumAsString(inputStream, ChecksumUtil.MD5); } catch (Exception ex) { logger.error(ex, "Error generating application server id"); } return new OseeServerInfo(checkSum, uri == null ? null : uri.toString(), port, defaultVersions, GlobalTime.GreenwichMeanTimestamp(), false); }</code><technical_language>OseeClient.OSEE_APPLICATION_SERVER</technical_language>

Target:
private static OseeServerInfo createOseeServerInfo(Log logger, ApplicationServerDataStore dataStore, String... defaultVersions) { String serverAddress = ""; if (System.getProperty(OseeClient.OSEE_APPLICATION_SERVER) != null) { serverAddress = System.getProperty(OseeClient.OSEE_APPLICATION_SERVER); } else { try { serverAddress = InetAddress.getLocalHost().getCanonicalHostName(); } catch (UnknownHostException ex) { } } int port = OseeServerProperties.getOseeApplicationServerPort(); String scheme = OseeServerProperties.getOseeApplicationServerScheme(); URI uri = null; try { uri = new URI(scheme, null, serverAddress, port, null, null, null); } catch (URISyntaxException ex) { logger.error(ex, "Error generating application server uri"); } String checkSum = "-1"; try { String address = String.format("%s:%s", serverAddress, port); ByteArrayInputStream inputStream = new ByteArrayInputStream(address.getBytes("UTF-8")); checkSum = ChecksumUtil.createChecksumAsString(inputStream, ChecksumUtil.MD5); } catch (Exception ex) { logger.error(ex, "Error generating application server id"); } return new OseeServerInfo(checkSum, uri == null ? null : uri.toString(), port, defaultVersions, GlobalTime.GreenwichMeanTimestamp(), false); }
Source:
<code>protected boolean validate() { ClusterValidator clusterValidator = getClusterValidator(cluster, getCluster()); List<String> volumeNamesWithLowSpace = clusterValidator.isSpaceLeftOnGlusterVolume(); if (volumeNamesWithLowSpace != null && volumeNamesWithLowSpace.size() > 0) { AuditLogable auditLog = new AuditLogableImpl(); <START> auditLog.addCustomValue("VolumeName", <END> volumeNamesWithLowSpace.stream().map(i -> i.toString()).collect(Collectors.joining(","))); auditLogDirector.log(auditLog, AuditLogType.HOST_DISK_RUNNING_LOW_SPACE); return false; } return validate(clusterValidator.oldClusterIsValid()); }</code><technical_language>this field represents a list of volumes, named in a plural form: VolumeNames. Also, dealing cluster, pls add auditLog cluster-id cluster-name</technical_language>

Target:
protected boolean validate() { ClusterValidator clusterValidator = getClusterValidator(cluster, getCluster()); List<String> volumeNamesWithLowSpace = clusterValidator.getLowDeviceSpaceVolumes(); if (volumeNamesWithLowSpace != null && volumeNamesWithLowSpace.size() > 0) { AuditLogable auditLog = new AuditLogableImpl(); auditLog.setClusterId(cluster.getId()); auditLog.setClusterName(cluster.getName()); auditLog.addCustomValue("VolumeNames", volumeNamesWithLowSpace.stream().map(i -> i.toString()).collect(Collectors.joining(","))); auditLogDirector.log(auditLog, AuditLogType.HOST_DISK_RUNNING_LOW_SPACE); return false; } return validate(clusterValidator.oldClusterIsValid()); }