auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void findSafeLiterals(AbstractApexNode<?> node) { ASTBinaryExpression binaryExp = node.getFirstChildOfType(ASTBinaryExpression.class); if (binaryExp != null) { findSafeLiterals(binaryExp); } ASTLiteralExpression literal = node.getFirstChildOfType(ASTLiteralExpression.class); if (literal != null) { int index = literal.jjtGetChildIndex(); if (index == 0) { if (node instanceof ASTVariableDeclaration) { addVariable((ASTVariableDeclaration) node); } else if (node instanceof ASTBinaryExpression) { ASTVariableDeclaration parent = node.getFirstParentOfType(ASTVariableDeclaration.class); if (parent != null) { addVariable(parent); } ASTAssignmentExpression assignment = node.getFirstParentOfType(ASTAssignmentExpression.class); if (assignment != null) { ASTVariableExpression var = assignment.getFirstChildOfType(ASTVariableExpression.class); if (var != null) { addVariable(var); } } } } } else { if (node instanceof ASTField) { ASTField field = (ASTField) node; if ("String".equalsIgnoreCase(field.getTypeRef())) { StandardFieldInfo fieldInfo = (StandardFieldInfo) field.getNode().getFieldInfo(); <START> if (fieldInfo.getValue() != null) { <END> addVariable(fieldInfo); } } } } }</code><technical_language>Is option in Jorje parser fail syntax errors produce inconsistent AST? This save time if enable in tests designer</technical_language>

Target:
private void findSafeLiterals(AbstractApexNode<?> node) { ASTBinaryExpression binaryExp = node.getFirstChildOfType(ASTBinaryExpression.class); if (binaryExp != null) { findSafeLiterals(binaryExp); } ASTLiteralExpression literal = node.getFirstChildOfType(ASTLiteralExpression.class); if (literal != null) { int index = literal.jjtGetChildIndex(); if (index == 0) { if (node instanceof ASTVariableDeclaration) { addVariable((ASTVariableDeclaration) node); } else if (node instanceof ASTBinaryExpression) { ASTVariableDeclaration parent = node.getFirstParentOfType(ASTVariableDeclaration.class); if (parent != null) { addVariable(parent); } ASTAssignmentExpression assignment = node.getFirstParentOfType(ASTAssignmentExpression.class); if (assignment != null) { ASTVariableExpression var = assignment.getFirstChildOfType(ASTVariableExpression.class); if (var != null) { addVariable(var); } } } } } else { if (node instanceof ASTField) { ASTField field = (ASTField) node; if ("String".equalsIgnoreCase(field.getType())) { if (field.getValue() != null) { listOfStringLiteralVariables.add(Helper.getFQVariableName(field)); } } } } }
Source:
<code>public void testDefault() throws Exception { final DefaultConfiguration checkConfig = createCheckConfig(ConstantNameCheck.class); final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; final String[] expected = { "25:29: " + getCheckMessage(MSG_INVALID_PATTERN, "badConstant", pattern), <START> "139:30: " + getCheckMessage(MSG_INVALID_PATTERN, "BAD__NAME", pattern), <END> }; verify(checkConfig, getPath("InputSimple.java"), expected); }</code><technical_language>expecting changes this file. Changes for issue in input file other tests avoid this conflict</technical_language>

Target:
public void testDefault() throws Exception { final DefaultConfiguration checkConfig = createCheckConfig(ConstantNameCheck.class); final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; final String[] expected = { "25:29: " + getCheckMessage(MSG_INVALID_PATTERN, "badConstant", pattern), "142:30: " + getCheckMessage(MSG_INVALID_PATTERN, "BAD__NAME", pattern), }; verify(checkConfig, getPath("InputConstantNameSimple.java"), expected); }
Source:
<code>@Override protected RawClient getClient() throws IOException { <START> HTTPClientConfig config = new HTTPClientConfig.Builder().withHost(Hosts.RIAK_HOST).build(); <END> return HTTPRiakClientFactory.getInstance().newClient(config); }</code><technical_language>missing .withPort(Hosts.RIAK_PORT)</technical_language>

Target:
@Override protected RawClient getClient() throws IOException { HTTPClientConfig config = new HTTPClientConfig.Builder().withUrl(Hosts.RIAK_URL).build(); return HTTPRiakClientFactory.getInstance().newClient(config); }
Source:
<code>public final double asDouble() { if (value == null) { assert NullHandling.replaceWithDefault(); <START> return 0.0; <END> } final Double theDouble = Doubles.tryParse(value); return theDouble == null ? 0.0 : theDouble; }</code><technical_language>Please review rest of ExprEval for</technical_language>

Target:
public final double asDouble() { if (value == null) { assert NullHandling.replaceWithDefault(); return 0.0; } final Double theDouble = Doubles.tryParse(value); assert NullHandling.replaceWithDefault() || theDouble != null; return theDouble == null ? 0.0 : theDouble; }
Source:
<code>private Map<String, Object> prepareDhisAttributesMap(Map<String, Object> eventParams) { Map<String, Object> dhisAttributes = new HashMap<>(eventParams); dhisAttributes.remove(MotechEvent.PARAM_INVALID_MOTECH_EVENT); dhisAttributes.remove(MotechEvent.PARAM_REDELIVERY_COUNT); <START> dhisAttributes.remove(EventParams.MESSAGE_DESTINATION); <END> return dhisAttributes; }</code><technical_language>remove JOB_ID_KEY scheduler service for good measure</technical_language>

