auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private ResourceNode findMatch(String path, Map<String, String> variables) { Optional<Map.Entry<PathItem, ResourceNode>> first = children.entrySet().stream().filter(f -> f.getKey() instanceof VariablePathItem) .filter(pi -> { VariablePathItem vpi = (VariablePathItem) pi.getKey(); Map<String, String> vars = PathInterpreter.resolveVariables(vpi.getExpression(), path); if (!vars.isEmpty()) { variables.putAll(vars); return true; } return false; }).findFirst(); <START> return first.map(Map.Entry::getValue).orElse(null); <END> }</code><technical_language>this stream sideeffects (updating variables), I a foreach loop: java for (Map.Entry<PathItem, ResourceNode> e : children.entrySet()) { if (e.getKey() instanceof VariablePathItem) { VariablePathItem vpi = (VariablePathItem) e.getKey(); Map<String, String> vars = PathInterpreter.resolveVariables(vpi.getExpression(), path); if (!vars.isEmpty()) { variables.putAll(vars); return e.getValue(); } } } return null;</technical_language>

Target:
private ResourceNode findMatch(String path, Map<String, String> variables) { for (Map.Entry<PathItem, ResourceNode> e : children.entrySet()) { if (e.getKey() instanceof VariablePathItem) { VariablePathItem vpi = (VariablePathItem) e.getKey(); Map<String, String> vars = PathInterpreter.resolveVariables(vpi.getExpression(), path); if (!vars.isEmpty()) { variables.putAll(vars); return e.getValue(); } } } return null; }
Source:
<code>public void start(J project, boolean newInstance) { this.job = project; try { this.tabs = CronTabList.create(spec, Hash.from(project.getFullName())); } catch (ANTLRException e) { <START> LOGGER.log(Level.WARNING, "Failed to parse crontab spec: "+spec,e); <END> } }</code><technical_language>I need Item name log job issue</technical_language>

Target:
public void start(J project, boolean newInstance) { this.job = project; try { this.tabs = CronTabList.create(spec, Hash.from(project.getFullName())); } catch (ANTLRException e) { LOGGER.log(Level.WARNING, String.format("Failed to parse crontab spec %s in job %s", spec, project.getFullName()), e); } }
Source:
<code>public byte[] getFirstData() { if (bodyType != AmqpMessageBodyType.DATA) { throw LOGGER.logExceptionAsError(new IllegalArgumentException(String.format("Can not return data for a " + "message which is of type %s.", getBodyType().toString()))); } <START> return Arrays.copyOf(data, data.length); <END> }</code><technical_language>getData() a copy of array this method does</technical_language>

Target:
public byte[] getFirstData() { if (bodyType != AmqpMessageBodyType.DATA) { throw logger.logExceptionAsError(new IllegalArgumentException( "This method can only be called for AMQP Data body type at present. Track this issue, " + "<LINK_0> for other body type support in " + "future.")); } return data; }
Source:
<code>final static String getUserNameFromSubject(Subject subject) { if (subject == null || subject.getPrincipals() == null || subject.getPrincipals().isEmpty()) { throw new IllegalArgumentException("Subject is null or does not contain principals"); } Iterator<Principal> piter = subject.getPrincipals().iterator(); Principal principal = piter.next(); String username = principal.getName(); while (piter.hasNext()) { principal = piter.next(); if (principal instanceof DelegatePrincipal) { <START> username = principal.getName(); <END> } } return username; }</code><technical_language>break one</technical_language>

Target:
final static String getUserNameFromSubject(Subject subject) { if (subject == null || subject.getPrincipals() == null || subject.getPrincipals().isEmpty()) { throw new IllegalArgumentException("Subject is null or does not contain principals"); } Iterator<Principal> piter = subject.getPrincipals().iterator(); Principal principal = piter.next(); String username = principal.getName(); while (piter.hasNext()) { principal = piter.next(); if (principal instanceof DelegatePrincipal) { username = principal.getName(); break; } } return username; }
Source:
<code>protected void processValue(int quark, long timestamp, ITmfStateValue value) throws AttributeNotFoundException, TimeRangeException, StateValueTypeException { ITmfStateSystemBuilder ss = getStateSystem(); if (ss == null) { throw new IllegalStateException(ILLEGAL_STATE_EXCEPTION_MESSAGE); } switch (getStackType()) { case POP: ss.popAttribute(timestamp, quark); break; case PUSH: ss.pushAttribute(timestamp, value, quark); break; case NULL: case PEEK: default: <START> if (!isUpdate()) { <END> ss.modifyAttribute(timestamp, value, quark); } else { ss.updateOngoingState(value, quark); } break; } }</code><technical_language>cab invert this? feels a gratuitous negation</technical_language>

Target:
protected void processValue(int quark, long timestamp, ITmfStateValue value) throws AttributeNotFoundException, TimeRangeException, StateValueTypeException { ITmfStateSystemBuilder ss = getStateSystem(); if (ss == null) { throw new IllegalStateException(ILLEGAL_STATE_EXCEPTION_MESSAGE); } switch (getStackType()) { case POP: ss.popAttribute(timestamp, quark); break; case PUSH: ss.pushAttribute(timestamp, value, quark); break; case NULL: case PEEK: default: if (isUpdate()) { ss.updateOngoingState(value, quark); } else { ss.modifyAttribute(timestamp, value, quark); } break; } }
Source:
<code>public void setCodecPrivateIfNeeded() { if (codec == Codec.H264) { List<ByteBuffer> sps = selectUnique(spsList); List<ByteBuffer> pps = selectUnique(ppsList); if (!sps.isEmpty() && !pps.isEmpty()) { getEntries().get(0).add(H264Utils.createAvcCFromPS(sps, pps, 4)); <START> } <END> } else if (codec == Codec.AAC) { if (adtsHeader != null) { getEntries().get(0).add(EsdsBox.fromADTS(adtsHeader)); } } }</code><technical_language>I add a warning here: } else { Logger.warn("Not adding a sample entry for h.264 track, missing SPS/PPS NAL units"); }</technical_language>

