auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Session performOpenSession(URI representationsFileURI, IProgressMonitor monitor) { Session session = null; try { monitor.beginTask(Messages.OpenRepresentationsFileJob_loadRepresentationsTask, 16); if (SiriusUtil.SESSION_RESOURCE_EXTENSION.equals(representationsFileURI.fileExtension())) { monitor.worked(1); <START> session = trySessionOpening(representationsFileURI, monitor); monitor.worked(1); } } catch (SiriusResourceVersionMismatchException e) { UICallBack uiCallback = SiriusEditPlugin.getPlugin().getUiCallback(); if (uiCallback instanceof UICallBack2) { UICallBack2 uiCallBack2 = (UICallBack2) uiCallback; uiCallBack2.askSessionReopeningWithResourceVersionMismatch(e); try { SiriusResourceVersionMismatchException.ignoreVersionMismatch = true; session = trySessionOpening(representationsFileURI, monitor); monitor.worked(1); } catch (RuntimeException ex) { SiriusEditPlugin.getPlugin().log(ex); } finally { SiriusResourceVersionMismatchException.ignoreVersionMismatch = false; } } <END> } catch (RuntimeException e) { SiriusEditPlugin.getPlugin().log(e); } finally { monitor.done(); } return session; }</code><technical_language>This behavior is coded trySessionOpening, put this in a common helper. in a new specific SessionCreationOperation ? SiriusRepairProcess, ExportRepresentationFromFileAction modified</technical_language>

Target:
public Session performOpenSession(URI representationsFileURI, IProgressMonitor monitor) { Session session = null; try { monitor.beginTask(Messages.OpenRepresentationsFileJob_loadRepresentationsTask, 16); if (SiriusUtil.SESSION_RESOURCE_EXTENSION.equals(representationsFileURI.fileExtension())) { monitor.worked(1); session = trySessionOpening(representationsFileURI, monitor); monitor.worked(1); } } catch (SiriusResourceVersionMismatchException e) { UICallBack uiCallback = SiriusEditPlugin.getPlugin().getUiCallback(); if (uiCallback != null) { uiCallback.askSessionReopeningWithResourceVersionMismatch(e); try { MigrationUtil.ignoreVersionMismatch = true; session = trySessionOpening(representationsFileURI, monitor); monitor.worked(1); } catch (RuntimeException ex) { SiriusEditPlugin.getPlugin().log(ex); } finally { MigrationUtil.ignoreVersionMismatch = false; } } } catch (RuntimeException e) { SiriusEditPlugin.getPlugin().log(e); } finally { monitor.done(); } return session; }
Source:
<code><START> protected Set<Guid> getStorageDomainsIds() { <END> Set<Guid> storageIds = new HashSet<>(); for (DiskImage disk : getSourceImages()) { storageIds.addAll(disk.getStorageIds()); } return storageIds; }</code><technical_language>ImagesHandler.getAllStorageIdsForImageIds</technical_language>

Target:
protected Collection<Guid> getStorageDomainsIds() { return ImagesHandler.getAllStorageIdsForImageIds(getSourceImages()); }
Source:
<code>public void setScenarioModifiers(List<AtBScenarioModifier> scenarioModifiers) { <START> this.scenarioModifiers = scenarioModifiers; <END> }</code><technical_language>preference: copy scenarioModifiers a new ArrayList</technical_language>

Target:
public void setScenarioModifiers(List<AtBScenarioModifier> scenarioModifiers) { scenarioModifiers = new ArrayList<>(); Collections.copy(this.scenarioModifiers, scenarioModifiers); }
Source:
<code>public void write(ChannelHandlerContext ctx, int allowedBytes) { int queuedData = queue.readableBytes(); if (!endOfStream) { if (queuedData == 0) { if (queue.isEmpty()) { padding = dataSize = 0; <START> return; <END> } ChannelPromise writePromise = ctx.newPromise().addListener(this); ctx.write(queue.remove(0, writePromise), writePromise); return; } if (allowedBytes == 0) { return; } } int writableData = min(queuedData, allowedBytes); ChannelPromise writePromise = ctx.newPromise().addListener(this); ByteBuf toWrite = queue.remove(writableData, writePromise); dataSize = queue.readableBytes(); int writablePadding = min(allowedBytes - writableData, padding); padding -= writablePadding; frameWriter().writeData(ctx, stream.id(), toWrite, writablePadding, endOfStream && size() == 0, writePromise); }</code><technical_language>nit: remove a return statement if else return; remove jump of control flow</technical_language>

Target:
public void write(ChannelHandlerContext ctx, int allowedBytes) { int queuedData = queue.readableBytes(); if (!endOfStream) { if (queuedData == 0) { if (queue.isEmpty()) { padding = dataSize = 0; } else { ChannelPromise writePromise = ctx.newPromise().addListener(this); ctx.write(queue.remove(0, writePromise), writePromise); } return; } if (allowedBytes == 0) { return; } } int writableData = min(queuedData, allowedBytes); ChannelPromise writePromise = ctx.newPromise().addListener(this); ByteBuf toWrite = queue.remove(writableData, writePromise); dataSize = queue.readableBytes(); int writablePadding = min(allowedBytes - writableData, padding); padding -= writablePadding; frameWriter().writeData(ctx, stream.id(), toWrite, writablePadding, endOfStream && size() == 0, writePromise); }
Source:
<code>private LookupEntry lookupEntryForIdOrUri(@Nullable String id, @Nullable String uri) { Iterable<LookupEntry> lookupEntries; if (!Strings.isNullOrEmpty(uri)) { lookupEntries = lookupEntryStore.entriesForCanonicalUris(ImmutableList.of(uri)); if (!lookupEntries.iterator().hasNext()) { throw new IllegalArgumentException("No lookup entry found for uri " + uri); } } else if (!Strings.isNullOrEmpty(id)) { lookupEntries = lookupEntryStore.entriesForIds( ImmutableList.of( SubstitutionTableNumberCodec.lowerCaseOnly().decode(id).longValue() ) ); if (!lookupEntries.iterator().hasNext()) { throw new IllegalArgumentException("No lookup entry found for id " + id); } } else { throw new IllegalArgumentException("No id or uri specified"); } <START> if (!lookupEntries.iterator().hasNext()) { <END> throw new IllegalArgumentException("No lookup entry found"); } return Iterables.getOnlyElement(lookupEntries); }</code><technical_language>Is this necessary? cases get caught other checks above</technical_language>

