auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public static Map<Integer, Map<Integer, Long>> getUpdateCountersSnapshot( IgniteEx ign, Set<Integer> grpIds ) { Map<Integer, Map<Integer, Long>> partsWithCountersPerGrp = new HashMap<>(); for (Integer grpId : grpIds) { CacheGroupContext grpCtx = ign.context().cache().cacheGroup(grpId); if (grpCtx == null) throw new GridNotIdleException("Group not found: " + grpId + "." + " Possible reasons: rebalance in progress or concurrent cache destroy."); GridDhtPartitionTopology top = grpCtx.topology(); Map<Integer, Long> partsWithCounters = partsWithCountersPerGrp.computeIfAbsent(grpId, k -> new HashMap<>()); for (GridDhtLocalPartition part : top.currentLocalPartitions()) { if (part.state() != GridDhtPartitionState.OWNING) continue; if (!part.dataStore().partUpdateCounter().sequential()) throw new GridNotIdleException("Cluster not idle. Probably due to continues rebalance"); partsWithCounters.put(part.id(), part.updateCounter()); } } return partsWithCountersPerGrp; }

Target:
public static Map<Integer, Map<Integer, PartitionUpdateCounter>> getUpdateCountersSnapshot( IgniteEx ign, Set<Integer> grpIds ) { Map<Integer, Map<Integer, PartitionUpdateCounter>> partsWithCountersPerGrp = new HashMap<>(); for (Integer grpId : grpIds) { CacheGroupContext grpCtx = ign.context().cache().cacheGroup(grpId); if (grpCtx == null) throw new GridNotIdleException("Group not found: " + grpId + "." + " Possible reasons: rebalance in progress or concurrent cache destroy."); GridDhtPartitionTopology top = grpCtx.topology(); Map<Integer, PartitionUpdateCounter> partsWithCounters = partsWithCountersPerGrp.computeIfAbsent(grpId, k -> new HashMap<>()); for (GridDhtLocalPartition part : top.currentLocalPartitions()) { if (part.state() != GridDhtPartitionState.OWNING) continue; @Nullable PartitionUpdateCounter updCntr = part.dataStore().partUpdateCounter(); partsWithCounters.put(part.id(), updCntr == null ? null : updCntr.copy()); } } return partsWithCountersPerGrp; }
Source:
public Iterable<VirtualMachine> listNodesByIds(final Iterable<String> ids) { return Iterables.filter(listNodes(), new Predicate<VirtualMachine>() { @Override public boolean apply(VirtualMachine vm) { return Iterables.contains(ids, vm.getId()); } }); }

Target:
public Iterable<VirtualMachine> listNodesByIds(final Iterable<String> ids) { return filter(listNodes(), new Predicate<VirtualMachine>() { @Override public boolean apply(VirtualMachine vm) { return contains(ids, vm.getId()); } }); }
Source:
public double getMinWeight( double distance ) { return 0.001 * distance; }

Target:
public double getMinWeight( double distance ) { return 0.1 * distance; }
Source:
public Response doImport(Action action) { validateParameters(action, "cluster.id|name", "storageDomain.id|name"); Guid destStorageDomainId = getDestStorageDomainId(action); ImportVmParameters params = new ImportVmParameters(getEntity(), parent.getStorageDomainId(), destStorageDomainId, parent.getDataCenterId(destStorageDomainId), getClusterId(action)); params.setImageToDestinationDomainMap(getDiskToDestinationMap(action)); params.setForceOverride(action.isSetExclusive() ? action.isExclusive() : false); if (action.isSetVm() && action.getVm().isSetSnapshots() && action.getVm().getSnapshots().isSetCollapseSnapshots()) { params.setCopyCollapse(action.getVm().getSnapshots().isCollapseSnapshots()); } if (action.isSetClone()) { params.setImportAsNewEntity(action.isClone()); if(action.isSetVm() && action.getVm().isSetName()) { params.getVm().setName(action.getVm().getName()); } } return doAction(VdcActionType.ImportVm, params, action); }

Target:
public Response doImport(Action action) { validateParameters(action, "cluster.id|name"); Guid destStorageDomainId = getDestStorageDomainId(action); ImportVmParameters params = new ImportVmParameters(getEntity(), parent.getStorageDomainId(), destStorageDomainId, parent.getDataCenterId(destStorageDomainId), getClusterId(action)); params.setImageToDestinationDomainMap(getDiskToDestinationMap(action)); params.setForceOverride(action.isSetExclusive() ? action.isExclusive() : false); if (action.isSetVm() && action.getVm().isSetSnapshots() && action.getVm().getSnapshots().isSetCollapseSnapshots()) { params.setCopyCollapse(action.getVm().getSnapshots().isCollapseSnapshots()); } if (action.isSetClone()) { params.setImportAsNewEntity(action.isClone()); if(action.isSetVm() && action.getVm().isSetName()) { params.getVm().setName(action.getVm().getName()); } } return doAction(VdcActionType.ImportVm, params, action); }
Source:
private void preserveOriginalFile(Path java) throws Exception { long expected = Files.getLastModifiedTime(java).toMillis(); StringWriter out = new StringWriter(); StringWriter err = new StringWriter(); Main main = new Main(new PrintWriter(out, true), new PrintWriter(err, true), System.in); int errorCode = main.format("-replace", java.toAbsolutePath().toString()); Assert.assertEquals("ErrorCode not 0: " + err + ": " + out, 0, errorCode); long actual = Files.getLastModifiedTime(java).toMillis(); Assert.assertEquals("Last modified time changed: " + java, expected, actual); }

Target:
private void preserveOriginalFile(Path java) throws Exception { long expected = Files.getLastModifiedTime(java).toMillis(); StringWriter out = new StringWriter(); StringWriter err = new StringWriter(); Main main = new Main(new PrintWriter(out, true), new PrintWriter(err, true), System.in); int errorCode = main.format("-replace", java.toAbsolutePath().toString()); assertThat(errorCode).named("Error Code").isEqualTo(0); long actual = Files.getLastModifiedTime(java).toMillis(); assertThat(actual).named("Last modified time changed: " + java).isEqualTo(expected); }
Source:
private ServiceResponse<?> validateContainerReleaseAndMode(String preffix, KieContainerResource container) { if(container == null) { return new ServiceResponse<>(ResponseType.FAILURE, preffix, "Release Id is null"); } return validateReleaseAndMode(preffix, container.getReleaseId()); }

