auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public static void classLevelSetup() throws Exception { Map<String, String> overrides = new HashMap<>(); overrides.put(MetastoreConf.ConfVars.EVENT_MESSAGE_FACTORY.getHiveName(), GzipJSONMessageEncoder.class.getCanonicalName()); overrides.put(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "true"); overrides.put(HiveConf.ConfVars.HIVE_TXN_MANAGER.varname, "org.apache.hadoop.hive.ql.lockmgr.DbTxnManager"); overrides.put(MetastoreConf.ConfVars.CAPABILITY_CHECK.getHiveName(),"false"); overrides.put(HiveConf.ConfVars.REPL_BOOTSTRAP_DUMP_OPEN_TXN_TIMEOUT.varname,"1s"); overrides.put(HiveConf.ConfVars.DYNAMICPARTITIONINGMODE.varname, "nonstrict"); internalBeforeClassSetup(overrides, overrides, TestReplicationScenarios.class, true, "mm"); }

Target:
public static void classLevelSetup() throws Exception { Map<String, String> overrides = new HashMap<>(); overrides.put(MetastoreConf.ConfVars.EVENT_MESSAGE_FACTORY.getHiveName(), GzipJSONMessageEncoder.class.getCanonicalName()); overrides.put(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "true"); overrides.put(HiveConf.ConfVars.HIVE_TXN_MANAGER.varname, "org.apache.hadoop.hive.ql.lockmgr.DbTxnManager"); overrides.put(MetastoreConf.ConfVars.CAPABILITY_CHECK.getHiveName(),"false"); overrides.put(HiveConf.ConfVars.REPL_BOOTSTRAP_DUMP_OPEN_TXN_TIMEOUT.varname,"1s"); overrides.put(HiveConf.ConfVars.DYNAMICPARTITIONINGMODE.varname, "nonstrict"); internalBeforeClassSetup(overrides, overrides, TestStatsReplicationScenariosMM.class, true, AcidTableKind.INSERT_ONLY); }
Source:
protected boolean canDoAction() { initVmTemplate(); if (isImagesAlreadyOnTarget()) { if (ovfEntityData == null && !getParameters().isImportAsNewEntity()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_UNSUPPORTED_OVF); return false; } if (vmTemplateFromConfiguration == null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_OVF_CONFIGURATION_NOT_SUPPORTED); return false; } setStorageDomainId(ovfEntityData.getStorageDomainId()); if (!validate(new StorageDomainValidator(getStorageDomain()).isDomainExistAndActive())) { return false; } if (!getStorageDomain().getStorageDomainType().isDataDomain()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_TYPE_UNSUPPORTED, String.format("$domainId %1$s", getParameters().getStorageDomainId()), String.format("$domainType %1$s", getStorageDomain().getStorageDomainType())); } } List<DiskImage> disks = new ArrayList(getVmTemplate().getDiskTemplateMap().values()); setImagesWithStoragePoolId(getStorageDomain().getStoragePoolId(), disks); getParameters().setImages(disks); getVmTemplate().setImages((ArrayList)disks); return super.canDoAction(); }

Target:
protected boolean canDoAction() { initVmTemplate(); if (isImagesAlreadyOnTarget()) { if (ovfEntityData == null && !getParameters().isImportAsNewEntity()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_UNSUPPORTED_OVF); return false; } if (vmTemplateFromConfiguration == null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_OVF_CONFIGURATION_NOT_SUPPORTED); return false; } setStorageDomainId(ovfEntityData.getStorageDomainId()); if (!validate(new StorageDomainValidator(getStorageDomain()).isDomainExistAndActive())) { return false; } if (!getStorageDomain().getStorageDomainType().isDataDomain()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_TYPE_UNSUPPORTED, String.format("$domainId %1$s", getParameters().getStorageDomainId()), String.format("$domainType %1$s", getStorageDomain().getStorageDomainType())); } } ArrayList<DiskImage> disks = new ArrayList(getVmTemplate().getDiskTemplateMap().values()); setImagesWithStoragePoolId(getStorageDomain().getStoragePoolId(), disks); getParameters().setImages(disks); getVmTemplate().setImages(disks); return super.canDoAction(); }
Source:
protected Object decodeUdp(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) throws Exception { int packetId = buf.getShort(2); int imeiLength = buf.getUnsignedShort(6); String imei = buf.toString(8, imeiLength, StandardCharsets.US_ASCII); int offset = 8 + imeiLength; return parseData(channel, remoteAddress, buf, offset, packetId, imei); }

Target:
protected Object decodeUdp(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) throws Exception { buf.skipBytes(2); int packetId = buf.readUnsignedShort(); buf.skipBytes(2); int imeiLength = buf.readUnsignedShort(); String imei = buf.toString(8, imeiLength, StandardCharsets.US_ASCII); buf.skipBytes(imeiLength); return parseData(channel, remoteAddress, buf, packetId, imei); }
Source:
public static boolean isAlgorithmSupported(String algorithm) { return ALGORITHM_SIMPLE_DIGEST_MD5.equals(algorithm) || ALGORITHM_SIMPLE_DIGEST_SHA_1.equals(algorithm) || ALGORITHM_SIMPLE_DIGEST_SHA_256.equals(algorithm) || ALGORITHM_SIMPLE_DIGEST_SHA_384.equals(algorithm) || ALGORITHM_SIMPLE_DIGEST_SHA_512.equals(algorithm) || ALGORITHM_PASSWORD_SALT_DIGEST_MD5.equals(algorithm) || ALGORITHM_PASSWORD_SALT_DIGEST_SHA_1.equals(algorithm) || ALGORITHM_PASSWORD_SALT_DIGEST_SHA_256.equals(algorithm) || ALGORITHM_PASSWORD_SALT_DIGEST_SHA_384.equals(algorithm) || ALGORITHM_PASSWORD_SALT_DIGEST_SHA_512.equals(algorithm) || BSDUnixDESCryptPassword.ALGORITHM_BSD_CRYPT_DES.equals(algorithm) || UnixDESCryptPassword.ALGORITHM_CRYPT_DES.equals(algorithm) || ClearPassword.ALGORITHM_CLEAR.equals(algorithm); }

