auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testGetNextLine() throws IOException { decompressorStream = new FixedLengthCharsetTransformingDecompressorStream(inputStream, FixedLengthCharset.UTF_32, 0, 32); compressionInputStream = new TransformingCompressionInputStream(decompressorStream, 0, 32); setUpRecordReaderForTest(compressionInputStream); Assert.assertTrue(recordReader.nextKeyValue()); <START> Assert.assertEquals(recordReader.getCurrentKey().get(), 0); <END> Assert.assertEquals(recordReader.getCurrentValue().toString(), "abcd"); Assert.assertTrue(recordReader.nextKeyValue()); Assert.assertEquals(recordReader.getCurrentKey().get(), 5); Assert.assertEquals(recordReader.getCurrentValue().toString(), "edfg"); Assert.assertFalse(recordReader.nextKeyValue()); Assert.assertNull(recordReader.getCurrentKey()); Assert.assertNull(recordReader.getCurrentValue()); Assert.assertFalse(recordReader.nextKeyValue()); Assert.assertNull(recordReader.getCurrentKey()); Assert.assertNull(recordReader.getCurrentValue()); }</code><technical_language>forgot. In this version of JUnit do assertEquals(expected, actual). Please fix, errors weird</technical_language>

Target:
public void testGetNextLine() throws IOException { decompressorStream = new FixedLengthCharsetTransformingDecompressorStream(inputStream, FixedLengthCharset.UTF_32, 0, 32); compressionInputStream = new TransformingCompressionInputStream(decompressorStream, 0, 32); setUpRecordReaderForTest(compressionInputStream); Assert.assertTrue(recordReader.nextKeyValue()); Assert.assertEquals(0, recordReader.getCurrentKey().get()); Assert.assertEquals("abcd", recordReader.getCurrentValue().toString()); Assert.assertTrue(recordReader.nextKeyValue()); Assert.assertEquals(5, recordReader.getCurrentKey().get()); Assert.assertEquals("edfg", recordReader.getCurrentValue().toString()); Assert.assertFalse(recordReader.nextKeyValue()); Assert.assertNull(recordReader.getCurrentKey()); Assert.assertNull(recordReader.getCurrentValue()); Assert.assertFalse(recordReader.nextKeyValue()); Assert.assertNull(recordReader.getCurrentKey()); Assert.assertNull(recordReader.getCurrentValue()); }
Source:
<code>private ICPPFunction resolveFunctionBinding(IASTNode point) { ICPPFunction function = getOverload(point); if (function == null) { ICPPEvaluation funcEval = fArguments[0]; <START> if (funcEval instanceof EvalFunctionSet && getOverload(point) == null) { <END> EvalFunctionSet funcEvalFunctionSet = (EvalFunctionSet)funcEval; funcEval = funcEvalFunctionSet.resolveFunction(Arrays.copyOfRange(fArguments, 1, fArguments.length), point); } IBinding binding = null; if (funcEval instanceof EvalBinding) { EvalBinding funcEvalBinding = (EvalBinding)funcEval; binding = funcEvalBinding.getBinding(); } else if (funcEval instanceof EvalMemberAccess) { EvalMemberAccess funcEvalMemberAccess = (EvalMemberAccess)funcEval; binding = funcEvalMemberAccess.getMember(); } if (binding instanceof ICPPFunction) { function = (ICPPFunction) binding; } } return function; }</code><technical_language>"getOverload(point) == null" condition is redundant. null</technical_language>

Target:
private ICPPFunction resolveFunctionBinding(IASTNode point) { ICPPFunction function = getOverload(point); if (function == null) { ICPPEvaluation funcEval = fArguments[0]; if (funcEval instanceof EvalFunctionSet) { EvalFunctionSet funcEvalFunctionSet = (EvalFunctionSet)funcEval; funcEval = funcEvalFunctionSet.resolveFunction(Arrays.copyOfRange(fArguments, 1, fArguments.length), point); } IBinding binding = null; if (funcEval instanceof EvalBinding) { EvalBinding funcEvalBinding = (EvalBinding)funcEval; binding = funcEvalBinding.getBinding(); } else if (funcEval instanceof EvalMemberAccess) { EvalMemberAccess funcEvalMemberAccess = (EvalMemberAccess)funcEval; binding = funcEvalMemberAccess.getMember(); } if (binding instanceof ICPPFunction) { function = (ICPPFunction) binding; } } return function; }
Source:
<code>public Image getImageFromPath(String path) { <START> return getImageDescripterFromPath(path).createImage(); <END> }</code><technical_language>Descripter -> Descriptor</technical_language>

Target:
public Image getImageFromPath(String path) { return getImageDescriptorFromPath(path).createImage(); }
Source:
<code>public void getObjectCachedNotification() throws IOException, SignatureException, XmlProcessingException { try { final PutObjectCachedNotificationRegistrationSpectraS3Response putNotificationResponse = client .putObjectCachedNotificationRegistrationSpectraS3 (new PutObjectCachedNotificationRegistrationSpectraS3Request("test@test.test")); final GetObjectCachedNotificationRegistrationSpectraS3Response getNotificationResponse = client .getObjectCachedNotificationRegistrationSpectraS3( (new GetObjectCachedNotificationRegistrationSpectraS3Request (putNotificationResponse.getS3ObjectCachedNotificationRegistrationResult().getId()))); assertThat(getNotificationResponse.getStatusCode(), is(200)); } finally { <START> deleteAllContents(client, BUCKET_NAME); <END> } }</code><technical_language>bucket here. This removed</technical_language>

