auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static int getMaxDHGroupExchangeKeySize() { int maxSupportedKeySize; synchronized (MAX_DHG_KEY_SIZE_HOLDER) { maxSupportedKeySize = MAX_DHG_KEY_SIZE_HOLDER.get(); if (maxSupportedKeySize != 0) { return maxSupportedKeySize; } if (System.getProperty(MAX_DHGEX_KEY_SIZE_PROP) != null) { maxSupportedKeySize = Integer.parseInt( System.getProperty(MAX_DHGEX_KEY_SIZE_PROP)); if (!isDHGroupExchangeSupported(maxSupportedKeySize)) { maxSupportedKeySize = -1; } } else { maxSupportedKeySize = -1; for (int s = 1024; s <= 8192 && isDHGroupExchangeSupported(s); s += 1024) { maxSupportedKeySize = s; } } MAX_DHG_KEY_SIZE_HOLDER.set(maxSupportedKeySize); } return maxSupportedKeySize; <START> } <END></code><technical_language>I change, run builder if is successful merge master branch close pull request (we do merge for code discussions)</technical_language>

Target:
public static int getMaxDHGroupExchangeKeySize() { int maxSupportedKeySize; synchronized (MAX_DHG_KEY_SIZE_HOLDER) { maxSupportedKeySize = MAX_DHG_KEY_SIZE_HOLDER.get(); if (maxSupportedKeySize != 0) { return maxSupportedKeySize; } String propValue = System.getProperty(MAX_DHGEX_KEY_SIZE_PROP); if (GenericUtils.isEmpty(propValue)) { for (int testKeySize = MAX_DHGEX_KEY_SIZE; testKeySize >= MIN_DHGEX_KEY_SIZE; testKeySize -= 1024) { if (isDHGroupExchangeSupported(testKeySize)) { maxSupportedKeySize = testKeySize; break; } } } else { maxSupportedKeySize = Integer.parseInt(propValue); ValidateUtils.checkTrue(maxSupportedKeySize != 0, "Configured " + MAX_DHGEX_KEY_SIZE_PROP + " value must be non-zero: %d", maxSupportedKeySize); } MAX_DHG_KEY_SIZE_HOLDER.set(maxSupportedKeySize); } return maxSupportedKeySize; }
Source:
<code>public static void updateBeanValue(final WComponent component) <START> { <END> updateBeanValue(component, false); }</code><technical_language>If flag changes "visible only", this change default "true". this a impact projects some unexpected behaviour (i.e. invisible components updated). This need identified impact in change log</technical_language>

Target:
public static void updateBeanValue(final WComponent component) { updateBeanValue(component, true); }
Source:
<code>public SamReader open(final Path path) { <START> return open(path, getPathWrapper(), Function.identity()); <END> }</code><technical_language>wrapper returned getPathWrapper() default for bam index, instead of bam</technical_language>

Target:
public SamReader open(final Path path) { return open(path, null, null); }
Source:
<code>public static Pair<String, String[]> createWhere(String[] fieldNames, Object[] values, EncryptedModel em, Persistable p) throws IllegalArgumentException { Set<String> fields = null; if(p instanceof IMetaData) { IMetaData m = (IMetaData)p; String[] thefields = m.getMetaDataFields(); fields = new HashSet<String>(); for(String s : thefields) { fields.add(TableBuilder.scrubName(s)); } } if(em instanceof IMetaData) { IMetaData m = (IMetaData)em; String[] thefields = m.getMetaDataFields(); fields = new HashSet<String>(); for(String s : thefields) { fields.add(TableBuilder.scrubName(s)); } } StringBuilder stringBuilder = new StringBuilder(); ArrayList<String> arguments = new ArrayList<String>(); boolean set = false; for(int i = 0 ; i < fieldNames.length; ++i) { String columnName = TableBuilder.scrubName(fieldNames[i]); if(fields != null) { if(!fields.contains(columnName)) { continue; } } if(set){ stringBuilder.append(" AND "); } stringBuilder.append(columnName); stringBuilder.append("=?"); arguments.add(values[i].toString()); set = true; } if(!set){ <START> throw new IllegalArgumentException(); <END> } String[] retArray = new String[arguments.size()]; for(int i =0; i< arguments.size(); i++){ retArray[i] = arguments.get(i); } return new Pair<String, String[]>(stringBuilder.toString(), retArray); }</code><technical_language>throw new IllegalArgumentException() -> throw new IllegalArgumentException("Unable match provided fields columns.") lines</technical_language>

Target:
public static Pair<String, String[]> createWhere(String[] fieldNames, Object[] values, EncryptedModel em, Persistable p) throws IllegalArgumentException { Set<String> fields = null; if(p instanceof IMetaData) { IMetaData m = (IMetaData)p; String[] thefields = m.getMetaDataFields(); fields = new HashSet<String>(); for(String s : thefields) { fields.add(TableBuilder.scrubName(s)); } } if(em instanceof IMetaData) { IMetaData m = (IMetaData)em; String[] thefields = m.getMetaDataFields(); fields = new HashSet<String>(); for(String s : thefields) { fields.add(TableBuilder.scrubName(s)); } } StringBuilder stringBuilder = new StringBuilder(); ArrayList<String> arguments = new ArrayList<String>(); boolean set = false; for(int i = 0 ; i < fieldNames.length; ++i) { String columnName = TableBuilder.scrubName(fieldNames[i]); if(fields != null) { if(!fields.contains(columnName)) { continue; } } if(set){ stringBuilder.append(" AND "); } stringBuilder.append(columnName); stringBuilder.append("=?"); arguments.add(values[i].toString()); set = true; } if(!set){ throw new IllegalArgumentException("Unable to match provided fields with columns."); } String[] retArray = new String[arguments.size()]; for(int i =0; i< arguments.size(); i++){ retArray[i] = arguments.get(i); } return new Pair<String, String[]>(stringBuilder.toString(), retArray); }
Source:
<code>public List<String> argumentTypeNames() { if (fArgumentTypeNames != null) { return fArgumentTypeNames; } List<String> result = new ArrayList<>(); for (String <START> string : <END> argumentTypeSignatures()) { result.add(TypeImpl.signatureToName(string)); } fArgumentTypeNames = result; return fArgumentTypeNames; }</code><technical_language>rename signature</technical_language>

