auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private static boolean isMethodInvocation(@Nullable Tree tree, LambdaExpressionTree lambdaTree) { if (tree != null && tree.is(Tree.Kind.METHOD_INVOCATION, Tree.Kind.NEW_CLASS)) { Arguments arguments; if(tree.is(Tree.Kind.NEW_CLASS)) { if(((NewClassTree) tree).classBody() != null) { return false; } arguments = ((NewClassTree) tree).arguments(); } else { MethodInvocationTree mit = (MethodInvocationTree) tree; if(mit.methodSelect().is(Tree.Kind.MEMBER_SELECT)) { MemberSelectExpressionTree mse = (MemberSelectExpressionTree) mit.methodSelect(); while (mse != null) { if(mse.expression().is(Tree.Kind.METHOD_INVOCATION)) { <START> return false; <END> } if(mse.expression().is(Tree.Kind.MEMBER_SELECT)) { mse = (MemberSelectExpressionTree) mse.expression(); } else { mse = null; } } } arguments = mit.arguments(); } List<VariableTree> parameters = lambdaTree.parameters(); return matchingParameters(parameters, arguments) || (arguments.isEmpty() && isNoArgMethodInvocationFromLambdaParam(tree, parameters)); } return false; }</code><technical_language>While I understand here, a while get I find name of method confusing. while loop extracted another aptly named method bit more clear</technical_language>

Target:
private static boolean isMethodInvocation(@Nullable Tree tree, LambdaExpressionTree lambdaTree) { if (tree != null && tree.is(Tree.Kind.METHOD_INVOCATION, Tree.Kind.NEW_CLASS)) { Arguments arguments; if(tree.is(Tree.Kind.NEW_CLASS)) { if(((NewClassTree) tree).classBody() != null) { return false; } arguments = ((NewClassTree) tree).arguments(); } else { MethodInvocationTree mit = (MethodInvocationTree) tree; if (hasMethodInvocationInMethodSelect(mit)) { return false; } arguments = mit.arguments(); } List<VariableTree> parameters = lambdaTree.parameters(); return matchingParameters(parameters, arguments) || (arguments.isEmpty() && isNoArgMethodInvocationFromLambdaParam(tree, parameters)); } return false; }
Source:
<code><START> private ReentrantLock getLock() { <END> if (sLock == null) { synchronized (this) { if (sLock == null) { return new ReentrantLock(); } } } return sLock; }</code><technical_language>This check feels a weird for a reasons. behaves a factory (in returns new instances) sLock is assigned here. initializes a static field instance method feels strange. I suspect if lock is acquired in method released in another, waits involved a more primitive synchronization technique sufficient (such a synchronized method block, of a ReentrantLock) -- leave this judgement this dodgy</technical_language>

Target:
private static ReentrantLock getLock() { if (sLock == null) { synchronized (Discovery.class) { if (sLock == null) { sLock = new ReentrantLock(); } } } return sLock; }
Source:
<code>private Trigger(int triggerId, long lastModifyTime, long submitTime, String submitUser, String source, Condition triggerCondition, Condition expireCondition, List<TriggerAction> actions, List<TriggerAction> expireActions, Map<String, Object> info, Map<String, Object> context) { <START> this.lastModifyTime = lastModifyTime; <END> this.submitTime = submitTime; this.submitUser = submitUser; this.source = source; this.triggerCondition = triggerCondition; this.expireCondition = expireCondition; this.actions = actions; this.triggerId = triggerId; this.expireActions = expireActions; this.info = info; this.context = context; }</code><technical_language>nit: good do validations here. requireNonNull checks,</technical_language>

Target:
private Trigger(int triggerId, long lastModifyTime, long submitTime, String submitUser, String source, Condition triggerCondition, Condition expireCondition, List<TriggerAction> actions, List<TriggerAction> expireActions, Map<String, Object> info, Map<String, Object> context) { requireNonNull(submitUser); requireNonNull(source); requireNonNull(triggerCondition); requireNonNull(expireActions); requireNonNull(info); requireNonNull(context); this.lastModifyTime = lastModifyTime; this.submitTime = submitTime; this.submitUser = submitUser; this.source = source; this.triggerCondition = triggerCondition; this.expireCondition = expireCondition; this.actions = actions; this.triggerId = triggerId; this.expireActions = expireActions; this.info = info; this.context = context; }
Source:
<code>public Builder addAdditionalTestExecutionListeners(TestExecutionListener... listeners) { <START> this.additionalTestExecutionListeners.addAll(Arrays.asList(listeners)); <END> return this; }</code><technical_language>Please Collections.addAll(Collection<? super T>, T...) instead</technical_language>

Target:
public Builder addAdditionalTestExecutionListeners(TestExecutionListener... listeners) { Collections.addAll(this.additionalTestExecutionListeners, listeners); return this; }
Source:
<code><START> public synchronized IConnection connect(String storm_id, String host, int port, AtomicBoolean[] remoteBpStatus) { <END> return new Client(topoConf, remoteBpStatus, clientChannelFactory, clientScheduleService, host, port, this); }</code><technical_language>This longer needs synchronized. protect connections, is longer needed if do is create a new Client</technical_language>

Target:
public IConnection connect(String storm_id, String host, int port, AtomicBoolean[] remoteBpStatus) { return new Client(topoConf, remoteBpStatus, clientChannelFactory, clientScheduleService, host, port); }
Source:
<code>Storage getStorage(Collection<String> scopes) throws IOException { GoogleCredential credential = null; try { if (mStorage == null) { if (mJsonKeyFile != null && mJsonKeyFile.exists()) { CLog.d("Using json key file %s.", mJsonKeyFile); credential = GoogleApiClientUtil.createCredentialFromJsonKeyFile( mJsonKeyFile, scopes); } else { CLog.d("Using local authentication."); try { <START> credential = GoogleCredential.getApplicationDefault().createScoped(scopes); <END> } catch (IOException e) { CLog.e(e.getMessage()); CLog.e("Try 'gcloud auth application-default login' to login."); throw e; } } mStorage = new Storage.Builder( GoogleNetHttpTransport.newTrustedTransport(), JacksonFactory.getDefaultInstance(), GoogleApiClientUtil.configureRetryStrategy( GoogleApiClientUtil.setHttpTimeout( credential, DEFAULT_TIMEOUT, DEFAULT_TIMEOUT))) .setApplicationName(GoogleApiClientUtil.APP_NAME) .build(); } return mStorage; } catch (GeneralSecurityException e) { throw new IOException(e); } }</code><technical_language>I some experiment this work expected, "gcloud auth" is showing. if</technical_language>