Target:
public void setCodecPrivateIfNeeded() { if (codec == Codec.H264) { List<ByteBuffer> sps = selectUnique(spsList); List<ByteBuffer> pps = selectUnique(ppsList); if (!sps.isEmpty() && !pps.isEmpty()) { getEntries().get(0).add(H264Utils.createAvcCFromPS(sps, pps, 4)); } else { Logger.warn("CodecMP4MuxerTrack: Not adding a sample entry for h.264 track, missing any SPS/PPS NAL units"); } } else if (codec == Codec.AAC) { if (adtsHeader != null) { getEntries().get(0).add(EsdsBox.fromADTS(adtsHeader)); } else { Logger.warn("CodecMP4MuxerTrack: Not adding a sample entry for AAC track, missing any ADTS headers."); } } }
Source:
<code>public boolean doBuild(TopologyBuilder bldr, Set<String> stageNames) { <START> if (!left.isBuilt() || !right.isBuilt()) { <END> return false; } if (getName() == null) { calculateName(stageNames); } if (stageNames.contains(getName())) { throw new RuntimeException("Duplicate Names"); } stageNames.add(getName()); bldr.setBolt(getName(), new UnionOperator<I>(), getNumPartitions()).shuffleGrouping(left.getName()).shuffleGrouping(right.getName()); return true; }</code><technical_language>throw exception log some error message error</technical_language>

Target:
public boolean doBuild(TopologyBuilder bldr, Set<String> stageNames) { if (!left.isBuilt() || !right.isBuilt()) { return false; } if (getName() == null) { setName(defaultNameCalculator("union", stageNames)); } if (stageNames.contains(getName())) { throw new RuntimeException("Duplicate Names"); } stageNames.add(getName()); bldr.setBolt(getName(), new UnionOperator<I>(), getNumPartitions()).shuffleGrouping(left.getName()).shuffleGrouping(right.getName()); return true; }
Source:
<code>protected void patchResourcewithSparql(final FedoraResource resource, final String requestBody) { updatePropertiesService.updateProperties(transaction().getId(), getUserPrincipal(), <START> FedoraId.create(resource.getId()), <END> requestBody); }</code><technical_language>Is this resource.getFedoraId()</technical_language>

Target:
protected void patchResourcewithSparql(final FedoraResource resource, final String requestBody) { updatePropertiesService.updateProperties(transaction().getId(), getUserPrincipal(), resource.getFedoraId(), requestBody); }
Source:
<code>void toMessageCollections() { FieldMask fieldMask = Given.fieldMask(Project.STATUS_FIELD_NUMBER, Project.TASK_FIELD_NUMBER); int count = 5; <START> Collection<Project> original = newLinkedList(); <END> for (int i = 0; i < count; i++) { Project project = Given.newProject(format("project-%s", i)); original.add(project); } Collection<Project> masked = FieldMasks.applyMask(fieldMask, original, Given.TYPE); assertSize(original.size(), masked); assertFalse(original == masked); for (Project project : masked) { assertMatchesMask(project, fieldMask); assertFalse(project.getTaskList() .isEmpty()); } }</code><technical_language>weird modify this portion of code, honestly a new ArrayList<>(count); below</technical_language>

Target:
void toMessageCollections() { FieldMask fieldMask = Given.fieldMask(Project.STATUS_FIELD_NUMBER, Project.TASK_FIELD_NUMBER); int count = 5; Collection<Project> original = newArrayListWithCapacity(count); for (int i = 0; i < count; i++) { Project project = Given.newProject(format("project-%s", i)); original.add(project); } Collection<Project> masked = FieldMasks.applyMask(fieldMask, original, Given.TYPE); assertSize(original.size(), masked); assertNotSame(original, masked); for (Project project : masked) { assertMatchesMask(project, fieldMask); assertFalse(project.getTaskList() .isEmpty()); } }
Source:
<code>static CharSequence toLowerCase(CharSequence s) { <START> if (s instanceof AsciiString) { <END> AsciiString asciiString = (AsciiString) s; return asciiString.toLowerCase(); } StringBuilder buffer = null; int len = s.length(); for (int index = 0; index < len; index++) { char c = s.charAt(index); if (c >= 'A' && c <= 'Z') { if (buffer == null) { buffer = new StringBuilder(s); } buffer.setCharAt(index, (char)(c + ('a' - 'A'))); } } if (buffer != null) { return buffer.toString(); } else { return s; } }</code><technical_language>is this related this PR</technical_language>

Target:
static CharSequence toLowerCase(CharSequence s) { StringBuilder buffer = null; int len = s.length(); for (int index = 0; index < len; index++) { char c = s.charAt(index); if (c >= 'A' && c <= 'Z') { if (buffer == null) { buffer = new StringBuilder(s); } buffer.setCharAt(index, (char)(c + ('a' - 'A'))); } } if (buffer != null) { return buffer.toString(); } else { return s; } }
Source:
<code><START> static <T> Collection<T> convertAllBeanDataToObjects(Collection<? extends BeanData> data) { <END> return Collections2.transform(data, new BeanDataToObjectFunction<T>()); }</code><technical_language>public</technical_language>

Target:
public static <T> Collection<T> convertAllBeanDataToObjects(Collection<? extends BeanData> data) { return Collections2.transform(data, new BeanDataToObjectFunction<T>()); }
Source:
<code><START> public void performDurableTopicDeadLetterChannelTestCase() throws Exception { <END> String deletingMessageID; String restoringMessageID; DLCBrowsePage dlcBrowsePage = homePage.getDLCBrowsePage(); Assert.assertNotNull(dlcBrowsePage.isDLCCreated(), "DeadLetter Channel not created. " + DLC_TEST_DURABLE_TOPIC); DLCContentPage dlcContentPage = dlcBrowsePage.getDLCContent(); deletingMessageID = dlcContentPage.deleteFunction(); Assert.assertTrue(checkMessages(deletingMessageID, DLC_TEST_DURABLE_TOPIC), "Deleting messages of dead letter channel is unsuccessful."); Long beforeRestoreMessageReceivedCount = consumerClient.getReceivedMessageCount(); restoringMessageID = dlcContentPage.restoreFunction(); waitUntilMessagesReceived(9L); AndesClientUtils.sleepForInterval(80000L); Long afterRestoreMessageReceivedCount = consumerClient.getReceivedMessageCount(); Assert.assertTrue(beforeRestoreMessageReceivedCount < afterRestoreMessageReceivedCount, restoringMessageID + "Durable topic message not successfully restored."); }</code><technical_language>method in this test is throwing generic Exception</technical_language>

