auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void updateAmount() { Money amount = Money.zero(); for (Map.Entry<JCheckBox, UUID> m : unitBoxes.entrySet()) { if (m.getKey().isSelected()) { amount = amount.plus(campaign.getUnit(m.getValue()).getSellValue()); } } for (Map.Entry<JSlider, Integer> m : partSliders.entrySet()) { int quantity = m.getKey().getValue(); if(quantity > 0) { amount = amount.plus(campaign.getPart(m.getValue()).getCurrentValue().multipliedBy(quantity)); } } for(int i = 0; i < assetBoxes.size(); i++) { JCheckBox box = assetBoxes.get(i); if(box.isSelected()) { amount = amount.plus(campaign.getFinances().getAllAssets().get(i).getValue()); } } int percent = 0; if (loan.getCollateralAmount().isPositive()) { percent = amount .multipliedBy(100) <START> .dividedBy(loan.getCollateralAmount().getAmount().doubleValue()) <END> .getAmount().intValue(); } if(percent < 100) { btnPay.setEnabled(false); } else { btnPay.setEnabled(true); } barAmount.setValue(percent); barAmount.setString(amount.toAmountString() + "/" + loan.getCollateralAmount().toAmountString()); }</code><technical_language>prefer a new overload Money takes a Money object avoid doubleValue call</technical_language>

Target:
private void updateAmount() { Money amount = Money.zero(); for (Map.Entry<JCheckBox, UUID> m : unitBoxes.entrySet()) { if (m.getKey().isSelected()) { amount = amount.plus(campaign.getUnit(m.getValue()).getSellValue()); } } for (Map.Entry<JSlider, Integer> m : partSliders.entrySet()) { int quantity = m.getKey().getValue(); if(quantity > 0) { amount = amount.plus(campaign.getPart(m.getValue()).getCurrentValue().multipliedBy(quantity)); } } for(int i = 0; i < assetBoxes.size(); i++) { JCheckBox box = assetBoxes.get(i); if(box.isSelected()) { amount = amount.plus(campaign.getFinances().getAllAssets().get(i).getValue()); } } int percent = 0; if (loan.getCollateralAmount().isPositive()) { percent = amount .multipliedBy(100) .dividedBy(loan.getCollateralAmount()) .getAmount().intValue(); } if(percent < 100) { btnPay.setEnabled(false); } else { btnPay.setEnabled(true); } barAmount.setValue(percent); barAmount.setString(amount.toAmountString() + "/" + loan.getCollateralAmount().toAmountString()); }
Source:
<code><START> RetryAfterDecoder(DateFormat rfc822Format) { <END> this.rfc822Format = checkNotNull(rfc822Format, "rfc822Format"); }</code><technical_language>do need this customizable</technical_language>

Target:
RetryAfterDecoder(DateFormat rfc822Format) { this.rfc822Format = Util.checkNotNull(rfc822Format, "rfc822Format"); }
Source:
<code><START> private List<Artifact> calculateArtifacts(Iterable<GradleDeployDetails> deployDetails) throws Exception { List<Artifact> artifacts = newArrayList(transform(deployDetails, new Function<GradleDeployDetails, Artifact>() { public Artifact apply(GradleDeployDetails from) { PublishArtifactInfo publishArtifact = from.getPublishArtifact(); DeployDetails deployDetails = from.getDeployDetails(); String artifactPath = deployDetails.getArtifactPath(); int index = artifactPath.lastIndexOf('/'); return new ArtifactBuilder(artifactPath.substring(index + 1)) .type(getTypeString(publishArtifact.getType(), publishArtifact.getClassifier(), publishArtifact.getExtension())) .md5(deployDetails.getMd5()).sha1(deployDetails.getSha1()).build(); } })); return artifacts; <END> }</code><technical_language>This function simplified to: java private List<Artifact> calculateArtifacts(Iterable<GradleDeployDetails> deployDetails) { return newArrayList(StreamSupport.stream(deployDetails.spliterator(), false).map(from -> { PublishArtifactInfo publishArtifact = from.getPublishArtifact(); DeployDetails deployDetails1 = from.getDeployDetails(); String artifactPath = deployDetails1.getArtifactPath(); int index = artifactPath.lastIndexOf('/'); return new ArtifactBuilder(artifactPath.substring(index + 1)) .type(getTypeString(publishArtifact.getType(), publishArtifact.getClassifier(), publishArtifact.getExtension())) .md5(deployDetails1.getMd5()).sha1(deployDetails1.getSha1()).build(); }).collect(Collectors.toList())); }</technical_language>

Target:
private List<Artifact> calculateArtifacts(Iterable<GradleDeployDetails> deployDetails) { return newArrayList(StreamSupport.stream(deployDetails.spliterator(), false).map(from -> { PublishArtifactInfo publishArtifact = from.getPublishArtifact(); DeployDetails deployDetails1 = from.getDeployDetails(); String artifactPath = deployDetails1.getArtifactPath(); int index = artifactPath.lastIndexOf('/'); return new ArtifactBuilder(artifactPath.substring(index + 1)) .type(getTypeString(publishArtifact.getType(), publishArtifact.getClassifier(), publishArtifact.getExtension())) .md5(deployDetails1.getMd5()).sha1(deployDetails1.getSha1()).build(); }).collect(Collectors.toList())); }
Source:
<code><START> public void setIOConfiguration(IOLine ioLine, IOMode ioMode) throws InvalidOperatingModeException, XBeeException { <END> if (!connectionInterface.isOpen()) throw new XBeeException(XBeeException.CONNECTION_NOT_OPEN); if (ioLine == null) throw new NullPointerException("IO line cannot be null."); if (ioMode == null) throw new NullPointerException("IO mode cannot be null."); String atCommand = ioLine.getATCommand(); ATCommandResponse response = sendATCommand(new ATCommand(atCommand, new byte[]{(byte)ioMode.getID()})); if (response == null || response.getResponseStatus() != ATCommandStatus.OK) throw new XBeeException(XBeeException.INVALID_OPERATION); }</code><technical_language>This need revisited throw proper exceptions</technical_language>