Target:
Storage getStorage(Collection<String> scopes) throws IOException { GoogleCredential credential = null; try { if (mStorage == null) { if (mJsonKeyFile != null && mJsonKeyFile.exists()) { CLog.d("Using json key file %s.", mJsonKeyFile); credential = GoogleApiClientUtil.createCredentialFromJsonKeyFile( mJsonKeyFile, scopes); } else { CLog.d("Using local authentication."); try { credential = GoogleCredential.getApplicationDefault().createScoped(scopes); } catch (IOException e) { CLog.e(e.getMessage()); CLog.e( "Try 'gcloud auth application-default login' to login for " + "personal account; Or 'export " + "GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json' " + "for service account."); throw e; } } mStorage = new Storage.Builder( GoogleNetHttpTransport.newTrustedTransport(), JacksonFactory.getDefaultInstance(), GoogleApiClientUtil.configureRetryStrategy( GoogleApiClientUtil.setHttpTimeout( credential, DEFAULT_TIMEOUT, DEFAULT_TIMEOUT))) .setApplicationName(GoogleApiClientUtil.APP_NAME) .build(); } return mStorage; } catch (GeneralSecurityException e) { throw new IOException(e); } }
Source:
<code>protected static ArchetypeTerm getTerm(Map<String, Map<String, ArchetypeTerm>> termDefinitions, String language, String nodeId) { Map<String, ArchetypeTerm> translations = termDefinitions.get(language); ArchetypeTerm term = translations.get(nodeId); if(term == null) { for(Map.Entry<String, ArchetypeTerm> entry: translations.entrySet()) { if(nodeId.startsWith(entry.getKey() + ".")) { NodeId.parse(nodeId); <START> return entry.getValue(); <END> } } } return term; }</code><technical_language>if is term definition for id1.1.1, is for id1.1 id1, I this is guaranteed return definition for id1.1</technical_language>

Target:
protected static ArchetypeTerm getTerm(Map<String, Map<String, ArchetypeTerm>> termDefinitions, String language, String nodeId) { Map<String, ArchetypeTerm> translations = termDefinitions.get(language); ArchetypeTerm term = translations.get(nodeId); Map<String, ArchetypeTerm> foundTerms = new LinkedHashMap<>(); if(term == null) { for(Map.Entry<String, ArchetypeTerm> entry: translations.entrySet()) { if(nodeId.startsWith(entry.getKey() + ".")) { foundTerms.put(nodeId, entry.getValue()); } } List<String> foundNodeIds = new ArrayList(foundTerms.keySet()); Collections.sort(foundNodeIds, Comparator.comparingInt((id) -> id.length())); return foundTerms.get(foundNodeIds.get(foundNodeIds.size()-1)); } return term; }
Source:
<code>public Iterator<V> iterator() { <START> return matchingMode == MATCHING_MODE.KEEP_ALL ? allList.iterator() : firstOrLastHash.values().iterator(); <END> }</code><technical_language>hm... I this class is a candidate for splitting subclasses: KeepFirstHashFile, KeepLastHashFile, KeepAllHashFile</technical_language>

Target:
public Iterator<V> iterator() { if (matchingMode == MATCHING_MODE.KEEP_ALL) { return allList.iterator(); } return firstOrLastHash.values().iterator(); }
Source:
<code>public void deserialize(String value) { if (allKeyValueMap == null) { saveEntity = value; return; } if (value != null) { keyValueMap_used = new HashMap<String, String>(); if (!value.isEmpty()) { String[] lines = value.split(PROPERTIES_DELIMETER); <START> keyValueMap_used = new HashMap<String, String>(); <END> String[] splitLine; for (String line : lines) { if (line.isEmpty()) { continue; } splitLine = line.split(KEY_VALUE_DELIMETER, 2); String key = splitLine[0]; if (allKeyValueMap.containsKey(key)) { keyValueMap_used.put(key, splitLine[1]); } } } } init(allKeyValueMap.keySet(), keyValueMap_used.keySet()); }</code><technical_language>this line redundant, is a new HashMap 4 lines</technical_language>

Target:
public void deserialize(String value) { if (allKeyValueMap == null) { saveEntity = value; return; } if (value != null) { keyValueMap_used = new HashMap<String, String>(); if (!value.isEmpty()) { String[] lines = value.split(PROPERTIES_DELIMETER); String[] splitLine; for (String line : lines) { if (line.isEmpty()) { continue; } splitLine = line.split(KEY_VALUE_DELIMETER, 2); String key = splitLine[0]; if (allKeyValueMap.containsKey(key)) { keyValueMap_used.put(key, splitLine[1]); } } } } init(allKeyValueMap.keySet(), keyValueMap_used.keySet()); }
Source:
<code>public void close() throws Exception { <START> for (final EventProcessor eventProcessor : eventProcessors) { <END> eventProcessor.interrupt(); } }</code><technical_language>forEach too</technical_language>