Target:
private <T> ServiceResponse<T> validateContainerReleaseAndMode(String preffix, KieContainerResource container) { if (container == null) { return new ServiceResponse<>(ResponseType.FAILURE, preffix + " Container is null"); } return validateReleaseAndMode(preffix, container.getReleaseId()); }
Source:
public void onActivityStarted(Activity activity) { ConnectivityIndicator.start(mContext); mCurrentActivity = activity; }

Target:
public void onActivityStarted(Activity activity) { mCurrentActivity = new WeakReference<>(activity); }
Source:
public boolean remove(Object o) { throw new UnsupportedOperationException("No remove in " + this.getClass().getName()); }

Target:
public boolean remove(Object o) { throw new UnsupportedOperationException("No remove(Object) in " + this.getClass().getName()); }
Source:
public MockEJBStrategyRule(Map<BeanType, Object> beans) { this(beans, new EnumMap<ContainerManagedResourceType,Object>(ContainerManagedResourceType.class));; }

Target:
public MockEJBStrategyRule(Map<BeanType, Object> beans) { this(beans, new EnumMap<ContainerManagedResourceType,Object>(ContainerManagedResourceType.class)); }
Source:
public MedicationRequest updateFHIRMedicationRequest(MedicationRequest medicationRequest, String uuid) { List<String> errors = new ArrayList<String>(); DrugOrder incomingDrugOrder = FHIRMedicationRequestUtil.generateDrugOrder(medicationRequest, errors); DrugOrder generatedDrugOrder = (DrugOrder) Context.getOrderService().getOrderByUuid(uuid); FHIRMedicationRequestUtil.copyObsAttributes(incomingDrugOrder, generatedDrugOrder, errors); if (generatedDrugOrder != null) { if (!errors.isEmpty()) { String errorMessage = ErrorUtil.generateErrorMessage(errors, "The request cannot be processed due to the " + "following issues \n"); throw new UnprocessableEntityException(errorMessage); } incomingDrugOrder = (DrugOrder) Context.getOrderService().saveOrder(generatedDrugOrder, null); return FHIRMedicationRequestUtil.generateMedicationRequest(incomingDrugOrder); } else { StrategyUtil.setIdIfNeeded(medicationRequest, uuid); return createFHIRMedicationRequest(medicationRequest); } }

Target:
public MedicationRequest updateFHIRMedicationRequest(MedicationRequest medicationRequest, String uuid) { List<String> errors = new ArrayList<String>(); DrugOrder incomingDrugOrder = FHIRMedicationRequestUtil.generateDrugOrder(medicationRequest, errors); DrugOrder generatedDrugOrder = (DrugOrder) Context.getOrderService().getOrderByUuid(uuid); FHIRMedicationRequestUtil.copyObsAttributes(incomingDrugOrder, generatedDrugOrder, errors); if (generatedDrugOrder != null) { if (!errors.isEmpty()) { String errorMessage = ErrorUtil.generateErrorMessage(errors, FHIRConstants.REQUEST_ISSUE_LIST); throw new UnprocessableEntityException(errorMessage); } incomingDrugOrder = (DrugOrder) Context.getOrderService().saveOrder(generatedDrugOrder, null); return FHIRMedicationRequestUtil.generateMedicationRequest(incomingDrugOrder); } else { StrategyUtil.setIdIfNeeded(medicationRequest, uuid); return createFHIRMedicationRequest(medicationRequest); } }
Source:
private void checkGps() { Timber.d("checking GPS"); if (!locationManager.isProviderEnabled()) { Timber.d("GPS is not enabled"); new AlertDialog.Builder(getActivity()) .setMessage(R.string.gps_disabled) .setCancelable(false) .setPositiveButton(R.string.enable_gps, (dialog, id) -> { Intent callGPSSettingIntent = new Intent( android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); Timber.d("Loaded settings page"); startActivityForResult(callGPSSettingIntent, 1); }) .setNegativeButton(R.string.menu_cancel_upload, (dialog, id) -> { DialogUtil.showAlertDialog( getActivity(), null, getString(R.string.nearby_needs_gps), getString(R.string.enable_gps), getString(R.string.cancel), new Runnable() { @Override public void run() { Intent callGPSSettingIntent = new Intent( android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); Timber.d("Loaded settings page"); startActivityForResult(callGPSSettingIntent, 1); } }, new Runnable() { @Override public void run() { ((MainActivity)getActivity()).viewPager.setCurrentItem(((MainActivity)getActivity()).CONTRIBUTIONS_TAB_POSITION); } }); dialog.cancel(); }) .create() .show(); } else { Timber.d("GPS is enabled"); checkLocationPermission(); } }

Target:
private void checkGps() { Timber.d("checking GPS"); if (!locationManager.isProviderEnabled()) { Timber.d("GPS is not enabled"); new AlertDialog.Builder(getActivity()) .setMessage(R.string.gps_disabled) .setCancelable(false) .setPositiveButton(R.string.enable_gps, (dialog, id) -> { Intent callGPSSettingIntent = new Intent( android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); Timber.d("Loaded settings page"); startActivityForResult(callGPSSettingIntent, 1); }) .setNegativeButton(R.string.menu_cancel_upload, (dialog, id) -> { DialogUtil.showAlertDialog( getActivity(), null, getString(R.string.nearby_needs_gps), getString(R.string.enable_gps), getString(R.string.cancel), () -> { Intent callGPSSettingIntent = new Intent( android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); Timber.d("Loaded settings page"); startActivityForResult(callGPSSettingIntent, 1); }, () -> { ((MainActivity)getActivity()).viewPager.setCurrentItem(((MainActivity)getActivity()).CONTRIBUTIONS_TAB_POSITION); }); dialog.cancel(); }) .create() .show(); } else { Timber.d("GPS is enabled"); checkLocationPermission(); } }
Source:
public void visitNode(AstNode node) { Symbol symbol = getContext().symbolTable().getSymbol(node); if (symbol != null && questionableFunctions.contains(symbol.qualifiedName())) { AstNode parent = node.getParent(); if (parent != null && parent.is(PythonGrammar.CALL_EXPR)) { parent.getChildren(PythonGrammar.ARGLIST).forEach(this::checkArgument); } } }