Target:
private Map<String, Object> prepareDhisAttributesMap(Map<String, Object> eventParams) { Map<String, Object> dhisAttributes = new HashMap<>(eventParams); dhisAttributes.remove(MotechEvent.PARAM_INVALID_MOTECH_EVENT); dhisAttributes.remove(MotechEvent.PARAM_REDELIVERY_COUNT); dhisAttributes.remove(EventParams.MESSAGE_DESTINATION); dhisAttributes.remove(MotechSchedulerService.JOB_ID_KEY); return dhisAttributes; }
Source:
<code>public static void setRestriction(XHook hook, int uid, String restrictionName, String methodName, boolean restricted) { if (uid == 0) { Util.log(hook, Log.WARN, "uid=0"); <START> } <END> try { PrivacyService.getClient().setRestriction( new ParcelableRestriction(uid, restrictionName, methodName, restricted)); } catch (Throwable ex) { Util.bug(null, ex); } boolean dangerous = PrivacyManager.getSettingBool(hook, 0, PrivacyManager.cSettingDangerous, false, false); if (methodName == null) if (restricted && !dangerous) { for (Hook md : getHooks(restrictionName)) if (md.isDangerous()) PrivacyManager.setRestriction(hook, uid, restrictionName, md.getName(), dangerous); } PrivacyManager .setSetting(hook, uid, PrivacyManager.cSettingState, Integer.toString(ActivityMain.STATE_CHANGED)); PrivacyManager.setSetting(null, uid, PrivacyManager.cSettingModifyTime, Long.toString(System.currentTimeMillis())); }</code><technical_language>curly braces removed too. This is code visible screen</technical_language>

