auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private void handleStandbyContainerStop(String standbyContainerID, String resourceID, String preferredHost, AbstractContainerAllocator containerAllocator) { Optional<StandbyContainerManager.FailoverMetadata> failoverMetadata = this.checkIfUsedForFailover(resourceID); if (failoverMetadata.isPresent()) { String activeContainerID = failoverMetadata.get().activeContainerID; String standbyContainerHostname = failoverMetadata.get().getStandbyContainerHostname(resourceID); log.info("Requesting resource for active container on host {}, and backup container on any host", activeContainerID, standbyContainerHostname, standbyContainerID); containerAllocator.requestResource(activeContainerID, standbyContainerHostname); containerAllocator.requestResource(standbyContainerID, ResourceRequestState.ANY_HOST); return; } else { log.info("Issuing request for standby container on host {}, since this is not for a failover", standbyContainerID, preferredHost); containerAllocator.requestResource(standbyContainerID, preferredHost); return; } }

Target:
private void handleStandbyContainerStop(String standbyContainerID, String resourceID, String preferredHost, AbstractContainerAllocator containerAllocator) { Optional<StandbyContainerManager.FailoverMetadata> failoverMetadata = this.checkIfUsedForFailover(resourceID); if (failoverMetadata.isPresent()) { String activeContainerID = failoverMetadata.get().activeContainerID; String standbyContainerHostname = failoverMetadata.get().getStandbyContainerHostname(resourceID); log.info("Requesting resource for active container on host {}, and backup container on any host", activeContainerID, standbyContainerHostname, standbyContainerID); SamzaResourceRequest resourceRequestForActive = containerAllocator.getResourceRequest(activeContainerID, standbyContainerHostname); failoverMetadata.get().recordResourceRequest(resourceRequestForActive); containerAllocator.issueResourceRequest(resourceRequestForActive); containerAllocator.requestResource(standbyContainerID, ResourceRequestState.ANY_HOST); } else { log.info("Issuing request for standby container on host {}, since this is not for a failover", standbyContainerID, preferredHost); containerAllocator.requestResource(standbyContainerID, preferredHost); } }
Source:
public void exitDoubleArray(ExprParser.DoubleArrayContext ctx) { Double[] values = new Double[ctx.doubleElement().size()]; for (int i = 0; i < values.length; i++) { if (ctx.doubleElement(i).getText().equalsIgnoreCase("null")) { values[i] = null; } else { values[i] = Double.parseDouble(ctx.doubleElement(i).getText()); } } nodes.put(ctx, new DoubleArrayExpr(values)); }

Target:
public void exitDoubleArray(ExprParser.DoubleArrayContext ctx) { Double[] values = new Double[ctx.numericElement().size()]; for (int i = 0; i < values.length; i++) { if (ctx.numericElement(i).NULL() != null) { values[i] = null; } else if (ctx.numericElement(i).LONG() != null) { values[i] = Numbers.parseDoubleObject(ctx.numericElement(i).LONG().getText()); } else if (ctx.numericElement(i).DOUBLE() != null) { values[i] = Numbers.parseDoubleObject(ctx.numericElement(i).DOUBLE().getText()); } else { throw new RE("Failed to parse array element %s as a double", ctx.numericElement(i).getText()); } } nodes.put(ctx, new DoubleArrayExpr(values)); }
Source:
private static Optional<Path> findAtPath(final Path path) { if (Files.exists(path)) { return Optional.of(path); } else { return Optional.empty(); } }

Target:
private static Optional<Path> findAtPath(final Path path) { return Optional.of(path).filter(Files::exists); }
Source:
private String getCommitMessage() { List<PatchSetDetail> details = change.getPatchSetDetails(); int index = details.size() - 1; for (PatchSetDetail detail : details) { if (detail.getPatchSet() == patchSet) { index = details.indexOf(detail); } } return details.get(index).getInfo().getMessage(); }

Target:
private String getCommitMessage() { List<PatchSetDetail> details = change.getPatchSetDetails(); PatchSetDetail patchSetDetail = details.get(details.size() - 1); for (PatchSetDetail detail : details) { if (detail.getPatchSet() == patchSet) { patchSetDetail = detail; } } return patchSetDetail.getInfo().getMessage(); }
Source:
void loadResources(final LoadListener loadListener) { com.verizon.ads.utils.ThreadUtils.runOffUiThread(new Runnable() { @Override public void run() { try { JSONObject iconImageJSON = verizonAd.getJSON("iconImage"); if (iconImageJSON != null) { AdapterNativeMappedImage adapterNativeMappedImage = nativeMappedImageFromJSON(iconImageJSON.optString("url")); if (adapterNativeMappedImage != null) { setIcon(adapterNativeMappedImage); } } JSONObject mainImageJSON = verizonAd.getJSON("mainImage"); if (mainImageJSON != null) { List<com.google.android.gms.ads.formats.NativeAd.Image> imagesList = new ArrayList<>(); AdapterNativeMappedImage adapterNativeMappedImage = nativeMappedImageFromJSON(mainImageJSON.optString("url")); if (adapterNativeMappedImage != null) { imagesList.add(adapterNativeMappedImage); ImageView imageView = new ImageView(context); imageView.setImageDrawable(adapterNativeMappedImage.getDrawable()); ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); imageView.setLayoutParams(layoutParams); setMediaView(imageView); } setImages(imagesList); } loadListener.onLoadComplete(); } catch (Exception e) { Log.e(TAG, "Unable to load resources.", e); loadListener.onLoadError(); } } }); }

Target:
void loadResources(final LoadListener loadListener) { ThreadUtils.runOffUiThread(new Runnable() { @Override public void run() { try { boolean iconSet = false; boolean mediaViewSet = false; JSONObject iconImageJSON = verizonAd.getJSON("iconImage"); if (iconImageJSON != null) { AdapterNativeMappedImage adapterNativeMappedImage = parseImageComponent(iconImageJSON); if (adapterNativeMappedImage != null) { setIcon(adapterNativeMappedImage); iconSet = true; } } JSONObject mainImageJSON = verizonAd.getJSON("mainImage"); if (mainImageJSON != null) { List<com.google.android.gms.ads.formats.NativeAd.Image> imagesList = new ArrayList<>(); AdapterNativeMappedImage adapterNativeMappedImage = parseImageComponent(mainImageJSON); if (adapterNativeMappedImage != null) { imagesList.add(adapterNativeMappedImage); ImageView imageView = new ImageView(context); imageView.setImageDrawable(adapterNativeMappedImage.getDrawable()); ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); imageView.setLayoutParams(layoutParams); setMediaView(imageView); mediaViewSet = true; } setImages(imagesList); } if (mediaViewSet && iconSet) { loadListener.onLoadComplete(); } else { Log.e(TAG, "Failed to set icon and/or media view"); loadListener.onLoadError(); } } catch (Exception e) { Log.e(TAG, "Unable to load resources.", e); loadListener.onLoadError(); } } }); }
Source:
public void execute(final K key, Runnable r) { Runnable old = latest.put(key, r); if (old == null) { exec.execute(() -> { Runnable run = latest.remove(key); if (run != null) { run.run();; } }); } }