Target:
public void setIOConfiguration(IOLine ioLine, IOMode ioMode) throws InvalidOperatingModeException, XBeeException { if (!connectionInterface.isOpen()) throw new XBeeException(XBeeException.CONNECTION_NOT_OPEN); if (ioLine == null) throw new NullPointerException("IO line cannot be null."); if (ioMode == null) throw new NullPointerException("IO mode cannot be null."); String atCommand = ioLine.getConfigurationATCommand(); ATCommandResponse response = sendATCommand(new ATCommand(atCommand, new byte[]{(byte)ioMode.getID()})); if (response == null || response.getResponseStatus() != ATCommandStatus.OK) throw new XBeeException(XBeeException.INVALID_OPERATION); }
Source:
<code>public boolean test(Pipeline pipeline) { if (!environment.containsArgument("disabled")) { return true; } boolean disabled = environment.getArgument("disabled"); <START> return (Boolean) pipeline.getOrDefault("disabled", false) == disabled; <END> }</code><technical_language>I cast (Boolean) is needed</technical_language>

Target:
public boolean test(Pipeline pipeline) { if (!environment.containsArgument("disabled")) { return true; } boolean desired = environment.getArgument("disabled"); Boolean disabled = (Boolean) pipeline.get("disabled"); if (disabled == null) { return desired; } return disabled == desired; }
Source:
<code>public boolean hasPrivileges(SecurityContext sc, Privilege[] privileges) { boolean res = false; for (AccessControlEntryImpl ace : principals.values()) { if (ace.getPrincipal().getName().equals(SimplePrincipal.EVERYONE.getName())) { <START> res |= ace.hasPrivileges(privileges); <END> } if (ace.getPrincipal().getName().equals(sc.getUserName())) { res |= ace.hasPrivileges(privileges); } if (sc.hasRole(ace.getPrincipal().getName())) { res |= ace.hasPrivileges(privileges); } } return res; }</code><technical_language>If res is true this point, return checking else? Or, remaining if blocks check for !res? (IMO, is a tad more efficient possibly a bit easier scanning code, is bad, either.)</technical_language>

Target:
public boolean hasPrivileges(SecurityContext sc, Privilege[] privileges) { for (AccessControlEntryImpl ace : principals.values()) { if (ace.getPrincipal().getName().equals(SimplePrincipal.EVERYONE.getName())) { if (ace.hasPrivileges(privileges)) { return true; } } if (ace.getPrincipal().getName().equals(sc.getUserName())) { if (ace.hasPrivileges(privileges)) { return true; } } if (sc.hasRole(ace.getPrincipal().getName())) { if (ace.hasPrivileges(privileges)) { return true; } } } return false; }
Source:
<code>public PlanNode visitAggregation(AggregationNode node, RewriteContext<Context> context) { context.get().variables.addAll(node.getGroupingKeys()); <START> for (AggregationNode.Aggregation aggregation : node.getAggregations().values()) { <END> aggregation.getArguments().forEach(expression -> subfieldExtractor.process(expression, context.get())); aggregation.getFilter().ifPresent(expression -> subfieldExtractor.process(expression, context.get())); aggregation.getOrderBy() .map(OrderingScheme::getOrderBy) .ifPresent(context.get().variables::addAll); aggregation.getMask().ifPresent(context.get().variables::add); } return context.defaultRewrite(node, context.get()); }</code><technical_language>aware of conflict #12710 depending lands first. cc: @hellium01</technical_language>

Target:
public PlanNode visitAggregation(AggregationNode node, RewriteContext<Context> context) { context.get().variables.addAll(node.getGroupingKeys()); for (AggregationNode.Aggregation aggregation : node.getAggregations().values()) { aggregation.getArguments().forEach(expression -> subfieldExtractor.process(castToExpression(expression), context.get())); aggregation.getFilter().ifPresent(expression -> subfieldExtractor.process(castToExpression(expression), context.get())); aggregation.getOrderBy() .map(OrderingScheme::getOrderBy) .ifPresent(context.get().variables::addAll); aggregation.getMask().ifPresent(context.get().variables::add); } return context.defaultRewrite(node, context.get()); }
Source:
<code><START> public QualifierRangeFilter(String family) { <END> range.setFamilyName(Preconditions.checkNotNull(family)); }</code><technical_language>please limit visibility of constructor</technical_language>

Target:
private QualifierRangeFilter(String family) { range.setFamilyName(Preconditions.checkNotNull(family)); }
Source:
<code>public synchronized Slice2DIndex getSlice2DIndex(int imageIndex) throws IOException { long addressPosition = ADDRESS_POSITION + imageIndex * ADDRESS_SIZE; raf.seek(addressPosition); long dataPosition = raf.readLong(); long endDataPosition = raf.readLong(); raf.seek(dataPosition); <START> int dimensions = raf.readInt(); <END> int[] index = new int[dimensions]; for (int i = 0; i < dimensions; i++) { index[i] = raf.readInt(); } int stringSize = (int) (endDataPosition - raf.getFilePointer()); byte[] stringBytes = new byte[stringSize]; raf.read(stringBytes); String varName = new String(stringBytes); return new Slice2DIndex(index, varName); }</code><technical_language>Sorry, I notice before: this change break configured layer in GeoServer? wondering if new code running a .idx configured previous code throws exceptions refers wrong values. TOPIC: Andrea changed sampleImage stored ImageMosaic stopped working configured layers, needed introduce backward-compatibility fix a naming for new file. Wondering if this slices change needs similar checks</technical_language>

Target:
public synchronized Slice2DIndex getSlice2DIndex(int imageIndex) throws IOException { long addressPosition = ADDRESS_POSITION + imageIndex * ADDRESS_SIZE; raf.seek(addressPosition); long dataPosition = raf.readLong(); long endDataPosition = raf.readLong(); raf.seek(dataPosition); int nextValue = raf.readInt(); int[] index; if (nextValue < 0) { int dimensions = -nextValue; index = new int[dimensions]; for (int i = 0; i < dimensions; i++) { index[i] = raf.readInt(); } } else { index = new int[2]; index[VariableAdapter.T] = nextValue; index[VariableAdapter.Z] = raf.readInt(); } int stringSize = (int) (endDataPosition - raf.getFilePointer()); byte[] stringBytes = new byte[stringSize]; raf.read(stringBytes); String varName = new String(stringBytes); return new Slice2DIndex(index, varName); }
Source:
<code>private TreeWalker(String namespace, JSTypeRegistry typeRegistry, Set<String> provides) { this.namespace = namespace; this.typeRegistry = typeRegistry; this.provides = provides; <START> this.valueSymbolsWalked = 0; <END> }</code><technical_language>Initialize in field declaration</technical_language>