Target:
public static boolean isAlgorithmSupported(String algorithm) { switch (algorithm) { case ALGORITHM_SIMPLE_DIGEST_MD5: case ALGORITHM_SIMPLE_DIGEST_SHA_1: case ALGORITHM_SIMPLE_DIGEST_SHA_256: case ALGORITHM_SIMPLE_DIGEST_SHA_384: case ALGORITHM_SIMPLE_DIGEST_SHA_512: case ALGORITHM_PASSWORD_SALT_DIGEST_MD5: case ALGORITHM_PASSWORD_SALT_DIGEST_SHA_1: case ALGORITHM_PASSWORD_SALT_DIGEST_SHA_256: case ALGORITHM_PASSWORD_SALT_DIGEST_SHA_384: case ALGORITHM_PASSWORD_SALT_DIGEST_SHA_512: case ALGORITHM_BSD_CRYPT_DES: case ALGORITHM_CRYPT_DES: case ALGORITHM_CLEAR: return true; default: return false; } }
Source:
public EnumSet<NeededData> getNeededData() { return EnumSet.of(NeededData.CHANGE); }

Target:
public EnumSet<NeededData> getNeededData() { loadRules(); EnumSet<NeededData> needed = EnumSet.noneOf(NeededData.class); for (List<Predicate<ChangeData>> list : rules.values()) { for (Predicate<ChangeData> p : list) { if (p instanceof Prefetchable) { needed.addAll(((Prefetchable) p).getNeededData()); } } } return needed; }
Source:
public String toString() { return String.valueOf(leftOp) + kind.operand + rightOp; }

Target:
public String toString() { return leftOp.toString() + kind.operand + rightOp.toString(); }
Source:
@Override void apply(RequestBuilder builder, @Nullable Object value) { try { checkNotNull(value, "@Url parameter is null."); } catch (NullPointerException npe) { throw Utils.parameterError(method, npe, p, "@Url parameter is null."); } builder.setRelativeUrl(value); }

Target:
@Override void apply(RequestBuilder builder, @Nullable Object value) { if (value == null) { throw Utils.parameterError(method, p, "@Url parameter is null."); } builder.setRelativeUrl(value); }
Source:
private void jobStatus(ExecutorDriver driver, TaskInfo task) { if (process == null) { LOGGER.error("No Cassandra process to handle node-job-status"); if (task != null) driver.sendStatusUpdate(taskStatus(task, TaskState.TASK_ERROR, nullSlaveStatusDetails())); return; } AbstractNodeJob current = currentJob.get(); if (current == null) { LOGGER.error("No current job to handle node-job-status"); return; } NodeJobStatus.Builder status = NodeJobStatus.newBuilder() .setExecutorId(this.executorInfo.getExecutorId().getValue()) .setTaskId(current.getTaskId().getValue()) .setJobType(current.getType()) .setRunning(!current.isFinished()) .addAllRemainingKeyspaces(current.getRemainingKeyspaces()) .addAllProcessedKeyspaces(current.getKeyspaceStatus().values()) .setStartedTimestamp(current.getStartTimestamp()) .setFinishedTimestamp(current.getFinishedTimestamp()); SlaveStatusDetails repairDetails = SlaveStatusDetails.newBuilder() .setStatusDetailsType(SlaveStatusDetails.StatusDetailsType.NODE_JOB_STATUS) .setNodeJobStatus(status).build(); LOGGER.debug("Sending node-job-status result, finished={}", current.isFinished()); driver.sendFrameworkMessage(repairDetails.toByteArray()); if (current.isFinished()) { driver.sendStatusUpdate(taskStatus(executorInfo.getExecutorId(), current.getTaskId(), TaskState.TASK_FINISHED, repairDetails)); currentJob.set(null); } if (task != null) { driver.sendStatusUpdate(taskStatus(task, TaskState.TASK_FINISHED, repairDetails)); } }

Target:
private void jobStatus(ExecutorDriver driver, TaskInfo task) { if (process == null) { LOGGER.error("No Cassandra process to handle node-job-status"); if (task != null) { serverProcessNotRunning(driver, task); } return; } AbstractNodeJob current = currentJob.get(); if (current == null) { LOGGER.error("No current job to handle node-job-status"); return; } NodeJobStatus.Builder status = NodeJobStatus.newBuilder() .setExecutorId(this.executorInfo.getExecutorId().getValue()) .setTaskId(current.getTaskId().getValue()) .setJobType(current.getType()) .setRunning(!current.isFinished()) .addAllRemainingKeyspaces(current.getRemainingKeyspaces()) .addAllProcessedKeyspaces(current.getKeyspaceStatus().values()) .setStartedTimestamp(current.getStartTimestamp()) .setFinishedTimestamp(current.getFinishedTimestamp()); SlaveStatusDetails repairDetails = SlaveStatusDetails.newBuilder() .setStatusDetailsType(SlaveStatusDetails.StatusDetailsType.NODE_JOB_STATUS) .setNodeJobStatus(status).build(); LOGGER.debug("Sending node-job-status result, finished={}", current.isFinished()); driver.sendFrameworkMessage(repairDetails.toByteArray()); if (current.isFinished()) { driver.sendStatusUpdate(taskStatus(executorInfo.getExecutorId(), current.getTaskId(), TaskState.TASK_FINISHED, repairDetails)); currentJob.set(null); } if (task != null) { driver.sendStatusUpdate(taskStatus(task, TaskState.TASK_FINISHED, repairDetails)); } }
Source:
public void testUnpackingCausesDecodeFail() { EmbeddedChannel e = new EmbeddedChannel(new Socks5InitialRequestDecoder()); e.writeInbound(Unpooled.wrappedBuffer(new byte[]{5, 2, 0})); e.writeInbound(Unpooled.wrappedBuffer(new byte[]{1})); Object o = e.readInbound(); assertTrue(o instanceof DefaultSocks5InitialRequest); DefaultSocks5InitialRequest req = (DefaultSocks5InitialRequest) o; assertSame(req.decoderResult(), DecoderResult.SUCCESS); }