Target:
public void execute(final K key, Runnable r) { Runnable old = latest.put(key, r); if (old == null) { exec.execute(() -> { Runnable run = latest.remove(key); if (run != null) { run.run(); } }); } else { LOG.debug("Replacing runnable for - {}", key, r); } }
Source:
private static void setFinalOutputChannel(DataChannel outputChannel, Schema outputSchema) { outputChannel.setShuffleType(NONE_SHUFFLE); outputChannel.setShuffleOutputNum(1); outputChannel.setStoreType(BuiltinStorages.DRAW); outputChannel.setSchema(outputSchema); }

Target:
private void setFinalOutputChannel(DataChannel outputChannel, Schema outputSchema) { outputChannel.setShuffleType(NONE_SHUFFLE); outputChannel.setShuffleOutputNum(1); outputChannel.setStoreType(finalOutputStoreType); outputChannel.setSchema(outputSchema); }
Source:
public OrcSnappyDecompressor(OrcDataSourceId orcDataSourceId, int maxBufferSize) { this.orcDataSourceId = orcDataSourceId; this.maxBufferSize = maxBufferSize; }

Target:
public OrcSnappyDecompressor(OrcDataSourceId orcDataSourceId, int maxBufferSize) { this.orcDataSourceId = requireNonNull(orcDataSourceId, "orcDataSourceId is null"); this.maxBufferSize = maxBufferSize; }
Source:
protected void recvCommands() throws IOException { PushCertificateParser certParser = getPushCertificateParser(); boolean readCapabilities = true; try { for (;;) { String line; try { line = pckIn.readString(); } catch (EOFException eof) { if (commands.isEmpty()) return; throw eof; } if (line == PacketLineIn.END) { break; } if (line.length() >= 48 && line.startsWith("shallow ")) { clientShallowCommits.add(ObjectId.fromString(line.substring(8, 48))); continue; } if (readCapabilities) { FirstLine firstLine = new FirstLine(line); enabledCapabilities = firstLine.getCapabilities(); readCapabilities = false; enableCapabilities(); line = firstLine.getLine(); if (line.equals(GitProtocolConstants.OPTION_PUSH_CERT)) { certParser.receiveHeader(pckIn, !isBiDirectionalPipe()); continue; } } if (line.equals(PushCertificateParser.BEGIN_SIGNATURE)) { certParser.receiveSignature(pckIn); continue; } ReceiveCommand cmd = parseCommand(line); if (cmd.getRefName().equals(Constants.HEAD)) { cmd.setResult(Result.REJECTED_CURRENT_BRANCH); } else { cmd.setRef(refs.get(cmd.getRefName())); } commands.add(cmd); if (certParser.enabled()) { certParser.addCommand(cmd); } } pushCert = certParser.build(); } catch (PackProtocolException e) { pckIn.discardUntilEnd(); fatalError(e.getMessage()); throw e; } }

Target:
protected void recvCommands() throws IOException { PushCertificateParser certParser = getPushCertificateParser(); boolean firstPkt = true; try { for (;;) { String line; try { line = pckIn.readString(); } catch (EOFException eof) { if (commands.isEmpty()) return; throw eof; } if (line == PacketLineIn.END) { break; } if (line.length() >= 48 && line.startsWith("shallow ")) { clientShallowCommits.add(ObjectId.fromString(line.substring(8, 48))); continue; } if (firstPkt) { firstPkt = false; FirstLine firstLine = new FirstLine(line); enabledCapabilities = firstLine.getCapabilities(); line = firstLine.getLine(); enableCapabilities(); if (line.equals(GitProtocolConstants.OPTION_PUSH_CERT)) { certParser.receiveHeader(pckIn, !isBiDirectionalPipe()); continue; } } if (line.equals(PushCertificateParser.BEGIN_SIGNATURE)) { certParser.receiveSignature(pckIn); continue; } ReceiveCommand cmd = parseCommand(line); if (cmd.getRefName().equals(Constants.HEAD)) { cmd.setResult(Result.REJECTED_CURRENT_BRANCH); } else { cmd.setRef(refs.get(cmd.getRefName())); } commands.add(cmd); if (certParser.enabled()) { certParser.addCommand(cmd); } } pushCert = certParser.build(); } catch (PackProtocolException | InvalidObjectIdException e) { if (sideBand) { try { pckIn.discardUntilEnd(); } catch (IOException e2) { } } fatalError(e.getMessage()); throw e; } }
Source:
public void testConsistentHashLoadBalance() { int runs = 10000; long invokerCount0 = 0; Map<Invoker, Long> invokerHited = new HashMap<>(); Map<Invoker, AtomicLong> counter = getInvokeCounter(runs, ConsistentHashLoadBalance.NAME); for (Invoker minvoker : counter.keySet()) { Long count = counter.get(minvoker).get(); if (count == 0) { invokerCount0 ++; } else { invokerHited.put(minvoker, count); } } Assert.assertEquals(counter.size() - 1, invokerCount0); Assert.assertEquals(1, invokerHited.size()); Assert.assertEquals(runs, invokerHited.values().iterator().next().intValue()); }