Target:
public void visitNode(AstNode node) { Symbol symbol = getContext().symbolTable().getSymbol(node); if (symbol != null && questionableFunctions.contains(symbol.qualifiedName())) { AstNode parent = node.getParent(); if (parent != null && parent.is(PythonGrammar.CALL_EXPR)) { AstNode argListNode = parent.getFirstChild(PythonGrammar.ARGLIST); if (argListNode != null) { checkRegexArgument(argListNode.getChildren().get(REGEX_ARGUMENT)); } } } }
Source:
private static Map<String, String> getHostToRackMap(String rackYamlFile) throws FileNotFoundException, YamlException { YamlReader yamlReader = new YamlReader(new FileReader(rackYamlFile)); Map rackHostsMap = (Map) yamlReader.read(); Map racks = (Map) rackHostsMap.get(RACKS_YAML_KEY_NAME); Map<String, String> hostToRackMap = new HashMap<>(); for (Map.Entry entry : (Set<Map.Entry>) racks.entrySet()) { Map rackInfoMap = (Map) entry.getValue(); String rackName = (String) entry.getKey(); if (rackInfoMap.containsKey(HOSTS_YAML_KEY_NAME)) { List<String> hostList = (List<String>) rackInfoMap.get(HOSTS_YAML_KEY_NAME); for (String host : hostList) { hostToRackMap.put(host, rackName); } } if (rackInfoMap.containsKey(HOST_GROUPS_YAML_KEY_NAME)) { List<Map> hostGroups = (List<Map>) rackInfoMap.get(HOST_GROUPS_YAML_KEY_NAME); for (Map hostGroup : hostGroups) { if (hostGroup.containsKey(HOSTS_YAML_KEY_NAME)) { List<String> hostList = (List<String>) hostGroup.get(HOSTS_YAML_KEY_NAME); for (String host : hostList) { hostToRackMap.put(host, rackName); } } } } } return hostToRackMap; }

Target:
private static Map<String, String> getHostToRackMap(String rackYamlFile) throws IOException { YamlReader yamlReader = new YamlReader(new FileReader(rackYamlFile)); Map rackHostsMap; try { rackHostsMap = (Map) yamlReader.read(); } finally { yamlReader.close(); } Map racks = (Map) rackHostsMap.get(RACKS_YAML_KEY_NAME); Map<String, String> hostToRackMap = new HashMap<>(); for (Map.Entry entry : (Set<Map.Entry>) racks.entrySet()) { Map rackInfoMap = (Map) entry.getValue(); String rackName = (String) entry.getKey(); if (rackInfoMap.containsKey(HOSTS_YAML_KEY_NAME)) { List<String> hostList = (List<String>) rackInfoMap.get(HOSTS_YAML_KEY_NAME); for (String host : hostList) { hostToRackMap.put(host, rackName); } } if (rackInfoMap.containsKey(HOST_GROUPS_YAML_KEY_NAME)) { List<Map> hostGroups = (List<Map>) rackInfoMap.get(HOST_GROUPS_YAML_KEY_NAME); for (Map hostGroup : hostGroups) { if (hostGroup.containsKey(HOSTS_YAML_KEY_NAME)) { List<String> hostList = (List<String>) hostGroup.get(HOSTS_YAML_KEY_NAME); for (String host : hostList) { hostToRackMap.put(host, rackName); } } } } } return hostToRackMap; }
Source:
private Iterable<ISegment> compactList(final long startTime, final Iterable<@NonNull ISegment> iterableToCompact) { return new Iterable<@NonNull ISegment>() { @Override public Iterator<ISegment> iterator() { return new Iterator<@NonNull ISegment>() { private @Nullable ISegment last = null; private @Nullable ISegment next = null; private Iterator<@NonNull ISegment> iterator = iterableToCompact.iterator(); @Override public @NonNull ISegment next() { if (hasNext()) { last = next; next = null; return Objects.requireNonNull(last); } throw new NoSuchElementException(); } @Override public boolean hasNext() { if (last == null) { if (iterator.hasNext()) { last = iterator.next(); if (last.getStart() >= startTime) { next = last; } } else { return false; } } ISegment prev = last; while (next == null && iterator.hasNext()) { ISegment tmp = iterator.next(); if (tmp.getStart() >= startTime && !overlaps(prev, tmp)) { next = tmp; } } return next != null; } }; } }; }

Target:
private Iterable<ISegment> compactList(final long startTime, final Iterable<@NonNull ISegment> iterableToCompact) { return new Iterable<@NonNull ISegment>() { @Override public Iterator<ISegment> iterator() { return new Iterator<@NonNull ISegment>() { private @Nullable ISegment fLast = null; private @Nullable ISegment fNext = null; private Iterator<@NonNull ISegment> fIterator = iterableToCompact.iterator(); @Override public @NonNull ISegment next() { if (hasNext()) { fLast = fNext; fNext = null; return Objects.requireNonNull(fLast); } throw new NoSuchElementException(); } @Override public boolean hasNext() { if (fLast == null) { if (fIterator.hasNext()) { fLast = fIterator.next(); if (fLast.getStart() >= startTime) { fNext = fLast; } } else { return false; } } ISegment prev = fLast; while (fNext == null && fIterator.hasNext()) { ISegment tmp = fIterator.next(); if (tmp.getStart() >= startTime && !overlaps(prev, tmp)) { fNext = tmp; } } return fNext != null; } }; } }; }
Source:
public TmfLocationArray(ITmfLocation[] locations, long[] ranks) { assert(locations.length == ranks.length); fLocations = Arrays.copyOf(locations, locations.length); fRanks = Arrays.copyOf(ranks, ranks.length); }

Target:
public TmfLocationArray(ITmfLocation[] locations, long[] ranks) { fLocations = Arrays.copyOf(locations, locations.length); fRanks = Arrays.copyOf(ranks, ranks.length); }
Source:
public void onEventMainThread(PostEvents.PostUploadCanceled event) { if (isAdded() && mSite.getId() == event.localSiteId) { loadPosts(LoadMode.FORCED); } }

Target:
public void onEventMainThread(PostEvents.PostUploadCanceled event) { if (isAdded() && mSite != null && mSite.getId() == event.localSiteId) { loadPosts(LoadMode.FORCED); } }
Source:
public void execute(TronObject object) { FlagKeeper flagkeeper = (FlagKeeper) object; if (flagkeeper != null) { Flag flag = flagkeeper.giveFlag(); if (flag != null) { List<SquareContainer> neighbours = this.getAllNeighboursOf(flagkeeper .getCurrentPosition()); neighbours.get(new Random().nextInt(neighbours.size())).addItem(flag); } } super.execute(object); }

