auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public UserTrades getTradeHistory(TradeHistoryParams p) throws IOException { CoingiOrdersList orderList; if (p instanceof CoingiTradeHistoryParams) { CoingiTradeHistoryParams params = (CoingiTradeHistoryParams) p; CoingiGetOrderHistoryRequest request = new CoingiGetOrderHistoryRequest(); if (params.getCurrencyPair() != null) request.setCurrencyPair(params.getCurrencyPair()); request.setPageNumber(params.getPageNumber()); request.setPageSize(params.getPageSize()); if (params.getStatus() != null) request.setStatus(params.getStatus()); if (params.getType() != null) request.setType(params.getType()); try { <START> orderList = getCoingiOrderHistory(request); <END> } catch (CoingiException e) { throw CoingiErrorAdapter.adapt(e); } return CoingiAdapters.adaptTradeHistory(orderList); } return null; }</code><technical_language>try / catch CoingiException hit applied</technical_language>

Target:
public UserTrades getTradeHistory(TradeHistoryParams p) throws IOException { try { if (p instanceof CoingiTradeHistoryParams) { CoingiTradeHistoryParams params = (CoingiTradeHistoryParams) p; CoingiGetOrderHistoryRequest request = new CoingiGetOrderHistoryRequest(); if (params.getCurrencyPair() != null) request.setCurrencyPair(params.getCurrencyPair()); request.setPageNumber(params.getPageNumber()); request.setPageSize(params.getPageSize()); if (params.getStatus() != null) request.setStatus(params.getStatus()); if (params.getType() != null) request.setType(params.getType()); CoingiOrdersList orderList = getCoingiOrderHistory(request); return CoingiAdapters.adaptTradeHistory(orderList); } return null; } catch (CoingiException e) { throw CoingiErrorAdapter.adapt(e); } }
Source:
<code>public void execute() { <START> if (canExecute()) { END> editor = Abstract4DIACUIPlugin.getCurrentActiveEditor(); checkSourceAndTarget(); connection = createConnectionElement(); connection.setSource(source); connection.setDestination(destination); connection.setDx1(connDx1); connection.setDx2(connDx2); connection.setDy(connDy); parent.addConnection(connection); if (performMappingCheck) { mirroredConnection = checkAndCreateMirroredConnection(); if (null != mirroredConnection) { mirroredConnection.execute(); } } } }</code><technical_language>This violates a bit contract of command. Typically caller is in charge of checking canExecute</technical_language>

Target:
public void execute() { editor = Abstract4DIACUIPlugin.getCurrentActiveEditor(); checkSourceAndTarget(); connection = createConnectionElement(); connection.setSource(source); connection.setDestination(destination); connection.setDx1(connDx1); connection.setDx2(connDx2); connection.setDy(connDy); parent.addConnection(connection); if(performMappingCheck){ mirroredConnection = checkAndCreateMirroredConnection(); if(null != mirroredConnection){ mirroredConnection.execute(); } } }
Source:
<code>private boolean isIpLevelBlocked(String apiTenantDomain, String ip) { Set<IPRange> ipRanges = blockedIpConditionsMap.get(apiTenantDomain); if (ipRanges != null && ipRanges.size() > 0) { for (IPRange ipRange : ipRanges) { if (APIConstants.BLOCKING_CONDITIONS_IP.equals(ipRange.getType())) { if (ip.equals(ipRange.getFixedIp())) { if (!ipRange.isInvert()) { return true; } } else { if (ipRange.isInvert()) { return true; } } } else if (APIConstants.BLOCK_CONDITION_IP_RANGE.equals(ipRange.getType())) { BigInteger ipBigIntegerValue = APIUtil.ipToBigInteger(ip); if (((ipBigIntegerValue.compareTo(ipRange.getStartingIpBigIntValue()) > 0) && (ipBigIntegerValue.compareTo(ipRange.getEndingIpBigIntValue()) < 0))) { if (!ipRange.isInvert()) { <START> return true; <END> } } else { if (ipRange.isInvert()) { return true; } } } } } return false; }</code><technical_language>this work for IPV4 IPV6</technical_language>

Target:
private boolean isIpLevelBlocked(String apiTenantDomain, String ip) { Set<IPRange> ipRanges = blockedIpConditionsMap.get(apiTenantDomain); if (ipRanges != null && ipRanges.size() > 0) { log.debug("Tenant " + apiTenantDomain + " contains block conditions"); for (IPRange ipRange : ipRanges) { if (APIConstants.BLOCKING_CONDITIONS_IP.equals(ipRange.getType())) { if (ip.equals(ipRange.getFixedIp())) { if (!ipRange.isInvert()) { log.debug("Block IP selected for Blocked"); return true; } } else { if (ipRange.isInvert()) { log.debug("Block IP selected for Blocked"); return true; } } } else if (APIConstants.BLOCK_CONDITION_IP_RANGE.equals(ipRange.getType())) { BigInteger ipBigIntegerValue = APIUtil.ipToBigInteger(ip); if (((ipBigIntegerValue.compareTo(ipRange.getStartingIpBigIntValue()) > 0) && (ipBigIntegerValue.compareTo(ipRange.getEndingIpBigIntValue()) < 0))) { if (!ipRange.isInvert()) { log.debug("Block IPRange selected for Blocked"); return true; } } else { if (ipRange.isInvert()) { log.debug("Block IPRange selected for Blocked"); return true; } } } } } return false; }
Source:
<code>public static JsonObject getVCAPService(JsonObject deploy) throws IOException { JsonObject services = getVCAPServices(deploy.get(VCAP_SERVICES)); JsonArray streamsServices = array(services, "streaming-analytics"); if (streamsServices == null || streamsServices.size() == 0) throw new IllegalStateException("No streaming-analytics services defined in VCAP_SERVICES"); String serviceName = jstring(deploy, SERVICE_NAME); if (serviceName == null) { <START> serviceName = System.getenv("SERVICE_NAME"); <END> } if (serviceName != null) serviceName = serviceName.trim(); if (serviceName == null || serviceName.isEmpty()) throw new IllegalStateException( "Streaming Analytics service name is not defined, please set configuration property: " + SERVICE_NAME); JsonObject service = null; for (JsonElement ja : streamsServices) { JsonObject possibleService = ja.getAsJsonObject(); if (serviceName.equals(possibleService.get("name").getAsString())) { service = possibleService; break; } } if (service == null) throw new IllegalStateException( "No streaming-analytics services defined in VCAP_SERVICES with name: " + serviceName); return service; }</code><technical_language>Needs match existing variable name</technical_language>