Target:
public void close() throws Exception { eventProcessors.forEach(eventProcessor -> eventProcessor.close()); }
Source:
<code>protected <START> synchronized com.ibm.icu.text.DecimalFormatSymbols <END> getIcuDecimalFormatSymbols() { if (cachedIcuDFS != null) { return cachedIcuDFS; } cachedIcuDFS = new com.ibm.icu.text.DecimalFormatSymbols(this.locale); cachedIcuDFS.setZeroDigit(zeroDigit); cachedIcuDFS.setDigit(digit); cachedIcuDFS.setDecimalSeparator(decimalSeparator); cachedIcuDFS.setGroupingSeparator(groupingSeparator); cachedIcuDFS.setPatternSeparator(patternSeparator); cachedIcuDFS.setPercent(percent.charAt(0)); cachedIcuDFS.setMonetaryDecimalSeparator(monetarySeparator); cachedIcuDFS.setMinusSign(minusSign.charAt(0)); cachedIcuDFS.setInfinity(infinity); cachedIcuDFS.setNaN(NaN); cachedIcuDFS.setExponentSeparator(exponentSeparator); try { cachedIcuDFS.setCurrency( com.ibm.icu.util.Currency.getInstance(currency.getCurrencyCode())); } catch (NullPointerException e) { currency = Currency.getInstance("XXX"); } cachedIcuDFS.setCurrencySymbol(currencySymbol); cachedIcuDFS.setInternationalCurrencySymbol(intlCurrencySymbol); return cachedIcuDFS; }</code><technical_language>Putting synchronized full story other methods fields modify cachedIcuDFS synchronized. need synchronized, declare/accept this class is threadsafe</technical_language>

Target:
protected com.ibm.icu.text.DecimalFormatSymbols getIcuDecimalFormatSymbols() { com.ibm.icu.text.DecimalFormatSymbols result = new com.ibm.icu.text.DecimalFormatSymbols(this.locale); result.setZeroDigit(zeroDigit); result.setDigit(digit); result.setDecimalSeparator(decimalSeparator); result.setGroupingSeparator(groupingSeparator); result.setPatternSeparator(patternSeparator); result.setPercent(percent.charAt(0)); result.setMonetaryDecimalSeparator(monetarySeparator); result.setMinusSign(minusSign.charAt(0)); result.setInfinity(infinity); result.setNaN(NaN); result.setExponentSeparator(exponentSeparator); try { result.setCurrency(com.ibm.icu.util.Currency.getInstance(currency.getCurrencyCode())); } catch (NullPointerException e) { currency = Currency.getInstance("XXX"); } result.setCurrencySymbol(currencySymbol); result.setInternationalCurrencySymbol(intlCurrencySymbol); return result; }
Source:
<code>public MainTabBasicDetailsView(ApplicationResources resources) { operatingSystem = new ValueLabel<VmOsType>(new AbstractRenderer<VmOsType>() { private OSNamesTranslator osNamesTranslator = new OSNamesTranslator();; @Override public String render(VmOsType object) { <START> return osNamesTranslator.translate(object); <END> } }); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); Driver.driver.initialize(this); ViewIdHandler.idHandler.generateAndSetIds(this); }</code><technical_language>please modify Enums.properties/Enums.java instead (since OSNamesTranslator is localized VMOstype localized on)</technical_language>

Target:
public MainTabBasicDetailsView(ApplicationResources resources) { operatingSystem = new EnumLabel<VmOsType>(); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); Driver.driver.initialize(this); ViewIdHandler.idHandler.generateAndSetIds(this); }
Source:
<code>public void validate() { if (sheetName.indexOf(".") != -1) { throw new IllegalStateException("Sheet name cannot contain dots (.)"); } if (file.exists()) { Datastore datastore = new ExcelDatastore(file.getName(), new FileResource(file), file.getAbsolutePath()); <START> final Schema[] schemas = datastore.openConnection().getDataContext().getSchemas(); <END> final String[] tableNames = schemas[1].getTableNames(); for (int i = 0; i < tableNames.length; i++) { if (tableNames[i].equals(sheetName)) { if (!overwriteSheetIfExists) { throw new IllegalStateException("The sheet '" + sheetName + "' already exists. Please select another sheet name."); } } } } }</code><technical_language>openConnection() call returns a DatastoreConnection. This needs closed in a finally block finished operation :-)</technical_language>

Target:
public void validate() { if (sheetName.indexOf(".") != -1) { throw new IllegalStateException("Sheet name cannot contain dots (.)"); } if (file.exists()) { Datastore datastore = new ExcelDatastore(file.getName(), new FileResource(file), file.getAbsolutePath()); try (final DatastoreConnection connection = datastore.openConnection()) { final String[] tableNames = connection.getDataContext().getDefaultSchema().getTableNames(); for (int i = 0; i < tableNames.length; i++) { if (tableNames[i].equals(sheetName)) { if (!overwriteSheetIfExists) { throw new IllegalStateException("The sheet '" + sheetName + "' already exists. Please select another sheet name."); } } } } } }
Source:
<code>public boolean inMultiCombat() { <START> return ctx.varpbits.varpbit(1021) == 0x20; <END> }</code><technical_language>shift mask bit is determine if in multi-way combat. Other bits for other things, if active time break method. return ctx.varpbits.varpbit(1021, 5, 0x1) == 1;</technical_language>

Target:
public boolean inMultiCombat() { return ctx.varpbits.varpbit(1021, 5, 0x1) == 1; }
Source:
<code>protected String toSqlType(Type type) { if (VARBINARY.equals(type)) { return "bytea"; } <START> else if (JSON.equals(type)) { <END> return "jsonb"; } return super.toSqlType(type); }</code><technical_language>else is rendudant</technical_language>

Target:
protected String toSqlType(Type type) { if (VARBINARY.equals(type)) { return "bytea"; } if (JSON.equals(type)) { return "jsonb"; } return super.toSqlType(type); }
Source:
<code>public OAuth2Authentication loadAuthentication(String accessToken) throws AuthenticationException, InvalidTokenException { if (isApiKey(accessToken)) { <START> return remoteTokenServices.loadAuthentication(accessToken); <END> } return jwtTokenService.loadAuthentication(accessToken); }</code><technical_language>include retry template, do return retryTemplate.execute(x -> remoteTokenServices.loadAuthentication(accessToken));</technical_language>

Target:
public OAuth2Authentication loadAuthentication(String accessToken) throws AuthenticationException, InvalidTokenException { if (isApiKey(accessToken)) { return retryTemplate.execute(x -> remoteTokenServices.loadAuthentication(accessToken)); } return jwtTokenService.loadAuthentication(accessToken); }
Source:
<code>public void updated(Dictionary<String, ?> config) throws ConfigurationException { <START> logger.debug("updated() is called!"); <END> if (config != null) { port = 8021; host = (String) config.get("host"); password = (String) config.get("password"); String portString = (String) config.get("port"); if(StringUtils.isNotBlank(portString)) port = Integer.parseInt(portString); eventCache = new LinkedHashMap<String, Channel>(); mwiCache = new HashMap<String, FreeswitchBinding.MWIModel>(); itemMap = new LinkedHashMap<String, LinkedList<FreeswitchBindingConfig>>(); try { connect(); } catch (InboundConnectionFailure e) { logger.error(String.format("Could not connect to freeswitch server: %s", e.getMessage()),e); } } }</code><technical_language>please remove decrease log level TRACE</technical_language>