Target:
public static void setRestriction(XHook hook, int uid, String restrictionName, String methodName, boolean restricted) { if (uid == 0) Util.log(hook, Log.WARN, "uid=0"); try { PrivacyService.getClient().setRestriction( new ParcelableRestriction(uid, restrictionName, methodName, restricted)); } catch (Throwable ex) { Util.bug(null, ex); } boolean dangerous = PrivacyManager.getSettingBool(hook, 0, PrivacyManager.cSettingDangerous, false, false); if (methodName == null) if (restricted && !dangerous) { for (Hook md : getHooks(restrictionName)) if (md.isDangerous()) PrivacyManager.setRestriction(hook, uid, restrictionName, md.getName(), dangerous); } PrivacyManager .setSetting(hook, uid, PrivacyManager.cSettingState, Integer.toString(ActivityMain.STATE_CHANGED)); PrivacyManager.setSetting(null, uid, PrivacyManager.cSettingModifyTime, Long.toString(System.currentTimeMillis())); }
Source:
<code>public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (TypeElement annotation : annotations) { for (Element element : roundEnv.getElementsAnnotatedWith(annotation)) { if (!(element instanceof TypeElement)) { this.processingEnv.getMessager() .printMessage(Diagnostic.Kind.ERROR, "How is this annotated?", element); continue; } if (!this.processingEnv.getTypeUtils() .isAssignable(element.asType(), this.processingEnv.getElementUtils() .getTypeElement(preprocessorInterfaceCanonicalName) .asType())) { this.processingEnv.getMessager() .printMessage(Diagnostic.Kind.ERROR, "Element is annotated as Preprocessor but is not assignable to " + preprocessorInterfaceCanonicalName + "!", element); } boolean anyConstructorFound = false; boolean noArgPublicConstructorFound = false; for(Element enclosedElement : element.getEnclosedElements()) { if(enclosedElement.getKind() == ElementKind.CONSTRUCTOR) { anyConstructorFound = true; ExecutableElement constructor = (ExecutableElement) enclosedElement; final boolean noArg = constructor.getParameters().size() == 0; final boolean isPublic = constructor.getModifiers().contains(Modifier.PUBLIC); if(noArg && isPublic) { noArgPublicConstructorFound = true; break; } } } if(!noArgPublicConstructorFound && anyConstructorFound){ <START> this.processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Element is annotated as Preprocessor but has not public no-arg constructor!", element); <END> } } } return false; }</code><technical_language>"but public" "but public"</technical_language>

Target:
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (TypeElement annotation : annotations) { for (Element element : roundEnv.getElementsAnnotatedWith(annotation)) { if (!(element instanceof TypeElement)) { this.processingEnv.getMessager() .printMessage(Diagnostic.Kind.ERROR, "How is this annotated?", element); continue; } if (!this.processingEnv.getTypeUtils() .isAssignable(element.asType(), this.processingEnv.getElementUtils() .getTypeElement(preprocessorInterfaceCanonicalName) .asType())) { this.processingEnv.getMessager() .printMessage(Diagnostic.Kind.ERROR, "Element is annotated as Preprocessor but is not assignable to " + preprocessorInterfaceCanonicalName + "!", element); } boolean anyConstructorFound = false; boolean noArgPublicConstructorFound = false; for(Element enclosedElement : element.getEnclosedElements()) { if(enclosedElement.getKind() == ElementKind.CONSTRUCTOR) { anyConstructorFound = true; ExecutableElement constructor = (ExecutableElement) enclosedElement; final boolean noArg = constructor.getParameters().isEmpty(); final boolean isPublic = constructor.getModifiers().contains(Modifier.PUBLIC); if(noArg && isPublic) { noArgPublicConstructorFound = true; break; } } } if(!noArgPublicConstructorFound && anyConstructorFound){ this.processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Element is annotated as Preprocessor but has no public no-arg constructor!", element); } } } return false; }
Source:
<code><START> private boolean shouldAllowSaslFailedClientsConnect() { <END> return Boolean.getBoolean(ALLOW_SASL_FAILED_CLIENTS); }</code><technical_language>nit: static</technical_language>

Target:
private static boolean shouldAllowSaslFailedClientsConnect() { return Boolean.getBoolean(ALLOW_SASL_FAILED_CLIENTS); }
Source:
<code>public VersioningService(final String toolingId, final Map<String, Collection<ICodeSystemVersion>> existingVersions, final String... otherToolingIds) { configuration = new PublishOperationConfiguration( <START> checkNotNull(toolingId, "toolingId"), <END> checkNotNull(otherToolingIds, "otherToolingIds")); this.existingVersions = existingVersions; currentVersionSuppliers = initCurrentVersionSuppliers(configuration.getToolingIds()); lockContexts = newHashMap(); lockTargets = newHashMap(); locked = new AtomicBoolean(); }</code><technical_language>Move null checks PublishOperationConfiguration constructor</technical_language>

Target:
public VersioningService(final String toolingId, final Map<String, Collection<ICodeSystemVersion>> existingVersions, final String... otherToolingIds) { this.configuration = new PublishOperationConfiguration(toolingId, otherToolingIds); this.existingVersions = existingVersions; currentVersionSuppliers = initCurrentVersionSuppliers(configuration.getToolingIds()); lockContexts = newHashMap(); lockTargets = newHashMap(); locked = new AtomicBoolean(); }
Source:
<code>public static Collection<PersonaAccount> getPersonaAccountsForAccount(long accountId) throws CentralRepoException { String queryClause = PERSONA_ACCOUNTS_QUERY_CALUSE + " WHERE persona_accounts.account_id = " + accountId <START> + "AND p.status_id != " + Persona.PersonaStatus.DELETED.getStatusId(); <END> CentralRepository cr = CentralRepository.getInstance(); if (cr != null) { String queryClause = PERSONA_ACCOUNTS_QUERY_CALUSE + " WHERE persona_accounts.account_id = " + accountId; PersonaAccountsQueryCallback queryCallback = new PersonaAccountsQueryCallback(); cr.executeSelectSQL(queryClause, queryCallback); return queryCallback.getPersonaAccountsList(); } return new ArrayList<>(); }</code><technical_language>a re-declaration error here, fixed parent branch. needs get merged in here</technical_language>

Target:
public static Collection<PersonaAccount> getPersonaAccountsForAccount(long accountId) throws CentralRepoException { String queryClause = PERSONA_ACCOUNTS_QUERY_CALUSE + " WHERE persona_accounts.account_id = " + accountId + "AND p.status_id != " + Persona.PersonaStatus.DELETED.getStatusId(); CentralRepository cr = CentralRepository.getInstance(); if (cr != null) { PersonaAccountsQueryCallback queryCallback = new PersonaAccountsQueryCallback(); cr.executeSelectSQL(queryClause, queryCallback); return queryCallback.getPersonaAccountsList(); } return new ArrayList<>(); }
Source:
<code>public RestApiSession(BullhornRestCredentials bullhornRestCredentials) { this.restCredentials = bullhornRestCredentials; this.restTemplate = RestTemplateFactory.getInstance(); this.dateTimeBhRestTokenWillExpire = getNow(); <START> if(bullhornRestCredentials.credentialCheck()) { <END> createSession(); } else { this.restUrl = restCredentials.getRestUrl(); this.bhRestToken = restCredentials.getBhRestToken(); } }</code><technical_language>minor nitpick - need match formatting of repo - needs a space word if</technical_language>

Target:
public RestApiSession(BullhornRestCredentials bullhornRestCredentials) { this.isSessionProvided = isSessionProvided(bullhornRestCredentials); this.restCredentials = bullhornRestCredentials; this.restTemplate = RestTemplateFactory.getInstance(); this.dateTimeBhRestTokenWillExpire = getNow(); if (!this.isSessionProvided) { createSession(); } else { this.restUrl = restCredentials.getRestUrl(); this.bhRestToken = restCredentials.getBhRestToken(); } }
Source:
<code>private ContentWriteController contentWriteController() { return ContentWriteController.create( configFetcher, contentWriteExecutor, lookupBackedContentIdGenerator, contentWriteMessageSender, contentModelOutputter(), lookupStore, contentResolver, contentWriter, new EquivalenceBreaker( contentResolver, entryStore, lookupWriter ), <START> new OldContentDeactivator( <END> new MongoContentLister( mongo, new MongoContentResolver(mongo, lookupStore) ), contentWriter, contentResolver ) ); }</code><technical_language>If of classes part of atlas repo change static factory methods code style</technical_language>

Target:
private ContentWriteController contentWriteController() { return ContentWriteController.create( configFetcher, contentWriteExecutor, lookupBackedContentIdGenerator, contentWriteMessageSender, contentModelOutputter(), lookupStore, contentResolver, contentWriter, EquivalenceBreaker.create( contentResolver, entryStore, lookupWriter ), OldContentDeactivator.create( new MongoContentLister( mongo, new MongoContentResolver(mongo, lookupStore) ), contentWriter, contentResolver ) ); }
Source:
<code>private void InitUsbPolicy() { VDSGroup cluster = (VDSGroup) getCluster().getSelectedItem(); VmOsType osType = (VmOsType) getOSType().getSelectedItem(); DisplayType displayType = (DisplayType) (getDisplayProtocol().getSelectedItem() != null ? ((EntityModel) getDisplayProtocol().getSelectedItem()).getEntity() : null); if (osType == null || cluster == null || displayType == null) { return; } getUsbPolicy().setIsChangable(true); <START> if (Version.v3_0.compareTo(cluster.getcompatibility_version()) >= 0) { <END> if (osType.isWindows()) { getUsbPolicy().setItems(Arrays.asList( UsbPolicy.DISABLED, UsbPolicy.ENABLED_LEGACY )); } else { getUsbPolicy().setItems(Arrays.asList(UsbPolicy.DISABLED)); getUsbPolicy().setSelectedItem(UsbPolicy.DISABLED); getUsbPolicy().setIsChangable(false); } } if (Version.v3_1.compareTo(cluster.getcompatibility_version()) <= 0) { if (osType.isLinux()) { getUsbPolicy().setItems(Arrays.asList( UsbPolicy.DISABLED, UsbPolicy.ENABLED_NATIVE )); } else { getUsbPolicy().setItems( Arrays.asList( UsbPolicy.DISABLED, UsbPolicy.ENABLED_LEGACY, UsbPolicy.ENABLED_NATIVE )); } } if (displayType != DisplayType.qxl) { getUsbPolicy().setIsChangable(false); } getUsbPolicy().setSelectedItem(UsbPolicy.DISABLED); }</code><technical_language>Instead of checking if cluster-version <= 3.0, I suggest check is < 3.1 (or do "if... else..." "if (Version.v3_1.compareTo(cluster.getcompatibility_version()) <= 0)" statement below). happen: If, for some reason, a cluster version 3.0.5, considered 3.0; i.e. this check lead wrong result</technical_language>

Target:
private void InitUsbPolicy() { VDSGroup cluster = (VDSGroup) getCluster().getSelectedItem(); VmOsType osType = (VmOsType) getOSType().getSelectedItem(); DisplayType displayType = (DisplayType) (getDisplayProtocol().getSelectedItem() != null ? ((EntityModel) getDisplayProtocol().getSelectedItem()).getEntity() : null); if (osType == null || cluster == null || displayType == null) { return; } getUsbPolicy().setIsChangable(true); if (Version.v3_1.compareTo(cluster.getcompatibility_version()) > 0) { if (osType.isWindows()) { getUsbPolicy().setItems(Arrays.asList( UsbPolicy.DISABLED, UsbPolicy.ENABLED_LEGACY )); } else { getUsbPolicy().setItems(Arrays.asList(UsbPolicy.DISABLED)); getUsbPolicy().setSelectedItem(UsbPolicy.DISABLED); getUsbPolicy().setIsChangable(false); } } if (Version.v3_1.compareTo(cluster.getcompatibility_version()) <= 0) { if (osType.isLinux()) { getUsbPolicy().setItems(Arrays.asList( UsbPolicy.DISABLED, UsbPolicy.ENABLED_NATIVE )); } else { getUsbPolicy().setItems( Arrays.asList( UsbPolicy.DISABLED, UsbPolicy.ENABLED_LEGACY, UsbPolicy.ENABLED_NATIVE )); } } if (displayType != DisplayType.qxl) { getUsbPolicy().setIsChangable(false); } getUsbPolicy().setSelectedItem(UsbPolicy.DISABLED); }
Source:
<code>private List<GlusterVolumeEntity> getAllGlusterVolumesWithMasterCompatibleVersion(Guid masterVolumeId) { GlusterVolumeEntity masterVolume = getGlusterVolumeDao().getById(masterVolumeId); VDSGroup masterCluster = getVdsGroupDao().get(masterVolume.getClusterId()); <START> List<VDSGroup> clusters = getVdsGroupDao().getGeoRepEligibleVdsGroups(masterCluster.getId(), masterCluster.getcompatibility_version().getValue()); <END> List<GlusterVolumeEntity> volumes = new ArrayList<GlusterVolumeEntity>(); if(clusters != null) { for(VDSGroup currentCluster : clusters) { volumes.addAll(getGlusterVolumeDao().getByClusterId(currentCluster.getId())); } } return volumes; }</code><technical_language>I earlier query more generic - getClustersByServiceAndCompatibilityVersion. filtering of cluster done in loop</technical_language>

Target:
private List<GlusterVolumeEntity> getAllGlusterVolumesWithMasterCompatibleVersion(Guid masterVolumeId) { GlusterVolumeEntity masterVolume = getGlusterVolumeDao().getById(masterVolumeId); VDSGroup masterCluster = getVdsGroupDao().get(masterVolume.getClusterId()); List<VDSGroup> clusters = getVdsGroupDao().getClustersByServiceAndCompatibilityVersion(true, false, masterCluster.getcompatibility_version().getValue()); List<GlusterVolumeEntity> volumes = new ArrayList<GlusterVolumeEntity>(); if(clusters != null) { for(VDSGroup currentCluster : clusters) { if(!currentCluster.getId().equals(masterCluster.getId())) { volumes.addAll(getGlusterVolumeDao().getByClusterId(currentCluster.getId())); } } } return volumes; }
Source:
<code>public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { if (env.getIteratorScope() == IteratorScope.scan) { throw new IllegalArgumentException(); } this.source = source; String zookeepers = options.get(ZOOKEEPER_CONNECT_OPT); String zkRoot = options.get(ZOOKEEPER_ROOT_OPT); if (zookeepers == null || zkRoot == null) { throw new IllegalArgumentException("A configuration item for GC iterator was not set"); } oldestActiveTs = ZookeeperUtil.getOldestTimestamp(zookeepers, zkRoot); <START> System.out.println("Running GC iterator with oldest active ts of "+oldestActiveTs); <END> }</code><technical_language>need remove this print convert log stmt</technical_language>

Target:
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { if (env.getIteratorScope() == IteratorScope.scan) { throw new IllegalArgumentException(); } this.source = source; String zookeepers = options.get(ZOOKEEPER_CONNECT_OPT); String zkRoot = options.get(ZOOKEEPER_ROOT_OPT); if (zookeepers == null || zkRoot == null) { throw new IllegalArgumentException("A configuration item for GC iterator was not set"); } oldestActiveTs = ZookeeperUtil.getOldestTimestamp(zookeepers, zkRoot); }
Source:
<code>public void invalidate() throws CacheAccessException { <START> if(map.map != null) { <END> for (K k : map.map.keySet()) { invalidate(k); } } if(map.keyCopyMap != null) { for(OnHeapKey<K> key : map.keyCopyMap.keySet()) { invalidate(key.getActualKeyObject()); } } map.clear(); }</code><technical_language>invalidation process a while. improve this part happen interference other cache operations? I interested in other opinions this. idea swap underlying map while do operation discarded anyway</technical_language>

Target:
private void invalidate() { if(map.map != null) { for (K k : map.map.keySet()) { try { invalidate(k); } catch (CacheAccessException cae) { LOG.warn("Failed to invalidate mapping for key {}", k, cae); } } } if(map.keyCopyMap != null) { for(OnHeapKey<K> key : map.keyCopyMap.keySet()) { try { invalidate(key.getActualKeyObject()); } catch (CacheAccessException cae) { LOG.warn("Failed to invalidate mapping for key {}", key, cae); } } } map.clear(); }
Source:
<code>protected IFigure createFigure() { IFigure fig = super.createFigure(); DSemanticDiagram dSemanticDiagram = getDSemanticDiagram(); ColorDescription backgroundColor = dSemanticDiagram.getDescription().getBackgroundColor(); if (backgroundColor != null) { RGBValues newValues = new AbstractColorUpdater().getRGBValuesFromColorDescription(dSemanticDiagram.getTarget(), backgroundColor); <START> fig.setBackgroundColor(new Color(null, newValues.getRed(), newValues.getGreen(), newValues.getBlue())); fig.setOpaque(true); <END> } return fig; }</code><technical_language>prevent this if color is "white"</technical_language>

Target:
protected IFigure createFigure() { IFigure fig = super.createFigure(); DSemanticDiagram dSemanticDiagram = getDSemanticDiagram(); if (dSemanticDiagram != null) { ColorDescription backgroundColor = dSemanticDiagram.getDescription().getBackgroundColor(); if (backgroundColor != null) { RGBValues rgbBackgroundValues = new AbstractColorUpdater().getRGBValuesFromColorDescription(dSemanticDiagram.getTarget(), backgroundColor); if (!isWhiteColor(rgbBackgroundValues)) { fig.setBackgroundColor(new Color(null, rgbBackgroundValues.getRed(), rgbBackgroundValues.getGreen(), rgbBackgroundValues.getBlue())); fig.setOpaque(true); } } } return fig; }
Source:
<code>protected void finalize() throws Throwable { if (mIsOpen) { CLEANUP_LOG.warn( <START> "Closing HBaseKijiTable in finalize(). You should close it explicitly", <END> mTableURI); CLEANUP_LOG.warn( "HBaseKijiTable still has retained references.", mTableURI, mRetainCount.get()); if (CLEANUP_LOG.isDebugEnabled()) { CLEANUP_LOG.debug( "Call stack when this HBaseKijiTable was constructed:\n{}", mConstructorStack); } close(); } super.finalize(); }</code><technical_language>"you close it" -> "you release() it." If wanted debug properly, retain log a stack trace of retained. stack of constructor call is relevant in retain/release model</technical_language>

Target:
protected void finalize() throws Throwable { if (mIsOpen.get()) { CLEANUP_LOG.warn( "Finalizing opened resource '{}' with retained references. " + "You must release() it.", mTableURI, mRetainCount.get()); if (CLEANUP_LOG.isDebugEnabled()) { CLEANUP_LOG.debug( "HBaseKijiTable '{}' was constructed through:\n{}", mTableURI, mConstructorStack); } close(); } super.finalize(); }
Source:
<code>public Block split( @TypeParameter("map<varchar,varchar>") Type mapType, @SqlType(StandardTypes.VARCHAR) Slice string, @SqlType(StandardTypes.VARCHAR) Slice entryDelimiter, @SqlType(StandardTypes.VARCHAR) Slice keyValueDelimiter, @SqlType("function(varchar, varchar, varchar, varchar)") DuplicateKeyResolutionLambda function) <START> { <END> return splitToMap(pageBuilder, mapType, string, entryDelimiter, keyValueDelimiter, function); }</code><technical_language>ditto adding requireNonNull</technical_language>

Target:
public Block split( @TypeParameter("map<varchar,varchar>") Type mapType, @SqlType(StandardTypes.VARCHAR) Slice string, @SqlType(StandardTypes.VARCHAR) Slice entryDelimiter, @SqlType(StandardTypes.VARCHAR) Slice keyValueDelimiter, @SqlType("function(varchar, varchar, varchar, varchar)") DuplicateKeyResolutionLambda function) { return splitToMap(pageBuilder, mapType, string, entryDelimiter, keyValueDelimiter, Optional.of(function)); }
Source:
<code><START> public void runMultipleActions(final VdcActionType actionType, <END> final List<VdcActionParametersBase> parameters, final IFrontendActionAsyncCallback successCallback, final Object state, final boolean runCallbacksOnEmptyRun) { if (parameters == null || parameters.isEmpty()) { if (runCallbacksOnEmptyRun && successCallback != null) { VdcReturnValueBase emptyResult = new VdcReturnValueBase(); VdcActionParametersBase emptyParams = new VdcActionParametersBase(); successCallback.executed(new FrontendActionAsyncResult(actionType, emptyParams, emptyResult, state)); } return; } int n = parameters.size(); IFrontendActionAsyncCallback[] callbacks = new IFrontendActionAsyncCallback[n]; callbacks[n - 1] = successCallback; runMultipleActions(actionType, parameters, new LinkedList<IFrontendActionAsyncCallback>(Arrays.asList(callbacks)), state); }</code><technical_language>add another override signature of this one, passes true runCallbacksOnEmptyRun default? obviate need change call in userportal, convenient for others in future. True is more reasonable default choice, hurt call userportal called a empty parameters</technical_language>

Target:
public void runMultipleActions(final VdcActionType actionType, final List<VdcActionParametersBase> parameters, final IFrontendActionAsyncCallback successCallback, final Object state, final boolean runCallbacksOnEmptyRun) { if (parameters == null || parameters.isEmpty()) { if (runCallbacksOnEmptyRun && successCallback != null) { successCallback.executed(new FrontendActionAsyncResult(actionType, null, null, state)); } return; } int n = parameters.size(); IFrontendActionAsyncCallback[] callbacks = new IFrontendActionAsyncCallback[n]; callbacks[n - 1] = successCallback; runMultipleActions(actionType, parameters, new LinkedList<IFrontendActionAsyncCallback>(Arrays.asList(callbacks)), state); }
Source:
<code><START> public Collection<Area> getAllAreas() { <END> return areas; }</code><technical_language>rename methods class FlexArea Area</technical_language>

Target:
public Collection<FlexArea> getAllAreas() { return flexAreas; }
Source:
<code>private List<Long> insertStackedContainer(final List<Long> left, final List<Long> right) { <START> List<Long> stack = new ArrayList<Long>(); <END> stack.add(left.get(0) + right.get(0)); stack.add(left.get(1) + right.get(1)); stack.add(left.get(2) + right.get(2)); stack.add(left.get(3) + right.get(3)); return stack; }</code><technical_language>new ArrayList<>();</technical_language>

Target:
private List<Long> insertStackedContainer(final List<Long> left, final List<Long> right) { List<Long> stack = new ArrayList<>(left.size()); for (int index = 0; index < left.size(); index++) { stack.add(left.get(index) + right.get(index)); } return stack; }
Source:
<code>private void initDockerFileFile(Logger log) { if (dockerFile != null && dockerFileDir != null) { <START> dockerFileFile = new File(dockerFileDir, dockerFile); <END> dockerFileMode = true; } else if (dockerFile != null) { dockerFileFile = new File(dockerFile); dockerFileMode = true; } else if (dockerFileDir != null) { dockerFileFile = new File(dockerFileDir, "Dockerfile"); dockerFileMode = true; } else { String deprecatedDockerFileDir = getAssemblyConfiguration() != null ? getAssemblyConfiguration().getDockerFileDir() : null; if (deprecatedDockerFileDir != null) { log.warn("<dockerFileDir> in the <assembly> section of a <build> configuration is deprecated"); log.warn("Please use <dockerFileDir> or <dockerFile> directly within the <build> configuration instead"); dockerFileFile = new File(deprecatedDockerFileDir,"Dockerfile"); dockerFileMode = true; } else { dockerFileMode = false; } } }</code><technical_language>please add a check, dockerFile is absolute path throw error if is</technical_language>

Target:
private void initDockerFileFile(Logger log) { if (dockerFile != null && dockerFileDir != null) { dockerFileFile = new File(dockerFile); if (dockerFileFile.isAbsolute()) { throw new IllegalArgumentException("<dockerFile> can not be absolute path if <dockerFileDir> also set."); } dockerFileFile = new File(dockerFileDir, dockerFile); dockerFileMode = true; } else if (dockerFile != null) { dockerFileFile = new File(dockerFile); dockerFileMode = true; } else if (dockerFileDir != null) { dockerFileFile = new File(dockerFileDir, "Dockerfile"); dockerFileMode = true; } else { String deprecatedDockerFileDir = getAssemblyConfiguration() != null ? getAssemblyConfiguration().getDockerFileDir() : null; if (deprecatedDockerFileDir != null) { log.warn("<dockerFileDir> in the <assembly> section of a <build> configuration is deprecated"); log.warn("Please use <dockerFileDir> or <dockerFile> directly within the <build> configuration instead"); dockerFileFile = new File(deprecatedDockerFileDir,"Dockerfile"); dockerFileMode = true; } else { dockerFileMode = false; } } }
Source:
<code>public boolean entryExpiredInMemoryFromIteration(InternalCacheEntry<K, V> entry, long currentTime) { if (persistenceManager.isEnabled()) { <START> blockingExecutor.submit(() -> entryExpiredInMemory(entry, currentTime, false)); <END> } else { entryExpiredInMemory(entry, currentTime, false); } return true; }</code><technical_language>1. check if actual stores active loaders? 2. persistenceManager.deleteFromAllStores() work another thread, remove join() deleteFromStoresAndNotify() instead</technical_language>

Target:
public boolean entryExpiredInMemoryFromIteration(InternalCacheEntry<K, V> entry, long currentTime) { if (persistenceManager.hasWriter()) { blockingExecutor.submit(() -> entryExpiredInMemorySync(entry, currentTime)); } else { entryExpiredInMemory(entry, currentTime, false); } return true; }
Source:
<code>public @Nonnull ItemStack getStackInSlot(int index) { final ItemStack itemStack = items.get(index); <START> return itemStack.isEmpty() ? master.getStackInSlot(index) : itemStack; <END> }</code><technical_language>This is a logic error. empty itemstack in shadow inventory override existing in shadowed one..</technical_language>

Target:
public @Nonnull ItemStack getStackInSlot(int index) { final ItemStack itemStack = items[index]; return itemStack.isEmpty() ? master.getStackInSlot(index) : itemStack; }
Source:
<code>private <T> T timed(Supplier<? extends T> callable, String schemaTimer) { Timer.Context time = startLatencyTimer(schemaTimer); <START> T value = callable.get(); <END> time.stop(); return value; }</code><technical_language>I close this timer in finally block callable throw exception</technical_language>

Target:
private <T> T timed(Supplier<? extends T> callable, String schemaTimer) { try (Timer.Context time = startLatencyTimer(schemaTimer)) { return callable.get(); } }
Source:
<code>synchronized VungleBannerAdapter getBannerRequest(@NonNull String placementId, @Nullable String requestUniqueId, @NonNull AdConfig adConfig) { VungleBannerAdapter bannerRequest = mVungleBanners.get(placementId); if (bannerRequest != null) { String activeUniqueRequestId = bannerRequest.getUniquePubRequestId(); <START> if (activeUniqueRequestId != null && activeUniqueRequestId.equals(requestUniqueId) || activeUniqueRequestId == null && requestUniqueId == null) { <END> Log.d(TAG, "Seems like Refresh: activeUniqueId: " + activeUniqueRequestId + " ### RequestId: " + requestUniqueId); } else { Log.d(TAG, "Does NOT seems like Refresh: activeUniqueId: " + activeUniqueRequestId + " ### RequestId: " + requestUniqueId); return null; } } else { bannerRequest = new VungleBannerAdapter(placementId, requestUniqueId, adConfig); mVungleBanners.put(placementId, bannerRequest); } Log.d(TAG, "New banner request:" + bannerRequest + "; size=" + mVungleBanners.size()); return bannerRequest; }</code><technical_language>Code is assuming refresh if publisher set extras a uniqueRequestId. Pub OPT IN refresh support, OPT OUT. Reasoning: - Assuming a refresh for a non-refresh cannibalize publisher's other banner implementation, a terrible pub experience. - Assuming a non-refresh is a refresh means a lost opportunity for Vungle, scoped Vungle adapter publisher get fill ruining flow of app. Risk is high incorrectly assume a refresh. Logic limited just: if (activeUniqueRequestId == null) { Log.w(TAG, "Ad loaded for placement ID: " + placementId + ", determine if this is a refresh. Set Vungle extras making ad request support refresh Vungle banner ads."); return null; } if (!activeUniqueRequestId.equals(requestUniqueId)) { Log.d(TAG, "Ad loaded for placement ID: " + placementId); return null; }</technical_language>

Target:
synchronized VungleBannerAdapter getBannerRequest(@NonNull String placementId, @Nullable String requestUniqueId, @NonNull AdConfig adConfig) { VungleBannerAdapter bannerRequest = mVungleBanners.get(placementId); if (bannerRequest != null) { String activeUniqueRequestId = bannerRequest.getUniquePubRequestId(); Log.d(TAG, "activeUniqueId: " + activeUniqueRequestId + " ### RequestId: " + requestUniqueId); if (activeUniqueRequestId == null) { Log.w(TAG, "Ad already loaded for placement ID: " + placementId + ", and cannot determine if this " + "is a refresh. Set Vungle extras when making an ad request to support refresh on Vungle banner ads."); return null; } if (!activeUniqueRequestId.equals(requestUniqueId)) { Log.w(TAG, "Ad already loaded for placement ID: " + placementId); return null; } } else { bannerRequest = new VungleBannerAdapter(placementId, requestUniqueId, adConfig); mVungleBanners.put(placementId, bannerRequest); } Log.d(TAG, "New banner request:" + bannerRequest + "; size=" + mVungleBanners.size()); return bannerRequest; }
Source:
<code>public static boolean isVirtIoScsiDiskInterfaceExists(VmBase vmBase) { if (vmBase.getImages().stream().anyMatch(i -> i.getDiskVmElementForVm(vmBase.getId()) .getDiskInterface() == DiskInterface.VirtIO_SCSI)) { return true; } <START> return false; <END> }</code><technical_language>simply return result of anyMatch 'if' 'return true/false' statements. imo, nicer extract "i -> i.getDiskVmElementForVm(vmBase.getId()).getDiskInterface() == DiskInterface.VirtIO_SCSI" part a separate method "isVirtioScsiDisk" easier read</technical_language>

Target:
public static boolean isVirtIoScsiDiskInterfaceExists(VmBase vmBase) { return vmBase.getImages().stream().anyMatch(i -> i.getDiskVmElementForVm(vmBase.getId()) .getDiskInterface() == DiskInterface.VirtIO_SCSI); }
Source:
<code>public String create(final String path, byte data[], List<ACL> acl, CreateMode createMode, Stat stat, long ttl) throws KeeperException, InterruptedException { final String clientPath = path; PathUtils.validatePath(clientPath, createMode.isSequential()); EphemeralType.validateTTL(createMode, ttl); final String serverPath = prependChroot(clientPath); RequestHeader h = new RequestHeader(); setCreateHeader(createMode, h); Create2Response response = new Create2Response(); <START> if (acl == null || acl.isEmpty() || acl.contains(null)) { <END> throw new KeeperException.InvalidACLException(); } Record record = makeCreateRecord(createMode, serverPath, data, acl, ttl); ReplyHeader r = cnxn.submitRequest(h, record, response, null); if (r.getErr() != 0) { throw KeeperException.create(KeeperException.Code.get(r.getErr()), clientPath); } if (stat != null) { DataTree.copyStat(response.getStat(), stat); } if (cnxn.chrootPath == null) { return response.getPath(); } else { return response.getPath().substring(cnxn.chrootPath.length()); } }</code><technical_language>this Validation multiple places if this piece of code is extracted method. Some private void validateACL(List<ACL> acl) throws InvalidACLException { if (acl == null || acl.isEmpty() || acl.contains(null)) { throw new KeeperException.InvalidACLException(); } } put this method other validation methods for example PathUtils.validatePath(clientPath, createMode.isSequential()); EphemeralType.validateTTL(createMode, -1); validateACL(acl);</technical_language>

Target:
public String create(final String path, byte data[], List<ACL> acl, CreateMode createMode, Stat stat, long ttl) throws KeeperException, InterruptedException { final String clientPath = path; PathUtils.validatePath(clientPath, createMode.isSequential()); EphemeralType.validateTTL(createMode, ttl); validateACL(acl); final String serverPath = prependChroot(clientPath); RequestHeader h = new RequestHeader(); setCreateHeader(createMode, h); Create2Response response = new Create2Response(); Record record = makeCreateRecord(createMode, serverPath, data, acl, ttl); ReplyHeader r = cnxn.submitRequest(h, record, response, null); if (r.getErr() != 0) { throw KeeperException.create(KeeperException.Code.get(r.getErr()), clientPath); } if (stat != null) { DataTree.copyStat(response.getStat(), stat); } if (cnxn.chrootPath == null) { return response.getPath(); } else { return response.getPath().substring(cnxn.chrootPath.length()); } }
Source:
<code>private void connectSender(Queue queue, String targetName, Symbol... capabilities) { if (logger.isDebugEnabled()) { logger.debug("Connecting outbound for " + queue); } { Sender sender = senders.get(queue); if (sender != null) { logger.debug("Sender for queue " + queue + " already exists, just giving up"); return; } } if (session == null) { logger.debug("Session is null"); return; } <START> Sender sender = session.sender(targetName + UUIDGenerator.getInstance().generateStringUUID()); <END> Target target = new Target(); target.setAddress(targetName); if (capabilities != null) { target.setCapabilities(capabilities); } sender.setTarget(target); Source source = new Source(); source.setAddress(queue.getName().toString()); sender.setSource(source); AMQPOutgoingInitializer outgoingInitializer = new AMQPOutgoingInitializer(queue, sender, sessionContext.getSessionSPI()); ProtonServerSenderContext senderContext = new ProtonServerSenderContext(protonRemotingConnection.getAmqpConnection(), sender, sessionContext, sessionContext.getSessionSPI(), outgoingInitializer); senders.put(queue, sender); protonRemotingConnection.getAmqpConnection().runLater(() -> { try { sessionContext.addSender(sender, senderContext); } catch (Exception e) { error(e); } protonRemotingConnection.getAmqpConnection().flush(); }); }</code><technical_language>Similar thread safety concerns fixed for receiver</technical_language>

Target:
private void connectSender(Queue queue, String targetName, Symbol... capabilities) { if (logger.isDebugEnabled()) { logger.debug("Connecting outbound for " + queue); } if (session == null) { logger.debug("Session is null"); return; } protonRemotingConnection.getAmqpConnection().runLater(() -> { try { if (senders.contains(queue)) { logger.debug("Sender for queue " + queue + " already exists, just giving up"); return; } senders.add(queue); Sender sender = session.sender(targetName + UUIDGenerator.getInstance().generateStringUUID()); sender.setSenderSettleMode(SenderSettleMode.UNSETTLED); sender.setReceiverSettleMode(ReceiverSettleMode.FIRST); Target target = new Target(); target.setAddress(queue.getAddress().toString()); if (capabilities != null) { target.setCapabilities(capabilities); } sender.setTarget(target); Source source = new Source(); source.setAddress(queue.getAddress().toString()); sender.setSource(source); AMQPOutgoingController outgoingInitializer = new AMQPOutgoingController(queue, sender, sessionContext.getSessionSPI()); ProtonServerSenderContext senderContext = new ProtonServerSenderContext(protonRemotingConnection.getAmqpConnection(), sender, sessionContext, sessionContext.getSessionSPI(), outgoingInitializer); sessionContext.addSender(sender, senderContext); } catch (Exception e) { error(e); } protonRemotingConnection.getAmqpConnection().flush(); }); }
Source:
<code>public String getMessage() { <START> return "Mapping defined in '" + source1.getSource() + "' and '" + source2.getSource() + "'"; <END> }</code><technical_language>add Null-checks sources</technical_language>

Target:
public String getMessage() { String source1Description = source1 != null ? source1.getSource().toString() : DESCRIPTION_UNKNOWN_SOURCE; String source2Description = source2 != null ? source2.getSource().toString() : DESCRIPTION_UNKNOWN_SOURCE; return "Mapping defined in '" + source1Description + "' and '" + source2Description + "'"; }
Source:
<code>public GridDhtPartitionsExchangeFuture( GridCacheSharedContext cctx, ReadWriteLock busyLock, GridDhtPartitionExchangeId exchId, ExchangeActions exchActions, CacheAffinityChangeMessage affChangeMsg ) { assert busyLock != null; assert exchId != null; assert exchId.topologyVersion() != null; assert exchActions == null || !exchActions.empty(); this.cctx = cctx; this.busyLock = busyLock; this.exchId = exchId; this.exchActions = exchActions; this.affChangeMsg = affChangeMsg; this.validator = new GridDhtPartitionsStateValidator(cctx); if (exchActions != null && exchActions.deactivate()) this.clusterIsActive = false; log = cctx.logger(getClass()); exchLog = cctx.logger(EXCHANGE_LOG); timeBag = new TimeBag(); initFut = new GridFutureAdapter<Boolean>() { @Override public IgniteLogger logger() { return log; } }; <START> MetricRegistry sysreg = cctx.kernalContext().metric().registry(SYS_METRICS); <END> startTimeMetric = sysreg.metric("StartPmeTime", null); startTimeMetric.value(System.nanoTime()); if (log.isDebugEnabled()) log.debug("Creating exchange future [localNode=" + cctx.localNodeId() + ", fut=" + this + ']'); }</code><technical_language>update metric in GridDhtPartitionsExchangeFuture only. Other changes reverted</technical_language>

Target:
public GridDhtPartitionsExchangeFuture( GridCacheSharedContext cctx, ReadWriteLock busyLock, GridDhtPartitionExchangeId exchId, ExchangeActions exchActions, CacheAffinityChangeMessage affChangeMsg ) { assert busyLock != null; assert exchId != null; assert exchId.topologyVersion() != null; assert exchActions == null || !exchActions.empty(); this.cctx = cctx; this.busyLock = busyLock; this.exchId = exchId; this.exchActions = exchActions; this.affChangeMsg = affChangeMsg; this.validator = new GridDhtPartitionsStateValidator(cctx); if (exchActions != null && exchActions.deactivate()) this.clusterIsActive = false; log = cctx.logger(getClass()); exchLog = cctx.logger(EXCHANGE_LOG); timeBag = new TimeBag(); initFut = new GridFutureAdapter<Boolean>() { @Override public IgniteLogger logger() { return log; } }; if (log.isDebugEnabled()) log.debug("Creating exchange future [localNode=" + cctx.localNodeId() + ", fut=" + this + ']'); }
Source:
<code>public TopologyDetails(String topologyId, Map<String, Object> topologyConf, StormTopology topology, int numWorkers, Map<ExecutorDetails, String> executorToComponents, int launchTime, String owner) { this.owner = owner; this.topologyId = topologyId; this.topologyConf = topologyConf; this.topology = topology; this.numWorkers = numWorkers; this.executorToComponent = new HashMap<>(0); if (executorToComponents != null) { this.executorToComponent.putAll(executorToComponents); } if (topology != null) { initResourceList(); } initConfigs(); this.launchTime = launchTime; this.topoName = (String) topologyConf.get(Config.TOPOLOGY_NAME); <START> this.distributeSysCompEvenly <END> = (boolean) topologyConf.getOrDefault(Config.TOPOLOGY_SYSTEM_COMPONENTS_EVEN_DISTRIBUTION, false); }</code><technical_language>This property is more useful in Scheduler code is sort executors in a manner conducive distribution</technical_language>

Target:
public TopologyDetails(String topologyId, Map<String, Object> topologyConf, StormTopology topology, int numWorkers, Map<ExecutorDetails, String> executorToComponents, int launchTime, String owner) { this.owner = owner; this.topologyId = topologyId; this.topologyConf = topologyConf; this.topology = topology; this.numWorkers = numWorkers; this.executorToComponent = new HashMap<>(0); if (executorToComponents != null) { this.executorToComponent.putAll(executorToComponents); } if (topology != null) { initResourceList(); } initConfigs(); this.launchTime = launchTime; this.topoName = (String) topologyConf.get(Config.TOPOLOGY_NAME); }
Source:
<code><START> private void handleDesignViewActivatedEvent() throws Exception { <END> if (sourceEditor != null) { String xmlSource = sourceEditor.getDocument().get(); if (xmlSource != null) { if (!xmlSource.trim().isEmpty()) { rebuildModelObject(xmlSource); } } } }</code><technical_language>Again, throwing a general Exception</technical_language>

Target:
private void handleDesignViewActivatedEvent() { if(sourceEditor!=null){ String xmlSource = sourceEditor.getDocument().get(); if(xmlSource!=null && sourceDirty){ if(!xmlSource.trim().isEmpty()){ rebuildModelObject(xmlSource); } } } }
Source:
<code>private boolean internalValidateAndSetQuota() { if (isInternalExecution()) { return true; } if (getStoragePool() == null) { log.error("Command: " + this.getClass().getName() <START> + ". Storage pool is not available for quota calculation. "); <END> } QuotaConsumptionParametersWrapper quotaConsumptionParametersWrapper = new QuotaConsumptionParametersWrapper(this, getReturnValue().getCanDoActionMessages()); quotaConsumptionParametersWrapper.setParameters(getQuotaConsumptionParameters()); return true; }</code><technical_language>if missing storagePool, flow errors. return false</technical_language>

Target:
private boolean internalValidateAndSetQuota() { if (isInternalExecution()) { return true; } if (getStoragePool() == null && getActionType().getQuotaDependency() != VdcActionType.QuotaDependency.NONE) { log.error("Command: " + this.getClass().getName() + ". Storage pool is not available for quota calculation. "); return false; } QuotaConsumptionParametersWrapper quotaConsumptionParametersWrapper = new QuotaConsumptionParametersWrapper(this, getReturnValue().getCanDoActionMessages()); quotaConsumptionParametersWrapper.setParameters(getQuotaConsumptionParameters()); return true; }