auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected Text createFilterText(Composite parent) { filterText = new Text(parent, SWT.NONE); Dialog.applyDialogFont(filterText); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.CENTER; filterText.setLayoutData(data); filterText.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.CR || e.character == '\r' || e.character == '\n') { gotoSelectedElement(); dispose(); } else if (e.keyCode == SWT.ARROW_DOWN) { <START> delegate.getTreeViewer().getTree().setFocus(); <END> } else if (e.character == SWT.ESC) { dispose(); } } }); filterText.setText(""); filterText.addModifyListener(e -> { TreeViewer viewer = delegate.getTreeViewer(); try { viewer.getControl().setRedraw(false); String text = filterText.getText(); if (StringUtils.isEmptyOrNull(text)) { viewer.setFilters(); } else { final SearchPattern pattern = new SearchPattern(); pattern.setPattern(text); viewer.setFilters(new ViewerFilter() { private boolean firstMatch = true; @Override public boolean select(Viewer v, Object parentElement, Object element) { boolean result = isMatch(pattern, element); if (result && element instanceof FileDiffRegion && firstMatch) { firstMatch = false; viewer.setSelection( new StructuredSelection(element)); } return result; } }); } viewer.expandAll(); } finally { viewer.getControl().setRedraw(true); } }); return filterText; }</code><technical_language>I need hit ARROW-DOWN get selected if selection yet. select item then</technical_language>

Target:
private Text createFilterText(Composite parent) { filterText = new Text(parent, SWT.NONE); Dialog.applyDialogFont(filterText); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER) .grab(true, false).applyTo(filterText); filterText.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.CR || e.character == '\r' || e.character == '\n') { gotoSelectedElement(); close(); } else if (e.keyCode == SWT.ARROW_DOWN) { delegate.getTreeViewer().getTree().setFocus(); selectFirst(); } else if (e.character == SWT.ESC) { close(); } } }); filterText.setMessage(UIText.DiffEditor_QuickOutlineFilterHint); filterText.addModifyListener(e -> { TreeViewer viewer = delegate.getTreeViewer(); try { viewer.getControl().setRedraw(false); String text = filterText.getText(); if (StringUtils.isEmptyOrNull(text)) { viewer.setFilters(); } else { final SearchPattern pattern = new SearchPattern(); pattern.setPattern(text); viewer.setFilters(new ViewerFilter() { @Override public boolean select(Viewer v, Object parentElement, Object element) { return isMatch(pattern, element); } }); } viewer.expandAll(); selectFirst(); } finally { viewer.getControl().setRedraw(true); } }); return filterText; }
Source:
<code>public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final LinkedSpan<T> other = (LinkedSpan<T>) obj; <START> return Objects.equals(this.linkedEntries, other.linkedEntries) && <END> this.sentenceid == other.sentenceid && Objects.equals(this.searchTerm, other.searchTerm); }</code><technical_language>remove this? OPENNLP-922 changes in style equals hashCode implementations</technical_language>

Target:
public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final LinkedSpan<T> other = (LinkedSpan<T>) obj; if (!Objects.equals(this.linkedEntries, other.linkedEntries)) { return false; } return this.sentenceid == other.sentenceid && Objects.equals(this.searchTerm, other.searchTerm); }
Source:
<code>protected List<MethodMatcher> getMethodInvocationMatchers() { return Arrays.asList( MethodMatcher.create().typeDefinition("java.net.Socket").name(INIT).withAnyParameters(), MethodMatcher.create().typeDefinition("java.net.ServerSocket").name(INIT).withAnyParameters(), MethodMatcher.create().typeDefinition(JAVAX_NET_SOCKET_FACTORY).name(INIT).withAnyParameters(), MethodMatcher.create().typeDefinition(JAVAX_NET_SOCKET_FACTORY).name("createSocket").withAnyParameters(), <START> MethodMatcher.create().typeDefinition("java.nio.channels.AsynchronousServerSocketChannel").name("open").withAnyParameters(), <END> MethodMatcher.create().typeDefinition("java.nio.channels.AsynchronousSocketChannel").name("open").withAnyParameters(), MethodMatcher.create().typeDefinition("java.nio.channels.SocketChannel").name("open").withAnyParameters(), MethodMatcher.create().typeDefinition("java.nio.channels.ServerSocketChannel").name("open").withAnyParameters(), MethodMatcher.create().typeDefinition("io.netty.channel.ChannelInitializer").name(INIT).withAnyParameters()); }</code><technical_language>"open" a constant</technical_language>

Target:
protected List<MethodMatcher> getMethodInvocationMatchers() { return Arrays.asList( MethodMatcher.create().typeDefinition("java.net.Socket").name(INIT).withAnyParameters(), MethodMatcher.create().typeDefinition("java.net.ServerSocket").name(INIT).withAnyParameters(), MethodMatcher.create().typeDefinition(JAVAX_NET_SOCKET_FACTORY).name(INIT).withAnyParameters(), MethodMatcher.create().typeDefinition(JAVAX_NET_SOCKET_FACTORY).name("createSocket").withAnyParameters(), MethodMatcher.create().typeDefinition("java.nio.channels.AsynchronousServerSocketChannel").name(OPEN_METHOD).withAnyParameters(), MethodMatcher.create().typeDefinition("java.nio.channels.AsynchronousSocketChannel").name(OPEN_METHOD).withAnyParameters(), MethodMatcher.create().typeDefinition("java.nio.channels.SocketChannel").name(OPEN_METHOD).withAnyParameters(), MethodMatcher.create().typeDefinition("java.nio.channels.ServerSocketChannel").name(OPEN_METHOD).withAnyParameters(), MethodMatcher.create().typeDefinition("io.netty.channel.ChannelInitializer").name(INIT).withAnyParameters()); }
Source:
<code>protected void close() { if (!shouldPause()) { tryStop(); } if (producer != null) { try { producer.close(Duration.ofSeconds(30)); } catch (Throwable t) { log.warn("Could not close producer", t); } } try { transformationChain.close(); } catch (Throwable t) { log.warn("Could not close transformation chain", t); } <START> try { retryWithToleranceOperator.close(); } catch (Throwable t) { log.warn("Could not close retry operator", t); } <END> }</code><technical_language>This is common enough a util for is extensively: suggestion Utils.closeQuietly(retryWithToleranceOperator, "retry operator");</technical_language>