Target:
public void getObjectCachedNotification() throws IOException, SignatureException, XmlProcessingException { final PutObjectCachedNotificationRegistrationSpectraS3Response putNotificationResponse = client .putObjectCachedNotificationRegistrationSpectraS3 (new PutObjectCachedNotificationRegistrationSpectraS3Request("test@test.test")); final GetObjectCachedNotificationRegistrationSpectraS3Response getNotificationResponse = client .getObjectCachedNotificationRegistrationSpectraS3( (new GetObjectCachedNotificationRegistrationSpectraS3Request (putNotificationResponse.getS3ObjectCachedNotificationRegistrationResult().getId()))); assertThat(getNotificationResponse.getStatusCode(), is(200)); }
Source:
<code>private void addDefectWidget(StringBuilder sb, IAtsWorkItem workItem, IAtsWidgetDefinition widget) { sb.append("Defects: "); Collection<String> defects = atsServer.getAttributeResolver().getAttributesToStringList(workItem, AtsAttributeTypes.ReviewDefect); if (!defects.isEmpty()) { <START> sb.append("<table border=\"1\" align=\"center\" width=\"98%\"><tr><th>Severity</th><th>Disposition</th><th>Closed</th><th>User</th><th>Created</th><th>Injected</th><th>Description</th><th>Location</th><th>Resolution</th></tr>"); <END> for (String xml : defects) { sb.append("<tr>"); for (String key : defectKeys) { sb.append("<td>"); String data = AXml.getTagData(xml, key); if (key.equals("user")) { data = atsServer.getUserService().getUserById(data).getName(); } else if (key.equals("date")) { data = DateUtil.getDateStr(new Date(Long.valueOf(data)), DateUtil.MMDDYYHHMM); } sb.append(data); sb.append("</td>"); } sb.append("</tr>"); } sb.append("</table>"); } }</code><technical_language>Suggest making string a constant</technical_language>

Target:
private void addDefectWidget(StringBuilder sb, IAtsWorkItem workItem, IAtsWidgetDefinition widget) { sb.append("Defects: "); Collection<String> defects = atsServer.getAttributeResolver().getAttributesToStringList(workItem, AtsAttributeTypes.ReviewDefect); if (!defects.isEmpty()) { sb.append(DEFECT_TABLE_HEADER); for (String xml : defects) { sb.append("<tr>"); for (String key : defectKeys) { sb.append("<td>"); String data = AXml.getTagData(xml, key); if (key.equals("user")) { data = atsServer.getUserService().getUserById(data).getName(); } else if (key.equals("date")) { data = DateUtil.getDateStr(new Date(Long.valueOf(data)), DateUtil.MMDDYYHHMM); } sb.append(data); sb.append("</td>"); } sb.append("</tr>"); } sb.append("</table>"); } }
Source:
<code>private int computeInterfaceSpeed(String ifaceName) { VdsNetworkInterface iface = ifaceByNames.get(ifaceName); Iterable<VdsNetworkInterface> slaves = bonds.get(ifaceName); if (slaves == null) { return iface.getSpeed(); } else { Integer speed = bondSpeeds.get(ifaceName); if (speed != null) { return speed; } <START> boolean chooseMinimum = isBondModeFailover(iface.getBondType()); <END> speed = chooseMinimum ? Integer.MAX_VALUE : 0; for (VdsNetworkInterface slave : slaves) { speed = chooseMinimum ? Math.min(speed, slave.getSpeed()) : speed + slave.getSpeed(); } bondSpeeds.put(ifaceName, speed); return speed; } }</code><technical_language>1. I bond type is initialized, need check bondOptions type. 2. is mode 3? 3. need if want (and how) backend calculate new/changed bond's speed. custom bond mode</technical_language>

Target:
private Integer computeInterfaceSpeed(String ifaceName) { VdsNetworkInterface iface = ifaceByNames.get(ifaceName); if (ifaceSpeeds.containsKey(ifaceName)) { return ifaceSpeeds.get(ifaceName); } else { Integer speed = null; if (iface.hasSpeed()) { speed = iface.getSpeed(); } else { Iterable<VdsNetworkInterface> slaves = bonds.get(ifaceName); if (slaves != null) { boolean chooseMinimum = isBondModeFailover(iface.getBondOptions()); speed = chooseMinimum ? Integer.MAX_VALUE : 0; for (VdsNetworkInterface slave : slaves) { if (!slave.hasSpeed()) { speed = null; break; } speed = chooseMinimum ? Math.min(speed, slave.getSpeed()) : speed + slave.getSpeed(); } } } ifaceSpeeds.put(ifaceName, speed); return speed; } }
Source:
<code>public void remoteInit() { try { Map<Currency, CurrencyMetaData> currenciesMetaData = exchangeMetaData.getCurrencies(); Map<CurrencyPair, CurrencyPairMetaData> pairsMetaData = exchangeMetaData.getCurrencyPairs(); <START> for (LatokenCurrency latokenCurrency : LatokenAdapters.allCurrencies) { <END> Currency currency = LatokenAdapters.adaptCurrency(latokenCurrency); int precision = latokenCurrency.getPrecision(); addCurrencyMetadata(currenciesMetaData, currency, precision); } for (LatokenPair latokenPair : LatokenAdapters.allPairs) { CurrencyPair pair = LatokenAdapters.adaptCurrencyPair(latokenPair); BigDecimal tradingFee = BigDecimal.valueOf(latokenPair.getTakerFee()); BigDecimal minAmount = BigDecimal .valueOf(latokenPair.getMinOrderAmount()) .setScale(latokenPair.getAmountPrecision(), RoundingMode.HALF_DOWN); int priceScale = latokenPair.getPricePrecision(); addCurrencyPairMetadata(pairsMetaData, pair, tradingFee, minAmount, priceScale); } } catch (Exception e) { throw new ExchangeException("Failed to initialize: " + e.getMessage(), e); } }</code><technical_language>calling remoteInit in time allow refresh metadata, statically downloaded pairs currencies allow that, this is wrong</technical_language>

Target:
public void remoteInit() { try { Map<Currency, CurrencyMetaData> currenciesMetaData = exchangeMetaData.getCurrencies(); Map<CurrencyPair, CurrencyPairMetaData> pairsMetaData = exchangeMetaData.getCurrencyPairs(); List<LatokenPair> allPairs = latoken.getAllPairs(); List<LatokenCurrency> allCurrencies = latoken.getAllCurrencies(); this.exchangeSpecification.setExchangeSpecificParametersItem("pairs", allPairs); for (LatokenCurrency latokenCurrency : allCurrencies) { Currency currency = LatokenAdapters.adaptCurrency(latokenCurrency); addCurrencyMetadata(currenciesMetaData, currency, PRECISION); } for (LatokenPair latokenPair : allPairs) { CurrencyPair pair = LatokenAdapters.adaptCurrencyPair(latokenPair); CurrencyPairMetaData pairMetadata = LatokenAdapters.adaptPairMetaData(latokenPair); addCurrencyPairMetadata(pairsMetaData, pair, pairMetadata); } } catch (Exception e) { throw new ExchangeException("Failed to initialize: " + e.getMessage(), e); } }
Source:
<code>private <T extends Message> CompletableFuture<T> call(ClientMetaService.Interface stub, Callable<T> callable) { HBaseRpcController controller = rpcControllerFactory.newController(); CompletableFuture<T> future = new CompletableFuture<>(); callable.call(controller, stub, resp -> { if (controller.failed()) { future.completeExceptionally(controller.getFailed()); synchronized (refreshMasters) { refreshMasters.notify(); <START> } <END> } else { future.complete(resp); } }); return future; }</code><technical_language>a notify flag strange race problem... a 'triggerRefresh' flag guard redundant notification</technical_language>