Target:
public static JsonObject getVCAPService(JsonObject deploy) throws IOException { JsonObject services = getVCAPServices(deploy.get(VCAP_SERVICES)); JsonArray streamsServices = array(services, "streaming-analytics"); if (streamsServices == null || streamsServices.size() == 0) throw new IllegalStateException("No streaming-analytics services defined in VCAP_SERVICES"); String serviceName = jstring(deploy, SERVICE_NAME); if (serviceName == null) { serviceName = System.getenv("STREAMING_ANALYTICS_SERVICE_NAME"); } if (serviceName != null) serviceName = serviceName.trim(); if (serviceName == null || serviceName.isEmpty()) throw new IllegalStateException( "Streaming Analytics service name is not defined, please set configuration property: " + SERVICE_NAME); JsonObject service = null; for (JsonElement ja : streamsServices) { JsonObject possibleService = ja.getAsJsonObject(); if (serviceName.equals(possibleService.get("name").getAsString())) { service = possibleService; break; } } if (service == null) throw new IllegalStateException( "No streaming-analytics services defined in VCAP_SERVICES with name: " + serviceName); return service; }
Source:
<code>public void search_shouldSearchForDiagnosisConceptsFromSpecifiedSets() throws Exception { <START> when(context.getLocale()).thenReturn(locale); <END> String queryString = "infection"; String diagnosisSetUuids = LUNG_DISEASE_DIAGNOSIS_SET_UUID; List<SimpleObject> conceptSearchResults = controller.search(context, uiUtils, emrApiProperties, emrConceptService, conceptService, queryString, diagnosisSetUuids, null, null); assertEquals(1, conceptSearchResults.size()); assertThat((String) ((SimpleObject) conceptSearchResults.get(0).get("conceptName")).get("name"), is("Tuberculosis infection")); }</code><technical_language>put this in setup method</technical_language>

Target:
public void search_shouldSearchForDiagnosisConceptsFromSpecifiedSets() throws Exception { controller.search(context, uiUtils, emrApiProperties, emrConceptService, conceptService, queryString, "1st_diagnosis_set_uuid,2nd_diagnosis_set_uuid", null, null); verify(emrApiProperties, never()).getDiagnosisSets(); }
Source:
<code>private void checkGitModules(ProgressMonitor pm, FsckError errors) throws IOException { for (GitmoduleEntry entry : <START> objChecker.getGitsubmodules()) <END> { AnyObjectId blobId = entry.getBlobId(); ObjectLoader blob = objdb.open(blobId, Constants.OBJ_BLOB); try { SubmoduleValidator.assertValidGitModulesFile( new String(blob.getBytes(), UTF_8)); } catch (IOException e) { CorruptObject co = new FsckError.CorruptObject( blobId.toObjectId(), Constants.OBJ_BLOB, ObjectChecker.ErrorType.INVALID_GIT_MODULES); errors.getCorruptObjects().add(co); } } }</code><technical_language>if ObjectChecker is reused for multiple check() calls? E.g. this clear objChecker.getGitsubmodules() starts finishes</technical_language>

Target:
private void checkGitModules(ProgressMonitor pm, FsckError errors) throws IOException { pm.beginTask(JGitText.get().validatingGitModules, objChecker.getGitsubmodules().size()); for (GitmoduleEntry entry : objChecker.getGitsubmodules()) { AnyObjectId blobId = entry.getBlobId(); ObjectLoader blob = objdb.open(blobId, Constants.OBJ_BLOB); try { SubmoduleValidator.assertValidGitModulesFile( new String(blob.getBytes(), UTF_8)); } catch (SubmoduleValidationException e) { CorruptObject co = new FsckError.CorruptObject( blobId.toObjectId(), Constants.OBJ_BLOB, exceptionToFsckError(e.getSubdmoduleError())); errors.getCorruptObjects().add(co); } pm.update(1); } pm.endTask(); }
Source:
<code>private static List<SegmentPruner> sortSegmentPruners(List<SegmentPruner> pruners) { List<SegmentPruner> sortedPruners = new ArrayList<>(); for (SegmentPruner pruner : pruners) { if (pruner instanceof TimeRangeSegmentPruner) { sortedPruners.add(pruner); } } for (SegmentPruner pruner: pruners) { <START> if (!(pruner instanceof TimeRangeSegmentPruner)) { <END> sortedPruners.add(pruner); } } return sortedPruners; }</code><technical_language>This check is needed right</technical_language>

Target:
private static List<SegmentPruner> sortSegmentPruners(List<SegmentPruner> pruners) { List<SegmentPruner> sortedPruners = new ArrayList<>(); for (SegmentPruner pruner : pruners) { if (pruner instanceof TimeSegmentPruner) { sortedPruners.add(pruner); } } for (SegmentPruner pruner: pruners) { if (!(pruner instanceof TimeSegmentPruner)) { sortedPruners.add(pruner); } } return sortedPruners; }
Source:
<code>AutoCloseable enter() { if (!lock.tryLock()) { throw new IllegalStateException(); } return () -> { <START> if (!lock.tryLock()) <END> throw new IllegalStateException(); }; }</code><technical_language>Release lock</technical_language>