Target:
public List<String> argumentTypeNames() { if (fArgumentTypeNames != null) { return fArgumentTypeNames; } List<String> result = new ArrayList<>(); for (String signature : argumentTypeSignatures()) { result.add(TypeImpl.signatureToName(signature)); } fArgumentTypeNames = result; return fArgumentTypeNames; }
Source:
<code>public int breakpointHit(IJavaThread thread, IJavaBreakpoint breakpoint) { JavaDebugOptionsManager manager = JavaDebugOptionsManager.getDefault(); if (!breakpoint.equals(manager.getThreadNameChangeBreakpoint())) { return DONT_CARE; } if (manager.isListeningOnThreadNameChanges()) { DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { <START> new DebugEvent(thread, DebugEvent.CHANGE) }); <END> } return DONT_SUSPEND; }</code><technical_language>I experiments, new DebugEvent(thread, CHANGE, STATE) more suitable. Leaving detail unspecified lead interpreted CONTENT trigger a content update, STATE trigger a label update. (All this I understood code ...)</technical_language>

Target:
public int breakpointHit(IJavaThread thread, IJavaBreakpoint breakpoint) { JavaDebugOptionsManager manager = JavaDebugOptionsManager.getDefault(); if (!breakpoint.equals(manager.getThreadNameChangeBreakpoint())) { return DONT_CARE; } if (manager.isListeningOnThreadNameChanges()) { DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { new DebugEvent(thread, DebugEvent.CHANGE, DebugEvent.STATE) }); } return DONT_SUSPEND; }
Source:
<code>public SnippetConfigurationPage() { super("snippet"); setTitle("GeoJSON geometry configuration"); <START> setDescription("Please select the geometries to use for the GeoJSON export"); <END> }</code><technical_language>Title description fit</technical_language>

Target:
public SnippetConfigurationPage() { super("snippet"); setTitle("Groovy snippet"); setDescription("Please provide an identifier for the snippet"); }
Source:
<code>public PaymentWorksVendor obtainPmwNewVendorRequestDetailForPmwIdentifier(String pmwNewVendorRequestId, PaymentWorksNewVendorRequestsBatchReportData reportData) { PaymentWorksNewVendorRequestDetailDTO pmwDetailForSpecificVendorDTO = null; PaymentWorksVendor pmwDetailForSpecificVendor = null; try { pmwDetailForSpecificVendorDTO = retrieveAllPaymentWorksDetailsForRequestedVendor(buildPaymentWorksPendingNewVendorRequestDetailURI(pmwNewVendorRequestId)); <START> } catch (ResponseProcessingException rpe) { <END> LOG.error("obtainPmwNewVendorRequestDetailForPmwIdentifier, unable to create PaymentWorksNewVendorRequestDetailDTO from payment works web service.", rpe); } if (ObjectUtils.isNotNull(pmwDetailForSpecificVendorDTO)) { pmwDetailForSpecificVendor = getPaymentWorksDtoToPaymentWorksVendorConversionService().createPaymentWorksVendorFromPaymentWorksNewVendorRequestDetailDTO( pmwDetailForSpecificVendorDTO, reportData); } return pmwDetailForSpecificVendor; }</code><technical_language>Is exception type caught specific? catch a broader exception type instead (like RuntimeException Exception)</technical_language>

Target:
public PaymentWorksVendor obtainPmwNewVendorRequestDetailForPmwIdentifier(String pmwNewVendorRequestId, PaymentWorksNewVendorRequestsBatchReportData reportData) { PaymentWorksNewVendorRequestDetailDTO pmwDetailForSpecificVendorDTO = null; PaymentWorksVendor pmwDetailForSpecificVendor = null; try { pmwDetailForSpecificVendorDTO = retrieveAllPaymentWorksDetailsForRequestedVendor(buildPaymentWorksPendingNewVendorRequestDetailURI(pmwNewVendorRequestId)); } catch (RuntimeException rte) { LOG.error("obtainPmwNewVendorRequestDetailForPmwIdentifier, unable to create PaymentWorksNewVendorRequestDetailDTO from payment works web service.", rte); } if (ObjectUtils.isNotNull(pmwDetailForSpecificVendorDTO)) { pmwDetailForSpecificVendor = getPaymentWorksDtoToPaymentWorksVendorConversionService().createPaymentWorksVendorFromPaymentWorksNewVendorRequestDetailDTO( pmwDetailForSpecificVendorDTO, reportData); } return pmwDetailForSpecificVendor; }
Source:
<code>private PlanNode getCostBasedJoin(JoinNode joinNode, Context context) { CostProvider costProvider = context.getCostProvider(); List<PlanNodeWithCost> possibleJoinNodes = new ArrayList<>(); if (!mustPartition(joinNode) && canReplicate(joinNode, context)) { possibleJoinNodes.add(getJoinNodeWithCost(costProvider, joinNode.withDistributionType(REPLICATED))); } if (!mustReplicate(joinNode, context)) { possibleJoinNodes.add(getJoinNodeWithCost(costProvider, joinNode.withDistributionType(PARTITIONED))); <START> } <END> JoinNode flipped = joinNode.flipChildren(); if (!mustPartition(flipped) && canReplicate(flipped, context)) { possibleJoinNodes.add(getJoinNodeWithCost(costProvider, flipped.withDistributionType(REPLICATED))); } if (!mustReplicate(flipped, context)) { possibleJoinNodes.add(getJoinNodeWithCost(costProvider, flipped.withDistributionType(PARTITIONED))); } if (possibleJoinNodes.stream().anyMatch(result -> result.getCost().hasUnknownComponents()) || possibleJoinNodes.isEmpty()) { return getSyntacticOrderJoin(joinNode, context, AUTOMATIC); } Ordering<PlanNodeWithCost> planNodeOrderings = costComparator.forSession(context.getSession()).onResultOf(PlanNodeWithCost::getCost); return planNodeOrderings.min(possibleJoinNodes).getPlanNode(); }</code><technical_language>ifs extracted method reused</technical_language>