Target:
public void updated(Dictionary<String, ?> config) throws ConfigurationException { logger.trace("updated() is called!"); if (config != null) { startWatchdog(); port = DEFAULT_PORT; host = (String) config.get("host"); password = (String) config.get("password"); String portString = (String) config.get("port"); if(StringUtils.isNotBlank(portString)) port = Integer.parseInt(portString); eventCache = new LinkedHashMap<String, Channel>(); mwiCache = new HashMap<String, FreeswitchBinding.MWIModel>(); itemMap = new LinkedHashMap<String, LinkedList<FreeswitchBindingConfig>>(); try { connect(); } catch (InboundConnectionFailure e) { logger.error("Could not connect to freeswitch server",e); disconnect(); } } else { stopWatchdog(); disconnect(); } }
Source:
<code>private void createBars() { BarGraphicObject bar; m_container = new VirtualBoundsGraphicObject(); m_container.setVirtualBounds(BAR_CONTAINER_BOUNDS); <START> m_container.setDrawContainerBounds(false); <END> int maxCount = Math.max(m_markerCount[0], m_markerCount[1]); maxCount = Math.max(maxCount, m_markerCount[2]); if (maxCount == 0) maxCount = 1; for (int severity = IMarker.SEVERITY_ERROR; severity >= IMarker.SEVERITY_INFO; severity--) { float barPercent = m_markerCount[severity] / (float) maxCount * 100.0f; bar = new BarGraphicObject(severity, Math.round(barPercent)); bar.setVirtualBounds(BARS_VIRTUAL_BOUNDS[severity]); bar.setLabel(m_markerSeverityLabels[severity] + " " + m_markerCount[severity]); bar.setDrawContainerBounds(true); m_container.addChildObject("bar" + severity, bar); } m_container.setBounds(m_canvas.getBounds()); m_canvas.add(m_container); }</code><technical_language>call useless. Remove</technical_language>

Target:
private void createBars() { BarGraphicObject bar; m_container = new VirtualBoundsGraphicObject(); m_container.setVirtualBounds(BAR_CONTAINER_BOUNDS); m_container.setDrawContainerBounds(false); int maxCount = Math.max(m_markerCount[0], m_markerCount[1]); maxCount = Math.max(maxCount, m_markerCount[2]); if (maxCount == 0) maxCount = 1; for (int severity = IMarker.SEVERITY_ERROR; severity >= IMarker.SEVERITY_INFO; severity--) { float barPercent = m_markerCount[severity] / (float) maxCount * 100.0f; bar = new BarGraphicObject(severity, Math.round(barPercent)); bar.setVirtualBounds(BARS_VIRTUAL_BOUNDS[severity]); bar.setLabel(m_markerSeverityLabels[severity] + " " + m_markerCount[severity]); m_container.addChildObject("bar" + severity, bar); } m_container.setBounds(m_canvas.getBounds()); m_canvas.add(m_container); }
Source:
<code>public void cleanup() { <START> if (!tagKeyId.isEmpty()) { <END> api().deleteTagKey(tagKeyId); } }</code><technical_language>Unlikely, this throw NPE. check for null too</technical_language>

Target:
public void cleanup() { if (tagKeyId != null && !tagKeyId.isEmpty()) { api().deleteTagKey(tagKeyId); } }
Source:
<code>public String toString() { return MoreObjects.toStringHelper(this) .add("ref", _ref) .add("cached", _cached) <START> .toString(); <END> }</code><technical_language>this include other fields a well</technical_language>

Target:
public String toString() { return MoreObjects.toStringHelper(this) .add("ref", _ref) .add("cached", _cached) .add("lastRun", _lastRun) .toString(); }
Source:
<code>public void visit(String name, Object value) { if (this.state == State.AUTHORS) { if (!(value instanceof String)) { throw new InvalidPluginException("Plugin annotation has invalid element 'author'"); } this.metadata.addAuthor((String) value); return; } if (name == null) { <START> throw new InvalidPluginException("Plugin annotation has null element"); <END> } if (this.state == State.DEPENDENCIES) { throw new InvalidPluginException("Plugin annotation has invalid element 'dependencies'"); } switch (name) { case "id": if (!(value instanceof String)) { throw new InvalidPluginException("Plugin annotation has invalid element 'id'"); } this.hasId = true; this.metadata.setId((String) value); return; case "name": if (!(value instanceof String)) { throw new InvalidPluginException("Plugin annotation has invalid element 'name'"); } this.metadata.setName((String) value); return; case "version": if (!(value instanceof String)) { throw new InvalidPluginException("Plugin annotation has invalid element 'version'"); } this.metadata.setVersion((String) value); return; case "description": if (!(value instanceof String)) { throw new InvalidPluginException("Plugin annotation has invalid element 'description'"); } this.metadata.setDescription((String) value); return; case "url": if (!(value instanceof String)) { throw new InvalidPluginException("Plugin annotation has invalid element 'url'"); } this.metadata.setUrl((String) value); return; default: super.visit(name, value); } }</code><technical_language>clarify name is null, e.g. Plugin annotation attribute name is null</technical_language>