Target:
private <T extends Message> CompletableFuture<T> call(ClientMetaService.Interface stub, Callable<T> callable) { HBaseRpcController controller = rpcControllerFactory.newController(); CompletableFuture<T> future = new CompletableFuture<>(); callable.call(controller, stub, resp -> { if (controller.failed()) { IOException failureReason = controller.getFailed(); future.completeExceptionally(failureReason); if (ClientExceptionsUtil.isConnectionException(failureReason)) { masterAddressRefresher.refreshNow(); } } else { future.complete(resp); } }); return future; }
Source:
<code>protected static void assertAuthzDecisionStatements(final Assertion assertion) throws WSSecurityException { <START> if ((assertion.getAuthzDecisionStatements() == null || assertion.getAuthzDecisionStatements().isEmpty()) <END> && assertion.getSubject() == null) { throw new WSSecurityException(ErrorCode.FAILURE, "Subject is required when Statements are absent"); } }</code><technical_language>Consider empty check in Collection</technical_language>

Target:
protected static void assertAuthzDecisionStatements(final Assertion assertion) throws WSSecurityException { if (CollectionUtils.isEmpty(assertion.getAuthzDecisionStatements()) && assertion.getSubject() == null) { throw new WSSecurityException(ErrorCode.FAILURE, "Subject is required when Statements are absent"); } }
Source:
<code>@Override public void postDecode() { if (refreshMinutes == 0) { postDecodeHelper(); } else { ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1); ScheduledExecutorService executorService = MoreExecutors.getExitingScheduledExecutorService(executor, 100, TimeUnit.MILLISECONDS); <START> executorService.scheduleWithFixedDelay(() -> { <END> postDecodeHelper(); }, 0, refreshMinutes, TimeUnit.MINUTES); } }</code><technical_language>intellij inspections recommend a method reference instead of a lambda here: this::postDecodeHelper</technical_language>

Target:
@Override public void postDecode() { postDecodeHelper(); if (refreshMinutes > 0) { ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1); ScheduledExecutorService executorService = MoreExecutors.getExitingScheduledExecutorService(executor, 100, TimeUnit.MILLISECONDS); executorService.scheduleWithFixedDelay(this :: postDecodeHelper, refreshMinutes, refreshMinutes, TimeUnit.MINUTES); } }
Source:
<code><START> private String getCacheKey(ResourceDataRequest request) { <END> final CanonicalUri uri = request.getUri(); final String href = uri.getAbsolutePath(); return getCacheKey(href); }</code><technical_language>Tighten up, delete line breaks</technical_language>

Target:
private String getCacheKey(ResourceDataRequest request) { return getCacheKey(request.getUri().getAbsolutePath()); }
Source:
<code>public void testTextWrapBoundariesUpdatesOnResize() { tested.resize(0, 0, 10, 10, true); <START> verify(textDecorator).setTextBoundaries(any()); <END> }</code><technical_language>verify text boundaries correct? Verifying simply set boundaries text decorator is ascertain values set</technical_language>

Target:
public void testTextWrapBoundariesUpdatesOnResize() { tested.resize(0, 0, 10, 10, true); verify(textDecorator).setTextBoundaries(PATH.getBoundingBox()); }
Source:
<code>public void validate_shouldFailIfPatientIsVoided() throws Exception { Cohort cohort = new Cohort(2); Patient patient = new Patient(7); patient.setVoided(true); cohort.addMembership(new CohortMembership(patient)); Errors errors = new BindException(cohort, "cohort"); new CohortValidator().validate(cohort, errors); <START> Assert.assertEquals(true, errors.hasFieldErrors("members")); <END> }</code><technical_language>check error message matches expected one? this failing for another reason</technical_language>

Target:
public void validate_shouldFailIfPatientIsVoided() throws Exception { Cohort cohort = new Cohort(2); Patient patient = new Patient(7); patient.setVoided(true); cohort.addMembership(new CohortMembership(patient)); Errors errors = new BindException(cohort, "cohort"); new CohortValidator().validate(cohort, errors); Assert.assertTrue(errors.hasFieldErrors("members")); String eMessage = "Patient " + patient.getPatientId() + " is voided, cannot add voided members to a cohort"; Assert.assertTrue(errors.getFieldErrors().stream().anyMatch(e -> e.getDefaultMessage().equals(eMessage))); }
Source:
<code>protected Object handleRequestMessage(Message<?> requestMessage) { MessageValues messageValues = (this.extractEmbeddedHeaders) ? extractEmbeddedHeaders(requestMessage) : <START> new MessageValues(requestMessage); <END> return (this.supportDeserializationNatively) ? messageValues.toMessage() : deserializePayloadIfNecessary(messageValues).toMessage(); }</code><technical_language>Embedded headers work native encoding/decoding - I suspect do separate setting for native deserialization</technical_language>

Target:
protected Object handleRequestMessage(Message<?> requestMessage) { if (!(requestMessage.getPayload() instanceof byte[])) { return requestMessage; } MessageValues messageValues; if (this.extractEmbeddedHeaders) { try { messageValues = AbstractMessageChannelBinder.this.embeddedHeadersMessageConverter.extractHeaders( (Message<byte[]>) requestMessage, true); } catch (Exception e) { AbstractMessageChannelBinder.this.logger.error( EmbeddedHeadersMessageConverter.decodeExceptionMessage( requestMessage), e); messageValues = new MessageValues(requestMessage); } messageValues = deserializePayloadIfNecessary(messageValues); } else { messageValues = deserializePayloadIfNecessary(requestMessage); } return messageValues.toMessage(); }
Source:
<code>public <ARCHIVEVIEW extends Assignable> ARCHIVEVIEW resolveArtifactAs(Class<ARCHIVEVIEW> archiveView) throws ResolutionException { Collection<ARCHIVEVIEW> archiveViews = new MavenBuilderImpl(system, session, settings, dependencies, versionManagement) .resolveAs(archiveView); <START> return (archiveViews == null || archiveViews.isEmpty()) ? null : archiveViews.iterator().next(); <END> }</code><technical_language>This condition is enough, verify jar</technical_language>