Target:
private PlanNode getCostBasedJoin(JoinNode joinNode, Context context) { List<PlanNodeWithCost> possibleJoinNodes = new ArrayList<>(); addJoinsWithDifferentDistributions(joinNode, possibleJoinNodes, context); addJoinsWithDifferentDistributions(joinNode.flipChildren(), possibleJoinNodes, context); if (possibleJoinNodes.stream().anyMatch(result -> result.getCost().hasUnknownComponents()) || possibleJoinNodes.isEmpty()) { return getSyntacticOrderJoin(joinNode, context, AUTOMATIC); } Ordering<PlanNodeWithCost> planNodeOrderings = costComparator.forSession(context.getSession()).onResultOf(PlanNodeWithCost::getCost); return planNodeOrderings.min(possibleJoinNodes).getPlanNode(); }
Source:
<code>public static Message.Builder createMessageBuilder(Clock clock) { MsbConfig msbConf = createMsbConfigurations(); <START> Clock clock1 = (clock != null ? clock : Clock.systemDefaultZone()); <END> Topics topic = new Topics("", ""); MetaMessage.Builder metaBuilder = createSimpleMetaBuilder(msbConf, clock1); return new Message.Builder() .withCorrelationId(Utils.generateId()) .withId(Utils.generateId()) .withTopics(topic) .withMetaBuilder(metaBuilder); }</code><technical_language>get rid of this "if" if implemented suggestion</technical_language>

Target:
public static Message.Builder createMessageBuilder(Clock clock) { MsbConfig msbConf = createMsbConfigurations(); Topics topic = new Topics("", ""); MetaMessage.Builder metaBuilder = createSimpleMetaBuilder(msbConf, clock); return new Message.Builder() .withCorrelationId(Utils.generateId()) .withId(Utils.generateId()) .withTopics(topic) .withMetaBuilder(metaBuilder); }
Source:
<code>public void onCreate(HarvestedResource resource) { String key = DigestUtils.sha1Hex(resource.getUri().toASCIIString()); if (resourceNotCreated(key)) { String resourceId = null; try { <START> resourceId = adapter.create(resource); <END> } catch (HarvestException e) { LOGGER.debug("Failed to create resource [{}].", resource.getName(), e); } if (StringUtils.isNotEmpty(resourceId)) { persistenceProvider.store(key, resourceId); } } else { LOGGER.debug("Already created resource [{}]. Doing nothing", resource.getName()); } }</code><technical_language>do operations fail? If log a debug message move on, missing events resource events failed processed. retry? Log error? @clockard, generate some kind of alert here</technical_language>

Target:
public void onCreate(HarvestedResource resource) { String key = Hashing.sha256() .hashString(resource.getUri().toASCIIString(), StandardCharsets.UTF_8) .toString(); if (resourceNotCreated(key)) { String resourceId = null; try { resourceId = adaptor.create(resource); } catch (HarvestException e) { LOGGER.debug("Failed to create resource [{}].", resource.getName(), e); } if (StringUtils.isNotEmpty(resourceId)) { persistenceProvider.store(key, resourceId); } } else { LOGGER.debug("Already created resource [{}]. Doing nothing", resource.getName()); } }
Source:
<code>public void runNonBlocking() { ThreadGroup group = new ThreadGroup("CBuilder" + fCounter++); InputStream stdin = fProcess.getInputStream(); InputStream stderr = fProcess.getErrorStream(); if (fOutput != null) { <START> fOutputReader = new ReaderThread(group, "OutputReader", stdin, fOutput); END> } if (fError != null) { fErrorReader = new ReaderThread(group, "ErrorReader", stderr, fError); } if (fOutput != null) { fOutputReader.start(); } if (fError != null) { fErrorReader.start(); } }</code><technical_language>If reading close stream input stream? aka getOutputStream()? Is leaking too? else it</technical_language>

Target:
public void runNonBlocking() { ThreadGroup group = new ThreadGroup("CBuilder" + fCounter++); InputStream stdin = fProcess.getInputStream(); InputStream stderr = fProcess.getErrorStream(); fOutputReader = new ReaderThread(group, "OutputReader", stdin, fOutput); fErrorReader = new ReaderThread(group, "ErrorReader", stderr, fError); fOutputReader.start(); fErrorReader.start(); }
Source:
<code>void onReplicaUpdate(KetchReplica replica) { if (log.isDebugEnabled()) { log.debug("Replica finished:\n{}", replica.describeForLog(), snapshot()); } if (replica.getType() == FOLLOWER) { return; } else if (runningRound == null) { return; } assert head.equals(runningRound.acceptedNew); int matching = 0; for (KetchReplica r : voters) { if (r.hasAccepted(head)) { matching++; } } int quorum = <START> voters.length / 2 + 1; <END> boolean success = matching >= quorum; if (!success) { return; } switch (state) { case CANDIDATE: term = ((ElectionRound) runningRound).getTerm(); state = LEADER; if (log.isDebugEnabled()) { log.debug("Won election, running term " + term); } case LEADER: committed = head; if (log.isDebugEnabled()) { log.debug("Committed {}/{} in term {}", Long.valueOf(committed.index), committed.abbreviate(8).name(), Long.valueOf(term)); } runningRound.success(); nextRound(); commitAsync(replica); if (log.isDebugEnabled()) { log.debug("Leader state:\n{}", snapshot()); } break; } }</code><technical_language>This calculate >50% number for acceptance assumption voters.length is uneven. Is sufficient want a majority of more 2/3 3/4? n/2+1 +2 extra backup, other formula sounds reasonable</technical_language>

Target:
void onReplicaUpdate(KetchReplica replica) { if (log.isDebugEnabled()) { log.debug("Replica finished:\n{}", replica.describeForLog(), snapshot()); } if (replica.getParticipation() == FOLLOWER_ONLY) { return; } else if (runningRound == null) { return; } assert head.equals(runningRound.acceptedNew); int matching = 0; for (KetchReplica r : voters) { if (r.hasAccepted(head)) { matching++; } } int quorum = voters.length / 2 + 1; boolean success = matching >= quorum; if (!success) { return; } switch (state) { case CANDIDATE: term = ((ElectionRound) runningRound).getTerm(); state = LEADER; if (log.isDebugEnabled()) { log.debug("Won election, running term " + term); } case LEADER: committed = head; if (log.isDebugEnabled()) { log.debug("Committed in term {}", committed.describeForLog(), Long.valueOf(term)); } runningRound.success(); nextRound(); commitAsync(replica); if (log.isDebugEnabled()) { log.debug("Leader state:\n{}", snapshot()); } break; } }
Source:
<code>public String explainAndPrepare(@CliOption(key = {"", "query"}, mandatory = true, help = "Query to explain and prepare") String sql, @CliOption(key = {"name"}, mandatory = false, help = "query name") String queryName) throws UnsupportedEncodingException { QueryPlan plan = getClient().explainAndPrepare(sql, queryName); <START> if (plan.isHasError() == true) { <END> return "Explain FAILED:" + plan.getErrorMsg(); } StringBuilder planStr = new StringBuilder(plan.getPlanString()); planStr.append("\n").append("Prepare handle:").append(plan.getPrepareHandle()); return planStr.toString(); }</code><technical_language>if (plan.isHasError()) is enough isHasError sounds weird. hasError only? I existing method, change name</technical_language>