Target:
public void visit(String name, Object value) { if (this.state == State.AUTHORS) { if (!(value instanceof String)) { throw new InvalidPluginException("Plugin annotation has invalid element 'author'"); } this.metadata.addAuthor((String) value); return; } if (name == null) { throw new InvalidPluginException("Plugin annotation attribute name is null"); } if (this.state == State.DEPENDENCIES) { throw new InvalidPluginException("Plugin annotation has invalid element 'dependencies'"); } switch (name) { case "id": if (!(value instanceof String)) { throw new InvalidPluginException("Plugin annotation has invalid element 'id'"); } this.hasId = true; this.metadata.setId((String) value); return; case "name": if (!(value instanceof String)) { throw new InvalidPluginException("Plugin annotation has invalid element 'name'"); } this.metadata.setName((String) value); return; case "version": if (!(value instanceof String)) { throw new InvalidPluginException("Plugin annotation has invalid element 'version'"); } this.metadata.setVersion((String) value); return; case "description": if (!(value instanceof String)) { throw new InvalidPluginException("Plugin annotation has invalid element 'description'"); } this.metadata.setDescription((String) value); return; case "url": if (!(value instanceof String)) { throw new InvalidPluginException("Plugin annotation has invalid element 'url'"); } this.metadata.setUrl((String) value); return; default: super.visit(name, value); } }
Source:
<code>public GrammarAST(int type, Token t) { <START> this(new CommonToken(type, t.getText())); <END> if ( t instanceof CommonToken ) { ((CommonToken) token).setStartIndex(((CommonToken) t).getStartIndex()); ((CommonToken) token).setStopIndex(((CommonToken) t).getStopIndex()); } token.setInputStream(t.getInputStream()); token.setLine(t.getLine()); token.setCharPositionInLine(t.getCharPositionInLine()); token.setTokenIndex(t.getTokenIndex()); }</code><technical_language>This as: java this(new CommonToken(t)); token.setType(type);</technical_language>

Target:
public GrammarAST(int type, Token t) { this(new CommonToken(t)); token.setType(type); }
Source:
<code>private void loadUrlNow(String url) { if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) { LOG.d(TAG, ">>> loadUrlNow()"); } Boolean shouldAllowNavigation = pluginManager.shouldAllowNavigation(url); <START> if (url.startsWith("file://") || url.startsWith("javascript:") || <END> (shouldAllowNavigation != null && shouldAllowNavigation == true)) { super.loadUrl(url); } }</code><technical_language>question I is do plugins return false. true: Allow page load null: Allow file javascript pages load false: ? I disallow file urls in case (which is a good idea; otherwise, do block them?) javascript:? allow that? Is part of bridge mechanism dropped</technical_language>

Target:
private void loadUrlNow(String url) { if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) { LOG.d(TAG, ">>> loadUrlNow()"); } if (url.startsWith("javascript:") || helper.shouldAllowNavigation(url)) { super.loadUrl(url); } }
Source:
<code>public void addTextFilter(String label, String placeholder, boolean disableFiltersInputHelp, Consumer<ActiveFilterItem<String>> callback) { filtersInputHelp.setDisabled(disableFiltersInputHelp); <START> addTextFilter(label, placeholder, callback); <END> }</code><technical_language>opposite, other addTextFilter method call this one, a default of false for disableFiltersInputHelps</technical_language>

Target:
public void addTextFilter(String label, String placeholder, boolean disableFiltersInputHelp, Consumer<ActiveFilterItem<String>> callback) { filtersInputHelp.setDisabled(disableFiltersInputHelp); if (disableFiltersInputHelp) { addCSSClass(filtersInputHelp, "hidden"); } createFilterOption(label); createTextInput(label, placeholder, refineSelect.getOptions().getLength() > 1, input -> input.setType("text"), v -> v, callback); }
Source:
<code>private CompletableFuture<ICluster> join0() { CompletableFuture<Transport> transportFuture = Transport.bind(config.getTransportConfig()); CompletableFuture<Void> clusterFuture = transportFuture.thenCompose(boundTransport -> { transport = boundTransport; messageObservable = transport.listen() <START> .filter(msg -> !SYSTEM_MESSAGES.contains(msg.qualifier())); END> membership = new MembershipProtocol(transport, config.getMembershipConfig()); gossip = new GossipProtocol(transport, membership, config.getGossipConfig()); failureDetector = new FailureDetector(transport, membership, config.getFailureDetectorConfig()); membership.setFailureDetector(failureDetector); membership.setGossipProtocol(gossip); Member localMember = membership.member(); onMemberAdded(localMember); membership.listen() .filter(MembershipEvent::isAdded).map(MembershipEvent::member).subscribe(this::onMemberAdded); membership.listen() .filter(MembershipEvent::isRemoved).map(MembershipEvent::member).subscribe(this::onMemberRemoved); failureDetector.start(); gossip.start(); gossipObservable = gossip.listen() .filter(msg -> !SYSTEM_GOSSIPS.contains(msg.qualifier())); return membership.start(); }); return clusterFuture.thenApply(aVoid -> Cluster.this); }</code><technical_language>if messageObservable filter system messages all. reach this messageObservable all. gossip cluster-management-messages user-traffic messages separated collide. traffic of user interfere cluster management cluster management interfere user messages</technical_language>

Target:
private CompletableFuture<ICluster> join0() { CompletableFuture<Transport> transportFuture = Transport.bind(config.getTransportConfig()); CompletableFuture<Void> clusterFuture = transportFuture.thenCompose(boundTransport -> { transport = boundTransport; messageObservable = transport.listen() .filter(msg -> !SYSTEM_MESSAGES.contains(msg.qualifier())); membership = new MembershipProtocol(transport, config.getMembershipConfig()); gossip = new GossipProtocol(transport, membership, config.getGossipConfig()); failureDetector = new FailureDetector(transport, membership, config.getFailureDetectorConfig()); membership.setFailureDetector(failureDetector); membership.setGossipProtocol(gossip); Member localMember = membership.member(); onMemberAdded(localMember); membership.listen() .filter(MembershipEvent::isAdded) .map(MembershipEvent::member) .subscribe(this::onMemberAdded, this::onError); membership.listen() .filter(MembershipEvent::isRemoved) .map(MembershipEvent::member) .subscribe(this::onMemberRemoved, this::onError); failureDetector.start(); gossip.start(); gossipObservable = gossip.listen() .filter(msg -> !SYSTEM_GOSSIPS.contains(msg.qualifier())); return membership.start(); }); return clusterFuture.thenApply(aVoid -> Cluster.this); }
Source:
<code>private void handleGetUserCountFailure(String errorCode, String errorMessage, String claim, String claimValue ) throws UserStoreException { for (UserManagementErrorEventListener listener : UMListenerServiceComponent .getUserManagementErrorEventListeners()) { if (listener.isEnable() && !listener <START> .onGetUserListFailure(errorCode, errorMessage, claim, claimValue, this)) { <END> return; } } }</code><technical_language>calling onGetUserListFailure method is a failure in counting users</technical_language>