Target:
private LookupEntry lookupEntryForIdOrUri(@Nullable String id, @Nullable String uri) { Iterable<LookupEntry> lookupEntries; if (!Strings.isNullOrEmpty(uri)) { lookupEntries = lookupEntryStore.entriesForCanonicalUris(ImmutableList.of(uri)); if (!lookupEntries.iterator().hasNext()) { throw new IllegalArgumentException("No lookup entry found for uri " + uri); } } else if (!Strings.isNullOrEmpty(id)) { lookupEntries = lookupEntryStore.entriesForIds( ImmutableList.of(codec.decode(id).longValue()) ); if (!lookupEntries.iterator().hasNext()) { throw new IllegalArgumentException("No lookup entry found for id " + id); } } else { throw new IllegalArgumentException("No id or uri specified"); } return Iterables.getOnlyElement(lookupEntries); }
Source:
<code>private void writePage(Page page) { int[] writerIndexes = getWriterIndexes(page); int[] sizes = new int[writers.size()]; for (int index : writerIndexes) { sizes[index]++; } int[][] writerPositions = new int[writers.size()][]; int[] counts = new int[writers.size()]; for (int position = 0; position < page.getPositionCount(); position++) { int index = writerIndexes[position]; int count = counts[index]; if (count == 0) { writerPositions[index] = new int[sizes[index]]; } writerPositions[index][count] = position; counts[index] = count + 1; } Page dataPage = getDataPage(page); for (int index = 0; index < writerPositions.length; index++) { int[] positions = writerPositions[index]; if (positions == null) { continue; } Page pageForWriter = dataPage; <START> if (positions.length != dataPage.getPositionCount()) { <END> pageForWriter = pageForWriter.getPositions(positions, 0, positions.length); } HiveWriter writer = writers.get(index); long currentWritten = writer.getWrittenBytes(); long currentMemory = writer.getSystemMemoryUsage(); writer.append(pageForWriter); writtenBytes += (writer.getWrittenBytes() - currentWritten); systemMemoryUsage += (writer.getSystemMemoryUsage() - currentMemory); } }</code><technical_language>verify(positions.length == counts[index])</technical_language>

Target:
private void writePage(Page page) { int[] writerIndexes = getWriterIndexes(page); int[] sizes = new int[writers.size()]; for (int index : writerIndexes) { sizes[index]++; } int[][] writerPositions = new int[writers.size()][]; int[] counts = new int[writers.size()]; for (int position = 0; position < page.getPositionCount(); position++) { int index = writerIndexes[position]; int count = counts[index]; if (count == 0) { writerPositions[index] = new int[sizes[index]]; } writerPositions[index][count] = position; counts[index] = count + 1; } Page dataPage = getDataPage(page); for (int index = 0; index < writerPositions.length; index++) { int[] positions = writerPositions[index]; if (positions == null) { continue; } Page pageForWriter = dataPage; if (positions.length != dataPage.getPositionCount()) { verify(positions.length == counts[index]); pageForWriter = pageForWriter.getPositions(positions, 0, positions.length); } HiveWriter writer = writers.get(index); long currentWritten = writer.getWrittenBytes(); long currentMemory = writer.getSystemMemoryUsage(); writer.append(pageForWriter); writtenBytes += (writer.getWrittenBytes() - currentWritten); systemMemoryUsage += (writer.getSystemMemoryUsage() - currentMemory); } }
Source:
<code>public void shouldParseConnectScriptWithOptions() throws Exception { String script = "connect option transport \"localhost:8888\"\n" + <START> "connect tcp://localhost:7788\n" + <END> "connected\n" + "close\n" + "closed\n"; ScriptParserImpl parser = new ScriptParserImpl(); AstScriptNode actual = parser.parseWithStrategy(script, SCRIPT); }</code><technical_language>connect transport option a location, tcp://localhost:8888, right</technical_language>

Target:
public void shouldParseConnectScriptWithOptions() throws Exception { String script = "connect http://localhost:7788\n" + " option transport tcp://localhost:8888\n" + "connected\n" + "close\n" + "closed\n"; ScriptParserImpl parser = new ScriptParserImpl(); AstScriptNode actual = parser.parseWithStrategy(script, SCRIPT); AstLocation location = new AstLocationLiteral(URI.create("http://localhost:7788")); AstLocation transport = new AstLocationLiteral(URI.create("tcp://localhost:8888")); AstScriptNode expected = new AstScriptNodeBuilder() .addConnectStream() .setLocation(location) .setTransport(transport) .addConnectedEvent().done() .addCloseCommand().done() .addClosedEvent().done() .done() .done(); assertEquals(expected, actual); }
Source:
<code>public static int purgeMobs() { int removed = 0; for (World world : Bukkit.getWorlds()) { for (Entity ent : world.getLivingEntities()) { <START> if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon || ent instanceof Ambient || ent instanceof Squid) <END> { ent.remove(); removed++; } } } return removed; }</code><technical_language>Replace ent instanceof Squid ent instanceof WaterMob</technical_language>

Target:
public static int purgeMobs() { int removed = 0; for (World world : Bukkit.getWorlds()) { for (Entity ent : world.getLivingEntities()) { if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon || ent instanceof Ambient || ent instanceof WaterMob) { ent.remove(); removed++; } } } return removed; }
Source:
<code>private void showAssigneePicker(TurboIssue issue) { List<TurboUser> assigneeList = ui.logic.getRepo(issue.getRepoId()).getUsers(); AssigneePickerDialog assigneePickerDialog = new AssigneePickerDialog(stage, issue, assigneeList); <START> Optional<AssigneePickerDialogResponse> assigneeDialogResponse = assigneePickerDialog.showAndWait(); <END> if (wasCancelled(assigneeDialogResponse)) { return; } Optional<String> newlyAssignedAssignee = assigneeDialogResponse.get().getAssigneeLoginName(); if (!issue.getAssignee().equals(newlyAssignedAssignee)) { addActionIfAssigneeChanged(issue, newlyAssignedAssignee); } }</code><technical_language>I for milestone picker: - Types implementation details, leave out of variable names. assignees? - need name intermediate result, do new AssigneePickerDialog(...).showAndWait(...). Also, dialog response class? prefix it</technical_language>