Target:
public void testUnpackingCausesDecodeFail() { EmbeddedChannel e = new EmbeddedChannel(new Socks5InitialRequestDecoder()); assertFalse(e.writeInbound(Unpooled.wrappedBuffer(new byte[]{5, 2, 0}))); assertTrue(e.writeInbound(Unpooled.wrappedBuffer(new byte[]{1}))); Object o = e.readInbound(); assertTrue(o instanceof DefaultSocks5InitialRequest); DefaultSocks5InitialRequest req = (DefaultSocks5InitialRequest) o; assertSame(req.decoderResult(), DecoderResult.SUCCESS); assertFalse(e.finish()); }
Source:
private void downloadPatient(final Patient patient, final Boolean showSnackBar) { new PatientApi().downloadPatientByUuid(patient.getUuid(), new DownloadPatientCallbackListener() { @Override public void onPatientDownloaded(Patient newPatient) { new PatientDAO().savePatient(newPatient).subscribe(); new VisitApi().syncVisitsData(newPatient); new VisitApi().syncLastVitals(newPatient.getUuid()); patients.remove(patient); notifyDataSetChanged(); if (showSnackBar) { view.showOpenPatientSnackbar(newPatient.getId()); } } @Override public void onPatientPhotoDownloaded(Patient patient) { new PatientDAO().updatePatient(patient.getId(), patient); } @Override public void onResponse() { } @Override public void onErrorResponse(String errorMessage) { ToastUtil.error("Failed to fetch patient data"); } }); }

Target:
private void downloadPatient(final Patient patient, final Boolean showSnackBar) { new PatientApi().downloadPatientByUuid(patient.getUuid(), new DownloadPatientCallbackListener() { @Override public void onPatientDownloaded(Patient newPatient) { new PatientDAO().savePatient(newPatient) .observeOn(AndroidSchedulers.mainThread()) .subscribe(id -> { new VisitApi().syncVisitsData(newPatient); new VisitApi().syncLastVitals(newPatient.getUuid()); patients.remove(patient); notifyDataSetChanged(); if (showSnackBar) { view.showOpenPatientSnackbar(newPatient.getId()); } }); } @Override public void onPatientPhotoDownloaded(Patient patient) { new PatientDAO().updatePatient(patient.getId(), patient); } @Override public void onResponse() { } @Override public void onErrorResponse(String errorMessage) { ToastUtil.error("Failed to fetch patient data"); } }); }
Source:
public void run() { log.info(Thread.currentThread().getName() + " is starting DFS"); try { frontier.searchForScenarios(queue, flag); } catch (IOException e) { e.printStackTrace(); } log.info(Thread.currentThread().getName() + " is done with DFS"); }

Target:
public void run() { log.info(Thread.currentThread().getName() + " is starting DFS"); try { frontier.searchForScenarios(queue, flag); } catch (IOException e) { log.error("", e); } log.info(Thread.currentThread().getName() + " is done with DFS"); }
Source:
private static CommandScheduler createCommandScheduler() { @SuppressWarnings("AccessOfSystemProperties") final String appEngineVersion = System.getProperty("com.google.appengine.runtime.version"); final boolean isRunningOnAppEngine = appEngineVersion != null; if (isRunningOnAppEngine) { log().error("CommandScheduler for AppEngine is not implemented yet."); return new ExecutorCommandScheduler(); } else { return new ExecutorCommandScheduler(); } }

Target:
private static CommandScheduler createCommandScheduler() { if (Environment.getInstance().isAppEngine()) { log().error("CommandScheduler for AppEngine is not implemented yet."); return new ExecutorCommandScheduler(); } else { return new ExecutorCommandScheduler(); } }
Source:
private TypePrinter<GraphQLEnumType> enumPrinter() { return (out, type, visibility) -> { if (isIntrospectionType(type)) { return; } SchemaPrinterComparatorEnvironment environment = SchemaPrinterComparatorEnvironment.newEnvironment() .withParentType(GraphQLEnumType.class) .withElementType(GraphQLEnumValueDefinition.class) .build(); Comparator<? super GraphQLType> comparator = options.comparatorRegistry.getComparator(environment); printComments(out, type, ""); out.format("enum %s%s {\n", type.getName(), directivesString(GraphQLEnumType.class, type.getDirectives())); List<GraphQLEnumValueDefinition> values = type.getValues() .stream() .sorted(comparator) .collect(toList()); for (GraphQLEnumValueDefinition enumValueDefinition : values) { printComments(out, enumValueDefinition, " "); out.format(" %s%s\n", enumValueDefinition.getName(), directivesString(GraphQLEnumValueDefinition.class, enumValueDefinition.getDirectives())); } out.format("}\n\n"); }; }

Target:
private TypePrinter<GraphQLEnumType> enumPrinter() { return (out, type, visibility) -> { if (isIntrospectionType(type)) { return; } SchemaPrinterComparatorEnvironment environment = SchemaPrinterComparatorEnvironment.newEnvironment() .parentType(GraphQLEnumType.class) .elementType(GraphQLEnumValueDefinition.class) .build(); Comparator<? super GraphQLType> comparator = options.comparatorRegistry.getComparator(environment); printComments(out, type, ""); out.format("enum %s%s {\n", type.getName(), directivesString(GraphQLEnumType.class, type.getDirectives())); List<GraphQLEnumValueDefinition> values = type.getValues() .stream() .sorted(comparator) .collect(toList()); for (GraphQLEnumValueDefinition enumValueDefinition : values) { printComments(out, enumValueDefinition, " "); out.format(" %s%s\n", enumValueDefinition.getName(), directivesString(GraphQLEnumValueDefinition.class, enumValueDefinition.getDirectives())); } out.format("}\n\n"); }; }
Source:
final static public < A extends LongAccess > ArrayImg< Unsigned2BitType, A > unsigned2Bits( final A access, final long... dim ) { final ArrayImg< Unsigned2BitType, A > img = new ArrayImg<>( access, dim, new Fraction( 1, 64 ) ); final Unsigned2BitType t = new Unsigned2BitType( img ); img.setLinkedType( t ); return img; }

Target:
final static public < A extends LongAccess > ArrayImg< Unsigned2BitType, A > unsigned2Bits( final A access, final long... dim ) { final ArrayImg< Unsigned2BitType, A > img = new ArrayImg<>( access, dim, new Fraction( 2, 64 ) ); final Unsigned2BitType t = new Unsigned2BitType( img ); img.setLinkedType( t ); return img; }
Source:
public Charset charset() { return Charset.defaultCharset(); }

Target:
public Charset charset() { return StandardCharsets.UTF_8; }
Source:
private LDAPStoreAttributeResourceDefinition(SimpleAttributeDefinition... attributes) { super(ModelElement.LDAP_STORE_ATTRIBUTE, new IDMConfigAddStepHandler(attributes) { @Override protected boolean isAlternativesRequired() { return false; } }, null, attributes); }