Target:
public void execute(TronObject object) throws IllegalStateException { FlagKeeper flagkeeper = object.asFlagKeeper(); if (flagkeeper != null) { Flag flag = flagkeeper.giveFlag(); if (flag != null) { List<SquareContainer> neighbours = flagkeeper.getCurrentPosition() .getAllNeighbours(); if (neighbours.size() == 0) throw new IllegalStateException( " The flagkeeper's current square must have at least one neigbour."); neighbours.get(new Random().nextInt(neighbours.size())).addItem(flag); } } super.execute(object); }
Source:
public void verify() throws Exception { if (isMemberNode(targetInstance)) { MapStoreConfig mapStoreConfig = targetInstance.getConfig().getMapConfig(basename).getMapStoreConfig(); final int writeDelaySeconds = mapStoreConfig.getWriteDelaySeconds(); Thread.sleep(mapStoreMaxDelayMs * 2 + maxTTLExpireyMs * 2 + ((writeDelaySeconds * 2) * 1000)); final MapStoreWithCounter mapStore = (MapStoreWithCounter) mapStoreConfig.getImplementation(); final IMap map = targetInstance.getMap(basename); log.info(basename + ": map size =" + map.size()); log.info(basename + ": " + mapStore); TestUtils.assertTrueEventually(new AssertTask() { @Override public void run() throws Exception { for (Object k : map.localKeySet()) { assertEquals(map.get(k), mapStore.store.get(k)); } assertEquals("sets should be equals", map.getAll(map.localKeySet()).entrySet(), mapStore.store.entrySet()); for (int k = putTTlKeyDomain; k < putTTlKeyDomain + putTTlKeyRange; k++) { assertNull(basename + ": TTL key should not be in the map", map.get(k)); } } }, 120); } }

Target:
public void verify() throws Exception { if (isMemberNode(targetInstance)) { MapStoreConfig mapStoreConfig = targetInstance.getConfig().getMapConfig(basename).getMapStoreConfig(); final int writeDelaySeconds = mapStoreConfig.getWriteDelaySeconds(); Thread.sleep(mapStoreMaxDelayMs * 2 + maxTTLExpireyMs * 2 + ((writeDelaySeconds * 2) * 1000)); final MapStoreWithCounter mapStore = (MapStoreWithCounter) mapStoreConfig.getImplementation(); final IMap map = targetInstance.getMap(basename); log.info(basename + ": map size =" + map.size()); log.info(basename + ": " + mapStore); TestUtils.assertTrueEventually(new AssertTask() { @Override public void run() throws Exception { for (Object k : map.localKeySet()) { assertEquals(map.get(k), mapStore.store.get(k)); } assertEquals("sets should be equals", map.getAll(map.localKeySet()).entrySet(), mapStore.store.entrySet()); for (int k = putTTlKeyDomain; k < putTTlKeyDomain + putTTlKeyRange; k++) { assertNull(basename + ": TTL key should not be in the map", map.get(k)); } } }); } }
Source:
public DebuggingContext enableDebugMode(IDeploymentConfig deploymentConfig, DebuggingContext debugContext, IProgressMonitor monitor) throws CoreException { assert deploymentConfig != null; assert debugContext != null; IDebugListener listener = debugContext.getDebugListener(); if (debugContext.isDebugEnabled() && listener != null) { IPod pod = getFirstPod(deploymentConfig); debugContext.setPod(pod); listener.onDebugChange(debugContext, monitor); } else { debugContext.setDebugEnabled(true); updateDebugConfig(deploymentConfig, debugContext, monitor); } return debugContext; }

Target:
public DebuggingContext enableDebugMode(IDeploymentConfig deploymentConfig, DebuggingContext debugContext, IProgressMonitor monitor) throws CoreException { Assert.isNotNull(deploymentConfig); Assert.isNotNull(debugContext); IDebugListener listener = debugContext.getDebugListener(); if (debugContext.isDebugEnabled() && listener != null) { IPod pod = getFirstPod(deploymentConfig); debugContext.setPod(pod); listener.onDebugChange(debugContext, monitor); } else { debugContext.setDebugEnabled(true); updateDebugConfig(deploymentConfig, debugContext, monitor); } return debugContext; }
Source:
public String serialize() { StringBuilder builder = new StringBuilder(); if (getItems() == null) { return ""; } for (KeyValueLineModel keyValueLineModel : (List<KeyValueLineModel>) getItems()) { String key = keyValueLineModel.getKeys().getSelectedItem(); if (!isKeyValid(key)) { continue; } builder.append(key); builder.append(KEY_VALUE_DELIMETER); if (keyValueLineModel.getValue().getIsAvailable()) { builder.append(keyValueLineModel.getValue().getEntity()); } else if (keyValueLineModel.getValues().getIsAvailable()) { builder.append(keyValueLineModel.getValues().getSelectedItem()); } builder.append(PROPERTIES_DELIMETER); } return builder.subSequence(0, builder.length() - 1).toString(); }

Target:
public String serialize() { StringBuilder builder = new StringBuilder(); if (getItems() == null) { return ""; } for (KeyValueLineModel keyValueLineModel : (List<KeyValueLineModel>) getItems()) { String key = keyValueLineModel.getKeys().getSelectedItem(); if (!isKeyValid(key)) { continue; } builder.append(key); builder.append(KEY_VALUE_DELIMETER); if (keyValueLineModel.getValue().getIsAvailable()) { builder.append(keyValueLineModel.getValue().getEntity()); } else if (keyValueLineModel.getValues().getIsAvailable()) { builder.append(keyValueLineModel.getValues().getSelectedItem()); } builder.append(PROPERTIES_DELIMETER); } if (builder.toString().endsWith(PROPERTIES_DELIMETER)) { return builder.subSequence(0, builder.length() - PROPERTIES_DELIMETER.length()).toString(); } return builder.toString(); }
Source:
Object toSerializableValue(Object value) { return value == null ? null : udtMapper.toUDT((U) value); }

Target:
Object toSerializableValue(Object value) { if (value == null) { return null; } else { @SuppressWarnings("unchecked") U mappedUdt = (U) value; return udtMapper.toUDT(mappedUdt); } }
Source:
public void testDelegateIsLazyLoadedAndRequestIncludesEndpointFromCallee() throws InterruptedException, ExecutionException { Injector child = injectorForCaller(new HttpCommandExecutorService() { @Override public HttpResponse invoke(HttpCommand command) { assertEquals(command.getCurrentRequest().getRequestLine(), "GET http://localhost:1111/client/1 HTTP/1.1"); return HttpResponse.builder().build(); } }); try { child.getInstance(Callee.class); fail("Callee shouldn't be bound yet"); } catch (ConfigurationException e) { } child.getInstance(Caller.class).getCallee(URI.create("http://howdyboys")).testWithEndpoint(); }