Target:
private void showAssigneePicker(TurboIssue issue) { List<TurboUser> assignees = ui.logic.getRepo(issue.getRepoId()).getUsers(); Optional<AssigneePickerDialog.AssigneePickerDialogResponse> assigneeDialogResponse = new AssigneePickerDialog(stage, issue, assignees).showAndWait(); if (wasCancelled(assigneeDialogResponse)) { return; } Optional<String> newlyAssignedAssignee = assigneeDialogResponse.get().getAssigneeLoginName(); changeAssignee(issue, newlyAssignedAssignee); }
Source:
<code>public void recenterMap(fr.free.nrw.commons.location.LatLng curLatLng) { <START> if (curLatLng == null) { return; } else if (!locationManager.isLocationEnabled()) { showEnableLocationDialog(); <END> } addCurrentLocationMarker(curLatLng); CameraPosition position; if (ViewUtil.isPortrait(getActivity())) { position = new CameraPosition.Builder() .target(isListBottomSheetExpanded() ? new LatLng(curLatLng.getLatitude() - CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT, curLatLng.getLongitude()) : new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude(), 0)) .zoom(isListBottomSheetExpanded() ? ZOOM_LEVEL : mapBox.getCameraPosition().zoom) .build(); } else { position = new CameraPosition.Builder() .target(isListBottomSheetExpanded() ? new LatLng(curLatLng.getLatitude() - CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE, curLatLng.getLongitude()) : new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude(), 0)) .zoom(isListBottomSheetExpanded() ? ZOOM_LEVEL : mapBox.getCameraPosition().zoom) .build(); } mapBox.animateCamera(CameraUpdateFactory.newCameraPosition(position), 1000); }</code><technical_language>~Ok. I managed figure out a show dialog appropriate.~ ~Try this:~ suggestion if (curLatLng == null) { if (!locationManager.isLocationEnabled()) { // Location is set High Accuracy. // prompt user a dialog box. showEnableLocationDialog(); } return; } ~Let if this works fine.~</technical_language>

Target:
public void recenterMap(fr.free.nrw.commons.location.LatLng curLatLng) { if (curLatLng == null) { if (!(locationManager.isNetworkProviderEnabled() || locationManager.isGPSProviderEnabled())) { showLocationOffDialog(); } return; } addCurrentLocationMarker(curLatLng); CameraPosition position; if (ViewUtil.isPortrait(getActivity())) { position = new CameraPosition.Builder() .target(isListBottomSheetExpanded() ? new LatLng(curLatLng.getLatitude() - CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT, curLatLng.getLongitude()) : new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude(), 0)) .zoom(isListBottomSheetExpanded() ? ZOOM_LEVEL : mapBox.getCameraPosition().zoom) .build(); } else { position = new CameraPosition.Builder() .target(isListBottomSheetExpanded() ? new LatLng(curLatLng.getLatitude() - CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE, curLatLng.getLongitude()) : new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude(), 0)) .zoom(isListBottomSheetExpanded() ? ZOOM_LEVEL : mapBox.getCameraPosition().zoom) .build(); } mapBox.animateCamera(CameraUpdateFactory.newCameraPosition(position), 1000); }
Source:
<code>public CommandResult<CanvasViolation> translate( final Element element, final double dx, final double dy ) { final Double[] p; try { p = GraphUtils.getPosition( ( View ) element.getContent() ); } catch ( ClassCastException e ) { <START> LOGGER.log( Level.WARNING, "Update element's position comman only cannot be applied to View elements." ); <END> return CanvasCommandResultBuilder.FAILED; } final double tx = p[ 0 ] + dx; final double ty = p[ 1 ] + dy; return move( element, tx, ty ); }</code><technical_language>Typo "...comman**d**..."</technical_language>

Target:
public CommandResult<CanvasViolation> translate( final Element element, final double dx, final double dy ) { final Point2D p; try { p = GraphUtils.getPosition( ( View ) element.getContent() ); } catch ( ClassCastException e ) { LOGGER.log( Level.WARNING, "Update element's position command only cannot be applied to View elements." ); return CanvasCommandResultBuilder.FAILED; } final double tx = p.getX() + dx; final double ty = p.getY() + dy; return move( element, tx, ty ); }
Source:
<code>public boolean canSave(IPath file) { IRemoteFileProxy proxy = null; URI fileURI = null; try { fileURI = new URI(file.toPortableString()); proxy = RemoteProxyManager.getInstance().getFileProxy(fileURI); } catch (URISyntaxException e) { <START> e.printStackTrace(); <END> } catch (CoreException e) { e.printStackTrace(); } IFileStore fileStore = proxy.getResource(fileURI.getPath()); if (fileStore.fetchInfo().exists()) { String msg = MessageFormat.format( Messages.PerfSaveSession_file_exists_msg, new Object[] { fileStore.getName() }); return MessageDialog.openQuestion(Display.getCurrent() .getActiveShell(), Messages.PerfSaveSession_file_exists_title, msg); } return true; }</code><technical_language>Do print stack trace. Handle better</technical_language>

Target:
public boolean canSave(IPath file) { IRemoteFileProxy proxy = null; URI fileURI = null; try { fileURI = new URI(file.toPortableString()); proxy = RemoteProxyManager.getInstance().getFileProxy(fileURI); } catch (URISyntaxException e) { MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.MsgProxyError, Messages.MsgProxyError); } catch (CoreException e) { MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.MsgProxyError, Messages.MsgProxyError); } IFileStore fileStore = proxy.getResource(fileURI.getPath()); if (fileStore.fetchInfo().exists()) { String msg = MessageFormat.format( Messages.PerfSaveSession_file_exists_msg, new Object[] { fileStore.getName() }); return MessageDialog.openQuestion(Display.getCurrent() .getActiveShell(), Messages.PerfSaveSession_file_exists_title, msg); } return true; }
Source:
<code>public void resourceOffers(SchedulerDriver driver, List<Protos.Offer> offers) { synchronized (_offersLock) { LOG.debug("resourceOffers: Currently have " + _offers.size() + " offers buffered" + (_offers.size() > 0 ? (":" + offerMapToString(_offers)) : "")); for (Protos.Offer offer : offers) { <START> if (_offers != null && isHostAccepted(offer.getHostname())) { <END> LOG.debug("resourceOffers: Recording offer from host: " + offer.getHostname() + ", offerId: " + offer.getId().getValue()); _offers.put(offer.getId(), offer); } else { LOG.debug("resourceOffers: Declining offer from host: " + offer.getHostname() + ", offerId: " + offer.getId().getValue()); driver.declineOffer(offer.getId()); } } LOG.debug("resourceOffers: After processing offers, now have " + _offers.size() + " offers buffered:" + offerMapToString(_offers)); } }</code><technical_language>If _offers null, thrown a null pointer exception line 221</technical_language>