Target:
public void performDurableTopicDeadLetterChannelTestCase() throws IOException { String deletingMessageID; String restoringMessageID; DLCBrowsePage dlcBrowsePage = homePage.getDLCBrowsePage(); Assert.assertNotNull(dlcBrowsePage.isDLCCreated(), "DeadLetter Channel not created. " + DLC_TEST_DURABLE_TOPIC); DLCContentPage dlcContentPage = dlcBrowsePage.getDLCContent(); deletingMessageID = dlcContentPage.deleteFunction(); Assert.assertTrue(checkMessages(deletingMessageID, DLC_TEST_DURABLE_TOPIC), "Deleting messages of dead letter channel is unsuccessful."); Long beforeRestoreMessageReceivedCount = consumerClient.getReceivedMessageCount(); restoringMessageID = dlcContentPage.restoreFunction(); waitUntilMessagesReceived(9L); AndesClientUtils.sleepForInterval(80000L); Long afterRestoreMessageReceivedCount = consumerClient.getReceivedMessageCount(); Assert.assertTrue(beforeRestoreMessageReceivedCount < afterRestoreMessageReceivedCount, restoringMessageID + " Durable topic message not successfully restored."); }
Source:
<code>public boolean contains(Object value) { final Iterator it = new StepIterator(this, stepSize); if (value == null) { return false; <START> } <END> while (it.hasNext()) { try { if (compareEqual(value, it.next())) { return true; } } catch (ClassCastException e) { return false; } } return false; }</code><technical_language>Minor thing, null check first</technical_language>

Target:
public boolean contains(Object value) { if (value == null) { return false; } final Iterator it = new StepIterator(this, stepSize); while (it.hasNext()) { if (compareEqual(value, it.next())) { return true; } } return false; }
Source:
<code>public Collection<ObjectId> resolve(AbbreviatedObjectId id) throws IOException { if (id.isComplete()) return Collections.singleton(id.toObjectId()); boolean noGarbage = avoidUnreachable; HashSet<ObjectId> matches = new HashSet<ObjectId>(4); PackList packList = db.getPackList(); resolveImpl(packList, id, noGarbage, matches); if <START> (MAX_RESOLVE_MATCHES > matches.size() && <END> packList.dirty()) { resolveImpl(db.scanPacks(packList), id, noGarbage, matches); } return matches; }</code><technical_language>matches.size() <= MAX_RESOLVE_MATCHES reverse ordering is harder read now</technical_language>

Target:
public Collection<ObjectId> resolve(AbbreviatedObjectId id) throws IOException { if (id.isComplete()) return Collections.singleton(id.toObjectId()); boolean noGarbage = avoidUnreachable; HashSet<ObjectId> matches = new HashSet<ObjectId>(4); PackList packList = db.getPackList(); resolveImpl(packList, id, noGarbage, matches); if (matches.size() <= MAX_RESOLVE_MATCHES && packList.dirty()) { resolveImpl(db.scanPacks(packList), id, noGarbage, matches); } return matches; }
Source:
<code>protected void updateButtons() { BatchImportTraceWizard wiz = getBatchWizard(); <START> ImportUtils.buildFilesToScan(wiz); <END> updateTable(); wiz.getContainer().updateButtons(); }</code><technical_language>If selecting a directory a lot of sub-directories method buildFilesToScan() takes long (due ImportUtil.recurseFiles()) blocks GUI. good run this in a Job show a progress bar possibility cancel</technical_language>

Target:
private void updateButtons() { BatchImportTraceWizard wiz = getBatchWizard(); updateTable(); wiz.getContainer().updateButtons(); }
Source:
<code>private String processTopicPartitionStatsRequest() { List<KafkaTopicPartitionStatsResponse> serializedResponses = new ArrayList<>(); <START> <END> synchronized (_runningTasks) { _runningTasks.forEach((dataStreamTask, connectorTaskEntry) -> { KafkaTopicPartitionTracker tracker = connectorTaskEntry.getConnectorTask().getKafkaTopicPartitionTracker(); KafkaTopicPartitionStatsResponse response = new KafkaTopicPartitionStatsResponse(tracker.getConsumerGroupId(), tracker.getTopicPartitions()); serializedResponses.add(response); }); } return KafkaTopicPartitionStatsResponse.toJson(serializedResponses); }</code><technical_language>I useful add informational log statement beginning of this method</technical_language>

Target:
private String processTopicPartitionStatsRequest() { _logger.info("process topic partitions stats request"); List<KafkaTopicPartitionStatsResponse> serializedResponses = new ArrayList<>(); synchronized (_runningTasks) { _runningTasks.forEach((dataStreamTask, connectorTaskEntry) -> { List<Datastream> datastreams = dataStreamTask.getDatastreams(); Set<String> datastreamNames = new HashSet<>(); datastreams.forEach(datastream -> datastreamNames.add(datastream.getName())); KafkaTopicPartitionTracker tracker = connectorTaskEntry.getConnectorTask().getKafkaTopicPartitionTracker(); KafkaTopicPartitionStatsResponse response = new KafkaTopicPartitionStatsResponse(tracker.getConsumerGroupId(), tracker.getTopicPartitions(), datastreamNames); serializedResponses.add(response); }); } return JsonUtils.toJson(serializedResponses); }
Source:
<code><START> @NonNull ByteBuffer getByteBufferAt(long position, long size) throws CTFReaderException, IOException { <END> MappedByteBuffer map = fFileChannel.map(MapMode.READ_ONLY, position, size); if( map == null){ throw new CTFReaderException("Failed to allocate mapped byte buffer"); } return map; }</code><technical_language>annotation a separate line</technical_language>

Target:
ByteBuffer getByteBufferAt(long position, long size) throws CTFReaderException, IOException { MappedByteBuffer map = fFileChannel.map(MapMode.READ_ONLY, position, size); if (map == null) { throw new CTFReaderException("Failed to allocate mapped byte buffer"); } return map; }
Source:
<code>synchronized private Set<Guid> removeClearedAndOldTasks() { Set<Guid> poolsOfActiveTasks = new HashSet<Guid>(); Set<Guid> poolsOfClearedAndOldTasks = new HashSet<Guid>(); Map<Guid, SPMAsyncTask> activeTaskMap = new HashMap<Guid, SPMAsyncTask>(); boolean isShouldBeUpdated = false; for (SPMAsyncTask task : _tasks.values()) { if (!CachingOver(task)) { activeTaskMap.put(task.getTaskID(), task); poolsOfActiveTasks.add(task.getStoragePoolID()); } else { isShouldBeUpdated = true; poolsOfClearedAndOldTasks.add(task.getStoragePoolID()); } } <START> if (isShouldBeUpdated) { <END> setNewMap(activeTaskMap); poolsOfClearedAndOldTasks.removeAll(poolsOfActiveTasks); } return poolsOfClearedAndOldTasks; }</code><technical_language>check here, if poolsOfClearedAndOldTasks is empty, instead isShouldBeUpdated</technical_language>