Target:
public void testDelegateIsLazyLoadedAndRequestIncludesEndpointFromCallee() throws InterruptedException, ExecutionException { Injector child = injectorForCaller(new HttpCommandExecutorService() { @Override public HttpResponse invoke(HttpCommand command) { assertEquals(command.getCurrentRequest().getRequestLine(), "GET http://localhost:1111/client/1 HTTP/1.1"); return HttpResponse.builder().build(); } }); try { child.getInstance(Callee.class); failBecauseExceptionWasNotThrown(ConfigurationException.class); } catch (ConfigurationException e) { } child.getInstance(Caller.class).getCallee(URI.create("http://howdyboys")).testWithEndpoint(); }
Source:
public void handleRowMove() { final List<GridRow> existingRowOrder = new ArrayList<>(uiModel.getRows()); final GridWidgetDnDProxy highlight = mock(GridWidgetDnDProxy.class); when(state.getEventColumnHighlight()).thenReturn(highlight); when(state.getOperation()).thenReturn(GridWidgetHandlersOperation.NONE); when(gridWidget.isVisible()).thenReturn(true); when(layer.getGridWidgets()).thenReturn(new HashSet<GridWidget>() {{ add(gridWidget); }}); final int eventX = (int) (gridWidget.getComputedLocation().getX() + uiColumn1.getWidth() / 2); final int eventY = (int) (gridWidget.getComputedLocation().getY() + renderer.getHeaderHeight() + uiModel.getRow(0).getHeight() / 2); when(event.getX()).thenReturn(eventX); when(event.getY()).thenReturn(eventY); handler.onNodeMouseMove(event); final int eventNewY = (int) (gridWidget.getComputedLocation().getY() + renderer.getHeaderHeight() + uiModel.getRow(0).getHeight() + uiModel.getRow(1).getHeight() / 2); when(state.getOperation()).thenReturn(GridWidgetHandlersOperation.ROW_MOVE); when(event.getY()).thenReturn(eventNewY); handler.onNodeMouseMove(event); verify(highlight).setY(gridWidget.getComputedLocation().getY() + renderer.getHeaderHeight()); verify(layer).batch(); assertEquals(existingRowOrder.get(0), uiModel.getRow(1)); assertEquals(existingRowOrder.get(1), uiModel.getRow(0)); assertEquals(existingRowOrder.get(2), uiModel.getRow(2)); }

Target:
public void handleRowMove() { final List<GridRow> existingRowOrder = new ArrayList<>(uiModel.getRows()); final GridWidgetDnDProxy highlight = mock(GridWidgetDnDProxy.class); when(state.getEventColumnHighlight()).thenReturn(highlight); when(state.getOperation()).thenReturn(GridWidgetHandlersOperation.NONE); when(gridWidget.isVisible()).thenReturn(true); when(layer.getGridWidgets()).thenReturn(Collections.singleton(gridWidget)); final int eventX = (int) (gridWidget.getComputedLocation().getX() + uiColumn1.getWidth() / 2); final int eventY = (int) (gridWidget.getComputedLocation().getY() + renderer.getHeaderHeight() + uiModel.getRow(0).getHeight() / 2); when(event.getX()).thenReturn(eventX); when(event.getY()).thenReturn(eventY); handler.onNodeMouseMove(event); final int eventNewY = (int) (gridWidget.getComputedLocation().getY() + renderer.getHeaderHeight() + uiModel.getRow(0).getHeight() + uiModel.getRow(1).getHeight() / 2); when(state.getOperation()).thenReturn(GridWidgetHandlersOperation.ROW_MOVE); when(event.getY()).thenReturn(eventNewY); handler.onNodeMouseMove(event); verify(highlight).setY(gridWidget.getComputedLocation().getY() + renderer.getHeaderHeight()); verify(layer).batch(); assertEquals(existingRowOrder.get(0), uiModel.getRow(1)); assertEquals(existingRowOrder.get(1), uiModel.getRow(0)); assertEquals(existingRowOrder.get(2), uiModel.getRow(2)); }
Source:
protected void dispatchEvent(Message event, EventContext context) throws InvocationTargetException { checkNotNull(event, "event"); checkNotNull(context, "event context"); init(); final Class<? extends Message> eventClass = event.getClass(); final Method method = eventHandlers.get(eventClass); if (method == null) { throw missingEventHandler(eventClass); } final EventHandlerMethod handler = new EventHandlerMethod(this, method); handler.invoke(event, context); }

Target:
protected void dispatchEvent(Message event, EventContext context) throws InvocationTargetException { checkNotNull(context, "context"); checkNotNull(event, "event"); init(); final Class<? extends Message> eventClass = event.getClass(); final Method method = eventHandlers.get(eventClass); if (method == null) { throw missingEventHandler(eventClass); } final EventHandlerMethod handler = new EventHandlerMethod(this, method); handler.invoke(event, context); }
Source:
private double calculateTokenSimilarity(MatchableEntity citation, MatchableEntity document) { Set<String> srcTokens = JavaConversions.asJavaSet(misc.niceTokens(citation.toReferenceString())); Set<String> dstTokens = JavaConversions.asJavaSet(misc.niceTokens(document.toReferenceString())); long mutualTokensCount = srcTokens.stream().filter(x -> dstTokens.contains(x)).count(); double similarity = 2.0 * mutualTokensCount / (srcTokens.size() + dstTokens.size()); return similarity; }

Target:
private double calculateTokenSimilarity(MatchableEntity citation, MatchableEntity document) { Set<String> citTokens = JavaConversions.asJavaSet(misc.niceTokens(citation.toReferenceString())); Set<String> docTokens = JavaConversions.asJavaSet(misc.niceTokens(document.toReferenceString())); long mutualTokensCount = citTokens.stream().filter(x -> docTokens.contains(x)).count(); double similarity = 2.0 * mutualTokensCount / (citTokens.size() + docTokens.size()); return similarity; }
Source:
public static PreparedStatement getPreparedStatementProxy(PreparedStatement delegate, QueryParameters queryParameters, int cteParameterCount) { try { return PROXY_CONSTRUCTOR.newInstance(new SubselectPreparedStatementProxyHandler(delegate, queryParameters, cteParameterCount)); } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } }

Target:
public static PreparedStatement getPreparedStatementProxy(PreparedStatement delegate, QueryParameters queryParameters, int cteParameterCount) { try { return PROXY_CONSTRUCTOR.newInstance(new SubselectPreparedStatementProxyHandler(delegate, queryParameters, cteParameterCount)); } catch (Exception e) { throw new IllegalStateException(e); } }
Source:
public DruidStatement execute() { synchronized (lock) { ensure(State.PREPARED); try { Callable<Sequence<Object[]>> opener = () -> plannerResult.run(); Future<Sequence<Object[]>> future = yielderOpenCloseExecutor.submit(opener); final Sequence<Object[]> baseSequence = future.get(); final Sequence<Object[]> retSequence = maxRowCount >= 0 && maxRowCount <= Integer.MAX_VALUE ? Sequences.limit(baseSequence, (int) maxRowCount) : baseSequence; yielder = Yielders.each(retSequence); state = State.RUNNING; } catch (Throwable t) { try { close(); } catch (Throwable t1) { t.addSuppressed(t1); } Throwables.propagate(t); } return this; } }