Target:
private TreeWalker(String namespace, JSTypeRegistry typeRegistry, Set<String> provides) { this.namespace = namespace; this.typeRegistry = typeRegistry; this.provides = provides; }
Source:
<code>public void testProtectedBasicUserEndpointPrincipalIsNotAuthorized403() { try { RULE.getJerseyTest().target("/protected").request() .header(HttpHeaders.AUTHORIZATION, "Basic Z3Vlc3Q6c2VjcmV0") .get(String.class); <START> failBecauseExceptionWasNotThrown(WebApplicationException.class); <END> } catch (WebApplicationException e) { assertThat(e.getResponse().getStatus()).isEqualTo(403); } }</code><technical_language>a ForbiddenException work is a WebApplicationException thrown</technical_language>

Target:
public void testProtectedBasicUserEndpointPrincipalIsNotAuthorized403() { try { RULE.getJerseyTest().target("/protected").request() .header(HttpHeaders.AUTHORIZATION, "Basic Z3Vlc3Q6c2VjcmV0") .get(String.class); failBecauseExceptionWasNotThrown(ForbiddenException.class); } catch (ForbiddenException e) { assertThat(e.getResponse().getStatus()).isEqualTo(403); } }
Source:
<code>public boolean hasE() { <START> return index() == 4; <END> }</code><technical_language>Now, I need a class constants shared package. Please consider. magic constants obvious, "magic constants". IndexOf.E for example</technical_language>

Target:
public boolean hasE() { return IndexOf.E.is(index()); }
Source:
<code>public TransactionManagerElement getTransactionManagerInfo() throws JAXBException { String xml = httpRequest(new int[]{HttpURLConnection.HTTP_OK, HttpURLConnection.HTTP_UNSUPPORTED_TYPE}, txnMgr, "GET", TxMediaType.TX_STATUS_EXT_MEDIA_TYPE); if (status == HttpURLConnection.HTTP_UNSUPPORTED_TYPE ) return null; <START> System.out.printf("Unmarshalling TransactionManagerElement%n%s", xml); <END> JAXBContext jc = JAXBContext.newInstance(TransactionManagerElement.class.getPackage().getName() ); Unmarshaller u = jc.createUnmarshaller(); Object o = u.unmarshal( new StreamSource( new StringReader(xml))); if (o instanceof TransactionManagerElement) return (TransactionManagerElement)o; return (TransactionManagerElement)((JAXBElement)o).getValue(); }</code><technical_language>System.out logger</technical_language>

Target:
public TransactionManagerElement getTransactionManagerInfo() throws JAXBException { String xml = httpRequest(new int[]{HttpURLConnection.HTTP_OK, HttpURLConnection.HTTP_UNSUPPORTED_TYPE}, txnMgr, "GET", TxMediaType.TX_STATUS_EXT_MEDIA_TYPE); if (status == HttpURLConnection.HTTP_UNSUPPORTED_TYPE ) return null; if (log.isTraceEnabled()) log.tracef("Unmarshalling TransactionManagerElement%n%s", xml); JAXBContext jc = JAXBContext.newInstance(TransactionManagerElement.class.getPackage().getName() ); Unmarshaller u = jc.createUnmarshaller(); Object o = u.unmarshal( new StreamSource( new StringReader(xml))); if (o instanceof TransactionManagerElement) return (TransactionManagerElement)o; return (TransactionManagerElement)((JAXBElement)o).getValue(); }
Source:
<code>public void writeToParcel(Parcel parcel, int flags) { parcel.writeString(namespace); parcel.writeString(text); parcel.writeString(fragment); parcel.writeParcelable(site, flags); <START> if (hasProperties()) { <END> parcel.writeParcelable(properties, flags); } parcel.writeString(thumbUrl); parcel.writeString(description); }</code><technical_language>a Parcel expert I want write this out unconditionally. If don't, I constructor byte offsets wrong for other values</technical_language>

Target:
public void writeToParcel(Parcel parcel, int flags) { parcel.writeString(namespace); parcel.writeString(text); parcel.writeString(fragment); parcel.writeParcelable(site, flags); parcel.writeParcelable(properties, flags); parcel.writeString(thumbUrl); parcel.writeString(description); }
Source:
<code>private List<String> getDeployedModules(String containerId) { try { CuratorFramework client = zkConnection.getClient(); if (null != client.checkExists().forPath(Paths.build(Paths.CONTAINERS, containerId))) { return client.getChildren().forPath(path(containerId)); } } catch (Exception e) { <START> throw ZooKeeperUtils.wrapThrowable(e); <END> } return Collections.emptyList(); }</code><technical_language>a good idea ignore NoNodeException is a chance exists() call getChildren() call above, node disappear (if so, ignore return empty list below)</technical_language>

Target:
private List<String> getDeployedModules(String containerId) { try { CuratorFramework client = zkConnection.getClient(); if (null != client.checkExists().forPath(Paths.build(Paths.CONTAINERS, containerId))) { return client.getChildren().forPath(path(containerId)); } } catch (Exception e) { ZooKeeperUtils.wrapAndThrowIgnoring(e, NoNodeException.class); } return Collections.emptyList(); }
Source:
<code>public static void main(String[] args) { new Log(); <START> String[] levels = { "/level/3.txt"}; <END> new Launcher().start(levels); }</code><technical_language>I assume loaded level3 for testing, right? Please change able load 3 levels. <bug</technical_language>

Target:
public static void main(String[] args) { new Log(); String[] levels = {"/level/1.txt", "/level/2.txt", "/level/3.txt"}; new Launcher().start(levels); }
Source:
<code>public Flux<Payload> requestChannel(Payload payload, Publisher<Payload> payloads) { try { <START> return responderRSocket.requestChannel(payloads); <END> } catch (Throwable t) { return Flux.error(t); } }</code><technical_language>this call other form payload argument</technical_language>