Target:
synchronized private Set<Guid> removeClearedAndOldTasks() { Set<Guid> poolsOfActiveTasks = new HashSet<Guid>(); Set<Guid> poolsOfClearedAndOldTasks = new HashSet<Guid>(); Map<Guid, SPMAsyncTask> activeTaskMap = new HashMap<Guid, SPMAsyncTask>(); for (SPMAsyncTask task : _tasks.values()) { if (!CachingOver(task)) { activeTaskMap.put(task.getTaskID(), task); poolsOfActiveTasks.add(task.getStoragePoolID()); } else { poolsOfClearedAndOldTasks.add(task.getStoragePoolID()); } } if (poolsOfClearedAndOldTasks.size() > 0) { setNewMap(activeTaskMap); poolsOfClearedAndOldTasks.removeAll(poolsOfActiveTasks); } return poolsOfClearedAndOldTasks; }
Source:
<code>Series(String string) { this.digits = <START> Arrays.stream(string.split((""))) <END> .map(Integer::parseInt) .collect(Collectors.toList()); this.digitsSize = this.digits.size(); }</code><technical_language>I put this line it's: this.digits = Arrays.stream(string.split("")) .map(Integer::parseInt) .collect(Collectors.toList()); this formatting is correct ctrl + alt + L if intellij Windows (it's cmd + alt + L mac). eclipse ctrl + shift + F (cmd + shift + F mac). useful :) string.split(("")) string.split(""). fault all, I notice :)</technical_language>

Target:
Series(String string) { this.digits = Arrays.stream(string.split("")) .map(Integer::parseInt) .collect(Collectors.toList()); this.digitsSize = this.digits.size(); }
Source:
<code>private static int getWindowHeightAPI23Plus(@NonNull Activity activity) { View decorView = activity.getWindow().getDecorView(); <START> if (decorView.getRootWindowInsets() == null) <END> return decorView.getHeight(); return decorView.getHeight() - decorView.getRootWindowInsets().getStableInsetBottom() - decorView.getRootWindowInsets().getStableInsetTop(); }</code><technical_language>save decorView.getRootWindowInsets() a variable in case null in calls</technical_language>

Target:
private static int getWindowHeightAPI23Plus(@NonNull Activity activity) { View decorView = activity.getWindow().getDecorView(); WindowInsets windowInsets = decorView.getRootWindowInsets(); if (windowInsets == null) return decorView.getHeight(); return decorView.getHeight() - windowInsets.getStableInsetBottom() - windowInsets.getStableInsetTop(); }
Source:
<code>public void testColumnHighlight() { final GridWidgetDnDProxy highlight = mock(GridWidgetDnDProxy.class); final Bounds bounds = new BaseBounds(GRID_X, GRID_Y, GRID_WIDTH, GRID_HEIGHT); when(state.getEventColumnHighlight()).thenReturn(highlight); when(state.getActiveGridWidget()).thenReturn(gridWidget); when(state.getOperation()).thenReturn(GridWidgetHandlersOperation.COLUMN_MOVE_PENDING); <START> when(state.getActiveGridColumns()).thenReturn(new ArrayList<GridColumn<?>>() {{ add(uiColumn); }}); <END> when(rendererHelper.getRenderingInformation()).thenReturn(renderingInformation); when(rendererHelper.getRowOffset(anyInt(), any(List.class))).thenCallRealMethod(); when(renderingInformation.getBounds()).thenReturn(bounds); when(gridWidget.getHeader()).thenReturn(gridWidgetHeader); when(gridWidget.getHeight()).thenReturn(GRID_HEIGHT); when(uiColumn.getWidth()).thenReturn(COLUMN_WIDTH); handler.onNodeMouseDown(event); verify(highlight).setWidth(COLUMN_WIDTH); verify(highlight).setHeight(GRID_HEIGHT); verify(highlight).setX(GRID_X); verify(highlight).setY(GRID_Y); verify(layer).batch(); }</code><technical_language>Please when(state.getActiveGridColumns()).thenReturn(Collections.singletonList(uiColumn));</technical_language>

Target:
public void testColumnHighlight() { final GridWidgetDnDProxy highlight = mock(GridWidgetDnDProxy.class); final Bounds bounds = new BaseBounds(GRID_X, GRID_Y, GRID_WIDTH, GRID_HEIGHT); when(state.getEventColumnHighlight()).thenReturn(highlight); when(state.getActiveGridWidget()).thenReturn(gridWidget); when(state.getOperation()).thenReturn(GridWidgetHandlersOperation.COLUMN_MOVE_PENDING); when(state.getActiveGridColumns()).thenReturn(Collections.singletonList(uiColumn)); when(rendererHelper.getRenderingInformation()).thenReturn(renderingInformation); when(rendererHelper.getRowOffset(anyInt(), any(List.class))).thenCallRealMethod(); when(renderingInformation.getBounds()).thenReturn(bounds); when(gridWidget.getHeader()).thenReturn(gridWidgetHeader); when(gridWidget.getHeight()).thenReturn(GRID_HEIGHT); when(uiColumn.getWidth()).thenReturn(COLUMN_WIDTH); handler.onNodeMouseDown(event); verify(highlight).setWidth(COLUMN_WIDTH); verify(highlight).setHeight(GRID_HEIGHT); verify(highlight).setX(GRID_X); verify(highlight).setY(GRID_Y); verify(layer).batch(); }
Source:
<code>public void execute(JobExecutionContext arg0) throws JobExecutionException { try { systemUser = userAPI.getSystemUser(); generateSitemapPerHost(); } catch (Exception e) { Logger.error(this, e.getMessage(), e); } finally { try { HibernateUtil.closeSession(); } catch (DotHibernateException e) { Logger.warn(this, e.getMessage(), e); } } <START> <END> }</code><technical_language>remove wrapping finally (including HibernateUtil.closeSession)</technical_language>

Target:
public void execute(JobExecutionContext arg0) throws JobExecutionException { try { systemUser = userAPI.getSystemUser(); generateSitemapPerHost(); } catch (Exception e) { Logger.error(this, e.getMessage(), e); } }
Source:
<code>public static ActorRequestFactory fromContext(ActorContext actorContext) { <START> Builder builder = newBuilder() <END> .setActor(actorContext.getActor()) .setTenantId(actorContext.getTenantId()) .setZoneOffset(actorContext.getZoneOffset()) .setZoneId(actorContext.getZoneId()); return builder.build(); }</code><technical_language>check for actorContext null first</technical_language>