Target:
public <ARCHIVEVIEW extends Assignable> ARCHIVEVIEW resolveArtifactAs(Class<ARCHIVEVIEW> archiveView) throws ResolutionException { Collection<ARCHIVEVIEW> archiveViews = new MavenBuilderImpl(system, session, settings, dependencies, versionManagement) .resolveAs(archiveView, new StrictFilter()); if (archiveViews != null && archiveViews.size() != 1) { throw new ResolutionException("Only one artifact should have been resolved. Resolved " + archiveViews.size() + " artifacts."); } return (archiveViews == null) ? null : archiveViews.iterator().next(); }
Source:
<code>protected boolean validateInputs() { if (!super.validateInputs()) { return false; } VdcQueryReturnValue returnValue = getQueryReturnValue(); returnValue.setExceptionString(""); try { String hostName = getParameters().getVdsHostName(); if (StringUtils.isEmpty(hostName)) { returnValue.setExceptionString("Cannot register Host - no Hostname address specified."); return false; } List<VDS> vdssByUniqueId = getVdssByUniqueId(); if (vdssByUniqueId.size() > 1) { returnValue.setExceptionString("Cannot register Host - unique id is ambigious."); return false; } if (vdssByUniqueId.size() == 1) { VDS vds = vdssByUniqueId.get(0); if (!VdsHandler.isPendingOvirt(vds)) { returnValue.setExceptionString(VdcBllMessages.VDS_STATUS_NOT_VALID_FOR_UPDATE.name()); return false; } Long otp = getParameters().getOtp(); <START> if (otp != null && !isValidOtp(vds, otp)) { <END> returnValue.setExceptionString(String.format("Invalid OTP for host %s", hostName)); return false; } } } catch (RuntimeException ex) { log.error(ex); returnValue.setExceptionString(String.format("Cannot register Host - An exception has been thrown: %1$s", ex.getMessage())); return false; } return true; }</code><technical_language>I otp != null check isValidOtp</technical_language>

Target:
protected boolean validateInputs() { if (!super.validateInputs()) { return false; } VdcQueryReturnValue returnValue = getQueryReturnValue(); returnValue.setExceptionString(""); try { String hostName = getParameters().getVdsHostName(); if (StringUtils.isEmpty(hostName)) { returnValue.setExceptionString("Cannot register Host - no Hostname address specified."); return false; } List<VDS> vdssByUniqueId = getVdssByUniqueId(); if (vdssByUniqueId.size() > 1) { returnValue.setExceptionString("Cannot register Host - unique id is ambigious."); return false; } if (vdssByUniqueId.size() == 1) { VDS vds = vdssByUniqueId.get(0); if (!VdsHandler.isPendingOvirt(vds)) { returnValue.setExceptionString(VdcBllMessages.VDS_STATUS_NOT_VALID_FOR_UPDATE.name()); return false; } Long otp = getParameters().getOtp(); if (!isValidOtp(vds, otp)) { returnValue.setExceptionString(String.format("Invalid OTP for host %s", hostName)); return false; } } } catch (RuntimeException ex) { log.error(ex); returnValue.setExceptionString(String.format("Cannot register Host - An exception has been thrown: %1$s", ex.getMessage())); return false; } return true; }
Source:
<code>public void reloadOffsets(SubscriptionName subscriptionName, Consumer consumer) { logger.info("Reloading offsets for {}", subscriptionName); try { PartitionOffsets offsets = subscriptionOffsetChangeIndicator.getSubscriptionOffsets( subscriptionName.getTopicName(), subscriptionName.getName(), brokersClusterName); for (PartitionOffset partitionOffset : offsets) { <START> SubscriptionPartitionOffset subscriptionPartitionOffset = new SubscriptionPartitionOffset( <END> new SubscriptionPartition(partitionOffset.getTopic(), subscriptionName, partitionOffset.getPartition(), NON_EXISTENT_PARTITION_ASSIGNMENT_TERM), partitionOffset.getOffset()); if (moveOffset(subscriptionName, consumer, subscriptionPartitionOffset)) { subscriptionOffsetChangeIndicator.removeOffset( subscriptionName.getTopicName(), subscriptionName.getName(), brokersClusterName, partitionOffset.getTopic(), partitionOffset.getPartition() ); logger.info("Removed offset indicator for subscription={} and partition={}", subscriptionName, subscriptionPartitionOffset.getPartition()); } } } catch (Exception ex) { throw new RetransmissionException(ex); } }</code><technical_language>do passing partitionOffset KafkaConsumerOffsetMover instead of subscriptionPartitionOffset? If access subscription is necessary in KafkaConsumerOffsetMover pass class constructor</technical_language>

Target:
public void reloadOffsets(SubscriptionName subscriptionName, Consumer consumer) { logger.info("Reloading offsets for {}", subscriptionName); try { PartitionOffsets offsets = subscriptionOffsetChangeIndicator.getSubscriptionOffsets( subscriptionName.getTopicName(), subscriptionName.getName(), brokersClusterName); for (PartitionOffset partitionOffset : offsets) { if (moveOffset(subscriptionName, consumer, partitionOffset)) { subscriptionOffsetChangeIndicator.removeOffset( subscriptionName.getTopicName(), subscriptionName.getName(), brokersClusterName, partitionOffset.getTopic(), partitionOffset.getPartition() ); logger.info("Removed offset indicator for subscription={} and partition={}", subscriptionName, partitionOffset.getPartition()); } } } catch (Exception ex) { throw new RetransmissionException(ex); } }
Source:
<code>public boolean swapBlockList(String src, String dst, long maxTimestamp) throws IOException { checkNNStartup(); if (stateChangeLog.isDebugEnabled()) { stateChangeLog.debug("*DIR* NameNode.swapBlockList: and {}", src, dst); } <START> namesystem.checkOperation(OperationCategory.WRITE); <END> return namesystem.swapBlockList(src, dst, maxTimestamp); }</code><technical_language>This required, This redundant check, check in FSNamesystem. required twice, lock after..</technical_language>