Target:
private LDAPStoreAttributeResourceDefinition(SimpleAttributeDefinition... attributes) { super(ModelElement.LDAP_STORE_ATTRIBUTE, new IDMConfigAddStepHandler(attributes) { @Override protected boolean isAlternativesRequired() { return false; } }, attributes); }
Source:
public PlanWithProperties visitSort(SortNode node, PreferredProperties preferredProperties) { PlanWithProperties child = planChild(node, PreferredProperties.undistributed()); if (child.getProperties().isSingleNode()) { List<LocalProperty<Symbol>> desiredProperties = new ArrayList<>(); for (Symbol symbol : node.getOrderingScheme().getOrderBy()) { desiredProperties.add(new SortingProperty<>(symbol, node.getOrderingScheme().getOrdering(symbol))); } if (LocalProperties.match(child.getProperties().getLocalProperties(), desiredProperties).stream() .noneMatch(Optional::isPresent)) { return child; } } if (isDistributedSortEnabled(session)) { child = planChild(node, PreferredProperties.any()); return withDerivedProperties( mergingExchange( idAllocator.getNextId(), REMOTE, new SortNode( idAllocator.getNextId(), child.getNode(), node.getOrderingScheme()), node.getOrderingScheme()), child.getProperties()); } if (!child.getProperties().isSingleNode()) { child = withDerivedProperties( gatheringExchange(idAllocator.getNextId(), REMOTE, child.getNode()), child.getProperties()); } return rebaseAndDeriveProperties(node, child); }

Target:
public PlanWithProperties visitSort(SortNode node, PreferredProperties preferredProperties) { PlanWithProperties child = planChild(node, PreferredProperties.undistributed()); if (child.getProperties().isSingleNode()) { List<LocalProperty<Symbol>> desiredProperties = new ArrayList<>(); for (Symbol symbol : node.getOrderingScheme().getOrderBy()) { desiredProperties.add(new SortingProperty<>(symbol, node.getOrderingScheme().getOrdering(symbol))); } if (LocalProperties.match(child.getProperties().getLocalProperties(), desiredProperties).stream() .noneMatch(Optional::isPresent)) { return child; } } if (isDistributedSortEnabled(session)) { child = planChild(node, PreferredProperties.any()); PlanNode source = roundRobinExchange(idAllocator.getNextId(), REMOTE, child.getNode()); return withDerivedProperties( mergingExchange( idAllocator.getNextId(), REMOTE, new SortNode( idAllocator.getNextId(), source, node.getOrderingScheme()), node.getOrderingScheme()), child.getProperties()); } if (!child.getProperties().isSingleNode()) { child = withDerivedProperties( gatheringExchange(idAllocator.getNextId(), REMOTE, child.getNode()), child.getProperties()); } return rebaseAndDeriveProperties(node, child); }
Source:
public List<Client> findAllClients() { return getClients(); }

Target:
public List<Client> findAllClients() { init(); return getClients(); }
Source:
public void broadcastDatastreamUpdate() { _adapter.touchAllInstanceAssignments(); }

Target:
public synchronized void broadcastDatastreamUpdate() { _adapter.touchAllInstanceAssignments(); }
Source:
int getPid(Process process) { if (PID_FIELD != null) { try { return ((Number) PID_FIELD.get(process)).intValue(); } catch (IllegalAccessException e) { throw new IllegalStateException("Cannot get process id. Not a UNIX system?", e); } } else if (PID_METHOD != null) { try { return ((Long) PID_METHOD.invoke(process)).intValue(); } catch (IllegalAccessException | InvocationTargetException e) { throw new IllegalStateException("Cannot get process id. Not a UNIX system?", e); } } else { throw new IllegalStateException("Cannot get process id. Not a UNIX system?"); } }

Target:
int getPid(Process process) { if (PID_FIELD != null) { try { return ((Number) PID_FIELD.get(process)).intValue(); } catch (IllegalAccessException e) { throw new IllegalStateException("Cannot get process ID. Not a UNIX system?", e); } } else if (PID_METHOD != null) { try { return ((Long) PID_METHOD.invoke(process)).intValue(); } catch (IllegalAccessException | InvocationTargetException e) { throw new IllegalStateException("Cannot get process ID. Not a UNIX system?", e); } } else { throw new IllegalStateException("Cannot get process ID. Not a UNIX system?"); } }
Source:
public Set<DiscoveredResourceDetails> discoverResources( ResourceDiscoveryContext<ApacheVirtualHostServiceComponent> context) throws InvalidPluginConfigurationException, Exception { Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>(); ApacheDirective vhost = context.getParentResourceComponent().getDirective(); ApacheDirectiveTree tree = new ApacheDirectiveTree(); tree.setRootNode(vhost); final List<ApacheDirective> allDirectories = tree.search("/"+ApacheDirectoryComponent.DIRECTORY_DIRECTIVE); ResourceType resourceType = context.getResourceType(); for (ApacheDirective apacheDirective : allDirectories) { String directoryParam; boolean isRegexp; List<String> params = apacheDirective.getValues(); if (params.size() > 1 && StringUtil.isNotBlank(params.get(1))) { directoryParam = params.get(1); isRegexp = true; } else { directoryParam = params.get(0); isRegexp = false; } Configuration pluginConfiguration = context.getDefaultPluginConfiguration(); pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, isRegexp)); String resourceName = AugeasNodeValueUtil.unescape(directoryParam); int index = 1; for (DiscoveredResourceDetails detail : discoveredResources) { if(detail.getResourceName().endsWith(resourceName)) index++; } StringBuilder resourceKey = new StringBuilder(); resourceKey.append(apacheDirective.getName()).append("|").append(directoryParam).append("|").append(index).append(";"); discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey.toString(), resourceName, null, null, pluginConfiguration, null)); } return discoveredResources; }

Target:
public Set<DiscoveredResourceDetails> discoverResources( ResourceDiscoveryContext<ApacheVirtualHostServiceComponent> context) throws InvalidPluginConfigurationException, Exception { Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>(); ApacheDirective vhost = context.getParentResourceComponent().getDirective(); return discoverResources(context, discoveredResources, vhost, ""); }
Source:
public static void setNameService (Map<String, String> domainIpMapProvided) { try { List<sun.net.spi.nameservice.NameService> nameServices = (List<sun.net.spi.nameservice.NameService>) org.apache.commons.lang3.reflect.FieldUtils.readStaticField(InetAddress.class, "nameServices", true); if (domainIpMap != null) { domainIpMap = domainIpMapProvided; } nameServices.add(new CustomDnsResolver()); } catch (IllegalAccessException e) { e.printStackTrace(); } }