Target:
protected void close() { if (!shouldPause()) { tryStop(); } if (producer != null) { try { producer.close(Duration.ofSeconds(30)); } catch (Throwable t) { log.warn("Could not close producer", t); } } try { transformationChain.close(); } catch (Throwable t) { log.warn("Could not close transformation chain", t); } Utils.closeQuietly(retryWithToleranceOperator, "retry operator"); }
Source:
<code>public static UsageReporter getInstance(Map<String, String> configs) { if (s_instance == null) { s_instance = new UsageReporter(); <START> s_instance.init(configs); <END> } return s_instance; }</code><technical_language>findbugs solution is right ;) new_instance = new UsageReporter(); new_instance.init(configs); s_instance = new_instance; better. in a synchronised block prevent synchronous call getInstance resulting in instances of a singleton present</technical_language>

Target:
public synchronized static UsageReporter getInstance(Map<String, String> configs) { if (s_instance == null) { UsageReporter new_instance = new UsageReporter(); new_instance.init(configs); s_instance = new_instance; } return s_instance; }
Source:
<code>public ProxyConfiguration(String name, int port, String userName, String password, String noProxyHost, String testUrl) { this.name = Util.fixEmptyAndTrim(name); this.port = port; this.userName = Util.fixEmptyAndTrim(userName); <START> this.secretPassword = password != null ? Secret.fromString(password) : null; <END> this.noProxyHost = Util.fixEmptyAndTrim(noProxyHost); this.testUrl = Util.fixEmptyAndTrim(testUrl); this.authenticator = newAuthenticator(); }</code><technical_language>want trim password fully safe</technical_language>

Target:
public ProxyConfiguration(String name, int port, String userName, String password, String noProxyHost, String testUrl) { this.name = Util.fixEmptyAndTrim(name); this.port = port; this.userName = Util.fixEmptyAndTrim(userName); String tempPassword = Util.fixEmptyAndTrim(password); this.secretPassword = tempPassword != null ? Secret.fromString(tempPassword) : null; this.noProxyHost = Util.fixEmptyAndTrim(noProxyHost); this.testUrl = Util.fixEmptyAndTrim(testUrl); this.authenticator = newAuthenticator(); }
Source:
<code>public String getUrlToShow() { if (!url.contains("user=")) { StringBuilder urlToShow = new StringBuilder(); urlToShow.append(url); if (!url.contains("?")) { urlToShow.append("?user=").append(googleId); } else { urlToShow.append("&user=").append(googleId); } <START> return urlToShow.toString(); <END> } return url; }</code><technical_language>StringBuilder is necessary here. do this: java if (url.contains("?")) { return url + "&user=" + googleId; } return url + "?user=" + googleId;</technical_language>