Target:
public boolean swapBlockList(String src, String dst, long maxTimestamp) throws IOException { checkNNStartup(); if (stateChangeLog.isDebugEnabled()) { stateChangeLog.debug("*DIR* NameNode.swapBlockList: and {}", src, dst); } return namesystem.swapBlockList(src, dst, maxTimestamp); }
Source:
<code>public void getEntryByEntryNumber() throws JSONException, IOException { String sha256Hex = DigestUtils.sha256Hex(item1); Response response = getRequest("/entry/1.json"); assertThat(response.getStatus(), equalTo(200)); <START> assertThat(response.getHeaders().get("cache-control").toString(), equalTo("[no-transform, max-age=31536000]")); <END> JsonNode res = Jackson.newObjectMapper().readValue(response.readEntity(String.class), JsonNode.class); assertThat(res.get("entry-number").textValue(), equalTo("1")); assertThat(res.get("item-hash").textValue(), equalTo("sha-256:" + sha256Hex)); assertThat(res.get("entry-timestamp").textValue(), containsString(LocalDate.now().toString())); }</code><technical_language>square brackets here? I expect a valid cache-control header this: Cache-Control: no-transform, max-age=31536000</technical_language>

Target:
public void getEntryByEntryNumber() throws JSONException, IOException { String sha256Hex = DigestUtils.sha256Hex(item1); Response response = getRequest("/entry/1.json"); assertThat(response.getStatus(), equalTo(200)); assertThat(response.getHeaders().get("cache-control"), contains("no-transform, max-age=31536000")); JsonNode res = Jackson.newObjectMapper().readValue(response.readEntity(String.class), JsonNode.class); assertThat(res.get("entry-number").textValue(), equalTo("1")); assertThat(res.get("item-hash").textValue(), equalTo("sha-256:" + sha256Hex)); assertTrue(res.get("entry-timestamp").textValue().matches("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$")); }
Source:
<code>public AsyncBenchmark(VoterConfig config) { this.config = config; <START> ClientConfig clientConfig = null; <END> if (config.sslfile.length() > 0) { try { clientConfig = new ClientConfig(config.user, config.password, new StatusListener()); if (config.sslfile.trim().length() > 0) { clientConfig.setTrustStore(config.sslfile); } } catch (Exception e) { System.err.println("Failed to configure ssl, exiting"); e.printStackTrace(); System.exit(-1); } } else clientConfig = new ClientConfig(config.user, config.password, new StatusListener()); if (config.topologyaware) { clientConfig.setTopologyChangeAware(true); } client = ClientFactory.createClient(clientConfig); periodicStatsContext = client.createStatsContext(); fullStatsContext = client.createStatsContext(); switchboard = new PhoneCallGenerator(config.contestants); System.out.print(HORIZONTAL_RULE); System.out.println(" Command Line Configuration"); System.out.println(HORIZONTAL_RULE); System.out.println(config.getConfigDumpString()); if(config.latencyreport) { System.out.println("NOTICE: Option latencyreport is ON for async run, please set a reasonable ratelimit.\n"); } }</code><technical_language>this code short others</technical_language>

Target:
public AsyncBenchmark(VoterConfig config) { this.config = config; ClientConfig clientConfig = new ClientConfig(config.user, config.password, new StatusListener()); if (!config.sslfile.trim().isEmpty()) { clientConfig.setTrustStoreConfigFromPropertyFile(config.sslfile); clientConfig.enableSSL(); } if (config.topologyaware) { clientConfig.setTopologyChangeAware(true); } client = ClientFactory.createClient(clientConfig); periodicStatsContext = client.createStatsContext(); fullStatsContext = client.createStatsContext(); switchboard = new PhoneCallGenerator(config.contestants); System.out.print(HORIZONTAL_RULE); System.out.println(" Command Line Configuration"); System.out.println(HORIZONTAL_RULE); System.out.println(config.getConfigDumpString()); if(config.latencyreport) { System.out.println("NOTICE: Option latencyreport is ON for async run, please set a reasonable ratelimit.\n"); } }
Source:
<code>public void testGetCommunicationSummaryStatisticsServiceName() throws StoreException { CompletionTime ct1 = new CompletionTime(); ct1.setBusinessTransaction("testapp"); ct1.setUri("in1"); ct1.setOperation("op1"); ct1.getProperties().add(new Property("prop", "val")); ct1.getProperties().add(new Property(Constants.PROP_SERVICE_NAME, "wildfly")); CommunicationDetails cd1 = new CommunicationDetails(); cd1.setBusinessTransaction("testapp"); cd1.setSource("in1[op1]"); cd1.setTarget("out1.1[op1.1]"); analytics.storeFragmentCompletionTimes(null, Arrays.asList(ct1)); analytics.storeCommunicationDetails(null, Arrays.asList(cd1)); Criteria criteria = new Criteria() .setStartTime(0) .setEndTime(100000) .setBusinessTransaction("testapp"); Collection<CommunicationSummaryStatistics> communicationSummaryStatisticsList = analytics.getCommunicationSummaryStatistics(null, criteria, false); Assert.assertEquals(1, communicationSummaryStatisticsList.size()); CommunicationSummaryStatistics communicationSummaryStatistics = communicationSummaryStatisticsList.iterator().next(); <START> Assert.assertNotNull("wildfly", communicationSummaryStatistics.getServiceName()); <END> Assert.assertEquals(1, communicationSummaryStatistics.getOutbound().size()); }</code><technical_language>assertEquals</technical_language>

Target:
public void testGetCommunicationSummaryStatisticsServiceName() throws StoreException { CompletionTime ct1 = new CompletionTime(); ct1.setBusinessTransaction("testapp"); ct1.setUri("in1"); ct1.setOperation("op1"); ct1.getProperties().add(new Property("prop", "val")); ct1.getProperties().add(new Property(Constants.PROP_SERVICE_NAME, "wildfly")); CommunicationDetails cd1 = new CommunicationDetails(); cd1.setBusinessTransaction("testapp"); cd1.setSource("in1[op1]"); cd1.setTarget("out1.1[op1.1]"); analytics.storeFragmentCompletionTimes(null, Arrays.asList(ct1)); analytics.storeCommunicationDetails(null, Arrays.asList(cd1)); Criteria criteria = new Criteria() .setStartTime(0) .setEndTime(100000) .setBusinessTransaction("testapp"); Collection<CommunicationSummaryStatistics> communicationSummaryStatisticsList = analytics.getCommunicationSummaryStatistics(null, criteria, false); Assert.assertEquals(1, communicationSummaryStatisticsList.size()); CommunicationSummaryStatistics communicationSummaryStatistics = communicationSummaryStatisticsList.iterator().next(); Assert.assertEquals("wildfly", communicationSummaryStatistics.getServiceName()); Assert.assertEquals(1, communicationSummaryStatistics.getOutbound().size()); }
Source:
<code>protected Collection<String> getInAppFrames(Dsn dsn) { String inAppFramesOption = Lookup.lookup(IN_APP_FRAMES_OPTION, dsn); if (Util.isNullOrEmpty(inAppFramesOption)) { if (inAppFramesOption == null) { logger.warn("No '" + IN_APP_FRAMES_OPTION + "' was configured, this option is highly recommended " + "as it affects stacktrace grouping and display on Sentry. See documentation: " + "<LINK_0>"); } return Collections.emptyList(); } List<String> inAppPackages = new ArrayList<>(); for (String inAppPackage : inAppFramesOption.split(",")) { if (!inAppPackage.trim().equals("")) { inAppPackages.add(inAppPackage); } } <START> return Collections.unmodifiableList(inAppPackages); <END> }</code><technical_language>I this kind of breaks current API contract in a subtle way: while this is ABI compatible, subclasses fail runtime add base class collection of in-app packages</technical_language>