Target:
public DruidStatement execute() { synchronized (lock) { ensure(State.PREPARED); try { final Sequence<Object[]> baseSequence = yielderOpenCloseExecutor.submit( () -> plannerResult.run() ).get(); final Sequence<Object[]> retSequence = maxRowCount >= 0 && maxRowCount <= Integer.MAX_VALUE ? Sequences.limit(baseSequence, (int) maxRowCount) : baseSequence; yielder = Yielders.each(retSequence); state = State.RUNNING; } catch (Throwable t) { try { close(); } catch (Throwable t1) { t.addSuppressed(t1); } throw Throwables.propagate(t); } return this; } }
Source:
public void setJavaClassNameColumnInSysAliases(TransactionController tc) throws StandardException { SchemaDescriptor sd = getSystemSchemaDescriptor(); TabInfoImpl ti=getNonCoreTI(SYSALIASES_CATALOG_NUM); faultInTabInfo(ti); FormatableBitSet columnToReadSet=new FormatableBitSet(SYSALIASESRowFactory.SYSALIASES_COLUMN_COUNT); FormatableBitSet columnToUpdateSet=new FormatableBitSet(SYSALIASESRowFactory.SYSALIASES_COLUMN_COUNT); for(int i=0;i<SYSALIASESRowFactory.SYSALIASES_COLUMN_COUNT;i++){ if (i+1 == SYSALIASESRowFactory.SYSALIASES_JAVACLASSNAME) { columnToReadSet.set(i); } columnToUpdateSet.set(i); } DataValueDescriptor[] rowTemplate = new DataValueDescriptor[SYSALIASESRowFactory.SYSALIASES_COLUMN_COUNT]; DataValueDescriptor[] replaceRow= new DataValueDescriptor[SYSALIASESRowFactory.SYSALIASES_COLUMN_COUNT]; ScanController sc= tc.openScan( ti.getHeapConglomerate(), false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_TABLE, TransactionController.ISOLATION_REPEATABLE_READ, columnToReadSet, null, ScanController.NA, null, null, ScanController.NA); while(sc.fetchNext(rowTemplate)){ for (int i=0; i<rowTemplate.length; i++) { if (i+1 == SYSALIASESRowFactory.SYSALIASES_JAVACLASSNAME) if(replaceRow[i] == null) { replaceRow[i] = new SQLLongvarchar("NULL"); } } sc.replace(replaceRow,columnToUpdateSet); } sc.close(); }

Target:
public void setJavaClassNameColumnInSysAliases(TransactionController tc) throws StandardException { TabInfoImpl ti = getNonCoreTI(SYSALIASES_CATALOG_NUM); faultInTabInfo(ti); FormatableBitSet columnToReadSet = new FormatableBitSet(SYSALIASESRowFactory.SYSALIASES_COLUMN_COUNT); FormatableBitSet columnToUpdateSet = new FormatableBitSet(SYSALIASESRowFactory.SYSALIASES_COLUMN_COUNT); for (int i = 0; i < SYSALIASESRowFactory.SYSALIASES_COLUMN_COUNT; i++) { columnToReadSet.set(i); columnToUpdateSet.set(i); } DataValueDescriptor[] rowTemplate = new DataValueDescriptor[SYSALIASESRowFactory.SYSALIASES_COLUMN_COUNT]; DataValueDescriptor[] replaceRow = new DataValueDescriptor[SYSALIASESRowFactory.SYSALIASES_COLUMN_COUNT]; ScanController sc = tc.openScan( ti.getHeapConglomerate(), false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_TABLE, TransactionController.ISOLATION_REPEATABLE_READ, columnToReadSet, null, ScanController.NA, null, null, ScanController.NA); while (sc.fetchNext(rowTemplate)) { for (int i = 0; i < rowTemplate.length; i++) { replaceRow[i] = rowTemplate[i].cloneValue(false); if (i + 1 == SYSALIASESRowFactory.SYSALIASES_JAVACLASSNAME && rowTemplate[i].isNull()) { replaceRow[i] = new SQLLongvarchar("NULL"); } } sc.replace(replaceRow, columnToUpdateSet); } sc.close(); }
Source:
public void beforeExecution(PreparedStatement stmt, StatementContext ctx) throws SQLException { this.context = ctx; if (!oraclePS.isAssignableFrom(stmt.getClass())) { try { final Method get_delegate = stmt.getClass().getMethod("getDelegate"); final Object candidate = get_delegate.invoke(stmt); if (!oraclePS.isAssignableFrom(candidate.getClass())) { throw new Exception("Obtained delegate, but it still wasn't an OraclePreparedStatement"); } else { this.stmt = candidate; } } catch (Exception e) { throw new IllegalStateException("Statement is not an OraclePreparedStatement, nor" + "one which we know how to find it from", e); } } else { this.stmt = stmt; } for (int[] bind : binds) { try { registerReturnParameter.invoke(this.stmt, bind[0], bind[1]); } catch (Exception e) { throw new RuntimeException(e); } } }

Target:
public void beforeExecution(PreparedStatement stmt, StatementContext ctx) throws SQLException { this.context = ctx; if (!stmt.isWrapperFor(OraclePreparedStatement.class)) { throw new IllegalStateException("Statement is not an instance of, nor a wrapper of, OraclePreparedStatement"); } this.stmt = stmt.unwrap(OraclePreparedStatement.class); for (int[] bind : binds) { try { this.stmt.registerReturnParameter(bind[0], bind[1]); } catch (Exception e) { throw new RuntimeException(e); } } }
Source:
public void replaceTitlesWithCaptions(String wikibaseIdentifier, int position) { compositeDisposable.add(mediaClient.getCaptionByWikibaseIdentifier(wikibaseIdentifier) .subscribeOn(ioScheduler) .observeOn(mainThreadScheduler) .timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS) .subscribe(subscriber -> { view.handleLabelforImage(subscriber, position); })); }