Target:
public static ActorRequestFactory fromContext(ActorContext actorContext) { checkNotNull(actorContext); Builder builder = newBuilder() .setActor(actorContext.getActor()) .setTenantId(actorContext.getTenantId()) .setZoneOffset(actorContext.getZoneOffset()) .setZoneId(actorContext.getZoneId()); return builder.build(); }
Source:
<code>private BuildCommand freshCheckout(String workingDir, Revision revision) { return compose( <START> cleandir(workingDir).setTest(test("-d", workingDir)), <END> mkdirs(workingDir).setTest(test("-nd", workingDir)), checkout(workingDir, revision) ); }</code><technical_language>I if sense echo a message recreating repo changed</technical_language>

Target:
private BuildCommand freshCheckout(String workingDir, Revision revision) { return compose( echoWithPrefix("Checking out a fresh copy"), cleandir(workingDir).setTest(test("-d", workingDir)), mkdirs(workingDir).setTest(test("-nd", workingDir)), checkout(workingDir, revision) ); }
Source:
<code>public SizeHandler<Lane, SVGShapeView> newSizeHandler() { return newSizeHandlerBuilder() .width(e -> e.getDimensionsSet().getWidth().getValue()) .height(e -> e.getDimensionsSet().getHeight().getValue()) <START> .minWidth(task -> 50d) <END> .maxWidth(task -> 1200d) .minHeight(task -> 50d) .maxHeight(task -> 1200d) .build(); }</code><technical_language>for lane I a bigger min width/height values actual 50, some 200x200, I this a lane is considered a container for other elements, minimum size bigger for example task one... opinion :)</technical_language>

Target:
public SizeHandler<Lane, SVGShapeView> newSizeHandler() { return newSizeHandlerBuilder() .width(e -> e.getDimensionsSet().getWidth().getValue()) .height(e -> e.getDimensionsSet().getHeight().getValue()) .minWidth(task -> 200d) .maxWidth(task -> 1200d) .minHeight(task -> 200d) .maxHeight(task -> 1200d) .build(); }
Source:
<code><START> public boolean replace(String key, String oldValue, String newValue) { <END> Assert.notNull(key, "'key' cannot be null"); Assert.notNull(oldValue, "'oldValue' cannot be null"); Assert.notNull(newValue, "'newValue' cannot be null"); int affectedRows = this.jdbcTemplate.update(getQuery(Query.REPLACE_VALUE), ps -> { ps.setString(1, newValue); ps.setString(2, key); ps.setString(3, oldValue); }); return affectedRows > 0; }</code><technical_language>this isn't: @Transactional(propagation = Propagation.REQUIRES_NEW) ? Thanks</technical_language>

Target:
public boolean replace(String key, String oldValue, String newValue) { Assert.notNull(key, "'key' cannot be null"); Assert.notNull(oldValue, "'oldValue' cannot be null"); Assert.notNull(newValue, "'newValue' cannot be null"); int affectedRows = this.jdbcTemplate.update(this.replaceValueQuery, ps -> { ps.setString(1, newValue); ps.setString(2, key); ps.setString(3, oldValue); ps.setString(4, this.region); }); return affectedRows > 0; }
Source:
<code>private static boolean createSymlinkAtomic(@Nonnull Path pathForSymlink, @Nonnull File fileForSymlink, @Nonnull Path target, @Nonnull String symlinkPath) { try { File symlink = File.createTempFile("symtmp", null, fileForSymlink); symlink.delete(); Path tempSymlinkPath = symlink.toPath(); Files.createSymbolicLink(tempSymlinkPath, target); try { Files.move(tempSymlinkPath, pathForSymlink, java.nio.file.StandardCopyOption.ATOMIC_MOVE); return true; } catch ( UnsupportedOperationException | SecurityException | IOException e) { } symlink.delete(); <START> } catch ( <END> SecurityException | InvalidPathException | UnsupportedOperationException | IOException e) { } return false; }</code><technical_language>Add @CheckReturnValue</technical_language>

Target:
private static boolean createSymlinkAtomic(@Nonnull Path pathForSymlink, @Nonnull File fileForSymlink, @Nonnull Path target, @Nonnull String symlinkPath) { try { File symlink = File.createTempFile("symtmp", null, fileForSymlink); tryToDeleteSymlink(symlink); Path tempSymlinkPath = symlink.toPath(); Files.createSymbolicLink(tempSymlinkPath, target); try { Files.move(tempSymlinkPath, pathForSymlink, java.nio.file.StandardCopyOption.ATOMIC_MOVE); return true; } catch ( UnsupportedOperationException | SecurityException | IOException ex) { reportAtomicFailure(pathForSymlink, ex); } tryToDeleteSymlink(symlink); } catch ( SecurityException | InvalidPathException | UnsupportedOperationException | IOException ex) { reportAtomicFailure(pathForSymlink, ex); } return false; }
Source:
<code>@Override public boolean test(Map<Object, Object> map) throws Exception { final int n = nextRandom(args.range()); final String key = "key"+n; final String otherKey = "other_"+key; final IgniteCache<String, Integer> cache = cacheForOperation(); final IgniteLock lock = ignite().reentrantLock(key, false, false, true); <START> lock.lock(); <END> try { cache.put(otherKey, cache.get(otherKey)+1); } finally { lock.unlock(); } return true; }</code><technical_language>newline</technical_language>