Target:
public Flux<Payload> requestChannel(Payload payload, Publisher<Payload> payloads) { try { return responderRSocket.requestChannel(payload, payloads); } catch (Throwable t) { return Flux.error(t); } }
Source:
<code>public static void GetClusterByServiceList(AsyncQuery aQuery, Guid dataCenterId, final boolean supportsVirtService, final boolean supportsGlusterService) { aQuery.converterCallback = new IAsyncConverter() { @Override public Object Convert(Object source, AsyncQuery _asyncQuery) { if (source == null) { return new ArrayList<VDSGroup>(); } final ArrayList<VDSGroup> list = (ArrayList<VDSGroup>) source; final ArrayList<VDSGroup> filteredList = new ArrayList<VDSGroup>(); <START> for(VDSGroup cluster : list) { <END> if ((supportsVirtService && cluster.supportsVirtService()) || (supportsGlusterService && cluster.supportsGlusterService())) { filteredList.add(cluster); } } Collections.sort(filteredList, new Linq.VdsGroupByNameComparer()); return filteredList; } }; Frontend.RunQuery(VdcQueryType.GetVdsGroupsByStoragePoolId, new StoragePoolQueryParametersBase(dataCenterId), aQuery); }</code><technical_language>consider extracting filter logic helper method (it's in GetClustersWithPermittedAction)</technical_language>

Target:
public static void GetClusterByServiceList(AsyncQuery aQuery, Guid dataCenterId, final boolean supportsVirtService, final boolean supportsGlusterService) { aQuery.converterCallback = new IAsyncConverter() { @Override public Object Convert(Object source, AsyncQuery _asyncQuery) { if (source == null) { return new ArrayList<VDSGroup>(); } final ArrayList<VDSGroup> list = (ArrayList<VDSGroup>) source; return getClusterByServiceList(list, supportsVirtService, supportsGlusterService); } }; Frontend.RunQuery(VdcQueryType.GetVdsGroupsByStoragePoolId, new StoragePoolQueryParametersBase(dataCenterId), aQuery); }
Source:
<code>public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game); for (Permanent perm : permanents) { List<String> cardSubType = perm.getSubtype(game); <START> if (!cardSubType.contains("Sliver") && perm.getOwnerId() == player.getId()) { <END> cardSubType.add("Sliver"); } } return true; }</code><technical_language>do equals() instead of ==</technical_language>

Target:
public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game); for (Permanent perm : permanents) { List<String> cardSubType = perm.getSubtype(game); if (!cardSubType.contains("Sliver") && perm.getOwnerId().equals(player.getId())) { cardSubType.add("Sliver"); } } return true; }
Source:
<code>public void testAggregationPushdownThroughOuterJoinNotFiringInCorrelatedAggregatesLeftSide() { <START> assertQuery("SELECT max(x) from (SELECT * from (VALUES 1) t(x) LEFT JOIN (VALUES 1) t2(y) ON t.x = t2.y) GROUP BY x", <END> "VALUES 1"); }</code><technical_language>please put parameter in separate line :)</technical_language>

Target:
public void testAggregationPushdownThroughOuterJoinNotFiringInCorrelatedAggregatesLeftSide() { assertQuery("SELECT max(x) FROM" + "(SELECT * from (VALUES 1) t(x) LEFT JOIN (VALUES 1) t2(y) ON t.x = t2.y)" + "GROUP BY x", "VALUES 1"); }
Source:
<code>public static ResourceSchema getResourceSchema(final Configuration configuration, Dependencies dependencies) throws IOException { final ResourceSchema schema = new ResourceSchema(); try { List<ColumnInfo> columns = null; final SchemaType schemaType = PhoenixConfigurationUtil.getSchemaType(configuration); if(SchemaType.QUERY.equals(schemaType)) { final String sqlQuery = PhoenixConfigurationUtil.getSelectStatement(configuration); Preconditions.checkNotNull(sqlQuery, "No Sql Query exists within the configuration"); final SqlQueryToColumnInfoFunction function = new SqlQueryToColumnInfoFunction(configuration); columns = function.apply(sqlQuery); <START> } else if (SchemaType.TABLE.equals(schemaType)) { <END> columns = dependencies.getSelectColumnMetadataList(configuration); } ResourceFieldSchema fields[] = new ResourceFieldSchema[columns.size()]; int i = 0; for(ColumnInfo cinfo : columns) { int sqlType = cinfo.getSqlType(); PDataType phoenixDataType = PDataType.fromTypeId(sqlType); byte pigType = TypeUtil.getPigDataTypeForPhoenixType(phoenixDataType); ResourceFieldSchema field = new ResourceFieldSchema(); field.setType(pigType).setName(cinfo.getDisplayName()); fields[i++] = field; } schema.setFields(fields); } catch(SQLException sqle) { LOG.error(String.format("Error: SQLException [%s] ",sqle.getMessage())); throw new IOException(sqle); } return schema; }</code><technical_language>nit: Earlier == for enum comparison, is a standard for Phoenix</technical_language>

Target:
public static ResourceSchema getResourceSchema(final Configuration configuration, Dependencies dependencies) throws IOException { final ResourceSchema schema = new ResourceSchema(); try { List<ColumnInfo> columns = null; final SchemaType schemaType = PhoenixConfigurationUtil.getSchemaType(configuration); if(schemaType == SchemaType.QUERY) { final String sqlQuery = PhoenixConfigurationUtil.getSelectStatement(configuration); Preconditions.checkNotNull(sqlQuery, "No Sql Query exists within the configuration"); final SqlQueryToColumnInfoFunction function = new SqlQueryToColumnInfoFunction(configuration); columns = function.apply(sqlQuery); } else if (schemaType == SchemaType.TABLE) { columns = dependencies.getSelectColumnMetadataList(configuration); } ResourceFieldSchema fields[] = new ResourceFieldSchema[columns.size()]; int i = 0; for(ColumnInfo cinfo : columns) { int sqlType = cinfo.getSqlType(); PDataType phoenixDataType = PDataType.fromTypeId(sqlType); byte pigType = TypeUtil.getPigDataTypeForPhoenixType(phoenixDataType); ResourceFieldSchema field = new ResourceFieldSchema(); field.setType(pigType).setName(cinfo.getDisplayName()); fields[i++] = field; } schema.setFields(fields); } catch(SQLException sqle) { LOG.error(String.format("Error: SQLException [%s] ",sqle.getMessage())); throw new IOException(sqle); } return schema; }
Source:
<code>public void add(final SampleResult sample) { synchronized (buffer) { buffer.add(sample); dataChanged = true; <START> CorrelationRecorder.setBuffer(buffer); <END> } }</code><technical_language>This correct in terms of isolation of objects. is this call needed</technical_language>