Target:
public void replaceTitlesWithCaptions(String wikibaseIdentifier, int position) { compositeDisposable.add(mediaClient.getCaptionByWikibaseIdentifier(wikibaseIdentifier) .subscribeOn(ioScheduler) .observeOn(mainThreadScheduler) .subscribe(caption -> { view.handleLabelforImage(caption, position); })); }
Source:
private String renderPopoverJs() { StringBuilder builder = new StringBuilder(); builder.append("var popup = " + getJsId() + ";"); builder.append("var element = popup.getElement();"); builder.append("$(element).popover('destroy');"); builder.append("popup.setPosition(" + position.renderJs() + ");"); builder.append("$(element).popover({"); if (titleModel != null) { builder.append("'title': '" + escapeQuoteJs(titleModel.getObject()) + "',"); } if (placement != null) { builder.append("'placement': '" + placement + "',"); } builder.append("'html': '" + html + "',"); if (html) { builder.append("'content': '" + escapeQuoteJs(model.getObject()) + "',"); } else { builder.append("'content': '" + Strings.escapeMarkup(model.getObject()) + "',"); } builder.append("});"); if(titleModel != null) { builder.append("$(element).attr('data-original-title', '" + escapeQuoteJs(titleModel.getObject()) + "');" ); } if (html) { builder.append("$(element).attr('data-content', '" + escapeQuoteJs(model.getObject()) + "');"); } else { builder.append("$(element).attr('data-content', '" + Strings.escapeMarkup(model.getObject()) + "');"); } return builder.toString(); }

Target:
private String renderPopoverJs() { StringBuilder builder = new StringBuilder(); builder.append("var popup = " + getJsId() + ";"); builder.append("var element = popup.getElement();"); builder.append("$(element).popover('destroy');"); builder.append("popup.setPosition(" + position.renderJs() + ");"); builder.append("$(element).popover({"); if (titleModel != null) { builder.append("'title': '" + escapeQuoteJs(titleModel.getObject()) + "',"); } if (placement != null) { builder.append("'placement': '" + placement + "',"); } builder.append("'html': '" + html + "',"); if (html) { builder.append("'content': '" + escapeQuoteJs(model.getObject()) + "',"); } else { builder.append("'content': '" + Strings.escapeMarkup(model.getObject()) + "',"); } builder.append("});"); if(titleModel != null) { builder.append("$(element).data('original-title', '"); builder.append(escapeQuoteJs(titleModel.getObject())); builder.append("');"); } if (html) { builder.append("$(element).attr('data-content', '" + escapeQuoteJs(model.getObject()) + "');"); } else { builder.append("$(element).attr('data-content', '" + Strings.escapeMarkup(model.getObject()) + "');"); } return builder.toString(); }
Source:
private Result<String> serviceExecution(ServiceEndPoint serviceEndPoint) { TimerContext totalTimeContext = _totalExecTimer.time(); try { TimerContext checkoutTimeContext = _checkoutTimer.time(); ServiceHandle<Service<String, String>> serviceHandle = _serviceCache.checkOut(serviceEndPoint); Service<String, String> service = serviceHandle.getService(); checkoutTimeContext.stop(); String work = serviceEndPoint.getPayload(); String result = service.process(work); TimerContext checkinTimeContext = _checkinTimer.time(); _serviceCache.checkIn(serviceHandle); checkinTimeContext.stop(); _serviceMeter.mark(); totalTimeContext.stop(); return _resultFactory.createResponse(result); } catch (Exception exception) { _serviceMeter.mark(); totalTimeContext.stop(); return _resultFactory.createResponse(exception); } }

Target:
private Result<String> serviceExecution(ServiceEndPoint serviceEndPoint) { Timer.Context totalTimeContext = _totalExecTimer.time(); try { Timer.Context checkoutTimeContext = _checkoutTimer.time(); ServiceHandle<Service<String, String>> serviceHandle = _serviceCache.checkOut(serviceEndPoint); Service<String, String> service = serviceHandle.getService(); checkoutTimeContext.stop(); String work = serviceEndPoint.getPayload(); String result = service.process(work); Timer.Context checkinTimeContext = _checkinTimer.time(); _serviceCache.checkIn(serviceHandle); checkinTimeContext.stop(); return _resultFactory.createResponse(result); } catch (Exception exception) { return _resultFactory.createResponse(exception); } finally { _serviceMeter.mark(); totalTimeContext.stop(); } }
Source:
public String getDescription() { final String description = translationService.getTranslation(FormEditorConstants.NewFormDefinitionlHandlerForm); return description != null && !description.isEmpty() ? description : "Form (Preview)"; }

Target:
public String getDescription() { return translationService.getTranslation(FormEditorConstants.NewFormDefinitionlHandlerForm); }
Source:
private String getUsername(HttpServletRequest request) { if (config.isUseAuditHttpHeaderName()) { return request.getHeader(config.getAuditHttpHeaderName()); } String user = request.getParameter("user"); String password = request.getParameter("password"); if (user != null && password != null) { return null; } return null; }

Target:
private String getUsername(HttpServletRequest request) { if (config.isUseAuditHttpHeaderName()) { return request.getHeader(config.getAuditHttpHeaderName()); } String user = request.getParameter("user"); String password = request.getParameter("password"); if (user != null && password != null) { return user; } return null; }
Source:
public Firmware getFirmware(FirmwareUID firmwareUID, Locale locale) { Preconditions.checkArgument(firmwareUID != null); if (locale == null) { locale = Locale.getDefault(); } String filename = firmwareFiles.get(firmwareUID); if (filename == null) { logger.debug("Cannot find firmware {}", firmwareUID); return null; } try { return getFirmware(firmwareUID, filename, locale); } catch (IOException e) { logger.error("Cannot find firmware " + firmwareUID, e); } return null; }

Target:
public Firmware getFirmware(FirmwareUID firmwareUID, Locale locale) { Preconditions.checkArgument(firmwareUID != null); if (locale == null) { locale = Locale.getDefault(); } String filename = firmwareFiles.get(firmwareUID); if (filename == null) { logger.debug("Cannot find firmware {}", firmwareUID); return null; } try { return getFirmware(firmwareUID, filename, locale); } catch (IOException e) { logger.debug("Cannot find firmware " + firmwareUID); } return null; }
Source:
public SAMRecordDuplicateComparator(final List<SAMFileHeader> headers) { for (SAMFileHeader header : headers) { populateLibraryIds(header); } }

Target:
public SAMRecordDuplicateComparator(final List<SAMFileHeader> headers) { populateLibraryIds(headers); }
Source:
protected SecurityGroup findSecurityGroupWithName(SecurityGroupExtension sgExt, String name) { Set<SecurityGroup> groups = sgExt.listSecurityGroups(); for (SecurityGroup g: groups) { if (name.equals(g.getName())) return g; } return null; }