Target:
protected Collection<String> getInAppFrames(Dsn dsn) { String inAppFramesOption = Lookup.lookup(IN_APP_FRAMES_OPTION, dsn); if (Util.isNullOrEmpty(inAppFramesOption)) { if (inAppFramesOption == null) { logger.warn("No '" + IN_APP_FRAMES_OPTION + "' was configured, this option is highly recommended " + "as it affects stacktrace grouping and display on Sentry. See documentation: " + "<LINK_0>"); } return Collections.emptyList(); } List<String> inAppPackages = new ArrayList<>(); for (String inAppPackage : inAppFramesOption.split(",")) { if (!inAppPackage.trim().equals("")) { inAppPackages.add(inAppPackage); } } return inAppPackages; }
Source:
<code>public SearchResult loadInBackground() { loading = true; if (search == null) { search = runSearch(); } else { SearchResult newSearch = new SearchResult(search); newSearch.setUrl(search.getUrl()); <START> newSearch.setViewstates(search.getViewstates()); <END> search = GCParser.searchByNextPage(newSearch, Settings.isShowCaptcha(), this); } loading = false; return search; }</code><technical_language>confused those. fields (as geocodes, error totalCnt) copied new SearchResult(search) constructor, they</technical_language>

Target:
public SearchResult loadInBackground() { loading = true; if (search == null) { search = runSearch(); } else { search = GCParser.searchByNextPage(new SearchResult(search), Settings.isShowCaptcha(), this); } loading = false; return search; }
Source:
<code>private Map<String, Object> mapIPv6(VmInitNetwork vmInitNetwork) { <START> if (!vmInitNetwork.getIpv6BootProtocol().equals(Ipv6BootProtocol.NONE)) { <END> Map<String, Object> networkIPv6 = new HashMap<>(); networkIPv6.put("id", vmInitNetwork.getName()); networkIPv6.put("link", vmInitNetwork.getName()); if (vmInitNetwork.getIpv6BootProtocol().equals(Ipv6BootProtocol.DHCP)) { networkIPv6.put("type", "dhcp6"); } else if (vmInitNetwork.getIpv6BootProtocol().equals(Ipv6BootProtocol.STATIC_IP)) { networkIPv6.put("type", "ipv6"); if (StringUtils.isNotEmpty(vmInitNetwork.getIpv6Address())) { networkIPv6.put("ip_address", vmInitNetwork.getIpv6Address()); } else { throw new IllegalArgumentException("IP address must be supplied for a static IP configuration"); } if (vmInitNetwork.getIpv6Prefix() != null) { networkIPv6.put("netmask", vmInitNetwork.getIpv6Prefix()); } if (StringUtils.isNotEmpty(vmInitNetwork.getIpv6Gateway())) { networkIPv6.put("gateway", vmInitNetwork.getIpv6Gateway()); } } return networkIPv6; } return null; }</code><technical_language>"!="</technical_language>

Target:
private Map<String, Object> mapIPv6(VmInitNetwork vmInitNetwork) { if (vmInitNetwork.getIpv6BootProtocol() == Ipv6BootProtocol.NONE) { return null; } else if (vmInitNetwork.getIpv6BootProtocol() == Ipv6BootProtocol.AUTOCONF) { throw new IllegalArgumentException("'Stateless address autoconfiguration' is not supported for virtual machines"); } Map<String, Object> networkIPv6 = new HashMap<>(); networkIPv6.put("id", vmInitNetwork.getName()); networkIPv6.put("link", vmInitNetwork.getName()); if (vmInitNetwork.getIpv6BootProtocol() == Ipv6BootProtocol.DHCP) { networkIPv6.put("type", "dhcp6"); } else if (vmInitNetwork.getIpv6BootProtocol() == Ipv6BootProtocol.STATIC_IP) { networkIPv6.put("type", "ipv6"); if (StringUtils.isNotEmpty(vmInitNetwork.getIpv6Address())) { networkIPv6.put("ip_address", vmInitNetwork.getIpv6Address()); } else { throw new IllegalArgumentException("IP address must be supplied for a static IP configuration"); } if (vmInitNetwork.getIpv6Prefix() != null) { networkIPv6.put("netmask", vmInitNetwork.getIpv6Prefix()); } if (StringUtils.isNotEmpty(vmInitNetwork.getIpv6Gateway())) { networkIPv6.put("gateway", vmInitNetwork.getIpv6Gateway()); } } return networkIPv6; }
Source:
<code>private OffsetDateTime getExpirationTime(String sharedAccessSignature) { String[] parts = sharedAccessSignature.split("&"); return Arrays.stream(parts) .map(part -> part.split("=")) .filter(pair -> pair.length == 2 && pair[0].equalsIgnoreCase("se")) .findFirst() .map(pair -> pair[1]) .map(expirationTimeStr -> { try { long epochSeconds = Long.parseLong(expirationTimeStr); return Instant.ofEpochSecond(epochSeconds).atOffset(ZoneOffset.UTC); } catch (NumberFormatException exception) { <START> return OffsetDateTime.MAX; <END> } }) .orElse(OffsetDateTime.MAX); }</code><technical_language>log in case of logger.verbose("Could parse .... ") give user information wrong in string a chance fix formatting issue in string? time, do want fill logs</technical_language>