Target:
AutoCloseable enter() { if(!lock.compareAndSet(false, true)) throw new IllegalStateException(); return new AutoCloseable() { @Override public void close() throws Exception { if(!lock.compareAndSet(true, false)) throw new IllegalStateException(); } }; }
Source:
<code>public BatchConfig(String tableNameWithType, Map<String, String> batchConfigsMap) { _batchConfigMap = batchConfigsMap; _tableNameWithType = tableNameWithType; _inputDirURI = batchConfigsMap.get(BatchConfigProperties.INPUT_DIR_URI); <START> Preconditions.checkState(_inputDirURI != null, "Property: %s cannot be null", BatchConfigProperties.INPUT_DIR_URI); <END> _outputDirURI = batchConfigsMap.get(BatchConfigProperties.OUTPUT_DIR_URI); Preconditions.checkState(_outputDirURI != null, "Property: %s cannot be null", BatchConfigProperties.OUTPUT_DIR_URI); _inputFsClassName = batchConfigsMap.get(BatchConfigProperties.INPUT_FS_CLASS); _outputFsClassName = batchConfigsMap.get(BatchConfigProperties.OUTPUT_FS_CLASS); String inputFormat = batchConfigsMap.get(BatchConfigProperties.INPUT_FORMAT); Preconditions.checkState(inputFormat != null, "Property: %s cannot be null", BatchConfigProperties.INPUT_FORMAT); _inputFormat = FileFormat.valueOf(inputFormat.toUpperCase()); _recordReaderClassName = batchConfigsMap.get(BatchConfigProperties.RECORD_READER_CLASS); _recordReaderConfigClassName = batchConfigsMap.get(BatchConfigProperties.RECORD_READER_CONFIG_CLASS); for (Map.Entry<String, String> entry : batchConfigsMap.entrySet()) { String key = entry.getKey(); if (key.startsWith(BatchConfigProperties.INPUT_FS_PROP_PREFIX)) { _inputFsProps.put(key, entry.getValue()); } if (key.startsWith(BatchConfigProperties.OUTPUT_FS_PROP_PREFIX)) { _outputFsProps.put(key, entry.getValue()); } if (key.startsWith(BatchConfigProperties.RECORD_READER_PROP_PREFIX)) { _recordReaderProps.put(key, entry.getValue()); } } }</code><technical_language>discussed offline, please relax this requirement of input output dir, user pass in BatchConfig null input output for file uploads</technical_language>

Target:
public BatchConfig(String tableNameWithType, Map<String, String> batchConfigsMap) { _batchConfigMap = batchConfigsMap; _tableNameWithType = tableNameWithType; String inputFormat = batchConfigsMap.get(BatchConfigProperties.INPUT_FORMAT); Preconditions.checkState(inputFormat != null, "Property: %s cannot be null", BatchConfigProperties.INPUT_FORMAT); _inputFormat = FileFormat.valueOf(inputFormat.toUpperCase()); _inputDirURI = batchConfigsMap.get(BatchConfigProperties.INPUT_DIR_URI); _inputFsClassName = batchConfigsMap.get(BatchConfigProperties.INPUT_FS_CLASS); _outputDirURI = batchConfigsMap.get(BatchConfigProperties.OUTPUT_DIR_URI); _outputFsClassName = batchConfigsMap.get(BatchConfigProperties.OUTPUT_FS_CLASS); _recordReaderClassName = batchConfigsMap.get(BatchConfigProperties.RECORD_READER_CLASS); _recordReaderConfigClassName = batchConfigsMap.get(BatchConfigProperties.RECORD_READER_CONFIG_CLASS); for (Map.Entry<String, String> entry : batchConfigsMap.entrySet()) { String key = entry.getKey(); if (key.startsWith(BatchConfigProperties.INPUT_FS_PROP_PREFIX)) { _inputFsProps.put(key, entry.getValue()); } if (key.startsWith(BatchConfigProperties.OUTPUT_FS_PROP_PREFIX)) { _outputFsProps.put(key, entry.getValue()); } if (key.startsWith(BatchConfigProperties.RECORD_READER_PROP_PREFIX)) { _recordReaderProps.put(key, entry.getValue()); } } }
Source:
<code><START> public List<String> columnLabelsList() { return Collections.unmodifiableList(columnLabels); } <END></code><technical_language>docs, a list columnLabelIndices.keySet() need a new member</technical_language>

Target:
public List<String> columnLabelsList() { return Collections.unmodifiableList(new ArrayList<String>(columnLabelIndices.keySet())); }
Source:
<code>private String formatTableList(List<String> items, ListMultimap<String, String> issueToFilesMap) { if (items.isEmpty()) { return ""; } String caption = "Issues list"; StringBuilder sb = new StringBuilder(); sb.append(NEW_LINE).append(NEW_LINE); sb.append("| ").append(caption).append(" |").append(NEW_LINE); sb.append("|"); sb.append(repeatString(caption.length() + 2, "-")); sb.append("|"); sb.append(NEW_LINE); for (String item : items) { sb.append("| ").append(item).append(" |").append(NEW_LINE); if (this.includeFilesInOverview > 0 && issueToFilesMap.containsKey(item)) { String files = String.join(", ", issueToFilesMap.get(item)); <START> sb.append("| :arrow_right_hook: *Files: ").append(files).append("* |").append(NEW_LINE); <END> } } return sb.toString(); }</code><technical_language>emoticon. more neutral, a tab</technical_language>