Target:
public static void setNameService (Map<String, String> domainIpMapProvided) { try { List<sun.net.spi.nameservice.NameService> nameServices = (List<sun.net.spi.nameservice.NameService>) org.apache.commons.lang3.reflect.FieldUtils.readStaticField(InetAddress.class, "nameServices", true); if (domainIpMap != null) { domainIpMap = domainIpMapProvided; } nameServices.add(new CustomDnsResolver()); } catch (IllegalAccessException e) { logger.error("Error during setNameService: ",e); } }
Source:
public ODataEntry insertEntityToTable(String tableName, ODataEntry entity) { ODataEntry createdEntry = new ODataEntry(); final Document document = new Document(); for (String columnName : entity.getData().keySet()) { String columnValue = entity.getValue(columnName); document.put(columnName, columnValue); entity.addValue(columnName, columnValue); } document.put("_id", new ObjectId()); jongo.getCollection(tableName).insert(document); String documentIdValue = document.get("_id").toString(); entity.addValue(DOCUMENT_ID, documentIdValue); createdEntry.addValue(DOCUMENT_ID, documentIdValue); createdEntry.addValue(ODataConstants.E_TAG, ODataUtils.generateETag(this.configId, tableName, entity)); return createdEntry; }

Target:
public ODataEntry insertEntityToTable(String tableName, ODataEntry entity) { ODataEntry createdEntry = new ODataEntry(); final Document document = new Document(); for (String columnName : entity.getData().keySet()) { String columnValue = entity.getValue(columnName); document.put(columnName, columnValue); entity.addValue(columnName, columnValue); } ObjectId objectId = new ObjectId(); document.put(DOCUMENT_ID, objectId); jongo.getCollection(tableName).insert(document); String documentIdValue = objectId.toString(); createdEntry.addValue(DOCUMENT_ID, documentIdValue); createdEntry.addValue(ODataConstants.E_TAG, ODataUtils.generateETag(this.configId, tableName, entity)); return createdEntry; }
Source:
private List<Observation> convertObservationMapToList(Map<String, String> observations, DateTime obsDatetime) { List<Observation> observationList = new ArrayList<>(); for (String observationConceptName : observations.keySet()) { if (valueIsNotEmpty(observations, observationConceptName)) { String[] observationsValues = observations.get(observationConceptName).replace(" ", "").split(","); for (String value : observationsValues) { Observation observation = new Observation(); ConceptName conceptName = new ConceptName(observationConceptName); Concept concept = new Concept(conceptName); observation.setConcept(concept); Observation.ObservationValue observationValue = new Observation.ObservationValue(value); observation.setValue(observationValue); observation.setObsDatetime(obsDatetime.toDate()); observationList.add(observation); } } else { LOGGER.warn("Observation value is null or empty for concept: " + observationConceptName + " and will not be created"); } } return observationList; }

Target:
private List<Observation> convertObservationMapToList(Map<String, String> observations, DateTime obsDatetime) { List<Observation> observationList = new ArrayList<>(); for (String observationConceptName : observations.keySet()) { if (valueIsNotEmpty(observations, observationConceptName)) { String[] observationValues = observations.get(observationConceptName).replace(", ", ",").split(","); for (String value : observationValues) { Observation observation = new Observation(); ConceptName conceptName = new ConceptName(observationConceptName); Concept concept = new Concept(conceptName); observation.setConcept(concept); Observation.ObservationValue observationValue = new Observation.ObservationValue(value); observation.setValue(observationValue); observation.setObsDatetime(obsDatetime.toDate()); observationList.add(observation); } } else { LOGGER.warn("Observation value is null or empty for concept: " + observationConceptName + " and will not be created"); } } return observationList; }
Source:
public Future<Void> updateBlobTtl(String blobId, String serviceId, long expiresAtMs, Callback<Void> callback) { FutureResult<Void> futureResult = new FutureResult<>(); handlePrechecks(futureResult, callback); Exception exception = null; try { getBlobIdFromString(blobId, clusterMap); if (!deletedBlobs.contains(blobId) && blobs.containsKey(blobId)) { InMemoryBlob blob = blobs.get(blobId); BlobProperties existing = blob.blobProperties; long newTtlSecs = Utils.getTtlInSecsFromExpiryMs(expiresAtMs, existing.getCreationTimeInMs()); blob.blobProperties.setTimeToLiveInSeconds(newTtlSecs); if (notificationSystem != null) { notificationSystem.onBlobTtlUpdated(blobId, serviceId, expiresAtMs); } } else if (deletedBlobs.contains(blobId)) { exception = new RouterException("Blob has been deleted", RouterErrorCode.BlobDeleted); } else { exception = new RouterException("Blob not found", RouterErrorCode.BlobDoesNotExist); } } catch (RouterException e) { exception = e; } catch (Exception e) { exception = new RouterException(e, RouterErrorCode.UnexpectedInternalError); } finally { completeOperation(futureResult, callback, null, exception); } return futureResult; }

Target:
public Future<Void> updateBlobTtl(String blobId, String serviceId, long expiresAtMs, Callback<Void> callback) { FutureResult<Void> futureResult = new FutureResult<>(); handlePrechecks(futureResult, callback); Exception exception = null; try { getBlobIdFromString(blobId, clusterMap); if (!deletedBlobs.contains(blobId) && blobs.containsKey(blobId)) { InMemoryBlob blob = blobs.get(blobId); BlobProperties currentProps = blob.blobProperties; long newTtlSecs = Utils.getTtlInSecsFromExpiryMs(expiresAtMs, currentProps.getCreationTimeInMs()); blob.blobProperties.setTimeToLiveInSeconds(newTtlSecs); if (notificationSystem != null) { notificationSystem.onBlobTtlUpdated(blobId, serviceId, expiresAtMs); } } else if (deletedBlobs.contains(blobId)) { exception = new RouterException("Blob has been deleted", RouterErrorCode.BlobDeleted); } else { exception = new RouterException("Blob not found", RouterErrorCode.BlobDoesNotExist); } } catch (RouterException e) { exception = e; } catch (Exception e) { exception = new RouterException(e, RouterErrorCode.UnexpectedInternalError); } finally { completeOperation(futureResult, callback, null, exception); } return futureResult; }
Source:
private TmfTimeRange getValidTimeRange(ITmfTrace trace) { if (!fTraces.containsKey(trace)) { return null; } if (!(trace instanceof TmfExperiment)) { return trace.getTimeRange(); } final ITmfTrace[] traces = ((TmfExperiment) trace).getTraces(); if (traces.length == 1) { return traces[0].getTimeRange(); } ITmfTimestamp start = traces[0].getStartTime(); ITmfTimestamp end = traces[0].getEndTime(); for (int i = 1; i < traces.length; i++) { ITmfTrace curTrace = traces[i]; if (curTrace.getStartTime().compareTo(start) < 1) { start = curTrace.getStartTime(); } if (curTrace.getEndTime().compareTo(end) > 1) { end = curTrace.getEndTime(); } } return new TmfTimeRange(start, end); }