Target:
private OffsetDateTime getExpirationTime(String sharedAccessSignature) { String[] parts = sharedAccessSignature.split("&"); return Arrays.stream(parts) .map(part -> part.split("=")) .filter(pair -> pair.length == 2 && pair[0].equalsIgnoreCase("se")) .findFirst() .map(pair -> pair[1]) .map(expirationTimeStr -> { try { long epochSeconds = Long.parseLong(expirationTimeStr); return Instant.ofEpochSecond(epochSeconds).atOffset(ZoneOffset.UTC); } catch (NumberFormatException exception) { logger.verbose("Invalid expiration time format in the SAS token: {}. Falling back to max " + "expiration time.", expirationTimeStr); return OffsetDateTime.MAX; } }) .orElse(OffsetDateTime.MAX); }
Source:
<code>public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) { final Edge edge = this.addOutEdge(label, inVertex, keyValues); if (inVertex.equals(this)) { <START> List<Edge> inE = inEdges.get(label); <END> if (null == inE) { inE = new ArrayList<>(); this.inEdges.put(label, inE); } inE.add(edge); } return edge; }</code><technical_language>inEdges null a pristine StarVertex</technical_language>

Target:
public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) { final Edge edge = this.addOutEdge(label, inVertex, keyValues); if (inVertex.equals(this)) { if(null == this.inEdges) this.inEdges = new HashMap<>(); List<Edge> inE = this.inEdges.get(label); if (null == inE) { inE = new ArrayList<>(); this.inEdges.put(label, inE); } inE.add(edge); } return edge; }
Source:
<code>public Optional<CloudResource> findByResourceReferenceAndStatusAndType(String resourceReference, CommonStatus status, ResourceType resourceType) { Optional<Resource> optionalResource = resourceService.findByResourceReferenceAndStatusAndType(resourceReference, status, resourceType); LOGGER.debug("Resource retrieved by optionalResource reference: {}, status: and type: {}. Is present: {}", resourceReference, status, resourceType, optionalResource.isPresent()); return optionalResource <START> .map(resource -> conversionService.convert(resource, CloudResource.class)); <END> }</code><technical_language>exact converter instead of ConversionService here</technical_language>

Target:
public Optional<CloudResource> findByResourceReferenceAndStatusAndType(String resourceReference, CommonStatus status, ResourceType resourceType) { Optional<Resource> optionalResource = resourceService.findByResourceReferenceAndStatusAndType(resourceReference, status, resourceType); LOGGER.debug("Resource retrieved by optionalResource reference: {}, status: and type: {}. Is present: {}", resourceReference, status, resourceType, optionalResource.isPresent()); return optionalResource .map(resource -> cloudResourceConverter.convert(resource)); }
Source:
<code>protected void executeCommand() { try { glusterSyncJob.refreshSelfHealData(cluster); } catch (Exception e) { log.error("Error while refreshing Gluster self heal data of cluster '{}': {}", cluster.getName(), e.getMessage()); <START> log.debug("Exception", e); <END> setSucceeded(false); } setSucceeded(true); }</code><technical_language>propagating failure message</technical_language>

Target:
protected void executeCommand() { try { glusterSyncJob.refreshSelfHealData(cluster); } catch (Exception e) { addCustomValue("ClusterName", cluster.getName()); auditLog(this, AuditLogType.GLUSTER_VOLUME_HEAL_REFRESH_FAILED); setSucceeded(false); } setSucceeded(true); }
Source:
<code>public List<String> getRequiredAttributeNames() { List<String> requiredAttributeList = new ArrayList<>(); String requiredAttributes = this.configs .getProperty(SalesforceConnectorConstants.PropertyConfig.REQUIRED_FIELDS); <START> if (requiredAttributes != null && !StringUtils.isBlank(requiredAttributes)) { <END> requiredAttributeList = Arrays.asList(requiredAttributes .split(IdentityProvisioningConstants.PropertyConfig.DELIMATOR)); } return requiredAttributeList; }</code><technical_language>isNotBlank</technical_language>

Target:
public List<String> getRequiredAttributeNames() { List<String> requiredAttributeList = new ArrayList<>(); String requiredAttributes = this.configs .getProperty(SalesforceConnectorConstants.PropertyConfig.REQUIRED_FIELDS); if (StringUtils.isNotBlank(requiredAttributes)) { requiredAttributeList = Arrays.asList(requiredAttributes .split(IdentityProvisioningConstants.PropertyConfig.DELIMATOR)); } return requiredAttributeList; }
Source:
<code>public ClosableIterator<List<CandidateCellForSweeping>> getCandidateCellsForSweeping( TableReference tableRef, CandidateCellForSweepingRequest request) { <START> return new GetCandidateCellsForSweepingIterator(this, new CqlExecutor(clientPool, ConsistencyLevel.ALL), <END> tableRef, request); }</code><technical_language>Passing in this ugly</technical_language>

Target:
public ClosableIterator<List<CandidateCellForSweeping>> getCandidateCellsForSweeping( TableReference tableRef, CandidateCellForSweepingRequest request) { return getCandidateRowsForSweeping(tableRef, request) .map(rows -> rows.stream() .map(CandidateRowForSweeping::cells) .flatMap(List::stream) .collect(Collectors.toList())); }
Source:
<code>public void onWireReceive(final WireEnvelope wireEnvelope) { requireNonNull(wireEnvelope, message.wireEnvelopeNonNull()); logger.debug(message.wireEnvelopeReceived(), this.wireSupport); if (hasReadChannels()) { try { emitChannelRecords(readAllChannels()); } catch (final KuraException e) { logger.error(message.errorPerformingRead(), e); } } final List<WireRecord> records = wireEnvelope.getRecords(); for (WireRecord wireRecord : records) { <START> final List<ChannelRecord> assetRecordsToWriteChannels = determineWritingChannels(wireRecord); <END> writeChannels(assetRecordsToWriteChannels); } }</code><technical_language>channelRecordsToWriteChannels</technical_language>