Target:
public void resourceOffers(SchedulerDriver driver, List<Protos.Offer> offers) { synchronized (_offersLock) { if (_offers == null) { return; } LOG.debug("resourceOffers: Currently have " + _offers.size() + " offers buffered" + (_offers.size() > 0 ? (":" + offerMapToString(_offers)) : "")); for (Protos.Offer offer : offers) { if (isHostAccepted(offer.getHostname())) { LOG.debug("resourceOffers: Recording offer from host: " + offer.getHostname() + ", offerId: " + offer.getId().getValue()); _offers.put(offer.getId(), offer); } else { LOG.debug("resourceOffers: Declining offer from host: " + offer.getHostname() + ", offerId: " + offer.getId().getValue()); driver.declineOffer(offer.getId()); } } LOG.debug("resourceOffers: After processing offers, now have " + _offers.size() + " offers buffered:" + offerMapToString(_offers)); } }
Source:
<code>public void continueOrPropagate(RetryableException ex) { ExceptionRetryBehaviour retryBehaviour = ExceptionRetryBehaviour.getRetryBehaviourForException(ex); synchronized (this) { if (mostRecentServerIndex.get() != null && mostRecentServerIndex.get() == failoverCount.get()) { long failures = failuresSinceLastSwitch.incrementAndGet(); if (shouldSwitchNode(retryBehaviour, failures)) { failoverToNextNode(retryBehaviour); } else if (retryBehaviour.shouldRetryInfinitelyManyTimes()) { failuresSinceLastSwitch.set(0); } } } checkAndHandleFailure(ex); if (retryBehaviour.shouldBackoffAndTryOtherNodes()) { if (failoverCount.get() % servers.size() == 0) { <START> pauseForBackoff(ex, 1000L); <END> } else { pauseForBackoff(ex); } } }</code><technical_language>this backoff configurable. 1 conservative for a default. figure out long, average, a leadership election takes, wait for amount of time</technical_language>

Target:
public void continueOrPropagate(RetryableException ex) { ExceptionRetryBehaviour retryBehaviour = ExceptionRetryBehaviour.getRetryBehaviourForException(ex); synchronized (this) { if (mostRecentServerIndex.get() != null && mostRecentServerIndex.get() == failoverCount.get()) { long failures = failuresSinceLastSwitch.incrementAndGet(); if (shouldSwitchNode(retryBehaviour, failures)) { failoverToNextNode(retryBehaviour); } else if (retryBehaviour.shouldRetryInfinitelyManyTimes()) { failuresSinceLastSwitch.set(0); } } } checkAndHandleFailure(ex); if (retryBehaviour.shouldBackoffAndTryOtherNodes()) { int numFailovers = failoverCount.get(); if (numFailovers > 0 && numFailovers % servers.size() == 0) { pauseForBackoff(ex, BACKOFF_BEFORE_ROUND_ROBIN_RETRY_MILLIS); } else { pauseForBackoff(ex); } } }
Source:
<code>public void testInitFromRDFS() throws IOException, InterruptedException { String separator = System.getProperty("file.separator"); String classpath = System.getProperty("java.class.path"); String java = System.getProperty("java.home") <START> + separator + "bin" + separator + "java"; <END> List<String> args = Arrays.asList(java, "-cp", classpath, "org.apache.jena.test.RDFSJenaInitTestApp"); Process child = new ProcessBuilder().command(args) .redirectError(ProcessBuilder.Redirect.INHERIT) .redirectOutput(ProcessBuilder.Redirect.PIPE) .start(); Assert.assertEquals(0, child.waitFor()); Assert.assertEquals(RDFS.subClassOf.toString()+"\n", IOUtils.toString(child.getInputStream())); }</code><technical_language>windows, java executable end ".exe". This avoid problem: java import org.apache.commons.lang3.SystemUtils; if (SystemUtils.IS_OS_WINDOWS) java += ".exe";</technical_language>

Target:
public void testInitFromRDFS() throws IOException, InterruptedException { String separator = System.getProperty("file.separator"); String classpath = System.getProperty("java.class.path"); String java = System.getProperty("java.home") + separator + "bin" + separator + "java"; if (SystemUtils.IS_OS_WINDOWS) java += ".exe"; List<String> args = Arrays.asList(java, "-cp", classpath, "org.apache.jena.test.RDFSJenaInitTestApp"); Process child = new ProcessBuilder().command(args) .redirectError(ProcessBuilder.Redirect.INHERIT) .redirectOutput(ProcessBuilder.Redirect.PIPE) .start(); Assert.assertEquals(0, child.waitFor()); Assert.assertEquals(RDFS.subClassOf.toString()+"\n", IOUtils.toString(child.getInputStream())); }
Source:
<code>public void publish(EventMessage<?> msg, P declaringInstance) { if (forwardEvents) { Iterable<C> targets = eventTargetResolver.apply(msg, declaringInstance); if (targets != null) { <START> Collection<C> copy = new ArrayList<>(); <END> targets.forEach(copy::add); copy.forEach(target -> this.entityModel.publish(msg, target)); } } }</code><technical_language>I check if targets implements Collection. In case, faster create a copy copy-constructor ArrayList. constructor size list correct size immediately, instead of needing grow iterator proceeds. If target implement Collection, is alternative this one..</technical_language>

Target:
public void publish(EventMessage<?> msg, P declaringInstance) { if (forwardEvents) { Iterable<C> targets = eventTargetResolver.apply(msg, declaringInstance); if (targets != null) { safeForEach(targets, target -> this.entityModel.publish(msg, target)); } } }
Source:
<code><START> public static String getAttributeKeyString(final Set<Integer> keys, final Schema schema) { <END> String keyString = ""; int counter = 1; for (int key : keys) { keyString += schema.getColumnName(key); if (counter != keys.size()) { keyString += ","; } counter++; } return keyString; }</code><technical_language>Joiner.on(",").join(getAttributeKeySchema(keys, schema).getColumnNames())</technical_language>