Target:
private TmfTimeRange getValidTimeRange(ITmfTrace trace) { if (!fTraces.containsKey(trace)) { return null; } if (!(trace instanceof TmfExperiment)) { return trace.getTimeRange(); } final ITmfTrace[] traces = ((TmfExperiment) trace).getTraces(); if (traces.length == 0) { return null; } if (traces.length == 1) { return traces[0].getTimeRange(); } ITmfTimestamp start = traces[0].getStartTime(); ITmfTimestamp end = traces[0].getEndTime(); for (int i = 1; i < traces.length; i++) { ITmfTrace curTrace = traces[i]; if (curTrace.getStartTime().compareTo(start) < 0) { start = curTrace.getStartTime(); } if (curTrace.getEndTime().compareTo(end) > 0) { end = curTrace.getEndTime(); } } return new TmfTimeRange(start, end); }
Source:
protected void executeCommand() { if (getDiskImage() != null) { try { Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand()); VDSReturnValue vdsReturnValue = performImageVdsmOperation(); getReturnValue().getInternalVdsmTaskIdList().add( createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getStorageDomainId())); } catch (VdcBLLException e) { if (e.getErrorCode() == VdcBllErrors.ImageDoesNotExistInDomainError) { log.warnFormat("The image group with id {0} wasn't actually deleted from the storage domain {1} " + "because it didn't exist in it", getDiskImage().getId(), getStorageDomainId()); } else if (e.getErrorCode() == VdcBllErrors.ImageDeleteError && isImageRemovedFromStorage()) { log.infoFormat("The image group with id {0} was deleted from storage"); } else { throw e; } } if (getParameters().getParentCommand() != VdcActionType.RemoveVmFromImportExport && getParameters().getParentCommand() != VdcActionType.RemoveVmTemplateFromImportExport) { performImageDbOperations(); } } else { log.warn("DiskImage is null, nothing to remove"); } setSucceeded(true); }

Target:
protected void executeCommand() { if (getDiskImage() != null) { try { Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand()); VDSReturnValue vdsReturnValue = performImageVdsmOperation(); getReturnValue().getInternalVdsmTaskIdList().add( createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getStorageDomainId())); } catch (VdcBLLException e) { if (e.getErrorCode() == VdcBllErrors.ImageDoesNotExistInDomainError) { log.infoFormat("Disk '{0}' doesn't exist on storage domain '{1}', rolling forward", getDiskImage().getId(), getStorageDomainId()); } else if (e.getErrorCode() == VdcBllErrors.ImageDeleteError && isImageRemovedFromStorage()) { log.infoFormat("Disk '{0}' was deleted from storage domain '{1}'", getDiskImage().getId(), getStorageDomainId()); } else { throw e; } } if (getParameters().getParentCommand() != VdcActionType.RemoveVmFromImportExport && getParameters().getParentCommand() != VdcActionType.RemoveVmTemplateFromImportExport) { performImageDbOperations(); } } else { log.warn("DiskImage is null, nothing to remove"); } setSucceeded(true); }
Source:
private ItemRest replace(ItemRest item, Operation operation) { checkOperationValue((String) operation.getValue()); Boolean discoverable = BooleanUtils.toBooleanObject((String) operation.getValue()); if (discoverable == null) { throw new PatchBadRequestException( "Boolean value not provided for discoverable operation."); } item.setDiscoverable(discoverable); return item; }

Target:
public ItemRest replace(ItemRest item, Operation operation) { Boolean discoverable = getBooleanOperationValue(operation.getValue()); item.setDiscoverable(discoverable); return item; }
Source:
protected List<Network> getNetworks() { if (networks == null) { networks = getDbFacade().getNetworkDao().getAllForDataCenter(network.getDataCenterId()); if (networks == null) { networks = Collections.<Network> emptyList(); } } return networks; }

Target:
protected List<Network> getNetworks() { if (networks == null) { networks = getDbFacade().getNetworkDao().getAllForDataCenter(network.getDataCenterId()); } return networks; }
Source:
public void afterProjectsRead(MavenSession session) throws MavenExecutionException { try { if (disableLifecycleParticipation(session)) { return; } List<MavenProject> projects = session.getProjects(); String tychoVersion = validateConsistentTychoVersion(projects); validateUniqueBaseDirs(projects); System.setProperty(P2_USER_AGENT_KEY, P2_USER_AGENT_VALUE + tychoVersion); configureComponents(session); for (MavenProject project : projects) { resolver.setupProject(session, project, DefaultReactorProject.adapt(project)); } List<ReactorProject> reactorProjects = DefaultReactorProject.adapt(session); for (MavenProject project : projects) { resolver.resolveProject(session, project, reactorProjects); } } catch (BuildFailureException e) { throw new MavenExecutionException(e.getMessage(), e); } }

Target:
public void afterProjectsRead(MavenSession session) throws MavenExecutionException { try { if (disableLifecycleParticipation(session)) { return; } List<MavenProject> projects = session.getProjects(); validate(projects); System.setProperty(P2_USER_AGENT_KEY, P2_USER_AGENT_VALUE + TychoVersion.getTychoVersion()); configureComponents(session); for (MavenProject project : projects) { resolver.setupProject(session, project, DefaultReactorProject.adapt(project)); } List<ReactorProject> reactorProjects = DefaultReactorProject.adapt(session); for (MavenProject project : projects) { resolver.resolveProject(session, project, reactorProjects); } } catch (BuildFailureException e) { throw new MavenExecutionException(e.getMessage(), e); } }
Source:
public void setParams(Integer n, MatrixLib p) { if (n != null) { if (n < 0) { throw new IllegalArgumentException( "The number of trials 'n' for a Multinomial Distribution must be nonnegative"); } this.n = n; this.hasN = true; } if (p != null) { if (p.numRows() != 1 || p.numCols() == 0) { throw new IllegalArgumentException( "The row vector p passed in is not a row vector"); } initializeProbabilityVector(p); this.hasP = true; } }