Target:
public void add(final SampleResult sample) { synchronized (buffer) { buffer.add(sample); dataChanged = true; } }
Source:
<code>public void testExceptionalCases() { ______TS("Case where more than 1 question with same question number"); FeedbackQuestionAttributes question = testData.feedbackQuestions.get("qn2InSession4"); assertEquals(2, question.questionNumber); FeedbackQuestionAttributes questionFromDatastore = BackDoor.getFeedbackQuestion(question.courseId, question.feedbackSessionName, question.questionNumber); assertEquals(question, questionFromDatastore); questionFromDatastore.questionNumber = 1; BackDoor.editFeedbackQuestion(questionFromDatastore); resultsPage = loginToInstructorFeedbackResultsPage("CFResultsUiT.instr", "Session with errors"); resultsPage.waitForPanelsToCollapse(); <START> resultsPage.verifyHtmlMainContent("/instructorFeedbackResultsPageWithDuplicateQuestionNumber.html"); <END> }</code><technical_language>this consistently pass? sort order of questions deterministic right</technical_language>

Target:
public void testExceptionalCases() { ______TS("Case where more than 1 question with same question number"); FeedbackQuestionAttributes firstQuestion = testData.feedbackQuestions.get("qn1InSession4"); assertEquals(1, firstQuestion.questionNumber); FeedbackQuestionAttributes firstQuestionFromDatastore = BackDoor.getFeedbackQuestion(firstQuestion.courseId, firstQuestion.feedbackSessionName, firstQuestion.questionNumber); FeedbackQuestionAttributes secondQuestion = testData.feedbackQuestions.get("qn2InSession4"); assertEquals(2, secondQuestion.questionNumber); FeedbackQuestionAttributes secondQuestionFromDatastore = BackDoor.getFeedbackQuestion(secondQuestion.courseId, secondQuestion.feedbackSessionName, secondQuestion.questionNumber); assertEquals(secondQuestion, secondQuestionFromDatastore); secondQuestionFromDatastore.questionNumber = 1; BackDoor.editFeedbackQuestion(secondQuestionFromDatastore); resultsPage = loginToInstructorFeedbackResultsPage("CFResultsUiT.instr", "Session with errors"); resultsPage.waitForPanelsToCollapse(); By firstQuestionPanel = By.xpath(" + firstQuestionFromDatastore.getId() + "']]"); resultsPage.verifyHtmlPart(firstQuestionPanel, "/instructorFeedbackResultsDuplicateQuestionNumberPanel1.html"); By secondQuestionPanel = By.xpath(" + secondQuestionFromDatastore.getId() + "']]"); resultsPage.verifyHtmlPart(secondQuestionPanel, "/instructorFeedbackResultsDuplicateQuestionNumberPanel2.html"); }
Source:
<code>public void drawTitle(GameContainer container) { if (won) { typeFontTitle.drawString( container.getWidth() / 2 - typeFontTitle.getWidth(gameOverText) / 2, container.getHeight() / 8, gameWonText, Color.yellow); } else { typeFontTitle.drawString( container.getWidth() / 2 <START> - typeFontTitle.getWidth(gameOverText) / 2, <END> container.getHeight() / 8, gameOverText, Color.yellow); } }</code><technical_language>gameOverText in branches of if-statement. Also, I variable for this, give of texts. get this text, a controller instead of this class, logic in this class</technical_language>

Target:
private void drawTitle(GameContainer container) { if (won) { gameTitleText = "GAME COMPLETED"; } else { gameTitleText = "GAME LOST"; } typeFontTitle.drawString( container.getWidth() / 2 - typeFontTitle.getWidth(gameTitleText) / 2, container.getHeight() / 8, gameTitleText, Color.yellow); }
Source:
<code>private List<LookupBean> getLookupListFromCoordinator(String tier) { try { final FullResponseHolder response = fetchLookupsForTier(tier); List<LookupBean> lookupBeanList = new ArrayList<>(); if (!response.getStatus().equals(HttpResponseStatus.OK)) { LOG.error( "Error while fetching lookup code from Coordinator with status[%s] and content[%s]", response.getStatus(), response.getContent() ); return null; } else { if (response.getContent().startsWith("[")) { return null; } else { Map<String, LookupExtractorFactoryContainer> lookupMap = jsonMapper.readValue( response.getContent(), LOOKUPS_ALL_REFERENCE ); if (!lookupMap.isEmpty()) { for (Map.Entry<String, LookupExtractorFactoryContainer> e : lookupMap.entrySet()) { lookupBeanList.add(new LookupBean(e.getKey(), null, e.getValue())); } } } } return lookupBeanList; } catch (ISE ise) { LOG.error(ise, "Coordinator is unavailable"); return null; } catch (Exception e) { <START> LOG.error(e, "Error while parsing lookup code for tier [%s] from response", tier); <END> return null; } }</code><technical_language>I change message generic Error while get lookup list coordinator for tier[%s] exception specific details. remove other catch block covering ISE specially</technical_language>

Target:
private List<LookupBean> getLookupListFromCoordinator(String tier) { try { final FullResponseHolder response = fetchLookupsForTier(tier); List<LookupBean> lookupBeanList = new ArrayList<>(); if (!response.getStatus().equals(HttpResponseStatus.OK)) { LOG.error( "Error while fetching lookup code from Coordinator with status[%s] and content[%s]", response.getStatus(), response.getContent() ); return null; } if (response.getContent().startsWith("[")) { LOG.info("Failed to retrieve lookup information from coordinator. Attempting to load lookups using snapshot instead"); return null; } else { Map<String, LookupExtractorFactoryContainer> lookupMap = jsonMapper.readValue( response.getContent(), LOOKUPS_ALL_REFERENCE ); lookupMap.forEach((k, v) -> lookupBeanList.add(new LookupBean(k, null, v))); } return lookupBeanList; } catch (Exception e) { LOG.error(e, "Error while trying to get lookup list from coordinator for tier[%s]", tier); return null; } }
Source:
<code>public void testListPath() throws Exception { Configuration config = new Configuration(this.getRawConfiguration()); <START> config.set("fs.azure.list.max.results", "5000"); <END> final AzureBlobFileSystem fs = (AzureBlobFileSystem) FileSystem .newInstance(getFileSystem().getUri(), config); final List<Future<Void>> tasks = new ArrayList<>(); ExecutorService es = Executors.newFixedThreadPool(10); for (int i = 0; i < TEST_FILES_NUMBER; i++) { final Path fileName = new Path("/test" + i); Callable<Void> callable = new Callable<Void>() { @Override public Void call() throws Exception { touch(fileName); return null; } }; tasks.add(es.submit(callable)); } for (Future<Void> task : tasks) { task.get(); } es.shutdownNow(); FileStatus[] files = fs.listStatus(new Path("/")); assertEquals(TEST_FILES_NUMBER, files.length ); }</code><technical_language>constant</technical_language>