Target:
public static String getAttributeKeyString(final Set<Integer> keys, final Schema schema) { return Joiner.on(",").join(getAttributeKeySchema(keys, schema).getColumnNames()); }
Source:
<code>public void createCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { getCertificateClient(httpClient, serviceVersion); createCertificateRunner((policy) -> { <START> getCertificateClient(httpClient, serviceVersion); <END> String certName = generateResourceId("testCer"); SyncPoller<CertificateOperation, KeyVaultCertificateWithPolicy> certPoller = client.beginCreateCertificate(certName, policy); certPoller.waitForCompletion(); KeyVaultCertificateWithPolicy expected = certPoller.getFinalResult(); assertEquals(certName, expected.getName()); assertNotNull(expected.getProperties().getCreatedOn()); deleteAndPurgeCertificate(certName); }); }</code><technical_language>Why's getCertificateClient() called twice</technical_language>

Target:
public void createCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { createCertificateClient(httpClient, serviceVersion); createCertificateRunner((policy) -> { String certName = generateResourceId("testCer"); SyncPoller<CertificateOperation, KeyVaultCertificateWithPolicy> certPoller = client.beginCreateCertificate(certName, policy); certPoller.waitForCompletion(); KeyVaultCertificateWithPolicy expected = certPoller.getFinalResult(); assertEquals(certName, expected.getName()); assertNotNull(expected.getProperties().getCreatedOn()); deleteAndPurgeCertificate(certName); }); }
Source:
<code>public static String encode(final FastqRecord record) { <START> final int capacity = record.getReadLength() * 2 + record.getReadName().length() + 5; <END> return write(new StringBuilder(capacity), record).toString(); }</code><technical_language>@magicDGS tests failing a null pointer exception. caused this unguarded call of record.getReadName().length()</technical_language>

Target:
public static String encode(final FastqRecord record) { int capacity = record.getReadLength() * 2 + 5; if (record.getReadName() != null) { capacity += record.getReadName().length(); } return write(new StringBuilder(capacity), record).toString(); }
Source:
<code>public TaskletConfiguration getWorkerTaskletConf() { return TaskletConfiguration.newBuilder() <START> .setId(dolphinJobId + "-" + WorkerTasklet.TASKLET_ID_PREFIX) <END> .setTaskletClass(WorkerTasklet.class) .setTaskletMsgHandlerClass(WorkerSideMsgHandler.class) .setUserParamConf(Configurations.merge( Tang.Factory.getTang().newConfigurationBuilder() .bindNamedParameter(DolphinJobId.class, dolphinJobId) .bindNamedParameter(StartingEpochIdx.class, Integer.toString(progressTracker.getGlobalMinEpochIdx())) .bindNamedParameter(ModelTableId.class, modelTableId) .bindNamedParameter(InputTableId.class, inputTableId) .bindNamedParameter(OfflineModelEvaluation.class, Boolean.toString(offlineModelEval)) .build(), workerConf)).build(); }</code><technical_language>I WorkerTasklet.TASKLET_ID_PREFIX TASKLET_ID_SUFFIX TASKLET_ID (and values updated trailing '-')</technical_language>

Target:
public TaskletConfiguration getWorkerTaskletConf() { return TaskletConfiguration.newBuilder() .setId(dolphinJobId + "-" + WorkerTasklet.TASKLET_ID) .setTaskletClass(WorkerTasklet.class) .setTaskletMsgHandlerClass(WorkerSideMsgHandler.class) .setUserParamConf(Configurations.merge( Tang.Factory.getTang().newConfigurationBuilder() .bindNamedParameter(DolphinJobId.class, dolphinJobId) .bindNamedParameter(StartingEpochIdx.class, Integer.toString(progressTracker.getGlobalMinEpochIdx())) .bindNamedParameter(ModelTableId.class, modelTableId) .bindNamedParameter(InputTableId.class, inputTableId) .bindNamedParameter(OfflineModelEvaluation.class, Boolean.toString(offlineModelEval)) .build(), workerConf)).build(); }
Source:
<code>public JSONObject(JSONTokener x) throws JSONException { this(); char c; String key; if (x.nextClean() != '{') { throw x.syntaxError("A JSONObject text must begin with '{'"); } for (;;) { c = x.nextClean(); switch (c) { case 0: throw x.syntaxError("A JSONObject text must end with '}'"); case '}': return; default: x.back(); key = x.nextValue().toString(); } c = x.nextClean(); if (c != ':') { throw x.syntaxError("Expected a ':' after a key"); } try { this.putOnce(key, x.nextValue()); <START> } catch (JSONException _e) { <END> throw x.syntaxError(_e.getMessage()); } switch (x.nextClean()) { case ';': case ',': if (x.nextClean() == '}') { return; } x.back(); break; case '}': return; default: throw x.syntaxError("Expected a ',' or '}'"); } } }</code><technical_language>_ (underscore) prefx for other variables. rename 'e'</technical_language>

Target:
public JSONObject(JSONTokener x) throws JSONException { this(); char c; String key; if (x.nextClean() != '{') { throw x.syntaxError("A JSONObject text must begin with '{'"); } for (;;) { c = x.nextClean(); switch (c) { case 0: throw x.syntaxError("A JSONObject text must end with '}'"); case '}': return; default: x.back(); key = x.nextValue().toString(); } c = x.nextClean(); if (c != ':') { throw x.syntaxError("Expected a ':' after a key"); } try { this.putOnce(key, x.nextValue()); } catch (JSONException e) { throw x.syntaxError(e.getMessage()); } switch (x.nextClean()) { case ';': case ',': if (x.nextClean() == '}') { return; } x.back(); break; case '}': return; default: throw x.syntaxError("Expected a ',' or '}'"); } } }
Source:
<code>public void setTipBar(List<TipItemInterface> tipItems) { tipBar.clear(); if (tipItems != null) { if (tipItems.size() == 0) { tipBarPanel.setVisible(false); } else { tipBarPanel.setVisible(true); for (TipItemInterface menuItem : tipItems) { final FlowPanel flowPanel = new FlowPanel(); final TipItemInterface currentItem = menuItem; final Label label = new Label(); label.setText("- " + currentItem.getLabel()); label.setStyleName(resources.tipBarStyle().fontStyle()); final Label actionLabel = new Label(); actionLabel.setText(currentItem.getActionLabel()); actionLabel.setStyleName(resources.tipBarStyle().linkStyle()); actionLabel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { currentItem.getCallBack().onClickAction(); } }); flowPanel.add(label); flowPanel.add(actionLabel); <START> tipBar.add(flowPanel); <END> } } } }</code><technical_language>dont call addTipBarItem() instead of duplicating code</technical_language>