Target:
public String getUrlToShow() { if (url.contains("user=")) { return url; } if (url.contains("?")) { return url + "&user=" + googleId; } return url + "?user=" + googleId; }
Source:
<code>public TextField() { labelElement = new Element("label"); inputElement = new Element("input"); String textFieldId = "textfield" + id++; inputElement.setAttribute("id", textFieldId); labelElement.setAttribute("for", textFieldId); inputElement.synchronizeProperty(VALUE_PROPERTY, "change"); inputElement.addEventListener("change", <START> e -> fireEvent(new ChangeEvent(this, true))); <END> getElement().appendChild(labelElement, inputElement); }</code><technical_language>![MAJOR](<LINK_1> Remove this call a constructor overridable "fireEvent" method. [![rule](<LINK_2>](<LINK_0></technical_language>

Target:
public TextField() { labelElement = new Element("label"); inputElement = new Element("input"); String textFieldId = generateId(); inputElement.setAttribute("id", textFieldId); labelElement.setAttribute("for", textFieldId); inputElement.synchronizeProperty(VALUE_PROPERTY, "change"); inputElement.addEventListener("change", e -> fireEvent(new ChangeEvent(this, true))); getElement().appendChild(labelElement, inputElement); }
Source:
<code>public PlanNode replace(int group, PlanNode node, String reason) { PlanNode old = getGroup(group).membership; checkArgument(new HashSet<>(old.getOutputSymbols()).equals(new HashSet<>(node.getOutputSymbols())), "%s: transformed expression doesn't produce same outputs: %s vs %s", reason, old.getOutputSymbols(), node.getOutputSymbols()); if (node instanceof GroupReference) { node = getNode(((GroupReference) node).getGroupId()); } else { node = insertChildrenAndRewrite(node); } incrementReferenceCounts(node, group); getGroup(group).membership = node; decrementReferenceCounts(old, group); <START> evictStatistics(group); END> return node; }</code><technical_language>rename method instead of commnting</technical_language>

Target:
public PlanNode replace(int group, PlanNode node, String reason) { PlanNode old = getGroup(group).membership; checkArgument(new HashSet<>(old.getOutputSymbols()).equals(new HashSet<>(node.getOutputSymbols())), "%s: transformed expression doesn't produce same outputs: %s vs %s", reason, old.getOutputSymbols(), node.getOutputSymbols()); if (node instanceof GroupReference) { node = getNode(((GroupReference) node).getGroupId()); } else { node = insertChildrenAndRewrite(node); } incrementReferenceCounts(node, group); getGroup(group).membership = node; decrementReferenceCounts(old, group); evictStatisticsAndCost(group); return node; }
Source:
<code>protected String determineFileName(String inputFileName) { for (final String prefix : inputPathPrefixes) { final Path prefPath = Paths.get(prefix).toAbsolutePath(); final String prefPathString = prefPath.toString(); if (inputFileName.startsWith(prefPathString)) { if (prefPath.toFile().isDirectory()) { return trimAnyPathSep(inputFileName.substring(prefPathString.length())); } else { <START> if (inputFileName.indexOf(FILE_SEPARATOR.charAt(0)) == -1) { <END> return inputFileName; } return trimAnyPathSep(inputFileName.substring(prefPathString.lastIndexOf(FILE_SEPARATOR))); } } } return inputFileName; }</code><technical_language>File.separatorChar suggestion if (inputFileName.indexOf(File.separatorChar) == -1) {</technical_language>

Target:
protected String determineFileName(String inputFileName) { return ShortFilenameUtil.determineFileName(inputPathPrefixes, inputFileName); }
Source:
<code>public Value list( Value request ) { final File dir = new File( request.getFirstChild( "directory" ).strValue() ); boolean fileInfo = false; <START> if ( request.getFirstChild("fileInfo").isDefined() ) { <END> fileInfo = request.getFirstChild("fileInfo").boolValue(); } final String regex; if ( request.hasChildren( "regex" ) ) { regex = request.getFirstChild( "regex" ).strValue(); } else { regex = ".*"; } boolean dirsOnly; if ( request.hasChildren( "dirsOnly" ) ) { dirsOnly = request.getFirstChild( "dirsOnly" ).boolValue(); } else { dirsOnly = false; } final String[] files = dir.list( new ListFilter( regex, dirsOnly ) ); if ( request.hasChildren( "order" ) ) { Value order = request.getFirstChild( "order" ); if ( files != null && order.hasChildren( "byname" ) && order.getFirstChild( "byname" ).boolValue() ) { Arrays.sort( files ); } } Value response = Value.create(); if ( files != null ) { ValueVector results = response.getChildren( "result" ); for( String file : files ) { Value fileValue = Value.create( file ); if( fileInfo ) { File currFile = new File ( dir + File.separator + file ); fileValue.getFirstChild("lastModified").setValue( currFile.lastModified() ); fileValue.getFirstChild("size").setValue( currFile.length() ); fileValue.getFirstChild("absolutePath").setValue( currFile.getAbsolutePath() ); fileValue.getFirstChild("isHidden").setValue( currFile.isHidden() ); fileValue.getFirstChild("isDirectory").setValue( currFile.isDirectory() ); } results.add( fileValue ); } } return response; }</code><technical_language>( "fileInfo" ) (same below)</technical_language>

Target:
public Value list( Value request ) { final File dir = new File( request.getFirstChild( "directory" ).strValue() ); boolean fileInfo = false; if ( request.getFirstChild( "info" ).isDefined() ) { fileInfo = request.getFirstChild( "info" ).boolValue(); } final String regex; if ( request.hasChildren( "regex" ) ) { regex = request.getFirstChild( "regex" ).strValue(); } else { regex = ".*"; } boolean dirsOnly; if ( request.hasChildren( "dirsOnly" ) ) { dirsOnly = request.getFirstChild( "dirsOnly" ).boolValue(); } else { dirsOnly = false; } final String[] files = dir.list( new ListFilter( regex, dirsOnly ) ); if ( request.hasChildren( "order" ) ) { Value order = request.getFirstChild( "order" ); if ( files != null && order.hasChildren( "byname" ) && order.getFirstChild( "byname" ).boolValue() ) { Arrays.sort( files ); } } Value response = Value.create(); if ( files != null ) { ValueVector results = response.getChildren( "result" ); for( String file : files ) { Value fileValue = Value.create( file ); if( fileInfo ) { Value info = fileValue.getFirstChild( "info" ); File currFile = new File ( dir + File.separator + file ); info.getFirstChild( "lastModified" ).setValue( currFile.lastModified() ); info.getFirstChild( "size" ).setValue( currFile.length() ); info.getFirstChild( "absolutePath" ).setValue( currFile.getAbsolutePath() ); info.getFirstChild( "isHidden" ).setValue( currFile.isHidden() ); info.getFirstChild( "isDirectory" ).setValue( currFile.isDirectory() ); } results.add( fileValue ); } } return response; }
Source:
<code>public void showAdvancedOptions(final ClickEvent clickEvent) { if (advancedOptions.getHidden()) { advancedOptions.setHidden(false); showHideAdvancedOptions.setTextContent(ts.format(LibraryConstants.HideAdvancedOptions)); } else { advancedOptions.setHidden(true); showHideAdvancedOptions.setTextContent(ts.format(LibraryConstants.ShowAdvancedOptions)); <START> artifactId.setValue(name.getValue()); <END> } }</code><technical_language>This change done in presenter (e.g.: presenter.restoreDefaultAdvancedOptions()), is a "business" logic. Also, if hide option is selected, I restore default groupId version, user modified it</technical_language>

Target:
public void showAdvancedOptions(final ClickEvent clickEvent) { if (advancedOptions.getHidden()) { advancedOptions.setHidden(false); showHideAdvancedOptions.setTextContent(ts.format(LibraryConstants.HideAdvancedOptions)); } else { advancedOptions.setHidden(true); showHideAdvancedOptions.setTextContent(ts.format(LibraryConstants.ShowAdvancedOptions)); presenter.restoreDefaultAdvancedOptions(); } }
Source:
<code>public String getUrl() { <START> String url = PluginImpl.getInstance().getConfig().getGerritFrontEndUrl(); <END> Provider provider = tEvent.getProvider(); if (provider != null) { String providerUrl = provider.getUrl(); if (providerUrl != null && !"".equals(providerUrl)) { url = providerUrl; } } if (tEvent instanceof ChangeBasedEvent) { ChangeBasedEvent changeBasedEvent = (ChangeBasedEvent)tEvent; if (null == changeBasedEvent.getPatchSet()) { return PluginImpl.getInstance().getConfig().getGerritFrontEndUrlFor( url, changeBasedEvent.getChange().getNumber(), null); } return PluginImpl.getInstance().getConfig().getGerritFrontEndUrlFor( url, changeBasedEvent.getChange().getNumber(), changeBasedEvent.getPatchSet().getNumber()); } return url; }</code><technical_language>I some duplicated code calculating frontend url for a change. I introduce a getFrontEndUrlFor(event) in Config object instead a lot of code in this file removed</technical_language>

Target:
public String getUrl() { return PluginImpl.getInstance().getConfig().getGerritFrontEndUrlFor(tEvent); }
Source:
<code>public TemporaryQueue createTemporaryQueue() throws JMSException { if (sessionType == ActiveMQSession.TYPE_TOPIC_SESSION) { throw new IllegalStateException("Cannot create a temporary queue using a TopicSession"); } try { <START> ActiveMQTemporaryQueue queue = ActiveMQDestination.createTemporaryQueue(this, (enable1xPrefixes ? PacketImpl.OLD_TEMP_QUEUE_PREFIX.toString() : "")); <END> SimpleString simpleAddress = queue.getSimpleAddress(); session.createTemporaryQueue(simpleAddress, RoutingType.ANYCAST, simpleAddress); connection.addTemporaryQueue(simpleAddress); return queue; } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } }</code><technical_language>(e.g. ignored) : avoid a string concatenation occurs in new createTemporaryQueue method for users enabling, if if moved around, existing method called for that. final ActiveMQTemporaryQueue queue; if (enable1xPrefixes) { queue = ActiveMQDestination.createTemporaryQueue(this, PacketImpl.OLD_TEMP_QUEUE_PREFIX.toString()); } else { queue = ActiveMQDestination.createTemporaryQueue(this); }</technical_language>

Target:
public TemporaryQueue createTemporaryQueue() throws JMSException { if (sessionType == ActiveMQSession.TYPE_TOPIC_SESSION) { throw new IllegalStateException("Cannot create a temporary queue using a TopicSession"); } try { final ActiveMQTemporaryQueue queue; if (enable1xPrefixes) { queue = ActiveMQDestination.createTemporaryQueue(this, PacketImpl.OLD_TEMP_QUEUE_PREFIX.toString()); } else { queue = ActiveMQDestination.createTemporaryQueue(this); } SimpleString simpleAddress = queue.getSimpleAddress(); session.createTemporaryQueue(simpleAddress, RoutingType.ANYCAST, simpleAddress); connection.addTemporaryQueue(simpleAddress); return queue; } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } }
Source:
<code>private List<Long> collectResumingTasksForResumeFailedMode(long attemptId) { List<ArchivedTask> tasks = sm .getSessionStore(getSiteId()) .getTasksOfAttempt(attemptId); List<Long> groupRetryErrorTaskIds = tasks.stream() <START> .filter(task -> task.getState() == TaskStateCode.GROUP_ERROR && task.getStateParams().has("retry_count")) <END> .map(task -> task.getId()) .collect(Collectors.toList()); List<Long> successTasks = tasks.stream() .filter(task -> task.getParentId().isPresent() && !groupRetryErrorTaskIds.contains(task.getParentId().get())) .filter(task -> task.getState() == TaskStateCode.SUCCESS) .map(task -> { if (!task.getParentId().isPresent()) { throw new IllegalArgumentException("Resuming successfully completed attempts is not supported"); } return task.getId(); }) .collect(Collectors.toList()); return ImmutableList.copyOf(successTasks); }</code><technical_language>I ask purpose check "retry_count"</technical_language>

Target:
private List<Long> collectResumingTasksForResumeFailedMode(long attemptId) { List<ArchivedTask> tasks = sm .getSessionStore(getSiteId()) .getTasksOfAttempt(attemptId); List<Long> groupRetryErrorTaskIds = tasks.stream() .filter(task -> task.getState() == TaskStateCode.GROUP_ERROR && task.getStateParams().has("retry_count")) .map(task -> task.getId()) .collect(Collectors.toList()); List<Long> successTasks = tasks.stream() .filter(task -> task.getParentId().isPresent() && !groupRetryErrorTaskIds.contains(task.getParentId().get())) .filter(task -> !task.getFullName().contains("^sub")) .filter(task -> task.getState() == TaskStateCode.SUCCESS) .map(task -> { if (!task.getParentId().isPresent()) { throw new IllegalArgumentException("Resuming successfully completed attempts is not supported"); } return task.getId(); }) .collect(Collectors.toList()); return ImmutableList.copyOf(successTasks); }
Source:
<code>public DataStoreTransaction beginTransaction() { EntityManager entityManager = entityManagerSupplier.get(); <START> JpaTransaction transaction = writeTransactionSupplier.get(entityManager, jpaTransactionCancel); <END> transaction.begin(); return transaction; }</code><technical_language>need pass transactionCancel argument supplier. supplier is created, a reference transactionSupplier closure. Remove this extra argument</technical_language>

Target:
public DataStoreTransaction beginTransaction() { EntityManager entityManager = entityManagerSupplier.get(); JpaTransaction transaction = writeTransactionSupplier.get(entityManager); transaction.begin(); return transaction; }
Source:
<code>public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { if (isPaid()){ return true; } Choice choice = new CardTypeChoice(exileHandler.availableTypes(types)); if (!game.getPlayer(controllerId).choose(Outcome.Neutral, choice, game)) { return false; } CardType choiceType = null; <START> for (CardType type:EnumSet.allOf(CardType.class)){ <END> if (type.toString().equals(choice.getChoice())){ choiceType = type; break; } } paid = exileHandler.useCardType(choiceType); return paid; }</code><technical_language>CardType.values() instead of EnumSet.allOf(...)</technical_language>

Target:
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { if (isPaid()){ return true; } CardType choiceType; EnumSet<CardType> availableChoices = exileHandler.availableTypes(types); if (availableChoices.size()==1){ choiceType = availableChoices.iterator().next(); }else { Choice choice = new CardTypeChoice(availableChoices); if (!game.getPlayer(controllerId).choose(Outcome.Neutral, choice, game)) { return false; } Optional<CardType> optionalChoice = Arrays.stream(CardType.values()).filter(type -> type.toString().equals(choice.getChoice())).findAny(); if (optionalChoice.isPresent()){ choiceType = optionalChoice.get(); }else{ return false; } } paid = exileHandler.useCardType(choiceType); return paid; }
Source:
<code>public void readKey( PageCursor cursor, RawBytes into, int keySize ) { int offsetBeforeRead = cursor.getOffset(); try { into.bytes = new byte[keySize]; cursor.getBytes( into.bytes ); } <START> catch ( BufferUnderflowException e ) <END> { throw Exceptions.withMessage( e, e.getMessage() + " keySize:" + keySize + " offset: " + offsetBeforeRead + " page size:" + cursor.getCurrentPageSize() ); } }</code><technical_language>Oh, I this debug-catch here, it</technical_language>

Target:
public void readKey( PageCursor cursor, RawBytes into, int keySize ) { into.bytes = new byte[keySize]; cursor.getBytes( into.bytes ); }
Source:
<code>public boolean execute( Property inputProperty, Node outputNode, Context context ) throws Exception { Binary binaryValue = inputProperty.getBinary(); CheckArg.isNotNull(binaryValue, "binary"); InputStream inputStream = binaryValue.getStream(); String mimeType = context.mimeTypeDetector().mimeTypeOf(getInputFileName(inputProperty), inputStream); Node sequencedNode = outputNode; if (outputNode.isNew()) { outputNode.setPrimaryType(METADATA_NODE); } else { sequencedNode = outputNode.addNode(METADATA_NODE, METADATA_NODE); } sequencedNode.setProperty(JCR_MIME_TYPE, mimeType); if (isPowerpoint(mimeType)) { sequencePowerpoint(sequencedNode, context.valueFactory(), inputStream); return true; } if (isWord(mimeType)) { sequenceWord(sequencedNode, context.valueFactory(), inputStream); return true; } if (isExcel(mimeType)) { sequenceExcel(sequencedNode, context.valueFactory(), inputStream); return true; } <START> logger.warn("Unknown mimetype: for microsoft office", mimeType); <END> return false; }</code><technical_language>this log message work? IIUC, this get forwarded ExtensionLogger, a ExecutionLogger.I18n instance created StringUtil.createString(String,Object...) format string. However, StringUtil method expects variables integers (based regular expression), it</technical_language>

Target:
public boolean execute( Property inputProperty, Node outputNode, Context context ) throws Exception { Binary binaryValue = inputProperty.getBinary(); CheckArg.isNotNull(binaryValue, "binary"); InputStream inputStream = binaryValue.getStream(); String mimeType = context.mimeTypeDetector().mimeTypeOf(getInputFileName(inputProperty), inputStream); Node sequencedNode = outputNode; if (outputNode.isNew()) { outputNode.setPrimaryType(METADATA_NODE); } else { sequencedNode = outputNode.addNode(METADATA_NODE, METADATA_NODE); } sequencedNode.setProperty(JCR_MIME_TYPE, mimeType); if (isPowerpoint(mimeType)) { sequencePowerpoint(sequencedNode, context.valueFactory(), inputStream); return true; } if (isWord(mimeType)) { sequenceWord(sequencedNode, context.valueFactory(), inputStream); return true; } if (isExcel(mimeType)) { sequenceExcel(sequencedNode, context.valueFactory(), inputStream); return true; } getLogger().warn("Unknown mimetype: {0} for microsoft office", mimeType); return false; }
Source:
<code>private void validateCommands(Devfile devfile, Set<String> toolNames) throws DevfileFormatException { Set<String> existingNames = new HashSet<>(); for (Command command : devfile.getCommands()) { if (!existingNames.add(command.getName())) { throw new DevfileFormatException( format("Duplicate command name found:'%s'", command.getName())); } <START> Set<String> nonexistingToolActions = <END> command .getActions() .stream() .map(Action::getTool) .filter(t -> !toolNames.contains(t)) .collect(toSet()); if (!nonexistingToolActions.isEmpty()) { throw new DevfileFormatException( format( "Found actions which refers to non-existing tools in command '%s':'%s'", command.getName(), String.join(",", nonexistingToolActions))); } } }</code><technical_language>nonexisting words. So, nonexisting -> nonExisting</technical_language>

Target:
private void validateCommands(Devfile devfile, Set<String> toolNames) throws DevfileFormatException { Set<String> existingNames = new HashSet<>(); for (Command command : devfile.getCommands()) { if (!existingNames.add(command.getName())) { throw new DevfileFormatException( format("Duplicate command name found:'%s'", command.getName())); } Set<String> nonExistingToolActions = command .getActions() .stream() .map(Action::getTool) .filter(t -> !toolNames.contains(t)) .collect(toSet()); if (!nonExistingToolActions.isEmpty()) { throw new DevfileFormatException( format( "Found actions which refer to non-existing tools in command '%s':'%s'", command.getName(), String.join(",", nonExistingToolActions))); } } }
Source:
<code>public BlockingChannelConnectionPoolTest() throws Exception { Properties props = new Properties(); props.setProperty("port", "6667"); VerifiableProperties propverify = new VerifiableProperties(props); NetworkConfig config = new NetworkConfig(propverify); ArrayList<Port> ports = new ArrayList<Port>(); ports.add(new Port(6667, PortType.PLAINTEXT)); ports.add(new Port(7667, PortType.SSL)); server1 = new SocketServer(config, new MetricRegistry(), ports); server1.start(); props.setProperty("port", "6668"); propverify = new VerifiableProperties(props); config = new NetworkConfig(propverify); ports = new ArrayList<Port>(); ports.add(new Port(6668, PortType.PLAINTEXT)); ports.add(new Port(7668, PortType.SSL)); server2 = new SocketServer(config, new MetricRegistry(), ports); server2.start(); props.setProperty("port", "6669"); propverify = new VerifiableProperties(props); config = new NetworkConfig(propverify); ports = new ArrayList<Port>(); ports.add(new Port(6669, PortType.PLAINTEXT)); ports.add(new Port(7669, PortType.SSL)); server3 = new SocketServer(config, new MetricRegistry(), ports); server3.start(); <START> sslFactory = TestUtils.createSSLFactory(); <END> SSLContext sslContext = sslFactory.createSSLContext(); sslSocketFactory = sslContext.getSocketFactory(); }</code><technical_language>Minor: this is a test, matter much. sslFactory sslSocketFactory static variables? This constructor is called for test creating similar objects time</technical_language>

Target:
public BlockingChannelConnectionPoolTest() throws Exception { Properties props = new Properties(); props.setProperty("port", "6667"); VerifiableProperties propverify = new VerifiableProperties(props); NetworkConfig config = new NetworkConfig(propverify); ArrayList<Port> ports = new ArrayList<Port>(); ports.add(new Port(6667, PortType.PLAINTEXT)); ports.add(new Port(7667, PortType.SSL)); server1 = new SocketServer(config, new MetricRegistry(), ports); server1.start(); props.setProperty("port", "6668"); propverify = new VerifiableProperties(props); config = new NetworkConfig(propverify); ports = new ArrayList<Port>(); ports.add(new Port(6668, PortType.PLAINTEXT)); ports.add(new Port(7668, PortType.SSL)); server2 = new SocketServer(config, new MetricRegistry(), ports); server2.start(); props.setProperty("port", "6669"); propverify = new VerifiableProperties(props); config = new NetworkConfig(propverify); ports = new ArrayList<Port>(); ports.add(new Port(6669, PortType.PLAINTEXT)); ports.add(new Port(7669, PortType.SSL)); server3 = new SocketServer(config, new MetricRegistry(), ports); server3.start(); }
Source:
<code>private static void adjustPlotStartAndEndTimeToMatchCurrentTime(PlotConfiguration settings, long currentTime) { if (settings.getTimeAxisSubsequentSetting() == TimeAxisSubsequentBoundsSetting.SCRUNCH) { if (currentTime > settings.getMaxTime()) { settings.setMaxTime(currentTime); } } else if (settings.getTimeAxisSubsequentSetting() == TimeAxisSubsequentBoundsSetting.JUMP && !settings.getPinTimeAxis()) { <START> if (currentTime < settings.getMaxTime()) { <END> long span = settings.getMaxTime() - settings.getMinTime(); settings.setMaxTime(currentTime); settings.setMinTime(currentTime - span); } } }</code><technical_language>I existing code is correct for "jump" plot behavior - this advance plot time marches on. this change result in desired behavior for non-changing historical data, result in incorrect behavior for live/streaming data. issue fact settings.getMaxTime() is returning system time in place. This sense a reasonable default in absence of a time service, overridden if a time service is available. Some care ensure defaults overridden in this manner (e.g. avoid overriding getMaxTime() is returning a persisted user-specified value.)</technical_language>

Target:
private static void adjustPlotStartAndEndTimeToMatchCurrentTime(PlotConfiguration settings, long currentTime) { if (settings.getTimeAxisSubsequentSetting() == TimeAxisSubsequentBoundsSetting.SCRUNCH) { if (currentTime > settings.getMaxTime()) { settings.setMaxTime(currentTime); } } else if (settings.getTimeAxisSubsequentSetting() == TimeAxisSubsequentBoundsSetting.JUMP && !settings.getPinTimeAxis()) { if (currentTime > settings.getMaxTime()) { long span = settings.getMaxTime() - settings.getMinTime(); settings.setMaxTime(currentTime); settings.setMinTime(currentTime - span); } } }
Source:
<code>private void requestForDownload(OCFile file) { Intent intent = new Intent(mContext, FileDownloader.class); intent.putExtra(FileDownloader.KEY_ACCOUNT, mAccount); intent.putExtra(FileDownloader.KEY_FILE, file); <START> if (mContext instanceof AvailableOfflineSyncJobService && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { <END> intent.putExtra(FileDownloader.KEY_IS_AVAILABLE_OFFLINE_FILE, true); mContext.startForegroundService(intent); } else { mContext.startService(intent); } mTransferWasRequested = true; }</code><technical_language>before. ContextCompat if (context instanceof AvailableOfflineSyncJobService && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { intent.putExtra(FileUploader.KEY_IS_AVAILABLE_OFFLINE_FILE, true); } ContextCompat.startForegroundService(context, intent) BTW, this code refactored a common section</technical_language>

Target:
private void requestForDownload(OCFile file) { Intent intent = new Intent(mContext, FileDownloader.class); intent.putExtra(FileDownloader.KEY_ACCOUNT, mAccount); intent.putExtra(FileDownloader.KEY_FILE, file); if (mRequestedFromAvOfflineService && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { intent.putExtra(FileDownloader.KEY_IS_AVAILABLE_OFFLINE_FILE, true); mContext.startForegroundService(intent); } else { mContext.startService(intent); } mTransferWasRequested = true; }
Source:
<code>public boolean shouldAcquire(String name) { int lastDot = name.lastIndexOf('.'); String pkgName = name.substring(0, lastDot == -1 ? 0 : lastDot); if (pkgName.equals("org.robolectric.res") || (pkgName.equals("org.robolectric.manifest"))) { return name.contains("Test"); } if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true; if (name.equals("android.R$styleable")) return true; return !( name.matches(".*\\.R(|\\$[a-z]+)$") || classesToNotAquire.contains(name) || name.startsWith("java.") || name.startsWith("javax.") || name.startsWith("sun.") || name.startsWith("com.sun.") || name.startsWith("org.w3c.") || name.startsWith("org.xml.") || name.startsWith("org.junit") || name.startsWith("org.hamcrest") <START> || name.startsWith("org.scalatest") <END> || name.startsWith("org.specs2") || name.startsWith("scala.") || name.startsWith("kotlin.") || name.startsWith("com.almworks.sqlite4java") ); }</code><technical_language>achieve calling doNotAquireClass("org.scalatest") builder... I prefer hard code exclusions for random libraries in here</technical_language>

Target:
public boolean shouldAcquire(String name) { int lastDot = name.lastIndexOf('.'); String pkgName = name.substring(0, lastDot == -1 ? 0 : lastDot); if (pkgName.equals("org.robolectric.res") || (pkgName.equals("org.robolectric.manifest"))) { return name.contains("Test"); } if (name.matches("com\\.android\\.internal\\.R(\\$.*)?")) return true; if (name.equals("android.R$styleable")) return true; for (String packageName : packagesToNotAquire) { if (name.startsWith(packageName)) return false; } return !(name.matches(".*\\.R(|\\$[a-z]+)$") || classesToNotAquire.contains(name)); }
Source:
<code><START> public String clickLinkButtonAndGetUrl(String linkText) { <END> WebElement button = getDriver().findElement(By.linkText(linkText)); WebElement html = getHtmlElement(); button.click(); waitForPageRefresh(html); return getCurrentUrl(); }</code><technical_language>protected. Knowledge of link text belongs in Page model classes. A Page class expose addDilution() method clickLinkButtonAndGetUrl("Add")</technical_language>

Target:
protected String clickLinkButtonAndGetUrl(String linkText) { WebElement button = getDriver().findElement(By.linkText(linkText)); WebElement html = getHtmlElement(); button.click(); waitForPageRefresh(html); return getCurrentUrl(); }
Source:
<code>public void createInitialLayout(IPageLayout layout) { if (layout == null) { return; } layout.setEditorAreaVisible(true); layout.setEditorAreaVisible(true); IFolderLayout topLeftFolder = layout.createFolder("topLeftFolder", IPageLayout.LEFT, 0.15f, IPageLayout.ID_EDITOR_AREA); topLeftFolder.addView(IPageLayout.ID_PROJECT_EXPLORER); <START> IFolderLayout topRightFolder = layout.createFolder("topRightFolder", IPageLayout.BOTTOM, 0.10f, IPageLayout.ID_EDITOR_AREA); END> topRightFolder.addView(HistogramView.ID); IFolderLayout middleRightFolder = layout.createFolder("middleRightFolder", IPageLayout.BOTTOM, 0.50f, "topRightFolder"); middleRightFolder.addView(CallStackView.ID); IFolderLayout bottomRightFolder = layout.createFolder("bottomRightFolder", IPageLayout.BOTTOM, 0.65f, "middleRightFolder"); bottomRightFolder.addView(TimeChartView.ID); layout.addPerspectiveShortcut(ID); layout.addNewWizardShortcut(NewTmfProjectWizard.ID); }</code><technical_language>give details this values. sources : doc? experiment</technical_language>

Target:
public void createInitialLayout(IPageLayout layout) { if (layout == null) { return; } layout.setEditorAreaVisible(true); layout.setEditorAreaVisible(true); IFolderLayout topLeftFolder = layout.createFolder("topLeftFolder", IPageLayout.LEFT, 0.15f, IPageLayout.ID_EDITOR_AREA); topLeftFolder.addView(IPageLayout.ID_PROJECT_EXPLORER); IFolderLayout topRightFolder = layout.createFolder("topRightFolder", IPageLayout.BOTTOM, EDITOR_AREA_RATIO, IPageLayout.ID_EDITOR_AREA); topRightFolder.addView(HistogramView.ID); IFolderLayout middleRightFolder = layout.createFolder("middleRightFolder", IPageLayout.BOTTOM, 0.50f, "topRightFolder"); middleRightFolder.addView(CallStackView.ID); IFolderLayout bottomRightFolder = layout.createFolder("bottomRightFolder", IPageLayout.BOTTOM, 0.65f, "middleRightFolder"); bottomRightFolder.addView(TimeChartView.ID); layout.addPerspectiveShortcut(ID); layout.addNewWizardShortcut(NewTmfProjectWizard.ID); }
Source:
<code>private void doAssert(AssertionResult assertionResult, String responseDataAsJsonString, boolean invert) throws Exception { <START> ObjectMapper mapper = new ObjectMapper(); <END> JsonNode input = mapper.readValue(responseDataAsJsonString, JsonNode.class); Expression<JsonNode> expression = JMESPathCache.getInstance().get(getJmesPath()); JsonNode currentValue = expression.search(input); log.debug("JMESPath query invoked on response {}. Query result is {}. ", expression, responseDataAsJsonString, currentValue); boolean success = checkResult(mapper, currentValue, assertionResult, invert); if (!invert) { if (!success) { failAssertion(invert, assertionResult); } } else { if (success) { failAssertion(invert, assertionResult); } } }</code><technical_language>Please avoid instantiating ObjectMapper a hot path</technical_language>

Target:
private void doAssert(AssertionResult assertionResult, String responseDataAsJsonString, boolean invert) throws Exception { JsonNode input = OBJECT_MAPPER.readValue(responseDataAsJsonString, JsonNode.class); Expression<JsonNode> expression = JMESPathCache.getInstance().get(getJmesPath()); JsonNode currentValue = expression.search(input); log.debug("JMESPath query invoked on response {}. Query result is {}. ", expression, responseDataAsJsonString, currentValue); boolean success = checkResult(OBJECT_MAPPER, currentValue, assertionResult, invert); if (!invert) { if (!success) { failAssertion(invert, assertionResult); } } else { if (success) { failAssertion(invert, assertionResult); } } }
Source:
<code>private static String loadResource(String fileName) { try { return Resources.toString(Resources.getResource(TestConstants.class, fileName), Charsets.UTF_8); } catch (IOException e) { <START> Throwables.propagate(e); <END> } throw new RuntimeException("Resource not available " + fileName); }</code><technical_language>> throw Throwables.propagate(e); remove throw statement</technical_language>

Target:
private static String loadResource(String fileName) { try { return Resources.toString(Resources.getResource(TestConstants.class, fileName), Charsets.UTF_8); } catch (IOException e) { throw Throwables.propagate(e); } }
Source:
<code>public boolean equals(Object obj) { if (obj instanceof SimpleStack) { SimpleStack other = (SimpleStack) obj; if (this.damage == OreDictionary.WILDCARD_VALUE || other.damage == OreDictionary.WILDCARD_VALUE) { return this.qnty == other.qnty && this.id == other.id; } if(this.nbt != null && other.nbt != null){ return this.id == other.id && this.qnty == other.qnty && this.damage == other.damage && this.nbt.equals(other.nbt); } <START> return this.id == other.id && this.qnty == other.qnty && this.damage == other.damage; <END> } return false; }</code><technical_language>This return happen, this.nbt == null && other.nbt == null, i think. (The Stacks same, NBT other not!)</technical_language>

Target:
public boolean equals(Object obj) { if (obj instanceof SimpleStack) { SimpleStack other = (SimpleStack) obj; if (this.damage == OreDictionary.WILDCARD_VALUE || other.damage == OreDictionary.WILDCARD_VALUE) { return this.qnty == other.qnty && this.id == other.id; } if(this.nbt != null && other.nbt != null){ return this.id == other.id && this.qnty == other.qnty && this.damage == other.damage && this.nbt.equals(other.nbt); } else if (this.nbt == null && other.nbt == null){ return this.id == other.id && this.qnty == other.qnty && this.damage == other.damage; } else { return false; } } return false; }
Source:
<code>public static String processScript(Map<String, Object> conf, String script) { Thread interruptThread = null; try { Process process = Runtime.getRuntime().exec(script); final long timeout = ObjectReader.getLong(conf.get(DaemonConfig.STORM_HEALTH_CHECK_TIMEOUT_MS), 5000L); final Thread curThread = Thread.currentThread(); interruptThread = new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(timeout); curThread.interrupt(); } catch (InterruptedException e) { } } }); interruptThread.start(); process.waitFor(); interruptThread.interrupt(); curThread.interrupted(); if (process.exitValue() != 0) { String str; InputStream stdin = process.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(stdin)); while ((str = reader.readLine()) != null) { if (str.startsWith("ERROR")) { LOG.warn("The healthcheck process exited with code {}", script, process.exitValue()); return FAILED; } } <START> return SUCCESS; <END> } return SUCCESS; } catch (InterruptedException | ClosedByInterruptException e) { LOG.warn("Script: timed out.", script); return TIMEOUT; } catch (Exception e) { LOG.warn("Script failed with exception: ", e); return FAILED_WITH_EXIT_CODE; } finally { if (interruptThread != null) { interruptThread.interrupt(); } } }</code><technical_language>this failed return FAILED_WITH_EXIT_CODE; exit code is 0</technical_language>