Target:
public String explainAndPrepare(@CliOption(key = {"", "query"}, mandatory = true, help = "Query to explain and prepare") String sql, @CliOption(key = {"name"}, mandatory = false, help = "query name") String queryName) throws UnsupportedEncodingException { QueryPlan plan = getClient().explainAndPrepare(sql, queryName); if (plan.isError()) { return "Explain FAILED:" + plan.getErrorMsg(); } StringBuilder planStr = new StringBuilder(plan.getPlanString()); planStr.append("\n").append("Prepare handle:").append(plan.getPrepareHandle()); return planStr.toString(); }
Source:
<code>static <T> Call<T> decorateCall(final RateLimiter rateLimiter, final Call<T> call) { return new DecoratedCall<T>(call) { @Override public Response<T> execute() throws IOException { <START> Try.CheckedSupplier<Response<T>> restrictedSupplier = RateLimiter.decorateCheckedSupplier(rateLimiter, call::execute); <END> final Try<Response<T>> response = Try.of(restrictedSupplier); return response.isSuccess() ? response.get() : tooManyRequestsError(); } private Response<T> tooManyRequestsError() { return Response.error(ERROR_CODE, ResponseBody.create(MediaType.parse("text/plain"), ERROR_MESSAGE)); } }; }</code><technical_language>Try.of(restrictedSupplier).recover(ex -> tooManyRequestsError()).get()</technical_language>

Target:
static <T> Call<T> decorateCall(final RateLimiter rateLimiter, final Call<T> call) { return new DecoratedCall<T>(call) { @Override public Response<T> execute() throws IOException { Try.CheckedSupplier<Response<T>> restrictedSupplier = RateLimiter.decorateCheckedSupplier(rateLimiter, call::execute); final Try<Response<T>> response = Try.of(restrictedSupplier); return response.isSuccess() ? response.get() : handleFailure(response); } private Response<T> handleFailure(Try<Response<T>> response) throws IOException { try { throw response.getCause(); } catch (RequestNotPermitted | IllegalStateException e) { return tooManyRequestsError(); } catch (IOException ioe) { throw ioe; } catch (Throwable t) { throw new RuntimeException("Exception executing call", t); } } private Response<T> tooManyRequestsError() { return Response.error(ERROR_CODE, ResponseBody.create(MediaType.parse("text/plain"), ERROR_MESSAGE)); } }; }
Source:
<code>protected Histogram<Integer> getUnfilteredBaseQHistogram() { <START> return getHistogram(unfilteredBaseQHistogramArray, "baseq", "count"); <END> }</code><technical_language>..UnfilteredBaseQualityCount</technical_language>

Target:
protected Histogram<Integer> getUnfilteredBaseQHistogram() { return getHistogram(unfilteredBaseQHistogramArray, "baseq", "unfiltered_baseq_count"); }
Source:
<code>Response<T> parseResponse(okhttp3.Response rawResponse) throws IOException { ResponseBody rawBody = rawResponse.body(); rawResponse = rawResponse.newBuilder() .body(new NoContentResponseBody(rawBody.contentType(), rawBody.contentLength())) .build(); int code = rawResponse.code(); if (code < 200 || code >= 300) { try { ResponseBody bufferedBody = Utils.buffer(rawBody); return Response.error(bufferedBody, rawResponse); } finally { rawBody.close(); } <START> } else if (code == 204 || code == 205) { <END> rawBody.close(); return Response.success(null, rawResponse); } ExceptionCatchingRequestBody catchingBody = new ExceptionCatchingRequestBody(rawBody); try { T body = serviceMethod.toResponse(catchingBody); return Response.success(body, rawResponse); } catch (RuntimeException e) { catchingBody.throwIfCaught(); throw e; } }</code><technical_language>else is needed a return. Please revert</technical_language>

Target:
Response<T> parseResponse(okhttp3.Response rawResponse) throws IOException { ResponseBody rawBody = rawResponse.body(); rawResponse = rawResponse.newBuilder() .body(new NoContentResponseBody(rawBody.contentType(), rawBody.contentLength())) .build(); int code = rawResponse.code(); if (code < 200 || code >= 300) { try { ResponseBody bufferedBody = Utils.buffer(rawBody); return Response.error(bufferedBody, rawResponse); } finally { rawBody.close(); } } if (code == 204 || code == 205) { rawBody.close(); return Response.success(null, rawResponse); } ExceptionCatchingRequestBody catchingBody = new ExceptionCatchingRequestBody(rawBody); try { T body = serviceMethod.toResponse(catchingBody); return Response.success(body, rawResponse); } catch (RuntimeException e) { catchingBody.throwIfCaught(); throw e; } }
Source:
<code>public void testWatermarkEmissionWithChaining() throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment(1); env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime); env.getConfig().setAutoWatermarkInterval(WATERMARK_INTERVAL_MILLIS); checkState(env.isChainingEnabled()); env .readTextFile(getSourceFile().getAbsolutePath()) .assignTimestampsAndWatermarks(getExtractorAssigner()) .addSink(getWatermarkCounter()); JobExecutionResult result = env.execute(); int actual = result.getAccumulatorResult(NUM_WATERMARKS_ACC_NAME); double expected = ((double) (long) result.getAccumulatorResult(DURATION_ACC_NAME)) / WATERMARK_INTERVAL_MILLIS; assertTrue("too few watermarks emitted: " + actual, actual >= MIN_EXPECTED_WATERMARKS); <START> assertEquals(1, actual / expected, .8d); END> }</code><technical_language>this good me, check this assertion brittle. Is this simply asserting actual number of WMs 20% of expected number -- is based long sink open</technical_language>

Target:
public void testWatermarkEmissionWithChaining() throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment(1); env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime); env.getConfig().setAutoWatermarkInterval(WATERMARK_INTERVAL_MILLIS); checkState(env.isChainingEnabled()); env .readTextFile(getSourceFile().getAbsolutePath()) .assignTimestampsAndWatermarks(getExtractorAssigner()) .addSink(getWatermarkCounter()); JobExecutionResult result = env.execute(); int actual = result.getAccumulatorResult(NUM_WATERMARKS_ACC_NAME); assertTrue("too few watermarks emitted: " + actual, actual >= MIN_EXPECTED_WATERMARKS); }
Source:
<code>public void resetToDefaults() { maximumPageSize = DEFAULT_PAGESIZE; showSiteHeader = true; useFlashClipboard = true; copySelfOnEmail = false; displayPatchSetsInReverseOrder = false; <START> displayPersonNameInReviewCategory = true; <END> downloadUrl = null; downloadCommand = null; dateFormat = null; timeFormat = null; }</code><technical_language>I thought default false</technical_language>