Target:
public void onWireReceive(final WireEnvelope wireEnvelope) { requireNonNull(wireEnvelope, message.wireEnvelopeNonNull()); logger.debug(message.wireEnvelopeReceived(), this.wireSupport); if (hasReadChannels()) { try { emitChannelRecords(readAllChannels()); } catch (final KuraException e) { logger.error(message.errorPerformingRead(), e); } } final List<WireRecord> records = wireEnvelope.getRecords(); for (WireRecord wireRecord : records) { final List<ChannelRecord> channelRecordsToWrite = determineWritingChannels(wireRecord); writeChannels(channelRecordsToWrite); } }
Source:
<code>private URL[] readPluginPath(InputStream input) { Properties ini = new Properties(); try { ini.load(input); } catch (IOException e) { return null; } List<URL>result = new ArrayList<>(5); String <START> group; String entry; <END> for (Enumeration<?> groups = ini.propertyNames(); groups.hasMoreElements();) { group = (String) groups.nextElement(); for (StringTokenizer entries = new StringTokenizer(ini.getProperty(group), ";"); entries.hasMoreElements();) { entry = (String) entries.nextElement(); if (!entry.equals("")) try { result.add(new URL(entry)); } catch (MalformedURLException e) { System.err.println("Ignoring plugin: " + entry); } } } return result.toArray(new URL[result.size()]); }</code><technical_language>this is unrelated main change increases scope of variable. is performance improvement if meant that</technical_language>

Target:
private URL[] readPluginPath(InputStream input) { Properties ini = new Properties(); try { ini.load(input); } catch (IOException e) { return null; } List<URL>result = new ArrayList<>(5); for (Enumeration<?> groups = ini.propertyNames(); groups.hasMoreElements();) { String group = (String) groups.nextElement(); for (StringTokenizer entries = new StringTokenizer(ini.getProperty(group), ";"); entries.hasMoreElements();) { String entry = (String) entries.nextElement(); if (!entry.equals("")) try { result.add(new URL(entry)); } catch (MalformedURLException e) { System.err.println("Ignoring plugin: " + entry); } } } return result.toArray(new URL[result.size()]); }
Source:
<code>protected void internalReceiveCommand(String itemName, Command command) { IntertechnoBindingConfig config = null; for (CULIntertechnoBindingProvider provider : providers) { config = provider.getConfigForItemName(itemName); if (config != null) { break; } } if (config != null && culHandlerLifecycle.isCulReady() && command instanceof OnOffType) { OnOffType type = (OnOffType) command; String commandValue = null; switch (type) { case ON: commandValue = config.getCommandON(); break; case OFF: commandValue = config.getCommandOFF(); break; } if (commandValue != null) { try { culHandlerLifecycle.getCul().send("is" + commandValue); } catch (CULCommunicationException e) { logger.error("Can't write to CUL", e); } } else { <START> logger.error("Can't determine value to send for command {}", command); <END> } } }</code><technical_language>This a warn instead of error</technical_language>

Target:
protected void internalReceiveCommand(String itemName, Command command) { IntertechnoBindingConfig config = null; for (CULIntertechnoBindingProvider provider : providers) { config = provider.getConfigForItemName(itemName); if (config != null) { break; } } if (config != null && culHandlerLifecycle.isCulReady() && command instanceof OnOffType) { OnOffType type = (OnOffType) command; String commandValue = null; switch (type) { case ON: commandValue = config.getCommandON(); break; case OFF: commandValue = config.getCommandOFF(); break; } if (commandValue != null) { try { culHandlerLifecycle.getCul().send("is" + commandValue); } catch (CULCommunicationException e) { logger.error("Can't write to CUL", e); } } else { logger.warn("Can't determine value to send for command {}", command); } } }
Source:
<code>public static String getTopologyId(String name, Nimbus.Iface client) { try { <START> TopologySummary topologySummary = client.getTopologySummaryByName(name); <END> if (topologySummary != null) { return topologySummary.get_id(); } } catch (Exception e) { throw new RuntimeException(e); } return null; }</code><technical_language>catch NotAliveException return null if This is syntax consistent original implementation</technical_language>

Target:
public static String getTopologyId(String name, Nimbus.Iface client) { try { TopologySummary topologySummary = client.getTopologySummaryByName(name); if (topologySummary != null) { return topologySummary.get_id(); } } catch (NotAliveException notAliveException) { return null; } catch (Exception e) { throw new RuntimeException(e); } return null; }
Source:
<code><START> public static boolean moveToTrash(URI uri) { <END> Preconditions.checkArgument( URIBuilder.DATASET_SCHEME.equals(uri.getScheme()), "Not a dataset URI: " + uri); Pair<DatasetRepository, Map<String, String>> pair = Registration.lookupDatasetUri(URI.create(uri.getRawSchemeSpecificPart())); DatasetRepository repo = pair.first(); Map<String, String> uriOptions = pair.second(); return repo.moveToTrash( uriOptions.get(URIBuilder.NAMESPACE_OPTION), uriOptions.get(URIBuilder.DATASET_NAME_OPTION)); }</code><technical_language>logic in this method is a largely a copy of delete(URI uri) method. Is worth adding a private delete(URI uri, boolean useTrash) method call? I mind leaving is, a small amount of redundant code simpler factoring out a method</technical_language>

Target:
public static boolean moveToTrash(URI uri) { return deleteWithTrash(uri, true); }
Source:
<code>public void testConfigureCustomCollection() throws Exception { <START> String collectioName = "TestMetaStore"; <END> MongoDbFactory mongoDbFactory = this.prepareMongoFactory(collectioName); MongoTemplate template = new MongoTemplate(mongoDbFactory); store = new MongoDbMetadataStore(template,collectioName); testBasics(); }</code><technical_language>Typo: collectio**n**Name</technical_language>

Target:
public void testConfigureCustomCollection() throws Exception { final String collectionName = "testMetadataStore"; final MongoDbFactory mongoDbFactory = this.prepareMongoFactory(collectionName); final MongoTemplate template = new MongoTemplate(mongoDbFactory); store = new MongoDbMetadataStore(template, collectionName); testBasics(); }
Source:
<code>protected boolean isFiltered() { List<String> filterVar = getHttpHeaders().getRequestHeader(USER_FILTER_FIELD); boolean filter = false; if (filterVar != null && filterVar.size() > 0) <START> filter = Boolean.valueOf(filterVar.iterator().next()); <END> return filter; }</code><technical_language>1. if is bool? exception? able recover nicely 2. unneeded boxing, returning class primitive expected, Boolean.parseBoolean() instead 3. please cache of header, queries hit calling isFiltered(), - need preform header retrieval casting time</technical_language>

Target:
protected boolean isFiltered() { if (filtered == null) { List<String> filterVar = getHttpHeaders().getRequestHeader(USER_FILTER_FIELD); if (filterVar != null && filterVar.size() > 0) filtered = Boolean.valueOf(filterVar.iterator().next()); else filtered = false; } return filtered; }