Target:
@Override public boolean test(Map<Object, Object> map) throws Exception { lock.lock(); lock.unlock(); return true; }
Source:
<code>public void openUrl(String url) { if (url.contains(replayBaseUrl)) { replayService.findById(Integer.parseInt(url.replace(replayBaseUrl, ""))).thenAccept(replay -> { Platform.runLater(() -> { replayDetailController = uiService.loadFxml("theme/vault/replay/replay_detail.fxml"); replayDetailController.setReplay(replay); Node replayDetailRoot = replayDetailController.getRoot(); replayDetailRoot.setVisible(true); replayDetailRoot.requestFocus(); Stage stage = new Stage(StageStyle.UNDECORATED); WindowController windowController = uiService.loadFxml("theme/window.fxml"); windowController.configure(stage, (Region) ((AnchorPane) replayDetailRoot).getChildren().get(0), true); replayDetailController.setOnClosure(stage::close); stage.setWidth(((Region) replayDetailRoot).getWidth()); stage.setHeight(((Region) replayDetailRoot).getHeight()); Stage mainStage = StageHolder.getStage(); stage.setX(mainStage.getX()); stage.setY(mainStage.getY()); stage.show(); }); <START> }); <END> return; } platformService.showDocument(url); }</code><technical_language>If extract thenAccept block a method a descriptive name, code more readable: replayService.findById(Integer.parseInt(url.replace(replayBaseUrl, ""))).thenAccept(this::displayReplayDetail); if set in commit-dialog, code indented arranged properly: ![image](<LINK_0></technical_language>

Target:
public void openUrl(String url) { Matcher replayUrlMatcher = replayUrlPattern.matcher(url); if (!replayUrlMatcher.matches()) { platformService.showDocument(url); return; } String replayId = replayUrlMatcher.group(1); replayService.findById(Integer.parseInt(replayId)) .thenAccept(replay -> Platform.runLater(() -> displayReplyDetail(replay, url))); }
Source:
<code>public void coercingOfDmxValues() { int value = Util.toDmxValue(300); <START> assertThat(value, is(equalTo(Channel.MAX_VALUE))); <END> value = Util.toDmxValue(-1); assertThat(value, is(equalTo(Channel.MIN_VALUE))); value = Util.toDmxValue(100); assertThat(value, is(equalTo(100))); }</code><technical_language>I this test class do need equalTo method. is method sufficient already</technical_language>

Target:
public void coercingOfDmxValues() { int value = Util.toDmxValue(300); assertThat(value, is(Channel.MAX_VALUE)); value = Util.toDmxValue(-1); assertThat(value, is(Channel.MIN_VALUE)); value = Util.toDmxValue(100); assertThat(value, is(100)); }
Source:
<code>public synchronized TreeSet<LongRange> remove(final String evalId, final String dataType, final LongRange idRange) { final Map<String, TreeSet<LongRange>> evalDataTypeRanges = evalPartitions.get(evalId); if (evalDataTypeRanges == null) { <START> return new TreeSet<>(); <END> } final TreeSet<LongRange> evalRanges = evalDataTypeRanges.get(dataType); if (evalRanges == null) { return new TreeSet<>(); } final TreeSet<LongRange> globalRanges = globalPartitions.get(dataType); final TreeSet<LongRange> removedRanges = new TreeSet<>(LONG_RANGE_COMPARATOR); final Set<LongRange> insideRanges = removeInsideRanges(globalRanges, evalRanges, idRange); removedRanges.addAll(insideRanges); final LongRange ceilingRange = evalRanges.ceiling(idRange); if (ceilingRange != null && ceilingRange.overlapsRange(idRange)) { final LongRange ceilingRemoved = removeIntersectingRange(globalRanges, evalRanges, ceilingRange, idRange); if (ceilingRemoved != null) { removedRanges.add(ceilingRemoved); } } final LongRange floorRange = evalRanges.floor(idRange); if (floorRange != null && floorRange.overlapsRange(idRange)) { final LongRange floorRemoved = removeIntersectingRange(globalRanges, evalRanges, floorRange, idRange); if (floorRemoved != null) { removedRanges.add(floorRemoved); } } return removedRanges; }</code><technical_language>this happen often</technical_language>

Target:
public synchronized TreeSet<LongRange> remove(final String evalId, final String dataType, final LongRange idRange) { final Map<String, TreeSet<LongRange>> evalDataTypeRanges = evalPartitions.get(evalId); if (evalDataTypeRanges == null) { LOG.log(Level.WARNING, "The evaluator {0} does not exist.", evalId); return new TreeSet<>(); } final TreeSet<LongRange> evalRanges = evalDataTypeRanges.get(dataType); if (evalRanges == null) { LOG.log(Level.WARNING, "The evaluator {0} does not contain any data whose type is {1}.", new Object[]{evalId, dataType}); return new TreeSet<>(); } final TreeSet<LongRange> globalRanges = globalPartitions.get(dataType); final TreeSet<LongRange> removedRanges = new TreeSet<>(LONG_RANGE_COMPARATOR); final Set<LongRange> insideRanges = removeInsideRanges(globalRanges, evalRanges, idRange); removedRanges.addAll(insideRanges); final LongRange ceilingRange = evalRanges.ceiling(idRange); if (ceilingRange != null && ceilingRange.overlapsRange(idRange)) { final LongRange ceilingRemoved = removeIntersectingRange(globalRanges, evalRanges, ceilingRange, idRange); if (ceilingRemoved != null) { removedRanges.add(ceilingRemoved); } } final LongRange floorRange = evalRanges.floor(idRange); if (floorRange != null && floorRange.overlapsRange(idRange)) { final LongRange floorRemoved = removeIntersectingRange(globalRanges, evalRanges, floorRange, idRange); if (floorRemoved != null) { removedRanges.add(floorRemoved); } } return removedRanges; }
Source:
<code>protected String buildLockRepForNewSubAccount(SubAccountGlobal subAccountGlobal, SubAccountGlobalNewAccountDetail newAccountDetail) { String subAccountNumber = subAccountGlobal.isApplyToAllNewSubAccounts() ? subAccountGlobal.getNewSubAccountNumber() : newAccountDetail.getSubAccountNumber(); StringBuilder lockrep = new StringBuilder(); <START> lockrep.append(Account.class.getName() + KFSConstants.Maintenance.AFTER_CLASS_DELIM); <END> lockrep.append(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE + KFSConstants.Maintenance.AFTER_FIELDNAME_DELIM); lockrep.append(newAccountDetail.getChartOfAccountsCode() + KFSConstants.Maintenance.AFTER_VALUE_DELIM); lockrep.append(KFSPropertyConstants.ACCOUNT_NUMBER + KFSConstants.Maintenance.AFTER_FIELDNAME_DELIM); lockrep.append(newAccountDetail.getAccountNumber() + KFSConstants.Maintenance.AFTER_VALUE_DELIM); lockrep.append(KFSPropertyConstants.SUB_ACCOUNT_NUMBER + KFSConstants.Maintenance.AFTER_FIELDNAME_DELIM); lockrep.append(subAccountNumber + KFSConstants.Maintenance.AFTER_VALUE_DELIM); return lockrep.toString(); }</code><technical_language>instead of lockrep.append(Account.class.getName() + KFSConstants.Maintenance.AFTER_CLASS_DELIM);, lockrep.append(Account.class.getName()).append(KFSConstants.Maintenance.AFTER_CLASS_DELIM);</technical_language>

Target:
protected String buildLockRepForNewSubAccount(SubAccountGlobal subAccountGlobal, SubAccountGlobalNewAccountDetail newAccountDetail) { String subAccountNumber = subAccountGlobal.isApplyToAllNewSubAccounts() ? subAccountGlobal.getNewSubAccountNumber() : newAccountDetail.getSubAccountNumber(); StringBuilder lockrep = new StringBuilder(); lockrep.append(Account.class.getName()).append(KFSConstants.Maintenance.AFTER_CLASS_DELIM); lockrep.append(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE).append(KFSConstants.Maintenance.AFTER_FIELDNAME_DELIM); lockrep.append(newAccountDetail.getChartOfAccountsCode()).append(KFSConstants.Maintenance.AFTER_VALUE_DELIM); lockrep.append(KFSPropertyConstants.ACCOUNT_NUMBER).append(KFSConstants.Maintenance.AFTER_FIELDNAME_DELIM); lockrep.append(newAccountDetail.getAccountNumber()).append(KFSConstants.Maintenance.AFTER_VALUE_DELIM); lockrep.append(KFSPropertyConstants.SUB_ACCOUNT_NUMBER).append(KFSConstants.Maintenance.AFTER_FIELDNAME_DELIM); lockrep.append(subAccountNumber).append(KFSConstants.Maintenance.AFTER_VALUE_DELIM); return lockrep.toString(); }
Source:
<code><START> public void testShowCreateTable() <END> { queryRunner.execute("CREATE TABLE IF NOT EXISTS test_show_create_table (\n" + "id INT WITH (primary_key=true),\n" + "user_name VARCHAR\n" + ") WITH (\n" + " partition_by_hash_columns = ARRAY['id'],\n" + " partition_by_hash_buckets = 2\n" + ")"); MaterializedResult result = queryRunner.execute("SHOW CREATE TABLE test_show_create_table"); String sqlStatement = (String) result.getOnlyValue(); String tableProperties = sqlStatement.split("\\)\\s*WITH\\s*\\(")[1]; checkTableProperty(tableProperties, "num_replicas", "\\d+"); checkTableProperty(tableProperties, "table_id", "'\\w+'"); checkTableProperty(tableProperties, "partition_by_hash_columns", Pattern.quote("ARRAY['id']")); checkTableProperty(tableProperties, "partition_by_hash_buckets", "2"); }</code><technical_language>please another test try set properties table_id num_replicas</technical_language>

Target:
public void testShowCreateTable() { queryRunner.execute("CREATE TABLE IF NOT EXISTS test_show_create_table (\n" + "id INT WITH (primary_key=true),\n" + "user_name VARCHAR\n" + ") WITH (\n" + " partition_by_hash_columns = ARRAY['id'],\n" + " partition_by_hash_buckets = 2," + " number_of_replicas = 1\n" + ")"); MaterializedResult result = queryRunner.execute("SHOW CREATE TABLE test_show_create_table"); String sqlStatement = (String) result.getOnlyValue(); String tableProperties = sqlStatement.split("\\)\\s*WITH\\s*\\(")[1]; assertTableProperty(tableProperties, "number_of_replicas", "1"); assertTableProperty(tableProperties, "partition_by_hash_columns", Pattern.quote("ARRAY['id']")); assertTableProperty(tableProperties, "partition_by_hash_buckets", "2"); }
Source:
<code>public static Map<String, Set<String>> determineProblematicNics(List<VdsNetworkInterface> interfaces, List<Network> clusterNetworks) { <START> Map<String, Set<String>> brokenNicsToNetworks = new HashMap<String, Set<String>>(); <END> Map<String, Network> networksByName = NetworkUtils.networksByName(clusterNetworks); for (VdsNetworkInterface iface : interfaces) { if (isRequiredInterfaceDown(networksByName, interfaces, iface)) { String baseNicName = NetworkUtils.stripVlan(iface); Set<String> networks = brokenNicsToNetworks.get(baseNicName); if (networks == null) { networks = new HashSet<String>(); brokenNicsToNetworks.put(baseNicName, networks); } networks.add(iface.getNetworkName()); } } return brokenNicsToNetworks; }</code><technical_language>be: new HashMap<>()</technical_language>

Target:
public static Map<String, Set<String>> determineProblematicNics(List<VdsNetworkInterface> interfaces, List<Network> clusterNetworks) { Map<String, Set<String>> brokenNicsToNetworks = new HashMap<>(); Map<String, Network> networksByName = NetworkUtils.networksByName(clusterNetworks); for (VdsNetworkInterface iface : interfaces) { if (isRequiredInterfaceDown(networksByName, interfaces, iface)) { String baseNicName = NetworkUtils.stripVlan(iface); Set<String> networks = brokenNicsToNetworks.get(baseNicName); if (networks == null) { networks = new HashSet<String>(); brokenNicsToNetworks.put(baseNicName, networks); } networks.add(iface.getNetworkName()); } } return brokenNicsToNetworks; }
Source:
<code>public static List<String> varargsToList(@Nullable Object[] args) { if (args == null || args.length == 0) { return null; } else { final List<String> list = new ArrayList<>(args.length); <START> for (Object arg : args) { <END> list.add(arg.toString()); } return list; } }</code><technical_language>This code faster Android, unfortunately, Java compiler optimise this :(</technical_language>

Target:
public static List<String> varargsToList(@Nullable Object[] args) { if (args == null || args.length == 0) { return null; } else { final List<String> list = new ArrayList<>(args.length); for (int i = 0; i < args.length; i++) { list.add(args[i].toString()); } return list; } }
Source:
<code>public Object getObject(String type, String value, byte[] byteValue) throws SQLException { if (typemap != null) { Class<?> c = typemap.get(type); <START> System.out.println("check type c in getOject in PgConnection : " + c); <END> if (c != null) { throw new PSQLException(GT.tr("Custom type maps are not supported."), PSQLState.NOT_IMPLEMENTED); } } if(type.equals("inet")) { try { System.out.println(InetAddress.getByName(value)); return InetAddress.getByName(value); } catch (UnknownHostException e) { e.printStackTrace(); } } PGobject obj = null; if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.log(Level.FINEST, "Constructing object from type={0} value=<{1}>", new Object[]{type, value}); } try { Class<? extends PGobject> klass = typeCache.getPGobject(type); if (klass != null) { obj = klass.newInstance(); obj.setType(type); System.out.println("Object type -->" + obj.getType()); if (byteValue != null && obj instanceof PGBinaryObject) { PGBinaryObject binObj = (PGBinaryObject) obj; binObj.setByteValue(byteValue, 0); } else { obj.setValue(value); } } else { obj = new PGobject(); obj.setType(type); obj.setValue(value); } System.out.println("Object -->" + obj.getValue()); return obj; } catch (SQLException sx) { throw sx; } catch (Exception ex) { throw new PSQLException(GT.tr("Failed to create object for: {0}.", type), PSQLState.CONNECTION_FAILURE, ex); } }</code><technical_language>logger instead</technical_language>

Target:
public Object getObject(String type, String value, byte[] byteValue) throws SQLException { if (typemap != null) { Class<?> c = typemap.get(type); if (c != null) { throw new PSQLException(GT.tr("Custom type maps are not supported."), PSQLState.NOT_IMPLEMENTED); } } if (type.equals("inet")) { try { return InetAddress.getByName(value); } catch (UnknownHostException e) { throw new PSQLException(GT.tr("IP address {0} of a host could not be determined", value), PSQLState.CONNECTION_FAILURE, e); } } PGobject obj = null; if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.log(Level.FINEST, "Constructing object from type={0} value=<{1}>", new Object[]{type, value}); } try { Class<? extends PGobject> klass = typeCache.getPGobject(type); if (klass != null) { obj = klass.newInstance(); obj.setType(type); if (byteValue != null && obj instanceof PGBinaryObject) { PGBinaryObject binObj = (PGBinaryObject) obj; binObj.setByteValue(byteValue, 0); } else { obj.setValue(value); } } else { obj = new PGobject(); obj.setType(type); obj.setValue(value); } return obj; } catch (SQLException sx) { throw sx; } catch (Exception ex) { throw new PSQLException(GT.tr("Failed to create object for: {0}.", type), PSQLState.CONNECTION_FAILURE, ex); } }
Source:
<code><START> public Collection<MergeStrategySection> getAllMergeStrategySections() { <END> List<MergeStrategySection> all = new ArrayList<MergeStrategySection>(); all.addAll(getLocalMergeStrategySections()); all.addAll(getInheritedMergeStrategySections()); return all; }</code><technical_language>I suspect want preserve order return a List</technical_language>