Target:
public static String processScript(Map<String, Object> conf, String script) { Thread interruptThread = null; try { Process process = Runtime.getRuntime().exec(script); final long timeout = ObjectReader.getLong(conf.get(DaemonConfig.STORM_HEALTH_CHECK_TIMEOUT_MS), 5000L); final Thread curThread = Thread.currentThread(); interruptThread = new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(timeout); curThread.interrupt(); } catch (InterruptedException e) { } } }); interruptThread.start(); process.waitFor(); interruptThread.interrupt(); curThread.interrupted(); if (process.exitValue() != 0) { String str; InputStream stdin = process.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(stdin)); while ((str = reader.readLine()) != null) { if (str.startsWith("ERROR")) { LOG.warn("The healthcheck process exited with code {}", script, process.exitValue()); return FAILED; } } return FAILED_WITH_EXIT_CODE; } return SUCCESS; } catch (InterruptedException | ClosedByInterruptException e) { LOG.warn("Script: timed out.", script); return TIMEOUT; } catch (Exception e) { LOG.warn("Script failed with exception: ", e); return FAILED; } finally { if (interruptThread != null) { interruptThread.interrupt(); } } }
Source:
<code>public void testSaveAndRename() { final Supplier pathSupplier = mock(Supplier.class); final Validator validator = mock(Validator.class); final Caller supportsSaveAndRename = mock(Caller.class); final Supplier metadataSupplier = mock(Supplier.class); final Supplier contentSupplier = mock(Supplier.class); final Supplier isDirtySupplier = mock(Supplier.class); final ParameterizedCommand parameterizedCommand = mock(ParameterizedCommand.class); final Command command = mock(Command.class); doReturn(pathSupplier).when(editor).getPathSupplier(); doReturn(validator).when(editor).getRenameValidator(); doReturn(supportsSaveAndRename).when(editor).getSaveAndRenameServiceCaller(); doReturn(metadataSupplier).when(editor).getMetadataSupplier(); <START> doReturn(contentSupplier).when(editor).getContentSupplier(); <END> doReturn(isDirtySupplier).when(editor).isDirtySupplier(); doReturn(parameterizedCommand).when(editor).onSuccess(); doReturn(command).when(builder).build(); final Command saveAndRenameCommand = editor.getSaveAndRename(); assertEquals(command, saveAndRenameCommand); }</code><technical_language>This test is kind of suspicious for passes if is rewritten as: java @Test public void testSaveAndRename() { final Command command = mock(Command.class); doReturn(command).when(builder).build(); final Command saveAndRenameCommand = editor.getSaveAndRename(); assertEquals(command, saveAndRenameCommand); }</technical_language>