Target:
public void testListPath() throws Exception { Configuration config = new Configuration(this.getRawConfiguration()); config.set(AZURE_LIST_MAX_RESULTS, "5000"); final AzureBlobFileSystem fs = (AzureBlobFileSystem) FileSystem .newInstance(getFileSystem().getUri(), config); final List<Future<Void>> tasks = new ArrayList<>(); ExecutorService es = Executors.newFixedThreadPool(10); for (int i = 0; i < TEST_FILES_NUMBER; i++) { final Path fileName = new Path("/test" + i); Callable<Void> callable = new Callable<Void>() { @Override public Void call() throws Exception { touch(fileName); return null; } }; tasks.add(es.submit(callable)); } for (Future<Void> task : tasks) { task.get(); } es.shutdownNow(); FileStatus[] files = fs.listStatus(new Path("/")); assertEquals(TEST_FILES_NUMBER, files.length ); }
Source:
<code><START> protected void endActionOnVmConfiguration() { <END> if (getVm().getstatus() == VMStatus.ImageLocked) { VmHandler.unlockVm(getVm(), getCompensationContext()); } UpdateVmInSpm(getVm().getstorage_pool_id(), Arrays.asList(getVm())); setSucceeded(true); }</code><technical_language>i strongly disagree removing check for vm is null, is case vm is deleted here? this code is called for async tasks IIRC, including remove vm this is defensive code i introduced of a bad experience..</technical_language>

Target:
protected void endActionOnVmConfiguration() { if (getVm() != null) { if (getVm().getstatus() == VMStatus.ImageLocked) { VmHandler.unlockVm(getVm(), getCompensationContext()); } UpdateVmInSpm(getVm().getstorage_pool_id(), Arrays.asList(getVm())); } else { setCommandShouldBeLogged(false); log.warn("VmCommand::EndVmCommand: Vm is null - not performing EndAction on Vm"); } setSucceeded(true); }
Source:
<code><START> public ValidationResult isReadOnlyPropertyCompatibleWithLunInterface() { <END> if (Boolean.TRUE.equals(disk.getReadOnly()) && disk.getDiskInterface() == DiskInterface.VirtIO_SCSI) { return new ValidationResult( VdcBllMessages.ACTION_TYPE_FAILED_VIRT_IO_SCSI_INTERFACE_FOR_LUN_TARGETS_DOES_NOT_SUPPORT_READ_ONLY_ATTR); } return ValidationResult.VALID; }</code><technical_language>1. please remove "Lun" methods name, this resides in DiskValidator, if want perform check disk.getDiskStorageType() is LUN, return valid result 2. this method is similar previous (isReadOnlyPropertyCompatibleWithInterface), merge method get interface/message parameters</technical_language>

Target:
public ValidationResult isReadOnlyPropertyCompatibleWithLunInterface() { if (Boolean.TRUE.equals(disk.getReadOnly()) && disk.getDiskInterface() == DiskInterface.VirtIO_SCSI) { return new ValidationResult( VdcBllMessages.ACTION_TYPE_FAILED_VIRT_IO_SCSI_INTERFACE_FOR_LUN_DISKS_DOES_NOT_SUPPORT_READ_ONLY_ATTR); } return ValidationResult.VALID; }
Source:
<code>public void setUp() throws Exception { Person person1 = new Person(); person1.addName(new PersonName("givenName", "middleName", "familyName")); user1 = new User(person1); Person person2 = new Person(); person2.addName(new PersonName("givenName", "middleNamf", "familyName")); user2 = new User(person2); nullUser = null; <START> } <END></code><technical_language>@ayush2297 changes part of ticket formatting changes</technical_language>

Target:
public void setUp() throws Exception { Person person1 = new Person(); person1.addName(new PersonName("givenName", "middleName", "familyName")); user1 = new User(person1); Person person2 = new Person(); person2.addName(new PersonName("givenName", "middleNamf", "familyName")); user2 = new User(person2); Person person3 = new Person(); person3.addName(new PersonName("givenName", "middleNamf", "familyNaae")); user3 = new User(person3); nullUser1 = null; nullUser2 = null; }
Source:
<code>void shutdown() { List<NGSession> allSessions; synchronized(lock) { done = true; allSessions = Stream.concat(workingPool.stream(), idlePool.stream()).collect(Collectors.toList()); idlePool.clear(); workingPool.clear(); } for (NGSession session : allSessions) { session.shutdown(); } for (NGSession session : allSessions) { try { <START> session.join(); <END> } catch (InterruptedException ex) { } } }</code><technical_language>if is a deadlock? timed join</technical_language>

Target:
void shutdown() throws InterruptedException { List<NGSession> allSessions; synchronized (lock) { done = true; allSessions = Stream.concat(workingPool.stream(), idlePool.stream()).collect(Collectors.toList()); idlePool.clear(); workingPool.clear(); } for (NGSession session : allSessions) { session.shutdown(); } long start = System.nanoTime(); for (NGSession session : allSessions) { long timeout = NGConstants.SESSION_TERMINATION_TIMEOUT_MILLIS - TimeUnit.NANOSECONDS.convert(System.nanoTime() - start, TimeUnit.MILLISECONDS); if (timeout < 1) { timeout = 1; } session.join(timeout); if (session.isAlive()) { throw new IllegalStateException( "NGSession has not completed in " + NGConstants.SESSION_TERMINATION_TIMEOUT_MILLIS + " ms"); } } }
Source:
<code>private void storeValues() { if (fCharsetEditor.presentsDefaultValue()) { InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).remove(ICDebugConstants.PREF_DEBUG_CHARSET); } else { fCharsetEditor.store(); InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).put(ICDebugConstants.PREF_DEBUG_CHARSET, fCharsetEditor.getPreferenceStore().getString(ICDebugConstants.PREF_DEBUG_CHARSET)); } if (fWideCharsetEditor.presentsDefaultValue()) { InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).remove(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET); } else { fWideCharsetEditor.store(); InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).put(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, fWideCharsetEditor.getPreferenceStore().getString(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET)); } InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).putBoolean( CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, fShowBinarySourceFilesButton.getSelection()); InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).putBoolean( CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR, fShowSourceNotFoundEditor.getSelection()); <START> if (Platform.getPreferencesService().getBoolean(CCorePlugin.PLUGIN_ID, CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR, true, null)) { <END> InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).putBoolean( CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR_ALL_TIME, fShowSourceNotFoundAllTime.getSelection()); } }</code><technical_language>purpose of if here. out stored in line. Also, store SHOW_SOURCE_NOT_FOUND_EDITOR_ALL_TIME time</technical_language>