Target:
private String formatTableList(List<String> items, ListMultimap<String, String> issueToFilesMap) { if (items.isEmpty()) { return ""; } String caption = "Issues list"; StringBuilder sb = new StringBuilder(); sb.append(NEW_LINE).append(NEW_LINE); sb.append("| ").append(caption).append(" |").append(NEW_LINE); sb.append("|"); sb.append(repeatString(caption.length() + 2, "-")); sb.append("|"); sb.append(NEW_LINE); for (String item : items) { sb.append("| ").append(item).append(" |").append(NEW_LINE); if (this.includeFilesInOverview > 0 && issueToFilesMap.containsKey(item)) { String files = String.join(", ", issueToFilesMap.get(item)); sb.append("| &nbsp;&nbsp; *Files: ").append(files).append("* |").append(NEW_LINE); } } return sb.toString(); }
Source:
<code><START> private String createIntermediateTableForeignKeyStepId() { <END> if (DbConnectionFactory.isMySql()) { return MYSQL_CREATE_INTERMEDIATE_TABLE_FOREIGN_KEYS_STEP_ID; } else if (DbConnectionFactory.isPostgres()) { return POSTGRES_CREATE_INTERMEDIATE_TABLE_FOREIGN_KEYS_STEP_ID; } else if (DbConnectionFactory.isMsSql()) { return MSSQL_CREATE_INTERMEDIATE_TABLE_FOREIGN_KEYS_STEP_ID; } else if (DbConnectionFactory.isOracle()) { return ORACLE_CREATE_INTERMEDIATE_TABLE_FOREIGN_KEYS_STEP_ID; } return H2_CREATE_INTERMEDIATE_TABLE_FOREIGN_KEYS_STEP_ID; }</code><technical_language>![MAJOR](<LINK_0> 'Severity: MAJOR') Reduce number of returns of this method 5, maximum allowed 3. [![rule](<LINK_1>](<LINK_2></technical_language>

Target:
private String createIntermediateTableForeignKeyStepId() { String sql = H2_CREATE_INTERMEDIATE_TABLE_FOREIGN_KEYS_STEP_ID; if (DbConnectionFactory.isMySql()) { sql = MYSQL_CREATE_INTERMEDIATE_TABLE_FOREIGN_KEYS_STEP_ID; } else if (DbConnectionFactory.isPostgres()) { sql = POSTGRES_CREATE_INTERMEDIATE_TABLE_FOREIGN_KEYS_STEP_ID; } else if (DbConnectionFactory.isMsSql()) { sql = MSSQL_CREATE_INTERMEDIATE_TABLE_FOREIGN_KEYS_STEP_ID; } else if (DbConnectionFactory.isOracle()) { sql = ORACLE_CREATE_INTERMEDIATE_TABLE_FOREIGN_KEYS_STEP_ID; } return sql; }
Source:
<code>public ValidationResult isMacAssignableValidator() { boolean allowDupMacs = macPool.isDuplicateMacAddressesAllowed(); boolean illegalDuplicateMacUsage = !allowDupMacs && macPool.isMacInUse(macAddress); if (illegalDuplicateMacUsage) { Optional<VM> optionalVm = macsUsedAcrossWholeSystem.getVmUsingMac(macPool.getId(), macAddress); if (!optionalVm.isPresent()) { optionalVm = macsUsedAcrossWholeSystem.getSnapshotUsingMac(macPool.getId(), macAddress); } return new ValidationResult(EngineMessage.NETWORK_MAC_ADDRESS_IN_USE, ReplacementUtils.createSetVariableString(VAR_MAC_IN_USE, macAddress), ReplacementUtils.createSetVariableString(VAR_IN_USE_BY, <START> optionalVm.isPresent() <END> ? optionalVm.get().getName() : "")); } return ValidationResult.VALID; }</code><technical_language>In case VM is present? If notable find VM for MAC</technical_language>

Target:
public ValidationResult isMacAssignableValidator() { boolean allowDupMacs = macPool.isDuplicateMacAddressesAllowed(); boolean illegalDuplicateMacUsage = !allowDupMacs && macPool.isMacInUse(macAddress); if (illegalDuplicateMacUsage) { Optional<VM> optionalVm = macsUsedAcrossWholeSystem.getVmUsingMac(macPool.getId(), macAddress); if (!optionalVm.isPresent()) { optionalVm = macsUsedAcrossWholeSystem.getSnapshotUsingMac(macPool.getId(), macAddress); } return new ValidationResult(EngineMessage.NETWORK_MAC_ADDRESS_IN_USE, ReplacementUtils.createSetVariableString(VAR_MAC_ADDRESS, macAddress), ReplacementUtils.createSetVariableString(VAR_VM_NAME, optionalVm.isPresent() ? optionalVm.get().getName() : "")); } return ValidationResult.VALID; }
Source:
<code>public QueryImpl[] getPartitionArray() { <START> return (QueryImpl[]) partitions.values().toArray(); <END> }</code><technical_language>i in a lot of places "QueryImpl" is used, "Query" is sufficient, interface is sufficient. "Query" code more flexible</technical_language>

Target:
public Query[] getPartitionArray() { return (Query[]) partitions.values().toArray(); }
Source:
<code><START> protected void startReplications() { <END> if (mReplicationPolicyManager != null) { if (mWifiLock == null) { WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); mWifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "ReplicationService"); } if(!mWifiLock.isHeld()){ mWifiLock.acquire(); } mReplicationPolicyManager.startReplications(); } }</code><technical_language>this run thread? If not, lose reference a held wifi lock</technical_language>

Target:
protected void startReplications() { if (mReplicationPolicyManager != null) { synchronized (mWifiLock) { if (!mWifiLock.isHeld()) { mWifiLock.acquire(); } } mReplicationPolicyManager.startReplications(); } }
Source:
<code>private Optional<Account> readAccountFromResponse(Response response) { JsonNode responseEntity = response.readEntity(JsonNode.class); String accountId = responseEntity.get("account_id").asText(); <START> MDC.put(GATEWAY_ACCOUNT_ID, accountId); <END> String tokenType = Optional.ofNullable(responseEntity.get("token_type")) .map(JsonNode::asText).orElse(CARD.toString()); TokenPaymentType tokenPaymentType = fromString(tokenType); return Optional.of(new Account(accountId, tokenPaymentType)); }</code><technical_language>This get invoked time. AccountAuthenticator result is cached Dropwizard, AuthFilter invoke AccountAuthenticator. readAccountFromResponse if object exists in cache (but of behaviour) <LINK_0> create MdcFilter a ContainerRequestFilter (which set invoked Authentication) put clear gateway_account_id</technical_language>

Target:
private Optional<Account> readAccountFromResponse(Response response) { JsonNode responseEntity = response.readEntity(JsonNode.class); String accountId = responseEntity.get("account_id").asText(); String tokenType = Optional.ofNullable(responseEntity.get("token_type")) .map(JsonNode::asText).orElse(CARD.toString()); TokenPaymentType tokenPaymentType = fromString(tokenType); return Optional.of(new Account(accountId, tokenPaymentType)); }
Source:
<code>public Map<String, Object> getComponentConfiguration() { Map<String, Object> configuration = super.getComponentConfiguration(); if (configuration == null) { configuration = new HashMap<>(); } String configKeyPrefix = "config."; configuration.put(configKeyPrefix + "topics", getTopicsString()); configuration.put(configKeyPrefix + "groupid", kafkaSpoutConfig.getConsumerGroupId()); for (Entry<String, Object> conf: kafkaSpoutConfig.getKafkaProps().entrySet()) { <START> if (conf.getValue() != null && isPrimitiveOrWrapper(conf.getValue().getClass())) { <END> configuration.put(configKeyPrefix + conf.getKey(), conf.getValue()); } } return configuration; }</code><technical_language>nit: leave a log message for dropped configuration keys here. DEBUG is fine I guess for storm-kafka-monitor</technical_language>