Target:
public void resetToDefaults() { maximumPageSize = DEFAULT_PAGESIZE; showSiteHeader = true; useFlashClipboard = true; copySelfOnEmail = false; displayPatchSetsInReverseOrder = false; displayPersonNameInReviewCategory = false; downloadUrl = null; downloadCommand = null; dateFormat = null; timeFormat = null; }
Source:
<code>public void run() { try { this.eventQueue.put(new DiscoveryServiceEvent(DISCOVERY_INIT_TOPOLOGY)); } catch (Exception e) { <START> log.error("Caught an exception. Stop running."); <END> shutdown(); } while (!shutdown) { try { DiscoveryServiceEvent event = eventQueue.take(); processEvent(event); } catch (Exception | LogReplicationDiscoveryServiceException e) { log.error("Caught an exception. Stop discovery service.", e); shutdown(); } } }</code><technical_language>log.error("...", e) -> print exception I need this try/catch</technical_language>

Target:
private void run() { while (!shutdown) { try { DiscoveryServiceEvent event = eventQueue.take(); processEvent(event); } catch (InterruptedException e) { log.error("Caught an exception. Stop discovery service.", e); shutdown(); } } }
Source:
<code>private String getUrl(String propertyPrefix) { String url = Common.envProps.getString(propertyPrefix + "db.url"); url = StringUtils.replaceMacros(url, System.getProperties()); Path dbPath = getDbPathFromUrl(url); Path dbFolder = dbPath.getParent(); String[] matchingDbs = dbFolder.toFile().list((dir, filename) ->{ if(filename.startsWith(dbPath.getFileName().toString())) return true; else return false; }); int version = 0; for(String match : matchingDbs) { try { int newVersion = getVersion(match); if(newVersion > version) version = newVersion; } catch (IOException e) { } } if(version == 0) version = getCurrentVersion(); <START> url = url + "." + version; <END> if (!url.contains(";DB_CLOSE_ON_EXIT=")) { url += ";DB_CLOSE_ON_EXIT=FALSE"; } if (!url.contains(";MV_STORE=")) { url += ";MV_STORE=FALSE"; } if (!url.contains(";IGNORECASE=")) { url += ";IGNORECASE=TRUE"; } return url; }</code><technical_language>hope H2 arguments in URL work</technical_language>

Target:
private String getUrl(String propertyPrefix) { String url = Common.envProps.getString(propertyPrefix + "db.url"); url = StringUtils.replaceMacros(url, System.getProperties()); String jdbcParts = url.split("jdbc:h2:"); String commandParts = jdbcParts[1].split(";"); Path dbPath = Paths.get(commandParts[0]); Path dbFolder = dbPath.getParent(); String[] matchingDbs = dbFolder.toFile().list((dir, filename) ->{ if(filename.startsWith(dbPath.getFileName().toString())) return true; else return false; }); int version = 0; for(String match : matchingDbs) { try { int newVersion = getVersion(match); if(newVersion > version) version = newVersion; } catch (IOException e) { } } if(version == 0) version = getCurrentVersion(); StringBuilder builder = new StringBuilder(); builder.append("jdbc:h2:"); builder.append(commandParts[0]); builder.append("." + version); for(int i=1; i<commandParts.length; i++) { builder.append(";"); builder.append(commandParts[i]); } url = builder.toString(); if (!url.contains(";DB_CLOSE_ON_EXIT=")) { url += ";DB_CLOSE_ON_EXIT=FALSE"; } if (!url.contains(";MV_STORE=")) { url = url.replaceAll(";MV_STORE=", ""); } if (!url.contains(";IGNORECASE=")) { url += ";IGNORECASE=TRUE"; } return url; }
Source:
<code>public OffHeapChainMap(PageSource source, Portability<? super K> keyPortability, int minPageSize, int maxPageSize, boolean shareByThieving) { this.chainStorage = new OffHeapChainStorageEngine<>(source, keyPortability, minPageSize, maxPageSize, shareByThieving, shareByThieving); <START> EvictionListener<K, InternalChain> listener = callable -> { <END> try { Map.Entry<K, InternalChain> entry = callable.call(); try { if (evictionListener != null) { evictionListener.onEviction(entry.getKey()); } } finally { entry.getValue().close(); } } catch (Exception e) { throw new AssertionError(e); } }; this.heads = new EvictionListeningReadWriteLockedOffHeapClockCache<>(listener, source, chainStorage); }</code><technical_language>I this code JDK 1.8, a bit needless change now. obscures rest of changes</technical_language>

Target:
public OffHeapChainMap(PageSource source, Portability<? super K> keyPortability, int minPageSize, int maxPageSize, boolean shareByThieving) { this.chainStorage = new OffHeapChainStorageEngine<>(source, keyPortability, minPageSize, maxPageSize, shareByThieving, shareByThieving); EvictionListener<K, InternalChain> listener = new EvictionListener<K, InternalChain>() { @Override public void evicting(Callable<Map.Entry<K, InternalChain>> callable) { try { Map.Entry<K, InternalChain> entry = callable.call(); try { if (evictionListener != null) { evictionListener.onEviction(entry.getKey()); } } finally { entry.getValue().close(); } } catch (Exception e) { throw new AssertionError(e); } } }; this.heads = new EvictionListeningReadWriteLockedOffHeapClockCache<>(listener, source, chainStorage); }
Source:
<code>public TaskEditorReviewsPart() { <START> taskReviewStore = TaskReviewsMappingStore.getInstance(); <END> setPartName("Reviews"); }</code><technical_language>A lot of issues brought in this file handled in version, I worry Blaine</technical_language>