Target:
private void storeValues() { if (fCharsetEditor.presentsDefaultValue()) { InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).remove(ICDebugConstants.PREF_DEBUG_CHARSET); } else { fCharsetEditor.store(); InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).put(ICDebugConstants.PREF_DEBUG_CHARSET, fCharsetEditor.getPreferenceStore().getString(ICDebugConstants.PREF_DEBUG_CHARSET)); } if (fWideCharsetEditor.presentsDefaultValue()) { InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).remove(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET); } else { fWideCharsetEditor.store(); InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).put(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, fWideCharsetEditor.getPreferenceStore().getString(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET)); } InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).putBoolean( CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, fShowBinarySourceFilesButton.getSelection()); InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).putBoolean( CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR, !fShowSourceNotFoundEditor.getSelection()); InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).putBoolean( CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR_ALL_TIME, fShowSourceNotFoundAllTime.getSelection()); }
Source:
<code>public void testItemNotExistObject() { abvsResult.reset(); try { ob.reset(abvsResult); ob.finish(); } catch (IOException e) { Assert.fail("Test failed to write the Object pointable."); } tvp.set(abvsResult); tvp.getValue(op); try { getTaggedValuePointable("key", tvpKey1); op.getValue(tvpKey1, tvpValue1); } catch (IOException | SystemException e) { Assert.fail("Test failed to write the object pointable."); } XDMConstants.setFalse(tvp); if (!FunctionHelper.arraysEqual(tvp, tvpValue1)) { Assert.fail("Value is incorrect for the given key. Expected: false with valuetag: " + ValueTag.XS_BOOLEAN_TAG + " Got valuetag: " + tvp.getTag()); } try { ob.reset(abvsResult); getTaggedValuePointable("name", tvpKey1); getTaggedValuePointable("A green door", tvpValue1); ob.addItem(tvpKey1, tvpValue1); getTaggedValuePointable("price", tvpKey2); getTaggedValuePointable(12.5, tvpValue2); ob.addItem(tvpKey2, tvpValue2); ob.finish(); } catch (IOException e) { Assert.fail("Test failed to write the object pointable."); } tvp.set(abvsResult); tvp.getValue(op); try { getTaggedValuePointable("key", tvpKey3); <START> op.getValue(tvpKey3, tvpValue3); <END> } catch (IOException | SystemException e) { Assert.fail("Test failed to write the object pointable."); } XDMConstants.setFalse(tvp); if (!FunctionHelper.arraysEqual(tvp, tvpValue3)) { Assert.fail("Value is incorrect for the given key. Expected: false with valuetag: " + ValueTag.XS_BOOLEAN_TAG + " Got valuetag: " + tvp.getTag()); } }</code><technical_language>// this... if (op.getValue(tvpKey3, tvpValue3)) { // key }</technical_language>

Target:
public void testItemNotExistObject() { abvsResult.reset(); try { ob.reset(abvsResult); ob.finish(); } catch (IOException e) { Assert.fail("Test failed to write the Object pointable."); } tvp.set(abvsResult); tvp.getValue(op); try { getTaggedValuePointable("key", false, tvpKey1); if (op.getValue(tvpKey1, tvp)) { Assert.fail("key not in object. Expected: false Got: true"); } } catch (IOException e) { Assert.fail("Test failed to write the object pointable."); } try { abvsResult.reset(); ob.reset(abvsResult); getTaggedValuePointable("name", false, tvpKey1); getTaggedValuePointable("A green door", tvpValue1); ob.addItem(tvpKey1, tvpValue1); getTaggedValuePointable("price", false, tvpKey2); getTaggedValuePointable(12.5, tvpValue2); ob.addItem(tvpKey2, tvpValue2); ob.finish(); } catch (IOException e) { Assert.fail("Test failed to write the object pointable."); } tvp.set(abvsResult); tvp.getValue(op); try { getTaggedValuePointable("key", false, tvpKey3); if (op.getValue(tvpKey3, tvp)) { Assert.fail("key not in object. Expected: false Got: true"); } if (!op.getValue(tvpKey1, tvp)) { Assert.fail("key in object. Expected: true Got: false"); } } catch (IOException e) { Assert.fail("Test failed to write the object pointable."); } }
Source:
<code>public String toString() { <START> return "FilterSupportStatus{" + <END> "isSupported=" + isSupported + ", reason='" + reason + '\'' + '}'; }</code><technical_language>String.format() this more readable</technical_language>

Target:
public String toString() { return String.format( "FilterSupportStatus{isSupported=%s, reason='%s'}", isSupported, reason); }
Source:
<code><START> public String getClientInfo() <END> { return clientInfo.orElse(null); }</code><technical_language>return Optional<String> implementation decide do if is present</technical_language>

Target:
public Optional<String> getClientInfo() { return clientInfo; }
Source:
<code>public void testDeleteBackupRelatedAlerts() { <START> AuditLog entry = dao.getByOriginAndCustomEventId(ORIGIN, CUSTOM_BAKUP_EVENT_ID); <END> assertFalse(entry.isDeleted()); dao.deleteBackupRelatedAlerts(); entry = dao.getByOriginAndCustomEventId(ORIGIN, CUSTOM_BAKUP_EVENT_ID); assertTrue(entry.isDeleted()); }</code><technical_language>add assertNotNull(entry); is a proper assumption prior validating entry data</technical_language>