Target:
public void setParams(Integer n, MatrixLib p) { if (n != null) { if (n < 0) { throw new IllegalArgumentException( "The number of trials 'n' for a Multinomial Distribution must be nonnegative"); } this.n = n; this.hasN = true; } if (p != null) { if (p.numRows() != 1 || p.numCols() == 0) { throw new IllegalArgumentException( "The vector p passed in is not a row vector"); } initializeProbabilityVector(p); this.hasP = true; } }
Source:
public void saveWidgetValues() { IDialogSettings settings = getDialogSettings(); if (settings != null) { settings.put(STORE_OPEN_TYPE_ID, openType); settings.put(STORE_REPLACE_SOURCE_ID, replaceSource); } }

Target:
public void saveWidgetValues() { IDialogSettings settings = getDialogSettings(); if (null != settings) { settings.put(STORE_OPEN_TYPE_ID, openType); settings.put(STORE_REPLACE_SOURCE_ID, replaceSource); } }
Source:
public void scanClassWithReadOnlyAndEmptyValueParams() { Swagger swagger = getSwagger(Issue1979Resource.class); Parameter readOnlyParam = swagger.getPath("/fun/readOnly").getGet().getParameters().get(0); assertTrue(readOnlyParam.isReadOnly()); QueryParameter allowEmptyParam = (QueryParameter) swagger.getPath("/fun/allowEmpty").getGet().getParameters().get(0); assertTrue(allowEmptyParam.getAllowEmptyValue()); }

Target:
public void scanClassWithReadOnlyAndEmptyValueParams() { Swagger swagger = getSwagger(Issue1979Resource.class); Parameter readOnlyParam = swagger.getPath("/fun/readOnly").getGet().getParameters().get(0); assertTrue(readOnlyParam.isReadOnly()); SerializableParameter allowEmptyParam = (SerializableParameter) swagger.getPath("/fun/allowEmpty").getGet().getParameters().get(0); assertTrue(allowEmptyParam.getAllowEmptyValue()); }
Source:
private void processFlagFile() throws CmdLineException, IOException { Path flagFile = Paths.get(flags.flagFile); BufferedReader buffer = java.nio.file.Files.newBufferedReader(flagFile, UTF_8); StringBuilder builder = new StringBuilder(); List<String> tokens = new ArrayList<>(); boolean quoted = false; boolean escaped = false; int c; while ((c = buffer.read()) != -1) { if (c == UTF8_BOM_CODE) { continue; } if (c == 32 || c == 9 || c == 10 || c == 13) { if (quoted) { builder.append((char) c); } else if (builder.length() != 0) { tokens.add(builder.toString()); builder.setLength(0); } } else if (c == 34) { if (escaped) { if (quoted) { builder.setCharAt(builder.length()-1, (char) c); } else { builder.append((char) c); } } else { quoted = !quoted; } } else { builder.append((char) c); } escaped = c == 92; } buffer.close(); if (builder.length() != 0) { tokens.add(builder.toString()); } flags.flagFile = ""; tokens = processArgs(tokens.toArray(new String[tokens.size()])); List<GuardLevel> previous = new ArrayList<>(Flags.guardLevels); Flags.guardLevels.clear(); flags.parse(tokens); Flags.guardLevels.addAll(previous); if (!flags.flagFile.isEmpty()) { reportError("ERROR - Arguments in the file cannot contain " + "--flagfile option."); } }

Target:
private void processFlagFile() throws CmdLineException, IOException { Path flagFile = Paths.get(flags.flagFile); BufferedReader buffer = java.nio.file.Files.newBufferedReader(flagFile, UTF_8); StringBuilder builder = new StringBuilder(); List<String> tokens = new ArrayList<>(); boolean quoted = false; boolean escaped = false; boolean isFirstCharacter = true; int c; while ((c = buffer.read()) != -1) { if (isFirstCharacter) { isFirstCharacter = false; if (c == UTF8_BOM_CODE) { continue; } } if (c == 32 || c == 9 || c == 10 || c == 13) { if (quoted) { builder.append((char) c); } else if (builder.length() != 0) { tokens.add(builder.toString()); builder.setLength(0); } } else if (c == 34) { if (escaped) { if (quoted) { builder.setCharAt(builder.length()-1, (char) c); } else { builder.append((char) c); } } else { quoted = !quoted; } } else { builder.append((char) c); } escaped = c == 92; } buffer.close(); if (builder.length() != 0) { tokens.add(builder.toString()); } flags.flagFile = ""; tokens = processArgs(tokens.toArray(new String[tokens.size()])); List<GuardLevel> previous = new ArrayList<>(Flags.guardLevels); Flags.guardLevels.clear(); flags.parse(tokens); Flags.guardLevels.addAll(previous); if (!flags.flagFile.isEmpty()) { reportError("ERROR - Arguments in the file cannot contain " + "--flagfile option."); } }
Source:
private BiConsumer<Throwable, Object> completeWithErrorContinue() { return (error, event) -> { final PrivilegedEvent errorEvent = (PrivilegedEvent) ((MessagingException) error).getEvent(); System.out.println("continuing after error... " + errorEvent.getContext().getDepthLevel()); (errorEvent.getContext()).success(errorEvent); }; }

Target:
private BiConsumer<Throwable, Object> completeWithErrorContinue() { return (error, event) -> { final PrivilegedEvent errorEvent = (PrivilegedEvent) ((MessagingException) error).getEvent(); (errorEvent.getContext()).success(errorEvent); }; }
Source:
private void remeasureTabs() { if (getVisibility() != View.VISIBLE) return; if (layoutWidth == 0) return; final int count = getTabCount(); int contentWidth = 0; for (int i = 0; i < count; i++) { View child = getTabAt(i).view; if (child.getVisibility() == View.VISIBLE) { contentWidth += Math.max(child.getMinimumWidth(), child.getMeasuredWidth()); } } if (contentWidth > layoutWidth) { setMode(TabLayout.MODE_SCROLLABLE); } else { setMode(TabLayout.MODE_FIXED); } }