Target:
public Map<String, Object> getComponentConfiguration() { Map<String, Object> configuration = super.getComponentConfiguration(); if (configuration == null) { configuration = new HashMap<>(); } String configKeyPrefix = "config."; configuration.put(configKeyPrefix + "topics", getTopicsString()); configuration.put(configKeyPrefix + "groupid", kafkaSpoutConfig.getConsumerGroupId()); for (Entry<String, Object> conf: kafkaSpoutConfig.getKafkaProps().entrySet()) { if (conf.getValue() != null && isPrimitiveOrWrapper(conf.getValue().getClass())) { configuration.put(configKeyPrefix + conf.getKey(), conf.getValue()); } else { LOG.debug("Dropping Kafka prop '{}' from component configuration", conf.getKey()); } } return configuration; }
Source:
<code>private String attributeKeyFrom(String key) { if (key.startsWith(EXTENDED_ATTRIBUTE_PREFIX)) { <START> key = key.replace(EXTENDED_ATTRIBUTE_PREFIX, ""); <END> } String formattedAttribute = Stream.of(key.split("\\.")) .map(part -> part.replaceAll("-", " ")) .collect(Collectors.joining(" ")); return WordUtils.capitalize(formattedAttribute); }</code><technical_language>strip EXTENDED_ATTRIBUTE_PREFIX.length() characters unwittingly modify attributes. For example ext.next.attribute -> nattribute</technical_language>

Target:
private String attributeKeyFrom(String key) { if (key.startsWith(EXTENDED_ATTRIBUTE_PREFIX)) { key = key.replaceFirst(EXTENDED_ATTRIBUTE_PREFIX, ""); } String formattedAttribute = Stream.of(key.split("\\.")) .map(part -> part.replaceAll("-", " ")) .collect(Collectors.joining(" ")); return WordUtils.capitalize(formattedAttribute); }
Source:
<code>private NodePair findPair(T value) { while (true) { <START> boolean list_is_clean = true; <END> Node crnt = head.getReference(), prev = null; AtomicMarkableReference<Node> ref = head; while (null != crnt) { if (ref.isMarked()) { list_is_clean = false; AtomicMarkableReference<Node> crnt_next = crnt.next; if (ref.compareAndSet(crnt, crnt_next.getReference(), true, crnt_next.isMarked())) { crnt = crnt_next.getReference(); continue; } } if (crnt.value.compareTo(value) <= 0 && !ref.isMarked()) return new NodePair(crnt, prev); ref = crnt.next; prev = crnt; crnt = crnt.next.getReference(); } if (list_is_clean) return new NodePair(null, prev); } }</code><technical_language>listIsClean</technical_language>

Target:
private NodePair findPair(T value) { again: while (true) { Node crnt = head.getReference(), prev = null; AtomicMarkableReference<Node> ref = head; while (null != crnt) { if (ref.isMarked()) { AtomicMarkableReference<Node> crnt_next = crnt.next; if (ref.compareAndSet(crnt, crnt_next.getReference(), true, crnt_next.isMarked())) { crnt = crnt_next.getReference(); continue; } else continue again; } if (crnt.value.compareTo(value) <= 0 && !ref.isMarked()) return new NodePair(crnt, prev); ref = crnt.next; prev = crnt; crnt = crnt.next.getReference(); } return new NodePair(null, prev); } }
Source:
<code>public Path getPath(String first, String... more) { if (Strings.isEmpty(first)) { return new BridgePath(vfs.root(), this); } <START> return null; <END> }</code><technical_language>is this correct</technical_language>

Target:
public Path getPath(String first, String... more) { if (Strings.isEmpty(first)) { return new BridgePath(virtualFileSystem.root(), this); } throw new IllegalArgumentException(Strings.apply( "A non root directory was requested in BridgeFileSystem.getPath: %s - %s", first, Strings.join(",", more))); }
Source:
<code>private void deleteProcessTempFiles(IProcess process) { if <START> (process.getAttribute(ATTR_LAUNCH_TEMP_FILES) == <END> null) { return; } Arrays.stream(process.getAttribute(ATTR_LAUNCH_TEMP_FILES).split(File.pathSeparator)).map(path -> new File(path)).forEach(file -> file.delete()); }</code><technical_language>Please extract local variable</technical_language>

Target:
private void deleteProcessTempFiles(IProcess process) { String tempFiles = process.getAttribute(ATTR_LAUNCH_TEMP_FILES); if (tempFiles == null) { return; } Arrays.stream(tempFiles.split(File.pathSeparator)).map(path -> new File(path)).forEach(file -> file.delete()); }
Source:
<code>public void init(ProcessingContext context, ProcessingComponentConfiguration config) throws IOException { super.init(context, config); slingRequest = context.getRequest(); String[] selectors = slingRequest.getRequestPathInfo().getSelectors(); if (selectors.length > 0) { <START> enabled = Arrays.asList(selectors).contains(SELECTOR); <END> if (enabled) { log.info("Inlining Stylesheet references for {}", slingRequest.getRequestURL().toString()); } } }</code><technical_language>this is necessary. this in a separate pipeline triggered selector add this existing newsletter pipeline (default is in /libs/mcm/config/rewriter/campaign-link-rewrite)</technical_language>

Target:
public void init(ProcessingContext context, ProcessingComponentConfiguration config) throws IOException { super.init(context, config); slingRequest = context.getRequest(); log.debug("Inlining Stylesheet references for {}", slingRequest.getRequestURL().toString()); }
Source:
<code>private static void loadExtensions(ModuleService moduleService, Map<String, Object> argMap) { ExtensionsManager extensionsManager = new ExtensionsManager(); Map<String, ExtensionProxy> proxies = moduleService.getContext().get(Base.GlobalContextKeys.EXTENSIONS_MAP); List<File> files; Object extensionFile = argMap.get("extension-file"); if(extensionFile != null) { <START> if(extensionFile instanceof List) { <END> files = (List<File>) argMap.get("extension-file"); } else { files = new ArrayList<>(); files.add((File)extensionFile); } } else { files = listFiles((String)argMap.get("extensions-dir"), "properties"); } for(File f : files) { String proxy = extensionsManager.load(f); proxies.put(proxy, extensionsManager.getExtensionByName(proxy)); } for(String proxy : proxies.keySet()) { extensionsManager.initialize(proxy); } }</code><technical_language>easier mark argument List (multi-value) not, get single type reduce logic</technical_language>