Target:
public void testSaveAndRename() { final Supplier pathSupplier = mock(Supplier.class); final Validator renameValidator = mock(Validator.class); final Supplier saveValidator = mock(Supplier.class); final Caller supportsSaveAndRename = mock(Caller.class); final Supplier metadataSupplier = mock(Supplier.class); final Supplier contentSupplier = mock(Supplier.class); final Supplier isDirtySupplier = mock(Supplier.class); final ParameterizedCommand parameterizedCommand = mock(ParameterizedCommand.class); final Command command = mock(Command.class); doReturn(pathSupplier).when(editor).getPathSupplier(); doReturn(renameValidator).when(editor).getRenameValidator(); doReturn(saveValidator).when(editor).getSaveValidator(); doReturn(supportsSaveAndRename).when(editor).getSaveAndRenameServiceCaller(); doReturn(metadataSupplier).when(editor).getMetadataSupplier(); doReturn(contentSupplier).when(editor).getContentSupplier(); doReturn(isDirtySupplier).when(editor).isDirtySupplier(); doReturn(parameterizedCommand).when(editor).onSuccess(); doReturn(command).when(builder).build(); final Command saveAndRenameCommand = editor.getSaveAndRename(); assertEquals(command, saveAndRenameCommand); verify(builder).addPathSupplier(pathSupplier); verify(builder).addValidator(renameValidator); verify(builder).addValidator(saveValidator); verify(builder).addRenameService(supportsSaveAndRename); verify(builder).addMetadataSupplier(metadataSupplier); verify(builder).addContentSupplier(contentSupplier); verify(builder).addIsDirtySupplier(isDirtySupplier); verify(builder).addSuccessCallback(parameterizedCommand); }