Target:
public TaskEditorReviewsPart() { taskReviewStore = TasksUiPlugin.getTaskReviewsMappingStore(); setPartName("Reviews"); }
Source:
<code>protected String generateLabelText(final Map<Integer, String> labels, final List<Integer> selectedFields, final Map<Integer, Field> keyFieldMap, final int row) { if(row < selectedFields.size()) { <START> final String value = labels.get(selectedFields.get(row)) != null ? labels.get(selectedFields.get(row)) : ""; <END> return keyFieldMap.get(selectedFields.get(row)).getName() + FIELDNAME_VALUE_SEPARATOR + value; } return ""; }</code><technical_language>StringUtils.EMPTY</technical_language>

Target:
protected String generateLabelText(final Map<Integer, String> labels, final List<Integer> selectedFields, final Map<Integer, Field> keyFieldMap, final int row) { if(row < selectedFields.size()) { final String value = labels.get(selectedFields.get(row)) != null ? labels.get(selectedFields.get(row)) : StringUtils.EMPTY; return keyFieldMap.get(selectedFields.get(row)).getName() + FIELDNAME_VALUE_SEPARATOR + value; } return ""; }
Source:
<code><START> protected String getReferenceDisplayName() { <END> if (referenceDisplayName == null) { final EObject domainModel = getViewModelContext().getDomainModel(); final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(domainModel); if (domain instanceof AdapterFactoryEditingDomain) { final AdapterFactory factory = ((AdapterFactoryEditingDomain) domain).getAdapterFactory(); final IItemLabelProvider labels = (IItemLabelProvider) factory.adapt(domainModel, IItemLabelProvider.class); if (labels instanceof ResourceLocator) { String typeKey; try { typeKey = getEStructuralFeature().getEType().getName(); referenceDisplayName = ((ResourceLocator) labels) .getString(String.format("_UI_%s_type", typeKey)); } catch (final DatabindingFailedException e) { } } } if (referenceDisplayName == null) { referenceDisplayName = LocalizationServiceHelper.getString(MultiReferenceSWTRenderer.class, MessageKeys.MultiReferenceSWTRenderer_defaultReferenceDisplayName); } } return referenceDisplayName; }</code><technical_language>check EMFFormsLabelProvider provides need? Especially EMFFormsLabelProviderImpl</technical_language>