Target:
private static void loadExtensions(ModuleService moduleService, Map<String, Object> argMap) { ExtensionsManager extensionsManager = new ExtensionsManager(); Map<String, ExtensionProxy> proxies = moduleService.getContext().get(ModuleService.EXTENSIONS_MAP); List<File> files = (List<File>)argMap.get("extension-file"); if(files == null) { files = listFiles((String)argMap.get("extensions-dir"), "properties"); } for(File f : files) { String proxy = extensionsManager.load(f); proxies.put(proxy, extensionsManager.getExtensionByName(proxy)); } for(String proxy : proxies.keySet()) { extensionsManager.initialize(proxy); } }
Source:
<code>void performSubmit(Request request) { BitmapHunter hunter = hunterMap.get(request.getKey()); if (hunter == null) { hunter = BitmapHunter.forRequest(context, request.getPicasso(), this, request, downloader); <START> hunter.attach(request); <END> Bitmap cache = loadFromCache(request); if (cache != null) { hunter.loadedFrom = MEMORY; performComplete(hunter); return; } hunterMap.put(request.getKey(), hunter); hunter.future = service.submit(hunter); } else { hunter.attach(request); } }</code><technical_language>Calling forRequest attach immediately is strange..</technical_language>

Target:
void performSubmit(Request request) { BitmapHunter hunter = hunterMap.get(request.getKey()); if (hunter != null) { hunter.attach(request); return; } hunter = BitmapHunter.forRequest(context, request.getPicasso(), this, request, downloader); Bitmap cached = loadFromCache(request); if (cached != null) { hunter.loadedFrom = MEMORY; hunter.result = cached; performComplete(hunter); return; } hunterMap.put(request.getKey(), hunter); hunter.future = service.submit(hunter); }
Source:
<code>private void initBreakpointOrganizers(IMemento memento) { if (memento != null) { IMemento node = memento.getChild(IDebugUIConstants.EXTENSION_POINT_BREAKPOINT_ORGANIZERS); if (node == null) { fOrganizers = null; } else { String value = node.getString(KEY_VALUE); if (value != null) { BreakpointOrganizerManager manager = BreakpointOrganizerManager.getDefault(); List<IBreakpointOrganizer> organziers = new ArrayList<>(); for (String id : value.split(",")) { IBreakpointOrganizer organizer = manager.getOrganizer(id); if (organizer != null) { organziers.add(organizer); } } fOrganizers = organziers.toArray(new IBreakpointOrganizer[organziers.size()]); for (IBreakpointOrganizer <START> fOrganizer : <END> organziers) { fOrganizer.addPropertyChangeListener(this); } } } } }</code><technical_language>rename organizer</technical_language>

Target:
private void initBreakpointOrganizers(IMemento memento) { if (memento != null) { IMemento node = memento.getChild(IDebugUIConstants.EXTENSION_POINT_BREAKPOINT_ORGANIZERS); if (node == null) { fOrganizers = null; } else { String value = node.getString(KEY_VALUE); if (value != null) { BreakpointOrganizerManager manager = BreakpointOrganizerManager.getDefault(); List<IBreakpointOrganizer> organziers = new ArrayList<>(); for (String id : value.split(",")) { IBreakpointOrganizer organizer = manager.getOrganizer(id); if (organizer != null) { organziers.add(organizer); } } fOrganizers = organziers.toArray(new IBreakpointOrganizer[organziers.size()]); for (IBreakpointOrganizer organizer : organziers) { organizer.addPropertyChangeListener(this); } } } } }
Source:
<code>public ApiResponse handleApiView(String name, JSONObject params) throws ApiException { ApiResponse result; switch (name) { case VIEW_RULE_CONFIG_VALUE: RuleConfig rc = extension.getRuleConfig(params.getString(PARAM_KEY)); if (rc != null) { result = new ApiResponseElement(name, rc.getValue()); } else { <START> throw new ApiException(ApiException.Type.DOES_NOT_EXIST); <END> } break; case VIEW_ALL_RULE_CONFIGS: List<RuleConfig> allRules = extension.getAllRuleConfigs(); ApiResponseList resultList = new ApiResponseList(name); for (RuleConfig rc2 : allRules) { Map<String, String> map = new HashMap<>(); map.put("key", String.valueOf(rc2.getKey())); map.put("defaultValue", rc2.getDefaultValue()); map.put("value", String.valueOf(rc2.getValue())); if (Constant.messages.containsKey(rc2.getKey())) { map.put("description", Constant.messages.getString(rc2.getKey())); } resultList.addItem(new ApiResponseSet("ruleConfig", map)); } result = resultList; break; default: throw new ApiException(ApiException.Type.BAD_VIEW); } return result; }</code><technical_language>PARAM_KEY detail of exception</technical_language>

Target:
public ApiResponse handleApiView(String name, JSONObject params) throws ApiException { ApiResponse result; switch (name) { case VIEW_RULE_CONFIG_VALUE: RuleConfig rc = extension.getRuleConfig(params.getString(PARAM_KEY)); if (rc != null) { result = new ApiResponseElement(name, rc.getValue()); } else { throw new ApiException(ApiException.Type.DOES_NOT_EXIST, PARAM_KEY); } break; case VIEW_ALL_RULE_CONFIGS: List<RuleConfig> allRules = extension.getAllRuleConfigs(); ApiResponseList resultList = new ApiResponseList(name); for (RuleConfig rc2 : allRules) { Map<String, String> map = new HashMap<>(); map.put("key", String.valueOf(rc2.getKey())); map.put("defaultValue", rc2.getDefaultValue()); map.put("value", String.valueOf(rc2.getValue())); if (Constant.messages.containsKey(rc2.getKey())) { map.put("description", Constant.messages.getString(rc2.getKey())); } resultList.addItem(new ApiResponseSet("ruleConfig", map)); } result = resultList; break; default: throw new ApiException(ApiException.Type.BAD_VIEW); } return result; }
Source:
<code>protected void assertComponentModelUsesDefaultOnSameValue(AbstractWComponent wComponent, String method, Object userContextValue, Object setterArgs[]) { wComponent.setLocked(false); invokeSetMethod(wComponent, method, userContextValue, setterArgs); ComponentModel shared = wComponent.getDefaultModel(); wComponent.setLocked(true); <START> <END> ComponentModel model = wComponent.getOrCreateComponentModel(); org.junit.Assert.assertSame(model, shared); setActiveContext(createUIContext()); invokeSetMethod(wComponent, method, userContextValue, setterArgs); model = wComponent.getOrCreateComponentModel(); org.junit.Assert.assertEquals(shared, model); resetContext(); }</code><technical_language>For lines below..... is "active context" (I assume isnt), calling getOrCreateComponentModel return default model (ie shared). Is lines testing for</technical_language>