Target:
public void setTipBar(List<TipItemInterface> tipItems) { tipBar.clear(); if (tipItems != null) { if (tipItems.size() == 0) { tipBarPanel.setVisible(false); } else { tipBarPanel.setVisible(true); for (TipItemInterface tipItem : tipItems) { addTipBarItem(tipItem); } } } }
Source:
<code>public boolean advanceNextPosition() { while (true) { <START> boolean hasNextPosition = delegate.advanceNextPosition(); <END> if (!hasNextPosition) { return false; } for (int i = 0; i < scratch.length; i++) { int index = bucketColumnIndices[i]; if (delegate.isNull(index)) { scratch[i] = null; continue; } Class<?> javaType = javaTypeList.get(i); if (javaType == boolean.class) { scratch[i] = delegate.getBoolean(index); } else if (javaType == long.class) { scratch[i] = delegate.getLong(index); } else if (javaType == double.class) { scratch[i] = delegate.getDouble(index); } else if (javaType == Slice.class) { scratch[i] = delegate.getSlice(index); } else if (javaType == Block.class) { scratch[i] = (Block) delegate.getObject(index); } else { throw new UnsupportedOperationException("unknown java type"); } } int bucket = HiveBucketing.getHiveBucket(tableBucketCount, typeInfoList, scratch); if ((bucket - bucketToKeep) % partitionBucketCount != 0) { throw new PrestoException(HIVE_INVALID_BUCKET_FILES, format( "A row that is supposed to be in bucket %s is encountered. Only rows in bucket %s (modulo %s) is expected", bucket, bucketToKeep % partitionBucketCount, partitionBucketCount)); } if (bucket == bucketToKeep) { return true; } } }</code><technical_language>This need interruptable (not yieldable, interruptable)</technical_language>