Target:
protected SecurityGroup findSecurityGroupWithName(SecurityGroupExtension sgExt, String name) { Set<SecurityGroup> groups = sgExt.listSecurityGroups(); String nameAlt = name.startsWith("jclouds#") ? Strings.removeFromStart(name, "jclouds#") : "jclouds#"+name; for (SecurityGroup g: groups) { if (name.equals(g.getName())) return g; if (nameAlt.equals(g.getName())) return g; } return null; }
Source:
public void installNode_NodeIsInstalledToTargetDirectory() throws FrontendUtils.UnknownVersionException { String nodeExecutable = tools.installNode("v14.15.4", null); Assert.assertNotNull(nodeExecutable); List<String> nodeVersionCommand = new ArrayList<>(); nodeVersionCommand.add(nodeExecutable); nodeVersionCommand.add("--version"); FrontendVersion node = FrontendUtils.getVersion("node", nodeVersionCommand); Assert.assertEquals("14.15.4", node.getFullVersion()); FrontendTools newTools = new FrontendTools(vaadinHomeDir, null); List<String> npmVersionCommand = new ArrayList<>( newTools.getNpmExecutable()); npmVersionCommand.add("--version"); FrontendVersion npm = FrontendUtils.getVersion("npm", npmVersionCommand); Assert.assertEquals("6.14.6", npm.getFullVersion()); }

Target:
public void installNode_NodeIsInstalledToTargetDirectory() throws FrontendUtils.UnknownVersionException { String nodeExecutable = tools.installNode("v12.18.3", null); Assert.assertNotNull(nodeExecutable); List<String> nodeVersionCommand = new ArrayList<>(); nodeVersionCommand.add(nodeExecutable); nodeVersionCommand.add("--version"); FrontendVersion node = FrontendUtils.getVersion("node", nodeVersionCommand); Assert.assertEquals("12.18.3", node.getFullVersion()); FrontendTools newTools = new FrontendTools(vaadinHomeDir, null); List<String> npmVersionCommand = new ArrayList<>( newTools.getNpmExecutable()); npmVersionCommand.add("--version"); FrontendVersion npm = FrontendUtils.getVersion("npm", npmVersionCommand); Assert.assertEquals("6.14.6", npm.getFullVersion()); }
Source:
public long nodesGetCount( ) { long base = storeReadLayer.nodesGetCount(); return ktx.hasTxStateWithChanges() ? base + ktx.txState().addedAndRemovedNodes().delta() : base; }

Target:
public long nodesGetCount( ) { ktx.assertOpen(); long base = storeReadLayer.nodesGetCount(); return ktx.hasTxStateWithChanges() ? base + ktx.txState().addedAndRemovedNodes().delta() : base; }
Source:
public static ExportForms load(List<FormStatus> forms, BriefcasePreferences preferences) { Map<FormStatus, ExportConfiguration> configurations = new HashMap<>(); forms.forEach(form -> { ExportConfiguration configuration = ExportConfiguration.load(preferences, "custom_" + form.getFormName() + "_"); if (!configuration.isEmpty() && configuration.isValid()) configurations.put(form, configuration); }); return new ExportForms( forms, configurations ); }

Target:
public static ExportForms load(List<FormStatus> forms, BriefcasePreferences preferences) { Map<FormStatus, ExportConfiguration> configurations = new HashMap<>(); forms.forEach(form -> configurations.put( form, ExportConfiguration.load(preferences, "custom_" + form.getFormName() + "_") )); return new ExportForms( forms, configurations ); }
Source:
private boolean hasTaskExecuted(Long taskID) { Set<TaskActivityType> activityTypes = new HashSet<>(); activityTypes.add(TaskActivityType.SUCCESS); QueryParams queryParams = new QueryParams((Order) null); List<TaskActivity> taskActivities = taskActivitiesDataService.byTaskAndActivityTypes(taskID, activityTypes, queryParams); return taskActivities.size() == 1 ? true : false; }

Target:
private boolean hasTaskExecuted(Long taskID) { Set<TaskActivityType> activityTypes = new HashSet<>(); activityTypes.add(TaskActivityType.SUCCESS); QueryParams queryParams = new QueryParams((Order) null); List<TaskActivity> taskActivities = taskActivitiesDataService.byTaskAndActivityTypes(taskID, activityTypes, queryParams); return taskActivities.size() == 1; }
Source:
public int saveAnswer(IAnswerData answer, FormIndex index, boolean evaluateConstraints) { ACRAUtil.addCustomData(ACRAUtil.LAST_ANSWER_DATA, (answer == null ? "null" : answer.getDisplayText())); ACRAUtil.addCustomData(ACRAUtil.LAST_INDEX, index.toString()); try { if (evaluateConstraints) { return mFormController.answerQuestion(index, answer); } else { mFormController.saveAnswer(index, answer); return FormEntryController.ANSWER_OK; } } catch(XPathException e) { createErrorDialog("There is a bug in one of your form's XPath Expressions \n" + e.getMessage(), EXIT); return FormEntryController.ANSWER_OK; } }

Target:
public int saveAnswer(IAnswerData answer, FormIndex index, boolean evaluateConstraints) { try { if (evaluateConstraints) { return mFormController.answerQuestion(index, answer); } else { mFormController.saveAnswer(index, answer); return FormEntryController.ANSWER_OK; } } catch(XPathException e) { createErrorDialog("There is a bug in one of your form's XPath Expressions \n" + e.getMessage(), EXIT); return FormEntryController.ANSWER_OK; } }
Source:
public void testChannelPromiseWithAutoReadClosed() { final List<Long> inboundMsgs = new ArrayList<Long>(); EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandlerAdapter() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { inboundMsgs.add((Long) msg); } }); channel.config().setAutoRead(false); assertEquals(0, inboundMsgs.size()); ChannelFuture channelFuture = channel.writeOneInbound(1L, channel.newPromise()); assertFalse(channelFuture.isDone()); channel.config().setAutoRead(true); assertEquals(1, inboundMsgs.size()); assertTrue(channelFuture.isDone()); assertTrue(channelFuture.isSuccess()); channel.finish(); }

Target:
public void testChannelPromiseWithAutoReadClosed() { final List<Long> inboundMsgs = new ArrayList<Long>(); EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandlerAdapter() { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { inboundMsgs.add((Long) msg); } }); channel.config().setAutoRead(false); assertEquals(0, inboundMsgs.size()); ChannelFuture channelFuture = channel.writeOneInbound(1L, channel.newPromise()); assertFalse(channelFuture.isDone()); channel.config().setAutoRead(true); assertEquals(1, inboundMsgs.size()); assertTrue(channelFuture.isDone()); assertTrue(channelFuture.isSuccess()); assertFalse(channel.finish()); }