Target:
private void assertComponentModelUsesDefaultOnSameValue(AbstractWComponent wComponent, String method, Object userContextValue, Object setterArgs[]) { wComponent.setLocked(false); invokeSetMethod(wComponent, method, userContextValue, setterArgs); ComponentModel shared = wComponent.getDefaultModel(); wComponent.setLocked(true); ComponentModel model = wComponent.getComponentModel(); org.junit.Assert.assertSame(model, shared); setActiveContext(createUIContext()); invokeSetMethod(wComponent, method, userContextValue, setterArgs); model = wComponent.getComponentModel(); org.junit.Assert.assertSame(shared, model); resetContext(); }
Source:
<code>public void removeSubscriptions(String id) { final String ecql = queryId(id); LOCK.lock(); try { persistentStore.delete(SubscriptionsPersistentStore.SUBSCRIPTIONS_TYPE, ecql, 0, 1000); } catch (PersistenceException e) { <START> LOGGER.warn("Could not delete subscriptions for query {}", ecql, e); <END> } finally { LOCK.unlock(); } }</code><technical_language>stack traces logged debug level warning level</technical_language>

Target:
public void removeSubscriptions(String id) { final String ecql = queryId(id); LOCK.lock(); try { persistentStore.delete(SUBSCRIPTIONS_TYPE, ecql, START_INDEX, PAGE_SIZE); } catch (PersistenceException e) { LOGGER.debug("Could not delete subscriptions for query {}", ecql, e); } finally { LOCK.unlock(); } }
Source:
<code>private TypeVariableName(String name, List<TypeName> bounds, List<AnnotationSpec> annotations) { super(annotations); this.name = checkNotNull(name, "name == null"); this.bounds = bounds; <START> this.boundsHashCode = bounds.hashCode(); <END> for (TypeName bound : this.bounds) { checkArgument(!bound.isPrimitive() && bound != VOID, "invalid bound: %s", bound); } }</code><technical_language>is this problematic for cycle detection</technical_language>

Target:
private TypeVariableName(String name, List<TypeName> bounds, List<AnnotationSpec> annotations) { super(annotations); this.name = checkNotNull(name, "name == null"); this.bounds = bounds; this.hashCode = name.hashCode() ^ bounds.hashCode(); for (TypeName bound : this.bounds) { checkArgument(!bound.isPrimitive() && bound != VOID, "invalid bound: %s", bound); } }
Source:
<code>public void setUpAuthorization() { if (!isHostAvailable()) { showError(hostEdit, R.string.error_empty); return; } if (isPortAvailable() && !isPortCorrect()) { showError(portEdit, R.string.error_authorization_port); return; } <START> Intent login_activity = new Intent(getApplicationContext(), LoginActivity.class); <END> login_activity.putExtra("host", getHost().toString()); login_activity.putExtra("port", getPort().toString()); startActivity(login_activity); finish(); }</code><technical_language>is Intents factory-like class specifically for this. please camel case for variables declaration</technical_language>

Target:
public void setUpAuthorization() { if (!isHostAvailable()) { showError(hostEdit, R.string.error_empty); return; } if (isPortAvailable() && !isPortCorrect()) { showError(portEdit, R.string.error_authorization_port); return; } setUpBackendAuthorization(); }
Source:
<code>@Override public SqlMonotonicity getMonotonicity(SqlOperatorBinding call) { if (call.getOperandCount() == 3) { final SqlMonotonicity mono0 = call.getOperandMonotonicity(0); if ((mono0 != SqlMonotonicity.NOT_MONOTONIC) && call.getOperandMonotonicity(1) == SqlMonotonicity.CONSTANT && ((call.isOperandNull(1, true)) || call.getOperandLiteralValue(1, BigDecimal.class) <START> .equals(BigDecimal.ZERO)) <END> && call.getOperandMonotonicity(2) == SqlMonotonicity.CONSTANT) { return mono0.unstrict(); } } return super.getMonotonicity(call); }</code><technical_language>I mono0 is operand1 is null, means substring('abc', null) returns null, breaks monotonicity of operand0</technical_language>

Target:
@Override public SqlMonotonicity getMonotonicity(SqlOperatorBinding call) { if (call.getOperandCount() == 3) { final SqlMonotonicity mono0 = call.getOperandMonotonicity(0); if ((mono0 != SqlMonotonicity.NOT_MONOTONIC) && call.getOperandMonotonicity(1) == SqlMonotonicity.CONSTANT && call.getOperandMonotonicity(2) == SqlMonotonicity.CONSTANT) { if (call.isOperandNull(1, true)) { return SqlMonotonicity.CONSTANT; } if (call.getOperandLiteralValue(1, BigDecimal.class) .equals(BigDecimal.ZERO)) { return mono0.unstrict(); } } } return super.getMonotonicity(call); }
Source:
<code>public void setUp() throws Exception { super.setUp(); loc = (JcloudsLocation) mgmt.getLocationRegistry().resolve(LOCATION_SPEC); <START> executor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool()); <END> }</code><technical_language>delete executor (and tearDown method well), used</technical_language>

Target:
public void setUp() throws Exception { super.setUp(); loc = (JcloudsLocation) mgmt.getLocationRegistry().resolve(LOCATION_SPEC); }
Source:
<code>public static ApiTemplate fromJSON(JsonNode json) { ApiTemplate template = new ApiTemplate(); final JsonNode params = json.get("params"); for (String paramName: <START> IteratorUtils.asIterable(params.fieldNames())) <END> { if (template.fixedParams.containsKey(paramName) || template.inputVars.containsKey(paramName)) { throw new IllegalArgumentException( "Repeated input parameter " + paramName); } JsonNode value = params.get(paramName); if (value.isValueNode()) { template.fixedParams.put(paramName, value.asText()); continue; } if (value.has("default")) { template.inputVars.put(paramName, value.get("default").asText()); } else { template.inputVars.put(paramName, null); } } final JsonNode output = json.get("output"); template.items = output.get("items").asText(); final JsonNode vars = output.get("vars"); for (String paramName: IteratorUtils.asIterable(vars.fieldNames())) { if (template.inputVars.containsKey(paramName)) { throw new IllegalArgumentException("Parameter " + paramName + " declared as both input and output"); } template.outputVars.put(paramName, vars.get(paramName).asText()); } return template; }</code><technical_language>iterate iterator: for (Iterator<String> = params.fieldNames(); it.hasNext(); ) { String paramName = it.next(); } While I agree this syntax is uglier, is worth introduce a new dependency commons-collections for this. Note new forEachRemaining() method used: params.fieldNames().forEachRemaining(paramName -> {...});</technical_language>