Target:
public boolean advanceNextPosition() { while (true) { if (Thread.interrupted()) { Thread.currentThread().interrupt(); throw new PrestoException(GENERIC_INTERNAL_ERROR, "RecordCursor was interrupted"); } boolean hasNextPosition = delegate.advanceNextPosition(); if (!hasNextPosition) { return false; } for (int i = 0; i < scratch.length; i++) { int index = bucketColumnIndices[i]; if (delegate.isNull(index)) { scratch[i] = null; continue; } Class<?> javaType = javaTypeList.get(i); if (javaType == boolean.class) { scratch[i] = delegate.getBoolean(index); } else if (javaType == long.class) { scratch[i] = delegate.getLong(index); } else if (javaType == double.class) { scratch[i] = delegate.getDouble(index); } else if (javaType == Slice.class) { scratch[i] = delegate.getSlice(index); } else if (javaType == Block.class) { scratch[i] = (Block) delegate.getObject(index); } else { throw new UnsupportedOperationException("unknown java type"); } } int bucket = HiveBucketing.getHiveBucket(tableBucketCount, typeInfoList, scratch); if ((bucket - bucketToKeep) % partitionBucketCount != 0) { throw new PrestoException(HIVE_INVALID_BUCKET_FILES, format( "A row that is supposed to be in bucket %s is encountered. Only rows in bucket %s (modulo %s) are expected", bucket, bucketToKeep % partitionBucketCount, partitionBucketCount)); } if (bucket == bucketToKeep) { return true; } } }
Source:
<code>public List<InterpreterCompletion> completion(String buf, int cursor) { if (buf.length() < cursor) { cursor = buf.length(); } String completionText = getCompletionTargetString(buf, cursor); if (completionText == null) { completionText = ""; cursor = completionText.length(); } if (Utils.isScala2_10()) { <START> ScalaCompleter c = (ScalaCompleter) Utils.invokeMethod(completor, "completer"); <END> Candidates ret = c.complete(completionText, cursor); List<String> candidates = WrapAsJava$.MODULE$.seqAsJavaList(ret.candidates()); List<InterpreterCompletion> completions = new LinkedList<InterpreterCompletion>(); for (String candidate : candidates) { completions.add(new InterpreterCompletion(candidate, candidate)); } return completions; } else { return new LinkedList<InterpreterCompletion>(); } }</code><technical_language>@karup1990 Thanks for fixing this. change another completor in this line? I ScalaCompleter c = (ScalaCompleter) Utils.invokeMethod(completer, "completer"); change - [spark/src/main/java/org/apache/zeppelin/spark/SparkInterpreter.java#L114](<LINK_2> - [spark/src/main/java/org/apache/zeppelin/spark/SparkInterpreter.java#L116](<LINK_1> - [spark/src/main/java/org/apache/zeppelin/spark/SparkInterpreter.java#L579](<LINK_0></technical_language>

Target:
public List<InterpreterCompletion> completion(String buf, int cursor) { if (buf.length() < cursor) { cursor = buf.length(); } String completionText = getCompletionTargetString(buf, cursor); if (completionText == null) { completionText = ""; cursor = completionText.length(); } if (Utils.isScala2_10()) { ScalaCompleter c = (ScalaCompleter) Utils.invokeMethod(completer, "completer"); Candidates ret = c.complete(completionText, cursor); List<String> candidates = WrapAsJava$.MODULE$.seqAsJavaList(ret.candidates()); List<InterpreterCompletion> completions = new LinkedList<InterpreterCompletion>(); for (String candidate : candidates) { completions.add(new InterpreterCompletion(candidate, candidate)); } return completions; } else { return new LinkedList<InterpreterCompletion>(); } }
Source:
<code>private synchronized static void allowPatchRequestsIfNeeded() throws GeneralException { if (isPatchRequestAllowed) { return; } try { Field methodsField = HttpURLConnection.class.getDeclaredField("methods"); methodsField.setAccessible(true); Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(methodsField, methodsField.getModifiers() & ~Modifier.FINAL); <START> String[] allowedMethods = getAllowedMethods((String[]) methodsField.get(null)); <END> Object noInstanceBecauseStaticField = null; methodsField.set(noInstanceBecauseStaticField, allowedMethods); isPatchRequestAllowed = true; } catch (IllegalAccessException | NoSuchFieldException e) { throw new GeneralException(CAN_NOT_ALLOW_PATCH); } }</code><technical_language>I noInstanceBecauseStaticField for methodsField.set(noInstanceBecauseStaticField, allowedMethods); do methodsField.get(noInstanceBecauseStaticField)</technical_language>

Target:
private synchronized static void allowPatchRequestsIfNeeded() throws GeneralException { if (isPatchRequestAllowed) { return; } try { Field methodsField = HttpURLConnection.class.getDeclaredField("methods"); methodsField.setAccessible(true); Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(methodsField, methodsField.getModifiers() & ~Modifier.FINAL); Object noInstanceBecauseStaticField = null; String[] existingMethods = (String[]) methodsField.get(noInstanceBecauseStaticField); String[] allowedMethods = getAllowedMethods(existingMethods); methodsField.set(noInstanceBecauseStaticField, allowedMethods); isPatchRequestAllowed = true; } catch (IllegalAccessException | NoSuchFieldException e) { throw new GeneralException(CAN_NOT_ALLOW_PATCH); } }
Source:
<code>protected RepositoryFile updateFile( final RepositoryFileImportBundle bundle, final RepositoryFile file, final IRepositoryFileData data ) throws PlatformImportException { RepositoryFile updatedFile = null; if ( isNodeRepositoryFileData( file ) ) { updatedFile = getRepository().updateFile( file, data, bundle.getComment() ); } else { String fileName = bundle.getName(); getLogger().trace( "The file [" + fileName + "] will be recreated because it content-type was changed." ); RepositoryFileAcl originFileAcl = getRepository().getAcl( file.getId() ); getRepository().deleteFile( file.getId(), true, null ); RepositoryFileAcl newFileAcl = bundle.getAcl(); <START> bundle.setExtraMetaData( bundle.getExtraMetaData() ); <END> updatedFile = createFile( bundle, file.getPath(), data ); bundle.setAcl( newFileAcl ); } return updatedFile; }</code><technical_language>Please revert this change</technical_language>

Target:
protected RepositoryFile updateFile( final RepositoryFileImportBundle bundle, final RepositoryFile file, final IRepositoryFileData data ) throws PlatformImportException { RepositoryFile updatedFile = null; if ( isNodeRepositoryFileData( file ) ) { updatedFile = getRepository().updateFile( file, data, bundle.getComment() ); } else { String fileName = bundle.getName(); getLogger().trace( "The file [" + fileName + "] will be recreated because it content-type was changed." ); RepositoryFileAcl originFileAcl = getRepository().getAcl( file.getId() ); getRepository().deleteFile( file.getId(), true, null ); RepositoryFileAcl newFileAcl = bundle.getAcl(); bundle.setAcl( originFileAcl ); bundle.setExtraMetaData( bundle.getExtraMetaData() ); updatedFile = createFile( bundle, file.getPath(), data ); bundle.setAcl( newFileAcl ); } return updatedFile; }
Source:
<code>void rehash() { ++rehashCount; long newBucketCountLong = bucketCount * 2L; if (newBucketCountLong > Integer.MAX_VALUE) { <START> throw new PrestoException(GENERIC_INSUFFICIENT_RESOURCES, "Size of hash table cannot exceed 1 billion entries"); <END> } int newBucketCount = (int) newBucketCountLong; int newMask = newBucketCount - 1; IntBigArray newBuckets = new IntBigArray(-1); newBuckets.ensureCapacity(newBucketCount); for (int i = 0; i < values.getPositionCount(); i++) { long valueRawHash = valueHashList.get(i); int bucketId = getHashPosition(valueRawHash, newMask); int probeCount = 1; int originalBucket = bucketId; while (newBuckets.get(bucketId) != -1) { int probe = nextProbe(probeCount); bucketId = nextBucketId(originalBucket, mask, probe); probeCount++; } newBuckets.set(bucketId, i); } buckets = newBuckets; valueHashList.ensureCapacity(newBucketCount); bucketCount = newBucketCount; maxfill = calculateMaxFill(newBucketCount, MAX_FILL_RATIO); mask = newMask; }</code><technical_language>This error message is (necessarily) accurate: 1. assuming initial bucketCount is a power of 2, 1,073,741,824. In case, I number. 2. if initial bucketCount starts other a power of 2, max number of buckets Integer.MAX_VALUE. BTW, I fact intermediate newBucketCountLong variable</technical_language>

Target:
void rehash() { ++rehashCount; long newBucketCountLong = bucketCount * 2L; if (newBucketCountLong > Integer.MAX_VALUE) { throw new PrestoException(GENERIC_INSUFFICIENT_RESOURCES, "Size of hash table cannot exceed " + Integer.MAX_VALUE + " entries (" + newBucketCountLong + ")"); } int newBucketCount = (int) newBucketCountLong; int newMask = newBucketCount - 1; IntBigArray newBuckets = new IntBigArray(-1); newBuckets.ensureCapacity(newBucketCount); for (int i = 0; i < values.getPositionCount(); i++) { long valueHash = valueHashes.get(i); int bucketId = getBucketId(valueHash, newMask); int probeCount = 1; while (newBuckets.get(bucketId) != EMPTY_BUCKET) { int probe = nextProbe(probeCount); bucketId = nextBucketId(bucketId, newMask, probe); probeCount++; } newBuckets.set(bucketId, i); } buckets = newBuckets; valueHashes.ensureCapacity(newBucketCount); bucketCount = newBucketCount; maxFill = calculateMaxFill(newBucketCount, MAX_FILL_RATIO); mask = newMask; }
Source:
<code>public MappingIterator(Collection<S> source, Function<S, D> transformation) { this.sourceIt = source.iterator(); this.transformation = transformation; <START> readNext(); <END> }</code><technical_language>I find strange constructor some work. catch surprise, especially if wants concatenate iterators. this if hasNext() next() advanced. more predictable. similar logic in CachingKeyPairProvider$CancellingKeyPairIterator . is similar MappingIterator<Path, KeyPair></technical_language>

Target:
public MappingIterator(Collection<S> source, Function<S, D> transformation) { this.sourceIt = source.iterator(); this.transformation = transformation; }
Source:
<code>private void setupMapView(Bundle savedInstanceState) { Timber.d("setupMapView called"); <START> MapboxMapOptions options = new MapboxMapOptions() <END> .compassGravity(Gravity.BOTTOM | Gravity.LEFT) .compassMargins(new int[]{12, 0, 0, 24}) .styleUrl(Style.OUTDOORS) .logoEnabled(false) .attributionEnabled(false) .camera(new CameraPosition.Builder() .target(new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude())) .zoom(ZOOM_LEVEL) .build()); if (!getParentFragment().getActivity().isFinishing()) { mapView = new MapView(getParentFragment().getActivity(), options); mapView.onCreate(savedInstanceState); mapView.getMapAsync(mapboxMap -> { NearbyMapFragment.this.mapboxMap = mapboxMap; addMapMovementListeners(); updateMapSignificantlyForCurrentLocation(); }); mapView.setStyleUrl("asset://mapstyle.json"); } }</code><technical_language>change is indentation. Please try change issue related codes. Other style fixes hard review. This style issues fixed another PR</technical_language>