Target:
public void testDeleteBackupRelatedAlerts() { AuditLog entry = dao.getByOriginAndCustomEventId(ORIGIN, CUSTOM_BAKUP_EVENT_ID); assertNotNull(entry); assertFalse(entry.isDeleted()); dao.deleteBackupRelatedAlerts(); entry = dao.getByOriginAndCustomEventId(ORIGIN, CUSTOM_BAKUP_EVENT_ID); assertNotNull(entry); assertTrue(entry.isDeleted()); }
Source:
<code>public void shouldSupportCustomPoliciesOutOfTestContainersPackage() { try ( GenericContainer<?> container = new GenericContainer<>("hello-world:latest") .withImagePullPolicy(new AbstractImagePullPolicy() { @Override protected boolean shouldPullCached(DockerImageName imageName, ImageData localImageData) { <START> return true; <END> } }) ) { container.withStartupCheckStrategy(new OneShotStartupCheckStrategy()); container.start(); } }</code><technical_language>suggestion return false; do unnecessary pulls</technical_language>

Target:
public void shouldSupportCustomPoliciesOutOfTestContainersPackage() { try ( GenericContainer<?> container = new GenericContainer<>() .withImagePullPolicy(new AbstractImagePullPolicy() { @Override protected boolean shouldPullCached(DockerImageName imageName, ImageData localImageData) { return false; } }) ) { container.withStartupCheckStrategy(new OneShotStartupCheckStrategy()); container.start(); } }
Source:
<code>private void validateExpiry(int expiry) { if (expiry < 1 || expiry > DEFAULT_EXPIRY_TIME) { throw new IllegalArgumentException( <START> "expires must be in range of 1 to " + DEFAULT_EXPIRY_TIME); <END> } }</code><technical_language>1. Replace expires expiry 2. more meaningful message "expiry minimum 1 maximum " + TimeUnit.SECONDS.toDays(DEFAULT_EXPIRY_TIME) + " days"</technical_language>

Target:
private void validateExpiry(int expiry) { if (expiry < 1 || expiry > DEFAULT_EXPIRY_TIME) { throw new IllegalArgumentException( "expiry must be minimum 1 second to maximum " + TimeUnit.SECONDS.toDays(DEFAULT_EXPIRY_TIME) + " days"); } }
Source:
<code>public void run() { try { final byte[] buf = new byte[BUFFER_SIZE]; int flushCountBeforeRead = 0; boolean readInterrupted = false; for (;;) { try { if (readInterrupted) { synchronized (writeLock) { boolean interruptedAgain = Thread.interrupted(); dst.flush(); <START> if (interruptedAgain) { interrupt(); } <END> } readInterrupted = false; if (!flushCount.compareAndSet(flushCountBeforeRead, 0)) { interrupt(); } } if (done) break; flushCountBeforeRead = flushCount.get(); final int n; try { n = src.read(buf); } catch (InterruptedIOException wakey) { readInterrupted = true; continue; } if (n < 0) break; synchronized (writeLock) { if (Thread.interrupted()) { interrupt(); continue; } boolean writeInterrupted = false; for (;;) { try { dst.write(buf, 0, n); } catch (InterruptedIOException wakey) { writeInterrupted = true; continue; } if (writeInterrupted || flushCount.get() > 0) interrupt(); break; } } } catch (IOException e) { break; } } } finally { try { src.close(); } catch (IOException e) { } try { dst.close(); } catch (IOException e) { } } }</code><technical_language>this is need? is difference (!flushCount.compareAndSet(flushCountBeforeRead, 0)) interrupt() below</technical_language>

Target:
public void run() { try { final byte[] buf = new byte[BUFFER_SIZE]; int flushCountBeforeRead = 0; boolean readInterrupted = false; for (;;) { try { if (readInterrupted) { synchronized (writeLock) { boolean interruptedAgain = Thread.interrupted(); dst.flush(); if (interruptedAgain) { interrupt(); } } readInterrupted = false; if (!flushCount.compareAndSet(flushCountBeforeRead, 0)) { interrupt(); } } if (done) break; flushCountBeforeRead = flushCount.get(); final int n; try { n = src.read(buf); } catch (InterruptedIOException wakey) { readInterrupted = true; continue; } if (n < 0) break; synchronized (writeLock) { if (isInterrupted()) { continue; } boolean writeInterrupted = false; for (;;) { try { dst.write(buf, 0, n); } catch (InterruptedIOException wakey) { writeInterrupted = true; continue; } if (writeInterrupted || flushCount.get() > 0) interrupt(); break; } } } catch (IOException e) { break; } } } finally { try { src.close(); } catch (IOException e) { } try { dst.close(); } catch (IOException e) { } } }
Source:
<code>private void putMetricData(List<Metric> batch) { <START> DynamicCounter.increment(METRICS_COUNTER, batch.size()); <END> final Stopwatch s = DynamicTimer.start(PUTS_TIMER); try { cloudWatch.putMetricData(createPutRequest(batch)); } catch (AmazonServiceException e) { final Tag error = new BasicTag("error", e.getErrorCode()); DynamicCounter.increment(ERRORS_COUNTER.withAdditionalTag(error)); } catch (Exception e) { final Tag error = new BasicTag("error", e.getClass().getSimpleName()); DynamicCounter.increment(ERRORS_COUNTER.withAdditionalTag(error)); LOG.error("Error while submitting data for metrics : " + batch, e); } finally { s.stop(); } }</code><technical_language>this a regular counter</technical_language>

Target:
private void putMetricData(List<Metric> batch) { METRICS_COUNTER.increment(batch.size()); final Stopwatch s = PUTS_TIMER.start(); try { cloudWatch.putMetricData(createPutRequest(batch)); } catch (AmazonServiceException e) { final Tag error = new BasicTag("error", e.getErrorCode()); DynamicCounter.increment(ERRORS_COUNTER_ID.withAdditionalTag(error)); } catch (Exception e) { final Tag error = new BasicTag("error", e.getClass().getSimpleName()); DynamicCounter.increment(ERRORS_COUNTER_ID.withAdditionalTag(error)); LOG.error("Error while submitting data for metrics : " + batch, e); } finally { s.stop(); } }
Source:
<code>private Map<String, Object> loadYamlConfig(String configFile) { <START> Path configPath = Paths.get(configFile); <END> if (!resources.exists(configPath)) { return emptyMap(); } try { return YamlParser.INSTANCE.parseMap(resources.sourceFile(configPath)); } catch (IOException e) { throw new IllegalStateException("Unable to read " + configFile, e); } }</code><technical_language>need fill body of method, need lambda</technical_language>

Target:
private Map<String, Object> loadYamlConfig(String configFile) { return emptyMap(); }