Target:
public static ApiTemplate fromJSON(JsonNode json) { ApiTemplate template = new ApiTemplate(); final JsonNode params = json.get("params"); Preconditions.checkNotNull(params, "Missing params node"); params.fieldNames().forEachRemaining(paramName -> { if (template.fixedParams.containsKey(paramName) || template.inputVars.containsKey(paramName)) { throw new IllegalArgumentException( "Repeated input parameter " + paramName); } JsonNode value = params.get(paramName); if (value.isValueNode()) { template.fixedParams.put(paramName, value.asText()); return; } if (value.has("default")) { template.inputVars.put(paramName, value.get("default").asText()); } else { template.inputVars.put(paramName, null); } }); final JsonNode output = json.get("output"); Preconditions.checkNotNull(params, "Missing output node"); template.items = output.get("items").asText(); final JsonNode vars = output.get("vars"); Preconditions.checkNotNull(vars, "Missing vars node"); vars.fieldNames().forEachRemaining(paramName -> { if (template.inputVars.containsKey(paramName)) { throw new IllegalArgumentException("Parameter " + paramName + " declared as both input and output"); } template.outputVars.put(paramName, vars.get(paramName).asText()); }); return template; }
Source:
<code>public SanctuaryBlade(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}"); this.subtype.add(SubType.EQUIPMENT); <START> GainProtectionFromColorAttachedEffect protectionEffect = new GainProtectionFromColorAttachedEffect(Duration.WhileOnBattlefield); <END> this.addAbility(new AttachedToCreatureTriggeredAbility(protectionEffect, false)); Effect boostEffect = new BoostEquippedEffect(2, 0); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, boostEffect)); this.addAbility(new EquipAbility(Outcome.BoostCreature, new GenericManaCost(3))); }</code><technical_language>GainAbilityAttachedEffect, ProtectionChosenColorSourceEffect ChooseColorEffect. ProtectionChosenColorAttachedEffect. existed classes possible</technical_language>

Target:
public SanctuaryBlade(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}"); this.subtype.add(SubType.EQUIPMENT); this.addAbility(new AttachedToCreatureSourceTriggeredAbility(new ChooseColorEffect(Outcome.Benefit), false)); Effect boostEffect = new BoostEquippedEffect(2, 0); boostEffect.concatBy("."); SimpleStaticAbility ability = new SimpleStaticAbility(Zone.BATTLEFIELD, boostEffect); ProtectionChosenColorAttachedEffect protectionEfect = new ProtectionChosenColorAttachedEffect(false); protectionEfect.setText("and has protection from the last chosen color."); ability.addEffect(protectionEfect); this.addAbility(ability); this.addAbility(new EquipAbility(Outcome.BoostCreature, new GenericManaCost(3))); }
Source:
<code>public JSONArray getCascadedJSONRules() { InputStream is = null; BufferedReader bufferedReader = null; try { WMSLayerInfo wmsLayerInfo = (WMSLayerInfo) getLayerInfo().getResource(); StyleInfo defaultRemoteStyle = getLayerInfo().getDefaultStyle(); if (defaultRemoteStyle.getName().isEmpty() || defaultRemoteStyle.getLegend() == null) return null; HTTPClient client = wmsLayerInfo.getStore().getWebMapServer(null).getHTTPClient(); HTTPResponse jsonResponse = client.get(new URL(super.getLegendInfo().getOnlineResource())); is = jsonResponse.getResponseStream(); bufferedReader = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); StringBuilder sb = new StringBuilder(); int cp; while ((cp = bufferedReader.read()) != -1) { sb.append((char) cp); } String jsonText = sb.toString(); LOGGER.fine("Cascaded GetLegend Request JSON Response: " + jsonText); JSONObject jsonLegend = JSONObject.fromObject(jsonText); JSONArray layerLegends = jsonLegend.getJSONArray(JSONLegendGraphicBuilder.LEGEND); JSONArray cascadedRules = layerLegends.getJSONObject(0).getJSONArray(JSONLegendGraphicBuilder.RULES); return cascadedRules; } catch (Exception e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); <START> throw new RuntimeException(e); <END> } finally { IOUtils.closeQuietly(bufferedReader); IOUtils.closeQuietly(is); } }</code><technical_language>throw a service exception, indication of ("Error while cascading legend") avoid logging, Dispatcher do for</technical_language>

Target:
public JSONArray getCascadedJSONRules() { InputStream is = null; BufferedReader bufferedReader = null; try { WMSLayerInfo wmsLayerInfo = (WMSLayerInfo) getLayerInfo().getResource(); StyleInfo defaultRemoteStyle = getLayerInfo().getDefaultStyle(); if (defaultRemoteStyle == WMSLayerInfoImpl.DEFAULT_ON_REMOTE) return null; HTTPClient client = wmsLayerInfo.getStore().getWebMapServer(null).getHTTPClient(); HTTPResponse jsonResponse = client.get(new URL(super.getLegendInfo().getOnlineResource())); is = jsonResponse.getResponseStream(); bufferedReader = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); StringBuilder sb = new StringBuilder(); int cp; while ((cp = bufferedReader.read()) != -1) { sb.append((char) cp); } String jsonText = sb.toString(); LOGGER.fine("Cascaded GetLegend Request JSON Response: " + jsonText); JSONObject jsonLegend = JSONObject.fromObject(jsonText); JSONArray layerLegends = jsonLegend.getJSONArray(JSONLegendGraphicBuilder.LEGEND); JSONArray cascadedRules = layerLegends.getJSONObject(0).getJSONArray(JSONLegendGraphicBuilder.RULES); return cascadedRules; } catch (Exception e) { throw new org.geoserver.platform.ServiceException("Unable to cascade Legend"); } finally { IOUtils.closeQuietly(bufferedReader); IOUtils.closeQuietly(is); } }