Target:
public void testConsistentHashLoadBalance() { int runs = 10000; long unHitedInvokerCount = 0; Map<Invoker, Long> hitedInvokers = new HashMap<>(); Map<Invoker, AtomicLong> counter = getInvokeCounter(runs, ConsistentHashLoadBalance.NAME); for (Invoker minvoker : counter.keySet()) { Long count = counter.get(minvoker).get(); if (count == 0) { unHitedInvokerCount++; } else { hitedInvokers.put(minvoker, count); } } Assert.assertEquals("the number of unHitedInvoker should be counter.size() - 1", counter.size() - 1, unHitedInvokerCount); Assert.assertEquals("the number of hitedInvoker should be 1", 1, hitedInvokers.size()); Assert.assertEquals("the number of hited count should be the number of runs", runs, hitedInvokers.values().iterator().next().intValue()); }
Source:
public void selectAllDeprecatedRuleKeys_return_values_even_if_there_is_no_rule() { db.executeUpdateSql("delete from deprecated_rule_keys"); DeprecatedRuleKeyDto deprecatedRuleKeyDto1 = new DeprecatedRuleKeyDto() .setUuid(uuidFactory.create()) .setOldRepositoryKey(randomAlphanumeric(50)) .setOldRuleKey(randomAlphanumeric(50)) .setRuleId(random.nextInt(1_000_000)) .setCreatedAt(1_500_000_000_000L); DeprecatedRuleKeyDto deprecatedRuleKeyDto2 = new DeprecatedRuleKeyDto() .setUuid(uuidFactory.create()) .setOldRepositoryKey(randomAlphanumeric(50)) .setOldRuleKey(randomAlphanumeric(50)) .setRuleId(random.nextInt(1_000_000)) .setCreatedAt(1_500_000_000_000L); underTest.insert(db.getSession(), deprecatedRuleKeyDto1); underTest.insert(db.getSession(), deprecatedRuleKeyDto2); List<DeprecatedRuleKeyDto> deprecatedRuleKeyDtos = underTest.selectAllDeprecatedRuleKeys(db.getSession()); assertThat(deprecatedRuleKeyDtos).hasSize(2); assertThat(deprecatedRuleKeyDtos) .extracting(DeprecatedRuleKeyDto::getNewRepositoryKey, DeprecatedRuleKeyDto::getNewRuleKey) .containsExactly( tuple(null, null), tuple(null, null) ); }

Target:
public void selectAllDeprecatedRuleKeys_return_values_even_if_there_is_no_rule() { db.rules().insertDeprecatedKey(); db.rules().insertDeprecatedKey(); Set<DeprecatedRuleKeyDto> deprecatedRuleKeyDtos = underTest.selectAllDeprecatedRuleKeys(db.getSession()); assertThat(deprecatedRuleKeyDtos).hasSize(2); assertThat(deprecatedRuleKeyDtos) .extracting(DeprecatedRuleKeyDto::getNewRepositoryKey, DeprecatedRuleKeyDto::getNewRuleKey) .containsExactly( tuple(null, null), tuple(null, null) ); }
Source:
synchronized void removeObjects(Map<?, ?> associatedObjects) { for (Object name : associatedObjects.values()) { RegistryObject toRemove = (RegistryObject) name; remove((toRemove).getObjectId(), true); if (toRemove instanceof ExtensionPoint) removeExtensionPoint(((ExtensionPoint) toRemove).getUniqueIdentifier()); } }

Target:
synchronized void removeObjects(Map<?, ?> associatedObjects) { for (Object registryObject : associatedObjects.values()) { RegistryObject toRemove = (RegistryObject) registryObject; remove((toRemove).getObjectId(), true); if (toRemove instanceof ExtensionPoint) removeExtensionPoint(((ExtensionPoint) toRemove).getUniqueIdentifier()); } }
Source:
private void copyPI(TaggedValuePointable tvp, NodeTreePointable ntp, IMutableValueStorage mvs) throws IOException { PINodeBuilder pnb = new PINodeBuilder(); VoidPointable vp1 = ppool.takeOne(VoidPointable.class); VoidPointable vp2 = ppool.takeOne(VoidPointable.class); PINodePointable pnp = ppool.takeOne(PINodePointable.class); tvp.getValue(pnp); pnp.getContent(ntp, vp1); pnp.getTarget(ntp, vp2); pnb.reset(mvs); pnb.setContent(vp2); pnb.setTarget(vp1); ppool.giveBack(pnp); ppool.giveBack(vp1); ppool.giveBack(vp2); }

Target:
private void copyPI(TaggedValuePointable tvp, NodeTreePointable ntp, IMutableValueStorage mvs) throws IOException { VoidPointable vp1 = ppool.takeOne(VoidPointable.class); VoidPointable vp2 = ppool.takeOne(VoidPointable.class); PINodePointable pnp = ppool.takeOne(PINodePointable.class); tvp.getValue(pnp); pnp.getContent(ntp, vp1); pnp.getTarget(ntp, vp2); pnb.reset(mvs); pnb.setContent(vp2); pnb.setTarget(vp1); ppool.giveBack(pnp); ppool.giveBack(vp1); ppool.giveBack(vp2); }
Source:
private Properties buildAssetConditionProperties(AssetCondition condition) { Properties buildingProperties = new Properties(); safelyAddProperty(buildingProperties, CuCamsConstants.CapAssetApi.CONDITION_CODE, condition.getAssetConditionCode()); safelyAddProperty(buildingProperties, CuCamsConstants.CapAssetApi.CONDITION_NAME, condition.getAssetConditionName()); return buildingProperties; }

Target:
private Properties buildAssetConditionProperties(AssetCondition condition) { Properties assetConditionProperties = new Properties(); safelyAddProperty(assetConditionProperties, CuCamsConstants.CapAssetApi.CONDITION_CODE, condition.getAssetConditionCode()); safelyAddProperty(assetConditionProperties, CuCamsConstants.CapAssetApi.CONDITION_NAME, condition.getAssetConditionName()); return assetConditionProperties; }
Source:
public synchronized void run() { if (!crlByUrlEnabled || crlLocationUrl == null) { return; } if (!crlLocationUrl.startsWith(HTTPS)) { postErrorEvent("The provided URL was not an HTTPS URL."); return; } Object entity = getRemoteCrl(); if (!(entity instanceof InputStream)) { postErrorEvent("Unable to download the CRL."); return; } FileBackedOutputStream fileBackedOutputStream = null; try { ByteSource byteSource; try (InputStream entityStream = (InputStream) entity) { fileBackedOutputStream = new FileBackedOutputStream(FILE_BACKED_STREAM_THRESHOLD); IOUtils.copy(entityStream, fileBackedOutputStream); fileBackedOutputStream.close(); byteSource = fileBackedOutputStream.asByteSource(); } File crlFile = getCrlFile(byteSource); if (!crlIsValid(byteSource)) { postErrorEvent("An error occurred while validating the CRL."); return; } writeCrlToFile(byteSource, crlFile); } catch (IOException e) { LOGGER.warn("Unable to copy CRL to local CRL. {}", e.getMessage()); postErrorEvent("An error occurred while downloading the CRL."); } finally { if (fileBackedOutputStream != null) { try { fileBackedOutputStream.reset(); } catch (IOException e) { LOGGER.warn("Error occurred while deleting the temporary file. {}", e.getMessage()); } } } }