Target:
private void setupMapView(Bundle savedInstanceState) { Timber.d("setupMapView called"); boolean isDarkTheme = applicationKvStore.getBoolean("theme", false); MapboxMapOptions options = new MapboxMapOptions() .compassGravity(Gravity.BOTTOM | Gravity.LEFT) .compassMargins(new int[]{12, 0, 0, 24}) .styleUrl(isDarkTheme ? Style.DARK : Style.OUTDOORS) .logoEnabled(true) .attributionEnabled(true) .camera(new CameraPosition.Builder() .target(new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude())) .zoom(ZOOM_LEVEL) .build()); if (!getParentFragment().getActivity().isFinishing()) { mapView = new MapView(getParentFragment().getActivity(), options); mapView.onCreate(savedInstanceState); mapView.getMapAsync(mapboxMap -> { LocalizationPlugin localizationPlugin = new LocalizationPlugin(mapView, mapboxMap); try { localizationPlugin.matchMapLanguageWithDeviceDefault(); } catch (RuntimeException exception) { Timber.d(exception.toString()); } NearbyMapFragment.this.mapboxMap = mapboxMap; addMapMovementListeners(); updateMapSignificantlyForCurrentLocation(); }); } }
Source:
<code>public void notifyVideoEnd() { <START> Log.d("___", "GOT IT"); <END> new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (videoEnabledWebChromeClient != null) { videoEnabledWebChromeClient.onHideCustomView(); } } }); }</code><technical_language>Debug logging accidentally left in</technical_language>

Target:
public void notifyVideoEnd() { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (videoEnabledWebChromeClient != null) { videoEnabledWebChromeClient.onHideCustomView(); } } }); }
Source:
<code>private void updateValueMetadataIfNeccessary(Record record, Object updateValue) { Object valueMetadata = null; try { if (record.getValue() instanceof Data) { valueMetadata = metadataInitializer.createFromData(serializationService.toData(updateValue)); } else { valueMetadata = metadataInitializer.createFromObject(serializationService.toObject(updateValue)); } } catch (IOException e) { ignore(e); <START> } <END> if (valueMetadata != null) { Metadata existing = getMetadata(record); if (existing == null) { existing = new Metadata(); setMetadata(record, existing); } existing.setValueMetadata(valueMetadata); } else { Metadata existing = getMetadata(record); if (existing != null) { if (existing.getKeyMetadata() == null) { removeMetadata(record); } else { existing.setValueMetadata(valueMetadata); } } } }</code><technical_language>Minor: do need rethrow other exceptions</technical_language>

Target:
private void updateValueMetadataIfNeccessary(Record record, Object updateValue) { Object valueMetadata = null; try { if (record.getValue() instanceof Data) { valueMetadata = metadataInitializer.createFromData(serializationService.toData(updateValue)); } else { valueMetadata = metadataInitializer.createFromObject(serializationService.toObject(updateValue)); } } catch (IOException e) { ignore(e); } catch (Exception e) { throw rethrow(e); } if (valueMetadata != null) { Metadata existing = getMetadata(record); if (existing == null) { existing = new Metadata(); setMetadata(record, existing); } existing.setValueMetadata(valueMetadata); } else { Metadata existing = getMetadata(record); if (existing != null) { if (existing.getKeyMetadata() == null) { removeMetadata(record); } else { existing.setValueMetadata(valueMetadata); } } } }
Source:
<code>public ServerFrontEnd(ChannelInboundHandlerAdapter adapter, int <START> port, boolean datagram) { <END> this.adapter = adapter; this.port = port; this.datagram = datagram; if(datagram){boss = null;}else{ boss = new NioEventLoopGroup();} }</code><technical_language>cleaner this private, add 2 static constructors: ServerFrontEnd.udp(adapter, port) ServerFrontEnd.tcp(adapter, port)</technical_language>

Target:
private ServerFrontEnd(ChannelInboundHandlerAdapter adapter, int port, boolean datagram) { this.adapter = adapter; this.port = port; this.datagram = datagram; if(datagram) { boss = null; } else { boss = new NioEventLoopGroup(); } }
Source:
<code>public void changePeriodTest() { final ArrayList<Integer> ticks = new ArrayList<>(); final TickingTimer tickingTimer = new TickingTimer("test3", 5, (Integer i) -> {}, () -> { tickingTimerStatus = true; ticks.clear(); }, TimeUnit.SECONDS); tickingTimer.start(); delay(3.9); if (hasTimeout()) { fail(); } else { tickingTimer.changePeriod(3); } delay(1.5); if (hasTimeout()) { fail(); } delay(1.6); if (hasTimeout()) { tickingTimerStatus = false; } else { fail(); } delay(2); if (hasTimeout()) { fail(); } delay(1.5); if (!hasTimeout()) { fail(); <START> } <END> }</code><technical_language>assertTrue etc</technical_language>

Target:
public void changePeriodTest() { final ArrayList<Integer> ticks = new ArrayList<>(); final TickingTimer tickingTimer = new TickingTimer("test3", 5, (Integer i) -> {}, () -> { isTriggered = true; ticks.clear(); }, TimeUnit.SECONDS); tickingTimer.start(); delay(3.9); assertTrue(!isTriggered()); tickingTimer.restartTimer(3); delay(1.5); assertTrue(!isTriggered()); delay(1.6); assertTrue(isTriggered()); resetTimeoutStatus(); delay(2); assertTrue(!isTriggered()); delay(1.5); assertTrue(isTriggered()); }