Target:
protected void handleGetUserCountFailure(String errorCode, String errorMessage, String claim, String claimValue ) throws UserStoreException { for (UserManagementErrorEventListener listener : UMListenerServiceComponent .getUserManagementErrorEventListeners()) { if (listener.isEnable() && !listener .onGetUserCountFailure(errorCode, errorMessage, claim, claimValue, this)) { return; } } }
Source:
<code>public void test() throws Exception { server.expect( server.formatUrl( REMOTE, PATH ), 200, new ByteArrayInputStream( CONTENT_1.getBytes( "UTF-8" ) ) ); <START> final RemoteRepository remote = new RemoteRepository( NPM_PKG_KEY, REMOTE, server.formatUrl( REMOTE, SUBPATH ) ); <END> client.stores().create( remote, "adding npm remote repo", RemoteRepository.class ); final HostedRepository hosted = new HostedRepository( NPM_PKG_KEY, HOSTED ); client.stores().create( hosted, "adding npm hosted repo", HostedRepository.class ); client.content().store( hosted.getKey(), PATH, new ByteArrayInputStream( CONTENT_1.getBytes() ) ); final Group group = new Group( NPM_PKG_KEY, GROUP, remote.getKey(), hosted.getKey() ); client.stores().create( group, "adding npm group repo", Group.class ); assertThat( client.content().exists( remote.getKey(), MAPPING_PATH ), equalTo( false ) ); assertThat( client.content().exists( remote.getKey(), PATH ), equalTo( true ) ); assertThat( client.content().exists( hosted.getKey(), MAPPING_PATH ), equalTo( true ) ); assertThat( client.content().exists( hosted.getKey(), PATH ), equalTo( true ) ); assertThat( client.content().exists( group.getKey(), MAPPING_PATH ), equalTo( true ) ); assertThat( client.content().exists( group.getKey(), PATH ), equalTo( true ) ); }</code><technical_language>this "subpath" is working for. is breaking ftest result</technical_language>

Target:
public void test() throws Exception { server.expect( server.formatUrl( REMOTE, PATH ), 200, new ByteArrayInputStream( CONTENT_1.getBytes( "UTF-8" ) ) ); final RemoteRepository remote = new RemoteRepository( NPM_PKG_KEY, REMOTE, server.formatUrl( REMOTE ) ); client.stores().create( remote, "adding npm remote repo", RemoteRepository.class ); final HostedRepository hosted = new HostedRepository( NPM_PKG_KEY, HOSTED ); client.stores().create( hosted, "adding npm hosted repo", HostedRepository.class ); client.content().store( hosted.getKey(), PATH, new ByteArrayInputStream( CONTENT_1.getBytes() ) ); final Group group = new Group( NPM_PKG_KEY, GROUP, remote.getKey(), hosted.getKey() ); client.stores().create( group, "adding npm group repo", Group.class ); assertThat( client.content().exists( remote.getKey(), MAPPING_PATH ), equalTo( false ) ); assertThat( client.content().exists( remote.getKey(), PATH ), equalTo( true ) ); assertThat( client.content().exists( hosted.getKey(), MAPPING_PATH ), equalTo( true ) ); assertThat( client.content().exists( hosted.getKey(), PATH ), equalTo( true ) ); assertThat( client.content().exists( group.getKey(), MAPPING_PATH ), equalTo( true ) ); assertThat( client.content().exists( group.getKey(), PATH ), equalTo( true ) ); }
Source:
<code>public void clear() { List<Subscription> unsubscribe = null; synchronized (this) { if (unsubscribed || subscriptions == null) { return; } else { <START> unsubscribe = new ArrayList<Subscription>(subscriptions); <END> } } unsubscribeFromAll(unsubscribe); }</code><technical_language>This clear subscriptions, copies it. pass out Set replace null. java Set<Subscription> unsubscribe = null; synchronized (this) { if (unsubscribed || subscriptions == null) { return; } unsubscribe = subscriptions; subscriptions = null; } unsubscribeFromAll(unsubscribe);</technical_language>

Target:
public void clear() { Collection<Subscription> unsubscribe = null; synchronized (this) { if (unsubscribed || subscriptions == null) { return; } else { unsubscribe = subscriptions; subscriptions = null; } } unsubscribeFromAll(unsubscribe); }
Source:
<code>private void populateData(boolean train) { try { File categories = new File(this.dataDirectory + "\\categories.txt"); BufferedReader brCategories = new BufferedReader(new FileReader(categories)); String temp = ""; while ((temp = brCategories.readLine()) != null) { String curFileName = train == true ? this.dataDirectory + "\\train\\" + temp.split(",")[0] + ".txt" : this.dataDirectory + "\\test\\" + temp.split(",")[0] + ".txt"; File currFile = new File(curFileName); BufferedReader currBR = new BufferedReader((new FileReader(currFile))); String tempCurrLine = ""; List<String> tempList = new ArrayList<String>(); while ((tempCurrLine = currBR.readLine()) != null) { tempList.add(tempCurrLine); this.totalNews++; } currBR.close(); Pair<String, List<String>> tempPair = Pair.of(temp, tempList); this.categoryData.add(tempPair); } brCategories.close(); <START> } catch (Exception e) { <END> System.out.println("Exception in populateData : " + e.getMessage()); } }</code><technical_language>a try clause reader</technical_language>