Target:
public synchronized void run() { if (!crlByUrlEnabled || crlLocationUrl == null) { return; } if (!crlLocationUrl.startsWith(HTTPS)) { postErrorEvent("The provided URL was not an HTTPS URL."); return; } Object entity = getRemoteCrl(); if (!(entity instanceof InputStream)) { postErrorEvent("Unable to download the remote CRL."); return; } FileBackedOutputStream fileBackedOutputStream = null; try { ByteSource byteSource; try (InputStream entityStream = (InputStream) entity) { fileBackedOutputStream = new FileBackedOutputStream(FILE_BACKED_STREAM_THRESHOLD); IOUtils.copy(entityStream, fileBackedOutputStream); fileBackedOutputStream.close(); byteSource = fileBackedOutputStream.asByteSource(); } File crlFile = getCrlFile(byteSource); if (!crlIsValid(byteSource)) { postErrorEvent("An error occurred while validating the CRL."); return; } writeCrlToFile(byteSource, crlFile); } catch (IOException e) { LOGGER.warn("Unable to copy CRL to local CRL. {}", e.getMessage()); postErrorEvent("An error occurred while downloading the CRL."); } finally { if (fileBackedOutputStream != null) { try { fileBackedOutputStream.reset(); } catch (IOException e) { LOGGER.warn("Error occurred while deleting the temporary file. {}", e.getMessage()); } } } }
Source:
public static Collection<Object[]> data() { return Arrays.asList(new Object[][] { {"GlideToBrick", R.string.brick_glide, new GlideToBrick(), R.id.brick_glide_to_edit_text_x, R.id.brick_glide_to_edit_text_y, "1+2", 42, "1 + 2 ", "42 "}, {"PlaceAtBrick", R.string.brick_place_at, new PlaceAtBrick(), R.id.brick_place_at_edit_text_x, R.id.brick_place_at_edit_text_y, "1+2", 42, "1 + 2 ", "42 "} }); }

Target:
public static Collection<Object[]> data() { return Arrays.asList(new Object[][] { {"GlideToBrick", R.string.brick_glide, new GlideToBrick()}, {"PlaceAtBrick", R.string.brick_place_at, new PlaceAtBrick()} }); }
Source:
private synchronized void onUpdate() { if (hueBridge != null) { if (pollingJob == null || pollingJob.isCancelled()) { int pollingInterval = DEFAULT_POLLING_INTERVAL; try { Object pollingIntervalConfig = getConfig().get(POLLING_INTERVAL); if (pollingIntervalConfig != null) { pollingInterval = ((BigDecimal) pollingIntervalConfig).intValue(); } else { logger.info("Polling interval not configured for this hue bridge. Using default value: {}s", pollingInterval); } } catch (NumberFormatException ex) { logger.info("Wrong configuration value for polling interval. Using default value: {}s", pollingInterval); } pollingJob = scheduler.scheduleWithFixedDelay(pollingRunnable, 1, pollingInterval, TimeUnit.SECONDS); } if (sensorPollingJob == null || sensorPollingJob.isCancelled()) { int pollingInterval = DEFAULT_SENSOR_POLLING_INTERVAL; try { Object pollingIntervalConfig = getConfig().get(SENSOR_POLLING_INTERVAL); if (pollingIntervalConfig != null) { pollingInterval = ((BigDecimal) pollingIntervalConfig).intValue(); } else { logger.info( "Sensor polling interval not configured for this hue bridge. Using default value: {}ms", pollingInterval); } } catch (NumberFormatException ex) { logger.info("Wrong configuration value for sensor polling interval. Using default value: {}ms", pollingInterval); } sensorPollingJob = scheduler.scheduleWithFixedDelay(sensorPollingRunnable, 1, pollingInterval, TimeUnit.MILLISECONDS); } } }

Target:
private synchronized void onUpdate() { if (hueBridge != null) { if (pollingJob == null || pollingJob.isCancelled()) { int pollingInterval = DEFAULT_POLLING_INTERVAL; if (hueBridgeConfig.getPollingInterval() < 1) { logger.info("Wrong configuration value for polling interval. Using default value: {}s", pollingInterval); } else { pollingInterval = hueBridgeConfig.getPollingInterval(); } pollingJob = scheduler.scheduleWithFixedDelay(pollingRunnable, 1, pollingInterval, TimeUnit.SECONDS); } if (sensorPollingJob == null || sensorPollingJob.isCancelled()) { int sensorPollingInterval = DEFAULT_SENSOR_POLLING_INTERVAL; if (hueBridgeConfig.getSensorPollingInterval() < 50) { logger.info("Wrong configuration value for sensor polling interval. Using default value: {}s", sensorPollingInterval); } else { sensorPollingInterval = hueBridgeConfig.getSensorPollingInterval(); } sensorPollingJob = scheduler.scheduleWithFixedDelay(sensorPollingRunnable, 1, sensorPollingInterval, TimeUnit.MILLISECONDS); } } }
Source:
public void endWindow() { try { bucketManager.blockUntilAllRequestsServiced(); handleIdleTime(); Preconditions.checkArgument(waitingEvents.isEmpty(), waitingEvents.keySet()); if (orderedOutput) { emitProcessedTuples(); Preconditions.checkArgument(decisions.isEmpty(), "events pending - " + decisions.size()); } appWindow++; if (!saveDataAtCheckpoint) { bucketManager.endWindow(super.getCurrentWindow()); } else { Preconditions.checkArgument(super.getContext().getValue(OperatorContext.APPLICATION_WINDOW_COUNT) == super .getContext().getValue(OperatorContext.CHECKPOINT_WINDOW_COUNT)); if (appWindow % super.getContext().getValue(DAGContext.CHECKPOINT_WINDOW_COUNT) == super.getContext().getValue( DAGContext.CHECKPOINT_WINDOW_COUNT) - 1) { bucketManager.endWindow(super.getCurrentWindow()); } } } catch (Throwable cause) { DTThrowable.rethrow(cause); } }

Target:
public void endWindow() { try { bucketManager.blockUntilAllRequestsServiced(); handleIdleTime(); Preconditions.checkArgument(waitingEvents.isEmpty(), waitingEvents.keySet()); if (orderedOutput) { emitProcessedTuples(); Preconditions.checkArgument(decisions.isEmpty(), "events pending - " + decisions.size()); } appWindow++; bucketManager.endWindow(super.getCurrentWindow()); } catch (Throwable cause) { DTThrowable.rethrow(cause); } }
Source:
public void testWriteValueCantCopyFieldName() throws Exception { IonStruct data = struct("{a:{b:10}}"); IonValue a = data.get("a"); IonReader ir = system().newReader(a); ir.next(); iw = makeWriter(); iw.stepIn(IonType.STRUCT); iw.writeValue(ir); }