Target:
private void remeasureTabs() { if (prevVisibility != View.VISIBLE) return; if (layoutWidth == 0) return; final int count = getTabCount(); int contentWidth = 0; for (int i = 0; i < count; i++) { View child = getTabAt(i).view; if (child.getVisibility() == View.VISIBLE) { contentWidth += Math.max(child.getMinimumWidth(), child.getMeasuredWidth()); } } if (contentWidth > layoutWidth) { setMode(TabLayout.MODE_SCROLLABLE); } else { setMode(TabLayout.MODE_FIXED); } }
Source:
public void visitIfStatement(IfStatementTree ifTree) { Slf4jTestVisitor slf4jTestVisitor = new Slf4jTestVisitor(); ifTree.condition().accept(slf4jTestVisitor); if (slf4jTestVisitor.match) { stackAndContinue(ifTree, super::visitIfStatement); } }

Target:
public void visitIfStatement(IfStatementTree ifTree) { LevelTestVisitor levelTestVisitor = new LevelTestVisitor(); ifTree.condition().accept(levelTestVisitor); if (levelTestVisitor.match) { stackAndContinue(ifTree, super::visitIfStatement); } else { super.visitIfStatement(ifTree); } }
Source:
public Serializable execute(TaskResult... results) throws IOException { List<String> filesRelativePathName = new ArrayList<>(); boolean s3PathIsPrefix = (keyName.lastIndexOf('/') == keyName.length() - 1); File f = new File(s3LocalRelativePath); if (f.exists()) { getOut().println("The local path already exists"); if (s3PathIsPrefix) { try { f.mkdir(); } catch (Exception e) { getOut().println("Couldn't create destination directory!"); System.exit(1); } } } AmazonS3 amazonS3 = getS3Client(host, scheme); if (s3PathIsPrefix) { downloadDir(bucketName, keyName, s3LocalRelativePath, false, amazonS3); filesRelativePathName = SchedulerExamplesUtils.listDirectoryContents(f, new ArrayList<>()); } else { s3LocalRelativePath = Paths.get(s3LocalRelativePath, Paths.get(s3Url).getFileName().toString()).toString(); downloadFile(bucketName, keyName, s3LocalRelativePath, false, amazonS3); filesRelativePathName.add(s3LocalRelativePath); } return (Serializable) filesRelativePathName; }

Target:
public Serializable execute(TaskResult... results) throws IOException { boolean s3PathIsPrefix = (s3RemoteRelativePath.lastIndexOf('/') == s3RemoteRelativePath.length() - 1); File f = new File(s3LocalRelativePath); createDirIfNotExists(f, s3PathIsPrefix); AmazonS3 amazonS3 = S3ConnectorUtils.getS3Client(accessKey, secretKey, scheme, host); if (s3PathIsPrefix) { downloadDir(bucketName, s3RemoteRelativePath, s3LocalRelativePath, false, amazonS3); return (Serializable) SchedulerExamplesUtils.listDirectoryContents(f, new ArrayList<>()); } else { s3LocalRelativePath = Paths.get(s3LocalRelativePath, Paths.get(s3Url).getFileName().toString()).toString(); downloadFile(bucketName, s3RemoteRelativePath, s3LocalRelativePath, false, amazonS3); return (Serializable) Arrays.asList(s3LocalRelativePath); } }
Source:
public synchronized void stop() { if (!isStopped) { if (coordinatorListener != null) { coordinatorListener.onJobModelExpired(); } metrics.isLeader.set(false); debounceTimer.stopScheduler(); zkController.stop(); shutdownMetrics(); if (coordinatorListener != null) { coordinatorListener.onCoordinatorStop(); } systemAdmins.stop(); isStopped = true; } }

Target:
public synchronized void stop() { if (coordinatorListener != null) { coordinatorListener.onJobModelExpired(); } metrics.isLeader.set(false); debounceTimer.stopScheduler(); zkController.stop(); shutdownMetrics(); if (coordinatorListener != null) { coordinatorListener.onCoordinatorStop(); } systemAdmins.stop(); }
Source:
protected void fillContextMenu(IMenuManager manager) { final ISelection selection = fViewer.getSelection(); ITmfFilterTreeNode filterTreeNode = null; if (selection instanceof StructuredSelection) { Object element = ((StructuredSelection) selection).getFirstElement(); if (element instanceof ITmfFilterTreeNode) { filterTreeNode = (ITmfFilterTreeNode) element; } } final ITmfFilterTreeNode selectedNode = filterTreeNode; if (selectedNode != null) { fillContextMenuForNode(selectedNode, manager); } manager.add(new Separator("delete")); if (fIsDialog && (selectedNode != null)) { Action deleteAction = new Action(Messages.FilterViewer_DeleteActionText) { @Override public void run() { selectedNode.remove(); fViewer.refresh(); } }; deleteAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); deleteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE); deleteAction.setAccelerator(SWT.DEL); manager.add(deleteAction); } manager.add(new Separator("edit")); if (fViewer.getInput() instanceof TmfFilterRootNode || filterTreeNode == null) { manager.add(new Separator()); ITmfFilterTreeNode root = (ITmfFilterTreeNode) fViewer.getInput(); fillContextMenuForNode(root, manager); } }

Target:
protected void fillContextMenu(IMenuManager manager) { final ISelection selection = fViewer.getSelection(); ITmfFilterTreeNode filterTreeNode = null; if (selection instanceof StructuredSelection) { Object element = ((StructuredSelection) selection).getFirstElement(); if (element instanceof ITmfFilterTreeNode) { filterTreeNode = (ITmfFilterTreeNode) element; } } final ITmfFilterTreeNode selectedNode = filterTreeNode; if (selectedNode != null) { fillContextMenuForNode(selectedNode, manager); } manager.add(new Separator("delete")); if (fIsDialog && (selectedNode != null)) { Action deleteAction = new Action(Messages.FilterViewer_DeleteActionText) { @Override public void run() { selectedNode.remove(); fViewer.refresh(); } }; deleteAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); manager.add(deleteAction); } manager.add(new Separator("edit")); if (fViewer.getInput() instanceof TmfFilterRootNode || filterTreeNode == null) { manager.add(new Separator()); ITmfFilterTreeNode root = (ITmfFilterTreeNode) fViewer.getInput(); fillContextMenuForNode(root, manager); } }
Source:
boolean isProvided() { int len = getCapacity(); for(int idx = 0; idx < len; idx++) { DatanodeStorageInfo cur = getStorageInfo(idx); if(cur != null) { if (cur.getStorageType() == StorageType.PROVIDED) { return true; } } } return false; }

Target:
boolean isProvided() { int len = getCapacity(); for (int idx = 0; idx < len; idx++) { DatanodeStorageInfo storage = getStorageInfo(idx); if (storage != null && storage.getStorageType().equals(StorageType.PROVIDED)) { return true; } } return false; }