Target:
protected String getReferenceDisplayName() { if (referenceDisplayName == null) { try { final EStructuralFeature feature = getEStructuralFeature(); if (feature != null) { final EClassifier type = feature.getEType(); final Bundle editBundle = bundleResolver.getEditBundle(type); referenceDisplayName = l10n.getString(editBundle, String.format("_UI_%s_type", type.getName())); } } catch (final DatabindingFailedException e) { } catch (final NoBundleFoundException ex) { } if (referenceDisplayName == null) { referenceDisplayName = LocalizationServiceHelper.getString(MultiReferenceSWTRenderer.class, MessageKeys.MultiReferenceSWTRenderer_defaultReferenceDisplayName); } } return referenceDisplayName; }
Source:
<code>public D create(Parameter[] parameters) { D result; try { result = targetClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { <START> throw new AssertionFailure( "Unexpected failure while instanciating a definition", e ); <END> } result.setType( type ); Map<String, JsonElement> parameterMap = new LinkedHashMap<>( staticParameters ); if ( parameters != null && parameters.length > 0 ) { for ( Parameter parameter : parameters ) { addParameter( parameterMap, parameter.name(), parameter.value() ); } } if ( !parameterMap.isEmpty() ) { result.setParameters( parameterMap ); } return result; }</code><technical_language>instan**t**iating</technical_language>

Target:
public D create(Parameter[] parameters) { D result; try { result = targetClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new AssertionFailure( "Unexpected failure while instantiating a definition", e ); } result.setType( type ); Map<String, String> luceneParameterMap = new LinkedHashMap<>(); if ( parameters != null ) { for ( Parameter parameter : parameters ) { luceneParameterMap.put( parameter.name(), parameter.value() ); } } Map<String, JsonElement> elasticsearchParameterMap = new LinkedHashMap<>(); for ( ParametersTransformer transformer : parameterTransformers ) { elasticsearchParameterMap.putAll( transformer.transform( luceneParameterMap ) ); } if ( !elasticsearchParameterMap.isEmpty() ) { result.setParameters( elasticsearchParameterMap ); } return result; }
Source:
<code>public static boolean isSanitizedHtml(String string) { if (string == null) { return false; } if (isTextContainingAny(string, "<", ">", "\"", "/", "\'")) { return false; } <START> return isTextContainingAny(string, "&lt;", "&gt;", "&quot;", "&#x2f;", "&#39;", "&amp;"); <END> }</code><technical_language>Also, consider this (up you): java return string != null && !isTextContainingAny(string, "<", ">", "\"", "/", "\'") && isTextContainingAny(string, "&lt;", "&gt;", "&quot;", "&#x2f;", "&#39;", "&amp;")</technical_language>

Target:
public static boolean isSanitizedHtml(String string) { return string != null && !isTextContainingAny(string, "<", ">", "\"", "/", "\'") && isTextContainingAny(string, "&lt;", "&gt;", "&quot;", "&#x2f;", "&#39;", "&amp;"); }
Source:
<code>public String toString() { StringBuilder output = new StringBuilder(); if (instance.getId() != null) { output.append(instance.getId()); } <START> return output.toString() + "STATE: " + currentState.toString(); <END> }</code><technical_language>output.append("STATE").append(currentState.toString()).toString</technical_language>

Target:
public String toString() { StringBuilder output = new StringBuilder(); if (instance.getId() != null) { output.append(instance.getId()); } return output.append("STATE").append(currentState.toString()).toString(); }
Source:
<code>public void testCompareTo() { assertEquals(0, sut6Tuple.compareTo(sut6Tuple)); assertEquals(1, sut6Tuple.compareTo(sut1Tuple)); assertEquals(-1, sut1Tuple.compareTo(sut6Tuple)); <START> } <END></code><technical_language>a comparisons of tuples of size of well. Checks tuples of lengths initial item lists sort is based length of tuple</technical_language>

Target:
public void testCompareTo() { int[] nrs = {1, 2, 3, 5, 7, 11, 12, 13}; IntTuple sut6TupleExtended = new IntTuple(nrs); int[] nrs2 = {1, 8, 3, 5, 7, 11}; IntTuple sut6TupleChanged = new IntTuple(nrs2); assertEquals(0, sut6Tuple.compareTo(sut6Tuple)); assertEquals(-1, sut6Tuple.compareTo(sut6TupleChanged)); assertEquals(1, sut6TupleChanged.compareTo(sut6Tuple)); assertEquals(-1, sut6Tuple.compareTo(sut6TupleExtended)); assertEquals(1, sut6TupleExtended.compareTo(sut6Tuple)); }
Source:
<code><START> private Comparator<ITestNGMethod> newComparator(boolean needPrioritySort) { <END> return needPrioritySort ? new TestMethodComparator() : null; }</code><technical_language>static</technical_language>

Target:
private static Comparator<ITestNGMethod> newComparator(boolean needPrioritySort) { return needPrioritySort ? new TestMethodComparator() : null; }
Source:
<code>private void stopRecording() { if (this.screenRecorder != null && this.screenRecorder.getState() == ScreenRecorder.State.RECORDING) { try { <START> TimeUnit.SECONDS.sleep(1); <END> screenRecorder.stop(); } catch (IOException e) { throw new IllegalArgumentException("Exception stopping test recording.", e); } catch (InterruptedException e) { throw new IllegalArgumentException("Exception stopping test recording.", e); } } }</code><technical_language>BTW explicit delay tests unstable instances (debugging, slow build machines, etc.)</technical_language>

Target:
private void stopRecording() { stopRecording(false); }
Source:
<code>public void shouldAllowConcurrentAccesses() throws Exception { final int numIterations = 500000; final String storeName = "word-count-store"; final String windowStoreName = "windowed-word-count-store"; ProducerRunnable producerRunnable = new ProducerRunnable(streamThree, inputValues, 1); producerRunnable.run(); <START> producerRunnable = new ProducerRunnable(streamConcurrent, inputValues, numIterations); <END> final Thread producerThread = new Thread(producerRunnable); kafkaStreams = createCountStream( streamConcurrent, outputTopicConcurrent, outputTopicConcurrentWindowed, storeName, windowStoreName, streamsConfiguration); startKafkaStreamsAndWaitForRunningState(kafkaStreams); producerThread.start(); try { waitUntilAtLeastNumRecordProcessed(outputTopicConcurrent, 1); final ReadOnlyKeyValueStore<String, Long> keyValueStore = kafkaStreams.store(StoreQueryParameters.fromNameAndType(storeName + "-" + streamConcurrent, QueryableStoreTypes.keyValueStore())); final ReadOnlyWindowStore<String, Long> windowStore = kafkaStreams.store(StoreQueryParameters.fromNameAndType(windowStoreName + "-" + streamConcurrent, QueryableStoreTypes.windowStore())); final Map<String, Long> expectedWindowState = new HashMap<>(); final Map<String, Long> expectedCount = new HashMap<>(); while (producerRunnable.getCurrIteration() < numIterations) { verifyGreaterOrEqual(inputValuesKeys.toArray(new String[0]), expectedWindowState, expectedCount, windowStore, keyValueStore); } } finally { producerRunnable.shutdown(); producerThread.interrupt(); producerThread.join(); } }</code><technical_language>this numIterations - 1</technical_language>

Target:
public void shouldAllowConcurrentAccesses() throws Exception { final int numIterations = 500000; final String storeName = "word-count-store"; final String windowStoreName = "windowed-word-count-store"; ProducerRunnable producerRunnable = new ProducerRunnable(streamThree, inputValues, 1); producerRunnable.run(); producerRunnable = new ProducerRunnable(streamConcurrent, inputValues, numIterations - 1); final Thread producerThread = new Thread(producerRunnable); kafkaStreams = createCountStream( streamConcurrent, outputTopicConcurrent, outputTopicConcurrentWindowed, storeName, windowStoreName, streamsConfiguration); startKafkaStreamsAndWaitForRunningState(kafkaStreams); producerThread.start(); try { waitUntilAtLeastNumRecordProcessed(outputTopicConcurrent, 1); final ReadOnlyKeyValueStore<String, Long> keyValueStore = IntegrationTestUtils.getStore(storeName + "-" + streamConcurrent, kafkaStreams, QueryableStoreTypes.keyValueStore()); final ReadOnlyWindowStore<String, Long> windowStore = IntegrationTestUtils.getStore(windowStoreName + "-" + streamConcurrent, kafkaStreams, QueryableStoreTypes.windowStore()); final Map<String, Long> expectedWindowState = new HashMap<>(); final Map<String, Long> expectedCount = new HashMap<>(); while (producerRunnable.getCurrIteration() < numIterations) { verifyGreaterOrEqual(inputValuesKeys.toArray(new String[0]), expectedWindowState, expectedCount, windowStore, keyValueStore); } } finally { producerRunnable.shutdown(); producerThread.interrupt(); producerThread.join(); } }
Source:
<code>public void testRawBytes() { <START> boolean bool0[] = {}; <END> boolean bool1[] = { true }; boolean bool7[] = { true, false, true, false, true, false, true }; boolean bool8[] = { true, false, true, false, true, false, true, false }; boolean bool9[] = { true, false, true, false, true, false, true, false, true }; boolean bool16[] = { false, true, true, false, false, false, true, true, true, true, false, false, false, false, false, true }; byte byte0[] = {}; byte byte1[] = { -128 }; byte byte7[] = { -86 }; byte byte8[] = { -86 }; byte byte9[] = { -86, -128 }; byte byte16[] = { 99, -63 }; assertEqualByteArrays(byte0, Decoder.convertBoolArrayToByteArray(bool0)); assertEqualByteArrays(byte1, Decoder.convertBoolArrayToByteArray(bool1)); assertEqualByteArrays(byte7, Decoder.convertBoolArrayToByteArray(bool7)); assertEqualByteArrays(byte8, Decoder.convertBoolArrayToByteArray(bool8)); assertEqualByteArrays(byte9, Decoder.convertBoolArrayToByteArray(bool9)); assertEqualByteArrays(byte16, Decoder.convertBoolArrayToByteArray(bool16)); }</code><technical_language>Nit: boolean[] bool0... (Java-style array declarations)</technical_language>

Target:
public void testRawBytes() { boolean[] bool0 = {}; boolean[] bool1 = { true }; boolean[] bool7 = { true, false, true, false, true, false, true }; boolean[] bool8 = { true, false, true, false, true, false, true, false }; boolean[] bool9 = { true, false, true, false, true, false, true, false, true }; boolean[] bool16 = { false, true, true, false, false, false, true, true, true, true, false, false, false, false, false, true }; byte[] byte0 = {}; byte[] byte1 = { -128 }; byte[] byte7 = { -86 }; byte[] byte8 = { -86 }; byte[] byte9 = { -86, -128 }; byte[] byte16 = { 99, -63 }; assertArrayEquals(byte0, Decoder.convertBoolArrayToByteArray(bool0)); assertArrayEquals(byte1, Decoder.convertBoolArrayToByteArray(bool1)); assertArrayEquals(byte7, Decoder.convertBoolArrayToByteArray(bool7)); assertArrayEquals(byte8, Decoder.convertBoolArrayToByteArray(bool8)); assertArrayEquals(byte9, Decoder.convertBoolArrayToByteArray(bool9)); assertArrayEquals(byte16, Decoder.convertBoolArrayToByteArray(bool16)); }
Source:
<code>public String toString() { final StringBuilder sb = new StringBuilder(getClass().getSimpleName()); synchronized (mLock) { <START> sb.append("{Media Id=").append(getMediaId()); sb.append("{mMetadata=").append(mMetadata); sb.append(", mStartPositionMs=").append(mStartPositionMs); sb.append(", mEndPositionMs=").append(mEndPositionMs); sb.append('}'); } <END> return sb.toString(); }</code><technical_language>Brackets('{') match ',' '{mMetadata'</technical_language>

Target:
public String toString() { final StringBuilder sb = new StringBuilder(getClass().getSimpleName()); synchronized (mLock) { sb.append("{Media Id=").append(getMediaId()); sb.append(", mMetadata=").append(mMetadata); sb.append(", mStartPositionMs=").append(mStartPositionMs); sb.append(", mEndPositionMs=").append(mEndPositionMs); sb.append('}'); } return sb.toString(); }
Source:
<code>public static Iterable<Map<String, Object>> join(Iterable<Map<?, ?>> input, int batchSize, Function<List<?>, List<Map<String, ?>>> getRowsFunction) { Iterable<Map.Entry<?, ?>> entries = Iterables.concat(Iterables.transform(input, java.util.Map::entrySet)); return FluentIterable.from(Iterables.partition(entries, batchSize)).transformAndConcat( batch -> { Map<?, ?> batchMap = batch.stream().collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())); List<?> keys = batch.stream().map(Map.Entry::getKey).collect(Collectors.toList()); List<Map<String, ?>> batchResult = getRowsFunction.apply(keys); return batchResult.stream().map(result -> { <START> Map<String, Object> map = Maps.newHashMap(); <END> Object row = result.get("row"); map.put(JoinComponent.JOIN_KEY.toString(), row); map.put(JoinComponent.OUTPUT_VALUE.toString(), result); map.put(JoinComponent.INPUT_VALUE.toString(), batchMap.get(row)); return map; }).collect(Collectors.toList()); } ); }</code><technical_language>this ImmutableMap.of()? better, a data object fields hacking this a map? (using a map a bit inefficient, I groovy works here)</technical_language>