Target:
public void testWriteValueCantCopyFieldName() throws Exception { IonStruct data = struct("{a:{b:10}}"); IonValue a = data.get("a"); IonReader ir = system().newReader(a); ir.next(); iw = makeWriter(); iw.stepIn(IonType.STRUCT); thrown.expect(IllegalStateException.class); iw.writeValue(ir); }
Source:
public static IdpResponse from(@NonNull Exception e) { if (e instanceof FirebaseUiException) { return new IdpResponse((FirebaseUiException) e); } else if (e instanceof FirebaseAuthAnonymousUpgradeException) { return ((FirebaseAuthAnonymousUpgradeException) e).getResponse(); } else if (e instanceof FirebaseUiUserCollisionException) { FirebaseUiUserCollisionException collisionException = (FirebaseUiUserCollisionException) e; User user = new User.Builder( collisionException.getProviderId(), collisionException.getEmail()) .build(); return new IdpResponse(user, null, null, false, new FirebaseUiException(((FirebaseUiUserCollisionException) e).getErrorCode(), e.getMessage()), collisionException.getCredential()); } else { FirebaseUiException wrapped = new FirebaseUiException(ErrorCodes.UNKNOWN_ERROR, e.getMessage()); wrapped.setStackTrace(e.getStackTrace()); return new IdpResponse(wrapped); } }

Target:
public static IdpResponse from(@NonNull Exception e) { if (e instanceof FirebaseUiException) { return new IdpResponse((FirebaseUiException) e); } else if (e instanceof FirebaseAuthAnonymousUpgradeException) { return ((FirebaseAuthAnonymousUpgradeException) e).getResponse(); } else if (e instanceof FirebaseUiUserCollisionException) { FirebaseUiUserCollisionException collisionException = (FirebaseUiUserCollisionException) e; User user = new User.Builder( collisionException.getProviderId(), collisionException.getEmail()) .build(); return new IdpResponse(user, null, null, false, new FirebaseUiException(collisionException.getErrorCode(), collisionException.getMessage()), collisionException.getCredential()); } else { FirebaseUiException wrapped = new FirebaseUiException(ErrorCodes.UNKNOWN_ERROR, e.getMessage()); wrapped.setStackTrace(e.getStackTrace()); return new IdpResponse(wrapped); } }
Source:
static Map<String, Object> bannerSoyData( GitilesView view, ImageLoader img, RootNode nav) { Map<String, Object> data = new HashMap<>(); data.put("siteTitle", null); data.put("logoUrl", null); data.put("homeUrl", null); if (nav == null) { return data; } for (Iterator<Node> i = nav.getChildren().iterator(); i.hasNext();) { Node n = i.next(); if (n instanceof HeaderNode) { HeaderNode h = (HeaderNode) n; if (h.getLevel() == 1) { data.put("siteTitle", MarkdownUtil.getInnerText(h)); i.remove(); break; } } } for (ReferenceNode r : nav.getReferences()) { String key = MarkdownUtil.getInnerText(r); String url = r.getUrl(); if ("logo".equalsIgnoreCase(key)) { Object src; if (url.startsWith("https://") || url.startsWith("http://")) { src = url; } else if (HtmlBuilder.isImageDataUri(url)) { src = Sanitizers.filterImageDataUri(url); } else if (img != null) { src = img.loadImage(url); } else { src = FilterImageDataUri.INSTANCE.getInnocuousOutput(); } data.put("logoUrl", src); } else if ("home".equalsIgnoreCase(key)) { if (MarkdownUtil.isAbsolutePathToMarkdown(url)) { url = GitilesView.doc().copyFrom(view).setPathPart(url).toUrl(); } data.put("homeUrl", url); } } return data; }

Target:
static Map<String, Object> bannerSoyData( GitilesView view, ImageLoader img, RootNode nav) { Map<String, Object> data = new HashMap<>(); data.put("siteTitle", null); data.put("logoUrl", null); data.put("homeUrl", null); if (nav == null) { return data; } for (Iterator<Node> i = nav.getChildren().iterator(); i.hasNext();) { Node n = i.next(); if (n instanceof HeaderNode) { HeaderNode h = (HeaderNode) n; if (h.getLevel() == 1) { data.put("siteTitle", MarkdownUtil.getInnerText(h)); i.remove(); break; } } } for (ReferenceNode r : nav.getReferences()) { String key = MarkdownUtil.getInnerText(r); String url = r.getUrl(); if ("logo".equalsIgnoreCase(key)) { Object src; if (HtmlBuilder.isValidHttpUri(url)) { src = url; } else if (HtmlBuilder.isImageDataUri(url)) { src = Sanitizers.filterImageDataUri(url); } else if (img != null) { src = img.loadImage(url); } else { src = FilterImageDataUri.INSTANCE.getInnocuousOutput(); } data.put("logoUrl", src); } else if ("home".equalsIgnoreCase(key)) { if (MarkdownUtil.isAbsolutePathToMarkdown(url)) { url = GitilesView.doc().copyFrom(view).setPathPart(url).toUrl(); } data.put("homeUrl", url); } } return data; }
Source:
private void runMigration() { if (migrationState.hasAlreadyMigrated()) { return; } destinationLog.truncate(destinationLog.getGreatestLogEntry()); long lowerBound = lowestSequenceToMigrate(); long upperBound = sourceLog.getGreatestLogEntry(); try (PaxosStateLogBatchReader<V> reader = new PaxosStateLogBatchReader<>(sourceLog, hydrator, 100)) { long numberOfBatches = (upperBound - lowerBound) / BATCH_SIZE + 1; LongStream.iterate(lowerBound, x -> x + BATCH_SIZE) .limit(numberOfBatches) .mapToObj(sequence -> reader.readBatch(sequence, BATCH_SIZE)) .forEach(destinationLog::writeBatchOfRounds); } migrationState.finishMigration(); }