Target:
private void populateData(boolean train) { File categories = new File(this.dataDirectory + File.separator + "categories.txt"); try (BufferedReader brCategories = new BufferedReader(new FileReader(categories))) { String temp = ""; while ((temp = brCategories.readLine()) != null) { String curFileName = train == true ? this.dataDirectory + File.separator + "train" + File.separator + temp.split(",")[0] + ".txt" : this.dataDirectory + File.separator + "test" + File.separator + temp.split(",")[0] + ".txt"; File currFile = new File(curFileName); BufferedReader currBR = new BufferedReader((new FileReader(currFile))); String tempCurrLine = ""; List<String> tempList = new ArrayList<>(); while ((tempCurrLine = currBR.readLine()) != null) { tempList.add(tempCurrLine); this.totalNews++; } currBR.close(); Pair<String, List<String>> tempPair = Pair.of(temp, tempList); this.categoryData.add(tempPair); } brCategories.close(); } catch (Exception e) { System.out.println("Exception in reading file :" + e.getMessage()); } }
Source:
<code>default String getConcatenatedName() { final List<String> names = getNames(); <START> return names.size() > 1 ? names.toString() : names.get(0); <END> }</code><technical_language>getFirstName() considers empty getNames(), getConcatenatedName() doesn't</technical_language>

Target:
default String getConcatenatedName() { final List<String> names = getNames(); Preconditions.checkState(!names.isEmpty()); return names.size() > 1 ? names.toString() : names.get(0); }
Source:
<code>private boolean hasConflictingAccount(Collection<Account> accountsToSet, AccountInfoMap accountInfoMap) { boolean res = false; for (Account account : accountsToSet) { Account accountInMap = accountInfoMap.getAccountById(account.getId()); if (accountInMap != null && account.getSnapshotVersion() != accountInMap.getSnapshotVersion()) { logger.error( "Account to update (accountId={} accountName={}) has an unexpected snapshot version in zk (expected={}, encountered={})", account.getId(), account.getName(), account.getSnapshotVersion(), accountInMap.getSnapshotVersion()); <START> res = true; <END> } Account potentialConflict = accountInfoMap.getAccountByName(account.getName()); if (potentialConflict != null && potentialConflict.getId() != account.getId()) { logger.error( "Account to update (accountId={} accountName={}) conflicts with an existing record (accountId={} accountName={})", account.getId(), account.getName(), potentialConflict.getId(), potentialConflict.getName()); res = true; } } return res; }</code><technical_language>safe break this, right? update is fail anway</technical_language>

Target:
private boolean hasConflictingAccount(Collection<Account> accountsToSet, AccountInfoMap accountInfoMap) { for (Account account : accountsToSet) { Account accountInMap = accountInfoMap.getAccountById(account.getId()); if (accountInMap != null && account.getSnapshotVersion() != accountInMap.getSnapshotVersion()) { logger.error( "Account to update (accountId={} accountName={}) has an unexpected snapshot version in zk (expected={}, encountered={})", account.getId(), account.getName(), account.getSnapshotVersion(), accountInMap.getSnapshotVersion()); return true; } Account potentialConflict = accountInfoMap.getAccountByName(account.getName()); if (potentialConflict != null && potentialConflict.getId() != account.getId()) { logger.error( "Account to update (accountId={} accountName={}) conflicts with an existing record (accountId={} accountName={})", account.getId(), account.getName(), potentialConflict.getId(), potentialConflict.getName()); return true; } } return false; }
Source:
<code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_event_bus); final EventBus eventBus = ((SamplesApplication) getApplication()).getEventBus(); final TextView textView = (TextView) findViewById(android.R.id.text1); subscription = eventBus.subscribe(EventQueue.STRING_QUEUE, new Subscriber<String>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { } @Override public void onNext(String s) { textView.setText(s); } <START> }); <END> startService(new Intent(this, EventGeneratorService.class)); }</code><technical_language>@mttkay If onCompleted() takes place, events belong STRING_QUEUE emitted in app lifecycle? Basically I Rx contracts. Also, figuring out differences Otto this EventBus are. @mttkay Thoughts</technical_language>

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_event_bus); final EventBus eventBus = ((SamplesApplication) getApplication()).getEventBus(); final TextView textView = (TextView) findViewById(android.R.id.text1); subscription = eventBus.subscribe(Events.STRING_QUEUE, new Subscriber<String>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { } @Override public void onNext(String s) { textView.setText(s); } }); startService(new Intent(this, EventGeneratorService.class)); }
Source:
<code>@Override String readValue(Buffer buffer, int length) { length *= 2; <START> if (length > 32) { <END> throw new AssertionError("hex field greater than 32 chars long: " + length); } char[] result = THIRTY_TWO_CHARS.get(); for (int i = 0; i < length; i += 2) { byte b = buffer.readByte(); result[i + 0] = HEX_DIGITS[(b >> 4) & 0xf]; result[i + 1] = HEX_DIGITS[b & 0xf]; } return new String(result, 0, length); }</code><technical_language>assert eliminate runtime check</technical_language>

Target:
@Override String readValue(Buffer buffer, int length) { length *= 2; if (length > 32) { throw new IllegalArgumentException("hex field greater than 32 chars long: " + length); } char[] result = Platform.get().idBuffer(); for (int i = 0; i < length; i += 2) { byte b = buffer.readByte(); result[i + 0] = HEX_DIGITS[(b >> 4) & 0xf]; result[i + 1] = HEX_DIGITS[b & 0xf]; } return new String(result, 0, length); }
Source:
<code>private String determineCustomerProfileSubUnitCode(PaymentGroup pdpPaymentGroup) { CustomerProfile customerProfile = null; String subUnitCode = KFSConstants.EMPTY_STRING; if (ObjectUtils.isNotNull(pdpPaymentGroup.getBatch())) { customerProfile = pdpPaymentGroup.getBatch().getCustomerProfile(); if (ObjectUtils.isNotNull(customerProfile)) { if (ObjectUtils.isNotNull(customerProfile.getSubUnitCode())) { subUnitCode = customerProfile.getSubUnitCode(); LOG.info("determineCustomerProfileSubUnitCode: subUnitCode = " + subUnitCode); } else { LOG.info("determineCustomerProfileSubUnitCode: No subUnitCode could be determined for customerProfile.customerShortName = " + customerProfile.getCustomerShortName()); } } else { LOG.info("determineCustomerProfileSubUnitCode: No customer profile exists for payee name = " + pdpPaymentGroup.getPayeeName()); } } else { <START> LOG.info("determineCustomerProfileSubUnitCode: pdpPaymemtGroup.getBatch() detected as NULL."); <END> } return subUnitCode; }</code><technical_language>Minor typo in log message, "...pdpPaymentGroup..." instead</technical_language>