Target:
public static Iterable<Map<String, Object>> join(Iterable<Map<?, ?>> input, int batchSize, Function<List<?>, List<Map<String, ?>>> getRowsFunction) { Iterable<Entry<?, ?>> entries = Iterables.concat(Iterables.transform(input, Map::entrySet)); return FluentIterable.from(Iterables.partition(entries, batchSize)).transformAndConcat( batch -> { List<?> keys = batch.stream().map(Entry::getKey).collect(Collectors.toList()); List<Map<String, ?>> batchResult = getRowsFunction.apply(keys); Map<?, ?> resultMap = Maps.uniqueIndex(batchResult, m -> m.get("row")); return batch.stream() .filter(inputItem -> resultMap.containsKey(inputItem.getKey())) .map(batchItem -> { Map<String, Object> map = Maps.newHashMap(); Object row = batchItem.getKey(); map.put(JoinComponent.JOIN_KEY.toString(), row); map.put(JoinComponent.OUTPUT_VALUE.toString(), resultMap.get(row)); map.put(JoinComponent.INPUT_VALUE.toString(), batchItem.getValue()); return map; }).collect(Collectors.toList()); } ); }
Source:
<code>public void stop() { managerNoReturn.stop(); managerNoReturn = null; managerForceReturn.stop(); <START> managerForceReturn.stop(); <END> }</code><technical_language>Is this double invocation performed purpose</technical_language>

Target:
public void stop() { managerNoReturn.stop(); managerNoReturn = null; managerForceReturn.stop(); managerForceReturn = null; }
Source:
<code>public void doFilter( ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain ) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; String uri = "*"; if ( filterConfig != null ) { <START> uri = filterConfig.getInitParameter( "access_control_allow_origin" ); <END> } response.setHeader( ACCESS_CONTROL_ALLOW_ORIGIN, uri ); if ( !"*".equals( uri ) ) { response.setHeader( VARY, "Origin" ); } Enumeration<String> requestMethodEnumeration = request.getHeaders( ACCESS_CONTROL_REQUEST_METHOD ); if ( requestMethodEnumeration != null ) { while ( requestMethodEnumeration.hasMoreElements() ) { String requestMethod = requestMethodEnumeration.nextElement(); addAllowedMethodIfValid( requestMethod, response ); } } Enumeration<String> requestHeaderEnumeration = request.getHeaders( ACCESS_CONTROL_REQUEST_HEADERS ); if ( requestHeaderEnumeration != null ) { while ( requestHeaderEnumeration.hasMoreElements() ) { String requestHeader = requestHeaderEnumeration.nextElement(); addAllowedHeaderIfValid( requestHeader, response ); } } chain.doFilter( request, response ); }</code><technical_language>overhead is negligible, - if passed uri argument constructor of this class, add this additional code hot path</technical_language>

Target:
public void doFilter( ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain ) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; response.setHeader( ACCESS_CONTROL_ALLOW_ORIGIN, accessControlAllowOrigin ); if ( vary != null ) { response.setHeader( VARY, vary ); } Enumeration<String> requestMethodEnumeration = request.getHeaders( ACCESS_CONTROL_REQUEST_METHOD ); if ( requestMethodEnumeration != null ) { while ( requestMethodEnumeration.hasMoreElements() ) { String requestMethod = requestMethodEnumeration.nextElement(); addAllowedMethodIfValid( requestMethod, response ); } } Enumeration<String> requestHeaderEnumeration = request.getHeaders( ACCESS_CONTROL_REQUEST_HEADERS ); if ( requestHeaderEnumeration != null ) { while ( requestHeaderEnumeration.hasMoreElements() ) { String requestHeader = requestHeaderEnumeration.nextElement(); addAllowedHeaderIfValid( requestHeader, response ); } } chain.doFilter( request, response ); }