Target:
private void runMigration() { if (migrationState.hasAlreadyMigrated()) { return; } destinationLog.truncate(destinationLog.getGreatestLogEntry()); long lowerBound = lowestSequenceToMigrate(); long upperBound = sourceLog.getGreatestLogEntry(); if (upperBound == PaxosAcceptor.NO_LOG_ENTRY) { migrationState.finishMigration(); return; } try (PaxosStateLogBatchReader<V> reader = new PaxosStateLogBatchReader<>(sourceLog, hydrator, 100)) { long numberOfBatches = (upperBound - lowerBound) / BATCH_SIZE + 1; LongStream.iterate(lowerBound, x -> x + BATCH_SIZE) .limit(numberOfBatches) .mapToObj(sequence -> reader.readBatch(sequence, BATCH_SIZE)) .forEach(destinationLog::writeBatchOfRounds); } migrationState.finishMigration(); }
Source:
public void completed() { }

Target:
public void completed() { languages.clear(); }
Source:
public void selectItem(String path) { String locator = " waitItem(path); try { new WebDriverWait(seleniumWebDriver, EXPECTED_MESS_IN_CONSOLE_SEC) .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(locator))) .click(); } catch (StaleElementReferenceException ex) { LOG.error(ex.getLocalizedMessage(), ex); waitProjectExplorer(); clickOnRefreshTreeButton(); waitItem(path); new WebDriverWait(seleniumWebDriver, EXPECTED_MESS_IN_CONSOLE_SEC) .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(locator))) .click(); } }

Target:
public void selectItem(String path) { String locator = " waitItem(path); try { new WebDriverWait(seleniumWebDriver, EXPECTED_MESS_IN_CONSOLE_SEC) .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(locator))) .click(); } catch (StaleElementReferenceException ex) { LOG.warn(ex.getLocalizedMessage(), ex); waitProjectExplorer(); clickOnRefreshTreeButton(); waitItem(path); new WebDriverWait(seleniumWebDriver, EXPECTED_MESS_IN_CONSOLE_SEC) .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(locator))) .click(); } }
Source:
public void setSystemTimes(long time) { systemTimes = new long[] { time }; }

Target:
void setSystemTimes(long time) { systemTimes = new long[] { time }; }
Source:
private boolean pickDefaultSuggestion(boolean autoCorrectToPreferred) { if (mKeyboardHandler.hasMessages(KeyboardUIStateHandler.MSG_UPDATE_SUGGESTIONS)) { performUpdateSuggestions(); } final CharSequence typedWord = mWord.getTypedWord(); final CharSequence actualWordToOutput = autoCorrectToPreferred ? mWord.getPreferredWord() : typedWord; if (!TextUtils.isEmpty(actualWordToOutput)) { TextEntryState.acceptedDefault(typedWord); boolean fixed = !TextUtils.equals(typedWord, actualWordToOutput); commitWordToInput(actualWordToOutput, fixed); if (!fixed) { checkAddToDictionaryWithAutoDictionary( mWord, mAutoComplete ? Suggest.AdditionType.Picked : Suggest.AdditionType.Typed); } return true; } return false; }

Target:
private boolean pickDefaultSuggestion(boolean autoCorrectToPreferred) { if (mKeyboardHandler.hasMessages(KeyboardUIStateHandler.MSG_UPDATE_SUGGESTIONS)) { performUpdateSuggestions(); } final CharSequence typedWord = mWord.getTypedWord(); final CharSequence actualWordToOutput = autoCorrectToPreferred ? mWord.getPreferredWord() : typedWord; if (!TextUtils.isEmpty(actualWordToOutput)) { TextEntryState.acceptedDefault(typedWord); final boolean fixed = !TextUtils.equals(typedWord, actualWordToOutput); commitWordToInput(actualWordToOutput, fixed); if (!fixed) { checkAddToDictionaryWithAutoDictionary( mWord, mAutoComplete ? Suggest.AdditionType.Picked : Suggest.AdditionType.Typed); } return true; } return false; }
Source:
protected CommandResult<RuleViolation> doAllow(final GraphCommandExecutionContext context, final Command<GraphCommandExecutionContext, RuleViolation> command) { final CommandResult<RuleViolation> result = super.doAllow(context, command); if (!CommandUtils.isError(result) && hasRules(context)) { final org.kie.workbench.common.stunner.core.graph.Graph target = getGraph(context); final Node<View<?>, Edge> candidate = (Node<View<?>, Edge>) getCandidate(context); final GraphCommandResultBuilder builder = new GraphCommandResultBuilder(); final Collection<RuleViolation> cardinalityRuleViolations = doEvaluate(context, RuleContextBuilder.GraphContexts.cardinality(target, candidate, CardinalityContext.Operation.DELETE)); builder.addViolations(cardinalityRuleViolations); for (final RuleViolation violation : cardinalityRuleViolations) { if (builder.isError(violation)) { return builder.build(); } } return builder.build(); } return result; }

Target:
protected CommandResult<RuleViolation> doAllow(final GraphCommandExecutionContext context, final Command<GraphCommandExecutionContext, RuleViolation> command) { final CommandResult<RuleViolation> result = super.doAllow(context, command); if (!CommandUtils.isError(result) && hasRules(context)) { final Graph target = getGraph(context); final Node<View<?>, Edge> candidate = (Node<View<?>, Edge>) getCandidate(context); final GraphCommandResultBuilder builder = new GraphCommandResultBuilder(); final Collection<RuleViolation> cardinalityRuleViolations = doEvaluate(context, RuleContextBuilder.GraphContexts.cardinality(target, candidate, CardinalityContext.Operation.DELETE)); builder.addViolations(cardinalityRuleViolations); for (final RuleViolation violation : cardinalityRuleViolations) { if (builder.isError(violation)) { return builder.build(); } } return builder.build(); } return result; }
Source:
public void setUp() { MockitoAnnotations.initMocks(this); results = new SearchResults<JudgmentSearchResult>(); results.addResult(new JudgmentSearchResult()); when(result.getTotalResults()).thenReturn(0L); when(judgmentsWebSearchService.search(org.mockito.Mockito.any(JudgmentCriteriaForm.class), org.mockito.Mockito.any(Pageable.class))).thenReturn(results); when(ccListService.findCommonCourts()).thenReturn(commonCourts); when(scListService.findScChambers()).thenReturn(scChambers); when(scJudgmentFormRepository.findAll()).thenReturn(scJudgmentForms); mockMvc = webAppContextSetup(webApplicationCtx) .build(); }

Target:
public void setUp() { MockitoAnnotations.initMocks(this); simpleDivisions = testCourtsFactory.getSimpleDivisions(); results = new SearchResults<JudgmentSearchResult>(); results.addResult(new JudgmentSearchResult()); when(judgmentsWebSearchService.search(Mockito.any(JudgmentCriteriaForm.class), Mockito.any(Pageable.class))).thenReturn(results); when(ccListService.findCommonCourts()).thenReturn(commonCourts); when(scListService.findScChambers()).thenReturn(scChambers); when(scJudgmentFormRepository.findAll()).thenReturn(scJudgmentForms); mockMvc = webAppContextSetup(webApplicationCtx) .build(); }
Source:
public void testGroupByCollectList() throws Exception { Schema purchaseSchema = Schema.recordOf( "purchase", Schema.Field.of("ts", Schema.of(Schema.Type.LONG)), Schema.Field.of("user", Schema.of(Schema.Type.STRING)), Schema.Field.of("item", Schema.of(Schema.Type.STRING)), Schema.Field.of("price", Schema.of(Schema.Type.DOUBLE))); Schema userSchema = Schema.recordOf( "user", Schema.Field.of("user", Schema.of(Schema.Type.STRING)), Schema.Field.of("itemList", Schema.arrayOf(Schema.of(Schema.Type.STRING)))); GroupByConfig groupByConfig = new GroupByConfig("user", "itemList:CollectList(item)"); GroupByAggregator groupByAggregator = new GroupByAggregator(groupByConfig); MockPipelineConfigurer mockConfigurer = new MockPipelineConfigurer(purchaseSchema, ImmutableMap.of( CoreValidator.ID, new CoreValidator())); groupByAggregator.configurePipeline(mockConfigurer); Assert.assertEquals(userSchema, mockConfigurer.getOutputSchema()); }

Target:
public void testGroupByCollectList() throws Exception { Schema purchaseSchema = Schema.recordOf( "purchase", Schema.Field.of("ts", Schema.of(Schema.Type.LONG)), Schema.Field.of("user", Schema.of(Schema.Type.STRING)), Schema.Field.of("item", Schema.of(Schema.Type.STRING)), Schema.Field.of("price", Schema.of(Schema.Type.DOUBLE))); Schema userSchema = Schema.recordOf( "user", Schema.Field.of("user", Schema.of(Schema.Type.STRING)), Schema.Field.of("itemList", Schema.arrayOf(Schema.of(Schema.Type.STRING)))); GroupByConfig groupByConfig = new GroupByConfig("user", "itemList:CollectList(item)"); GroupByAggregator groupByAggregator = new GroupByAggregator(groupByConfig); MockPipelineConfigurer mockConfigurer = new MockPipelineConfigurer(purchaseSchema, Collections.EMPTY_MAP); groupByAggregator.configurePipeline(mockConfigurer); Assert.assertEquals(userSchema, mockConfigurer.getOutputSchema()); }
Source:
public void setFocus() { StyledText widget = fSourceViewer.getTextWidget(); if (fSourceViewer != null && widget != null && !widget.isDisposed()) { widget.setFocus(); } }

Target:
public void setFocus() { if (fSourceViewer != null) { StyledText widget = fSourceViewer.getTextWidget(); if (widget != null && !widget.isDisposed()) { widget.setFocus(); } } }
Source:
public void setStrategy(DifferentialEntropyStateStrategy strategy) { requireNonNull(strategy, "strategy is null"); this.strategy = strategy; }

Target:
public void setStrategy(DifferentialEntropyStateStrategy strategy) { this.strategy = requireNonNull(strategy, "strategy is null"); }
Source:
public void onNewUser(User user) { TextInputLayout emailLayout = findViewById(R.id.email_layout); List<AuthUI.IdpConfig> providerConfig = getFlowParams().providerInfo; int emailIndex = providerConfig.indexOf(new AuthUI.IdpConfig.EmailBuilder().build()); if (providerConfig.get(emailIndex).getParams() .getBoolean(ExtraConstants.EXTRA_ALLOW_NEW_EMAILS, true)) { RegisterEmailFragment fragment = RegisterEmailFragment.newInstance( getFlowParams(), user); FragmentTransaction ft = getSupportFragmentManager().beginTransaction() .replace(R.id.fragment_register_email, fragment, RegisterEmailFragment.TAG); if (emailLayout != null) ft.addSharedElement(emailLayout, "email_field"); ft.disallowAddToBackStack().commit(); } else { emailLayout.setError(getString(R.string.fui_error_email_does_not_exist)); } }

Target:
public void onNewUser(User user) { TextInputLayout emailLayout = findViewById(R.id.email_layout); AuthUI.IdpConfig emailConfig = ProviderUtils.getConfigFromIdps( getFlowParams().providerInfo, EmailAuthProvider.PROVIDER_ID); if (emailConfig.getParams().getBoolean(ExtraConstants.EXTRA_ALLOW_NEW_EMAILS, true)) { RegisterEmailFragment fragment = RegisterEmailFragment.newInstance( getFlowParams(), user); FragmentTransaction ft = getSupportFragmentManager().beginTransaction() .replace(R.id.fragment_register_email, fragment, RegisterEmailFragment.TAG); if (emailLayout != null) { String emailFieldName = getString(R.string.fui_email_field_name); ViewCompat.setTransitionName(emailLayout, emailFieldName); ft.addSharedElement(emailLayout, emailFieldName); } ft.disallowAddToBackStack().commit(); } else { emailLayout.setError(getString(R.string.fui_error_email_does_not_exist)); } }
Source:
public void setUp() throws Exception { attrs = mock(AttributeSet.class); context = mock(Context.class); array = mock(TypedArray.class); when(array.getFloat(R.styleable.fui_SpacedEditText_fui_spacingProportion, 1)).thenReturn (spacingPropotion); when(context.obtainStyledAttributes(attrs, R.styleable.fui_SpacedEditText)).thenReturn(array); spacedEditText = new SpacedEditText(RuntimeEnvironment.application, attrs); spacedEditText.initAttrs(context, attrs); }

Target:
public void setUp() throws Exception { attrs = mock(AttributeSet.class); context = mock(Context.class); array = mock(TypedArray.class); when(array.getFloat(R.styleable.SpacedEditText_spacingProportion, 1)) .thenReturn(spacingProportion); when(context.obtainStyledAttributes(attrs, R.styleable.SpacedEditText)).thenReturn(array); spacedEditText = new SpacedEditText(RuntimeEnvironment.application, attrs); spacedEditText.initAttrs(context, attrs); }
Source:
public BufferedImage getImage() { if (!open.get()) { return null; } return image; }

Target:
public BufferedImage getImage() { if (!open.get()) { return null; } try { byte[] buffer = readNextFrame(); BufferedImage image = buildImage(buffer); return image; } catch (IOException e) { e.printStackTrace(); } return null; }
Source:
public void checkout(File baseDir, Revision revision, SubprocessExecutionContext execCtx) { throw new RuntimeException("Checkout not implemented"); }

Target:
public void checkout(File baseDir, Revision revision, SubprocessExecutionContext execCtx) { InMemoryStreamConsumer output = ProcessOutputStreamConsumer.inMemoryConsumer(); this.updateTo(output, revision, baseDir, execCtx); }
Source:
public void testAllDomainsHaveSpaceForNewDisksFailure() { setUpGeneralValidations(); setUpDiskValidations(); List disksList = getNonEmptyDiskList(); doReturn(disksList).when(cmd).getDisksList(); doReturn(new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN)).when(multipleStorageDomainsValidator) .allDomainsHaveSpaceForNewDisks(disksList); assertFalse(cmd.canDoAction()); verify(multipleStorageDomainsValidator).allDomainsHaveSpaceForNewDisks(disksList); assertTrue(cmd.getReturnValue() .getCanDoActionMessages() .contains(VdcBllMessages.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN.name())); }

Target:
public void testAllDomainsHaveSpaceForNewDisksFailure() { setUpGeneralValidations(); setUpDiskValidations(); List<DiskImage> disksList = getNonEmptyDiskList(); doReturn(disksList).when(cmd).getDisksList(); doReturn(new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN)).when(multipleStorageDomainsValidator) .allDomainsHaveSpaceForNewDisks(disksList); CanDoActionTestUtils.runAndAssertCanDoActionFailure(cmd, VdcBllMessages.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN); verify(multipleStorageDomainsValidator).allDomainsHaveSpaceForNewDisks(disksList); }
Source:
public void testMergeInOneCommand() { LogConfig.logOnLevel(Level.ALL); batcher.setMergeValueChanges(true); List<CommandAndHandler> list = new ArrayList<CommandAndHandler>(); ValueChangedCommand command = new ValueChangedCommand(); command.setAttributeId("0"); command.setOldValue(0); command.setNewValue(1); ((ArrayList<CommandAndHandler>) list).add(new CommandAndHandler(command)); ValueChangedCommand command1 = new ValueChangedCommand(); command1.setAttributeId("0"); command1.setOldValue(1); command1.setNewValue(2); ((ArrayList<CommandAndHandler>) list).add(new CommandAndHandler(command1)); ValueChangedCommand command2 = new ValueChangedCommand(); command2.setAttributeId("0"); command2.setOldValue(2); command2.setNewValue(3); ((ArrayList<CommandAndHandler>) list).add(new CommandAndHandler(command2)); for (CommandAndHandler commandAndHandler : list) { batcher.batch(commandAndHandler); } try { List<CommandAndHandler> nextBatch = batcher.getWaitingBatches().getVal(); Assert.assertEquals(1, nextBatch.size()); Assert.assertEquals(ValueChangedCommand.class, nextBatch.get(0).getCommand().getClass()); ValueChangedCommand cmd = (ValueChangedCommand) nextBatch.get(0).getCommand(); Assert.assertEquals(0, cmd.getOldValue()); Assert.assertEquals(3, cmd.getNewValue()); Assert.assertTrue(batcher.isEmpty()); } catch (InterruptedException e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }

Target:
public void testMergeInOneCommand() { LogConfig.logOnLevel(Level.ALL); batcher.setMergeValueChanges(true); List<CommandAndHandler> list = new ArrayList<CommandAndHandler>(); ValueChangedCommand command = new ValueChangedCommand(); command.setAttributeId("0"); command.setOldValue(0); command.setNewValue(1); list.add(new CommandAndHandler(command)); ValueChangedCommand command1 = new ValueChangedCommand(); command1.setAttributeId("0"); command1.setOldValue(1); command1.setNewValue(2); list.add(new CommandAndHandler(command1)); ValueChangedCommand command2 = new ValueChangedCommand(); command2.setAttributeId("0"); command2.setOldValue(2); command2.setNewValue(3); list.add(new CommandAndHandler(command2)); for (CommandAndHandler commandAndHandler : list) { batcher.batch(commandAndHandler); } try { List<CommandAndHandler> nextBatch = batcher.getWaitingBatches().getVal(); Assert.assertEquals(1, nextBatch.size()); Assert.assertEquals(ValueChangedCommand.class, nextBatch.get(0).getCommand().getClass()); ValueChangedCommand cmd = (ValueChangedCommand) nextBatch.get(0).getCommand(); Assert.assertEquals(0, cmd.getOldValue()); Assert.assertEquals(3, cmd.getNewValue()); Assert.assertTrue(batcher.isEmpty()); } catch (InterruptedException e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }
Source:
public void setException(Throwable t) { if (t != null) { if (t instanceof ReadTimeoutException) { error = "READ_TIMEOUT"; exceptionType = t.getClass().getSimpleName(); } else if (t instanceof OriginConnectException) { OriginConnectException oce = (OriginConnectException) t; if (oce.getErrorType() != null) { error = oce.getErrorType().toString(); } else { error = "ORIGIN_CONNECT_ERROR"; } final Throwable cause = t.getCause(); if (cause != null) { exceptionType = t.getCause().getClass().getSimpleName(); } else { exceptionType = t.getClass().getSimpleName(); } } else if (t instanceof OutboundException) { OutboundException obe = (OutboundException) t; error = obe.getOutboundErrorType().toString(); exceptionType = OutboundException.class.getSimpleName(); } else { error = t.getMessage(); exceptionType = t.getClass().getSimpleName(); } if (t.getCause() != null) { cause = t.getCause().toString(); } } }

Target:
public void setException(Throwable t) { if (t != null) { if (t instanceof ReadTimeoutException) { error = "READ_TIMEOUT"; exceptionType = t.getClass().getSimpleName(); } else if (t instanceof OriginConnectException) { OriginConnectException oce = (OriginConnectException) t; if (oce.getErrorType() != null) { error = oce.getErrorType().toString(); } else { error = "ORIGIN_CONNECT_ERROR"; } final Throwable cause = t.getCause(); if (cause != null) { exceptionType = t.getCause().getClass().getSimpleName(); } else { exceptionType = t.getClass().getSimpleName(); } } else if (t instanceof OutboundException) { OutboundException obe = (OutboundException) t; error = obe.getOutboundErrorType().toString(); exceptionType = OutboundException.class.getSimpleName(); } else if (t instanceof SSLHandshakeException) { error = t.getMessage(); exceptionType = t.getClass().getSimpleName(); cause = t.getCause().getMessage(); } else { error = t.getMessage(); exceptionType = t.getClass().getSimpleName(); cause = Throwables.getStackTraceAsString(t); } } }