Target:
public List<MergeStrategySection> getAllMergeStrategySections() { List<MergeStrategySection> all = new ArrayList<MergeStrategySection>(); all.addAll(getLocalMergeStrategySections()); all.addAll(getInheritedMergeStrategySections()); return all; }
Source:
<code><START> public Object getFractionUnique() { <END> if (nProcessed == 0 || uniqueCount == 1) { return 0d; } else { double fractionUnique = uniqueCount / (double) nProcessed; if (tooManyValues) { return String.format("<= %.3f", fractionUnique); } else { return fractionUnique; } } }</code><technical_language>Try a single return type. String appropriate</technical_language>

Target:
public Double getFractionUnique() { if (nProcessed == 0 || uniqueCount == 1) { return 0d; } else { return uniqueCount / (double) nProcessed; } }
Source:
<code><START> public Iterable<IAnalysisModuleHelper> getAnalysisModules() { <END> if (fModules == null) { populateAnalysisModules(); } return fModules; }</code><technical_language>is fModules static? list of modules is for XML modules? In this case, getAnalysisModules() method a static method (and interface method). class ends a "static" class, empty private constructor prevent instantiation. this method synchronized, avoid risk of threads calling time entering if block</technical_language>

Target:
public synchronized Iterable<IAnalysisModuleHelper> getAnalysisModules() { if (fModules == null) { populateAnalysisModules(); } return fModules; }
Source:
<code><START> public boolean setTrace(ITmfTrace trace) throws TmfAnalysisException { <END> if (!super.setTrace(trace)) { return false; } if (!fSegmentStoreModule.setTrace(trace)) { return false; } if (!fStateSystemModule.setTrace(trace)) { return false; } return true; }</code><technical_language>early exit if trace is same? I asking, I</technical_language>