Target:
private String determineCustomerProfileSubUnitCode(PaymentGroup pdpPaymentGroup) { CustomerProfile customerProfile = null; String subUnitCode = KFSConstants.EMPTY_STRING; if (ObjectUtils.isNotNull(pdpPaymentGroup.getBatch())) { customerProfile = pdpPaymentGroup.getBatch().getCustomerProfile(); if (ObjectUtils.isNotNull(customerProfile)) { if (ObjectUtils.isNotNull(customerProfile.getSubUnitCode())) { subUnitCode = customerProfile.getSubUnitCode(); LOG.info("determineCustomerProfileSubUnitCode: subUnitCode = " + subUnitCode); } else { LOG.info("determineCustomerProfileSubUnitCode: No subUnitCode could be determined for customerProfile.customerShortName = " + customerProfile.getCustomerShortName()); } } else { LOG.info("determineCustomerProfileSubUnitCode: No customer profile exists for payee name = " + pdpPaymentGroup.getPayeeName()); } } else { LOG.info("determineCustomerProfileSubUnitCode: pdpPaymentGroup.getBatch() detected as NULL."); } return subUnitCode; }
Source:
<code>protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { Authentication result = null; <START> for (final Authenticator authenticator : authenticatorsRegistry.get()) <END> { final AuthenticationSupplier authenticationSupplier = authenticator.getAuthenticationSupplier(); logger.debug("Authentication supplier attempt using {}", authenticationSupplier.getClass() .getName()); final Authentication authentication = authenticationSupplier.supply(request); if (authentication == null) { logger.debug("Unable to get an authentication instance using {}", authenticationSupplier.getClass() .getName()); continue; } final AuthenticationProvider authenticationProvider = authenticator.getAuthenticationProvider(); logger.debug("Authentication provider attempt using {}", authenticationProvider.getClass() .getName()); try { result = authenticationProvider.authenticate(authentication); if (result != null) { SecurityContextHolder.getContext() .setAuthentication(result); logger.debug("Authentication success using {}", authenticationProvider.getClass() .getName()); break; } } catch (AuthenticationException e) { logger.debug("Authentication request failed", e); continue; } } filterChain.doFilter(request, response); }</code><technical_language>@fuss86 : ignore this</technical_language>

Target:
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { Authentication result = null; for (final Authenticator authenticator : authenticatorsRegistry) { final AuthenticationSupplier authenticationSupplier = authenticator.getAuthenticationSupplier(); logger.debug("Authentication supplier attempt using {}", authenticationSupplier.getClass() .getName()); final Authentication authentication = authenticationSupplier.supply(request); if (authentication == null) { logger.debug("Unable to get an authentication instance using {}", authenticationSupplier.getClass() .getName()); continue; } final AuthenticationProvider authenticationProvider = authenticator.getAuthenticationProvider(); logger.debug("Authentication provider attempt using {}", authenticationProvider.getClass() .getName()); try { result = authenticationProvider.authenticate(authentication); if (result != null) { SecurityContextHolder.getContext() .setAuthentication(result); logger.debug("Authentication success using {}", authenticationProvider.getClass() .getName()); break; } } catch (AuthenticationException e) { logger.debug("Authentication request failed", e); continue; } } filterChain.doFilter(request, response); }
Source:
<code>public Subscriber<? super T> call(Subscriber<? super T> child) { final SerialSubscription ssub = new SerialSubscription(); final SwitchIfEmptySubscriber parent = new SwitchIfEmptySubscriber(child, ssub); ssub.set(parent); child.add(ssub); <START> child.setProducer(new Producer() { <END> @Override public void request(long n) { parent.requestMore(n); }}); return parent; }</code><technical_language>instantiate ProducerArbiter parent supply SwitchIfEmptySubscriber child, saving this 'relaying' allocation. (Remark, life easier if implement Producer in Subscriber, request() is protected final, is unoverridable :( )</technical_language>

Target:
public Subscriber<? super T> call(Subscriber<? super T> child) { final SerialSubscription ssub = new SerialSubscription(); ProducerArbiter arbiter = new ProducerArbiter(); final ParentSubscriber<T> parent = new ParentSubscriber<T>(child, ssub, arbiter, alternate); ssub.set(parent); child.add(ssub); child.setProducer(arbiter); return parent; }
Source:
<code>public void should_create_job_with_custom_workspace() { String jobName = "MyJob"; String customWorkspace = "/tmp/my-workspace"; String jobDslScript = String.format("job('%s') { customWorkspace('%s') }", jobName, customWorkspace); Job seed = createSeedJobWithJobDsl(jobDslScript); seed.startBuild().waitUntilFinished(); Job job = jenkins.jobs.get(Job.class, jobName); Build build = job.startBuild().waitUntilFinished(); <START> assertTrue(build.getConsole().contains(customWorkspace)); <END> }</code><technical_language>assertThat(build.getConsole(), containsString(customWorkspace))</technical_language>

Target:
public void should_create_job_with_custom_workspace() { String jobName = "MyJob"; String customWorkspace = "/tmp/my-workspace"; String jobDslScript = String.format("job('%s') { customWorkspace('%s') }", jobName, customWorkspace); Job seed = createSeedJobWithJobDsl(jobDslScript); seed.startBuild().waitUntilFinished(); Job job = jenkins.jobs.get(Job.class, jobName); Build build = job.startBuild().waitUntilFinished(); assertThat(build.getConsole(), containsString(customWorkspace)); }
Source:
<code>public void stopTransport() { if (transport != null && transportStatus == ComponentStatus.RUNNING) <START> transport.stop(); <END> transportStatus = ComponentStatus.TERMINATED; try { unregisterServerMBeans(); } catch (Exception e) { throw new CacheException(e); } }</code><technical_language>I meant brackets encapsulate entire rest of method</technical_language>

Target:
public void stopTransport() { if (transport != null && transportStatus == ComponentStatus.RUNNING) { transport.stop(); transportStatus = ComponentStatus.TERMINATED; try { unregisterServerMBeans(); } catch (Exception e) { throw new CacheException(e); } } }