Target:
public boolean setTrace(ITmfTrace trace) throws TmfAnalysisException { if (!super.setTrace(trace)) { return false; } return fSegmentStoreModule.setTrace(trace) && fStateSystemModule.setTrace(trace); }
Source:
<code>public List<SubscriptionName> listActiveSubscriptionNames() { return getCurrentData().stream() .map(this::tryToReadSubscriptionSilently) <START> .filter(o -> o != null) <END> .filter(Subscription::isActive) .map(Subscription::toSubscriptionName) .collect(Collectors.toList()); }</code><technical_language>filter(Objects::nonNull)</technical_language>

Target:
public List<SubscriptionName> listActiveSubscriptionNames() { return getCurrentData().stream() .map(this::tryToReadSubscriptionSilently) .filter(Objects::nonNull) .filter(Subscription::isActive) .map(Subscription::toSubscriptionName) .collect(Collectors.toList()); }
Source:
<code>public void testWriteHandle() throws Exception { Map<String, byte[]> customMetadata = new HashMap<>(); customMetadata.put("test", "test".getBytes(StandardCharsets.UTF_8)); try (WriteHandle writer = result( newCreateLedgerOp() .withAckQuorumSize(1) .withWriteQuorumSize(2) .withEnsembleSize(3) .withDigestType(DigestType.MAC) .withCustomMetadata(customMetadata) .withPassword("password".getBytes(StandardCharsets.UTF_8)) .execute());) { byte[] data = "foo".getBytes(StandardCharsets.UTF_8); <START> writer.append(ByteBuffer.wrap(data)).get(); <END> writer.append(ByteBuffer.wrap(data)).get(); writer.append(Unpooled.wrappedBuffer(data)).get(); writer.append(ByteBuffer.wrap(data)).get(); long expectedEntryId = writer.append(ByteBuffer.wrap(data)).get(); assertEquals(expectedEntryId, writer.getLastAddConfirmed()); } }</code><technical_language>1) do want test line 65 line 69? write in a loop? is difference line 67 other lines? 2) consider verifying mock BookieClient times is called</technical_language>

Target:
public void testWriteHandle() throws Exception { try (WriteHandle writer = result(newCreateLedgerOp() .withAckQuorumSize(1) .withWriteQuorumSize(2) .withEnsembleSize(3) .withPassword(password) .execute());) { result(writer.append(ByteBuffer.wrap(data))); result(writer.append(Unpooled.wrappedBuffer(data))); long expectedEntryId = result(writer.append(ByteBuffer.wrap(data))); assertEquals(expectedEntryId, writer.getLastAddConfirmed()); } }