auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public static Resource getResource(final String filePath) { return new WritableResource() { @Override public File getFile() { final String filename = getFilename(); if (filename != null) { return new File(filename); } return null; } @Override public InputStream getInputStream() throws IOException { return getInputStreamFromName(filePath); } @Override public String getFilename() { String filename = null; final String prefix = extractPrefix(filePath); if (prefix == null) { filename = filePath; } else if (prefix.equals(RESOURCE_PREFIX) || prefix.equals(CLASSPATH_PREFIX)) { final String path = filePath.substring(prefix.length() + 1); final URL url; if (prefix.equals(RESOURCE_PREFIX)) { url = CommonHelper.class.getResource(startWithSlash(path)); } else { url = Thread.currentThread().getContextClassLoader().getResource(path); } if (url == null) { throw new TechnicalException("Do not use the resource: or classpath: prefix for non-existing files. Use a direct path (relative or absolute, no prefix)"); } filename = url.toString().substring(5); } logger.debug("filepath: -> filename: {}", filePath, filename); return filename; } @Override public boolean exists() { final File f = getFile(); if (f != null) { return f.exists(); } return true; } @Override public OutputStream getOutputStream() throws IOException { final String filename = getFilename(); if (filename != null) { return new FileOutputStream(filePath); } return null; } }; }

Target:
public static Resource getResource(final String filePath) { return new WritableResource() { @Override public File getFile() { final String filename = getFilename(); if (filename != null) { return new File(filename); } logger.warn("This filePath: is not a file. Returning null in the getFile() method", filePath); return null; } @Override public InputStream getInputStream() throws IOException { return getInputStreamFromName(filePath); } @Override public String getFilename() { String filename = null; final String prefix = extractPrefix(filePath); if (prefix == null) { filename = filePath; } else if (prefix.equals(RESOURCE_PREFIX) || prefix.equals(CLASSPATH_PREFIX)) { final String path = filePath.substring(prefix.length() + 1); final URL url; if (prefix.equals(RESOURCE_PREFIX)) { url = CommonHelper.class.getResource(startWithSlash(path)); } else { url = Thread.currentThread().getContextClassLoader().getResource(path); } if (url == null) { throw new TechnicalException("Do not use the resource: or classpath: prefix for non-existing files. Use a direct path (relative or absolute, no prefix)"); } filename = url.toString().substring(5); } logger.debug("filepath: -> filename: {}", filePath, filename); return filename; } @Override public boolean exists() { final File f = getFile(); if (f != null) { return f.exists(); } return true; } @Override public OutputStream getOutputStream() throws IOException { final String filename = getFilename(); if (filename != null) { return new FileOutputStream(filePath); } return null; } }; }
Source:
public static void refreshReloadableConfigsInVdcOptionCache() { List<VdcOption> list = getVdcOptionDAO().getAll(); for (VdcOption option : list) { try { if (isReloadable(option.getoption_name())) { updateOption(option); } } catch (NoSuchFieldException e) { log.errorFormat("Not refreshing field {0}: does not exist in class ConfigValues.", option.getoption_name()); } } }

Target:
public static void refreshReloadableConfigsInVdcOptionCache() { List<VdcOption> list = getVdcOptionDAO().getAll(); for (VdcOption option : list) { try { if (isReloadable(option.getoption_name())) { updateOption(option); } } catch (NoSuchFieldException e) { log.errorFormat("Not refreshing field {0}: does not exist in class {1}.", option.getoption_name(), ConfigValues.class.getSimpleName()); } } }
Source:
private Collection<? extends IClasspathEntry> junitLauncher(IJavaProject javaProject, String version) throws JavaModelException { File projectDir = CorePlugin.getInstance().getStateLocation().append("junit5").toFile(); if (!projectDir.exists()) { if (!projectDir.mkdirs()) { throw new RuntimeException("Cannot create directory " + projectDir.getAbsolutePath()); } } File buildFile = new File(projectDir, "build.gradle"); String buildScript = "" + "plugins {\n" + " id 'java-library'\n" + "}\n" + "\n" + "repositories {\n" + " jcenter()\n" + "}\n" + "\n" + "dependencies {\n" + " testmplementation 'org.junit.platform:junit-platform-launcher:" + version + "'\n" + "}\n"; try { buildFile.createNewFile(); Files.write(buildFile.toPath(), buildScript.getBytes(), StandardOpenOption.WRITE); } catch (IOException e) { throw new UncheckedIOException(e); } GradleConnector connector = GradleConnector.newConnector(); try (ProjectConnection connection = connector.forProjectDirectory(projectDir).connect()) { EclipseProject eclipseProject = connection.getModel(EclipseProject.class); return collectExternalDependencies(this.projectContext, javaProject, eclipseProject.getClasspath()); } }

Target:
private Collection<? extends IClasspathEntry> junitLauncher(IJavaProject javaProject, String version) throws JavaModelException { File projectDir = CorePlugin.getInstance().getStateLocation().append("junit5").toFile(); if (!projectDir.exists()) { if (!projectDir.mkdirs()) { throw new RuntimeException("Cannot create directory " + projectDir.getAbsolutePath()); } } File buildFile = new File(projectDir, "build.gradle"); String buildScript = "" + "plugins {\n" + " id 'java-library'\n" + "}\n" + "\n" + "repositories {\n" + " jcenter()\n" + "}\n" + "\n" + "dependencies {\n" + " testImplementation 'org.junit.platform:junit-platform-launcher:" + version + "'\n" + "}\n"; try { buildFile.createNewFile(); Files.write(buildFile.toPath(), buildScript.getBytes(), StandardOpenOption.WRITE); } catch (IOException e) { throw new UncheckedIOException(e); } GradleConnector connector = GradleConnector.newConnector(); try (ProjectConnection connection = connector.forProjectDirectory(projectDir).connect()) { EclipseProject eclipseProject = connection.getModel(EclipseProject.class); return collectExternalDependencies(this.projectContext, javaProject, eclipseProject.getClasspath()); } }
Source:
public void testListMembers() { List<Member> members = api().list(); assertNotNull(members); assertTrue(members.size() > 0); for (Member member : members) { if (!member.id().equals(selfID)) { this.nonSelfMember = member; return; } } throw new RuntimeException("Could not find another member in cluster with different id"); }

Target:
public void testListMembers() { List<Member> members = api().list(); assertNotNull(members); assertTrue(members.size() > 0); for (Member member : members) { if (!member.id().equals(selfID)) { this.nonSelfMember = member; return; } } fail("Could not find another member in cluster with different id"); }
Source:
private static int execute(CommandSource sender, Collection<? extends Entity> entities, DimensionType dim, BlockPos pos) throws CommandSyntaxException { entities.removeIf(e -> !canEntityTeleport(e)); if (entities.isEmpty()) throw NO_ENTITIES.create(); entities.stream().filter(e -> e.dimension == dim).forEach(e -> sender.sendFeedback(new TranslationTextComponent("commands.forge.setdim.invalid.nochange", e.getDisplayName().getFormattedText(), dim), true)); entities.stream().filter(e -> e.dimension != dim).forEach(e -> e.changeDimension(dim, new PortallessTeleporter())); return 0; }

Target:
private static int execute(CommandSource sender, Collection<? extends Entity> entities, DimensionType dim, BlockPos pos) throws CommandSyntaxException { entities.removeIf(e -> !canEntityTeleport(e)); if (entities.isEmpty()) throw NO_ENTITIES.create(); entities.stream().filter(e -> e.dimension == dim).forEach(e -> sender.sendFeedback(new TranslationTextComponent("commands.forge.setdim.invalid.nochange", e.getDisplayName().getFormattedText(), dim), true)); entities.stream().filter(e -> e.dimension != dim).forEach(e -> e.changeDimension(dim, PORTALLESS)); return 0; }
Source:
public void createObjects(long reps) { for (long i = 0; i < reps; i++) { realm.where(AllTypes.class).findFirst(); } }

Target:
public void createObjects(long reps) { RealmResults<AllTypes> results = realm.where(AllTypes.class).findAll(); for (long i = 0; i < reps; i++) { results.first(); } }
Source:
protected List<String> getTokens() { List<String> allAliases = new ArrayList(); try { allAliases = aliasService.getAliasesForCluster(AliasService.NO_CLUSTER_NAME); allAliases.stream().filter(a -> a.contains("TOKEN_MAX_LIFETIME_POSTFIX")).map(a -> a.substring(0, a.indexOf("TOKEN_MAX_LIFETIME_POSTFIX"))) .collect(Collectors.toList()); } catch (AliasServiceException e) { log.errorAccessingTokenState(e); } return allAliases; }

Target:
protected List<String> getTokens() { List<String> allAliases = new ArrayList(); try { allAliases = aliasService.getAliasesForCluster(AliasService.NO_CLUSTER_NAME); allAliases = allAliases.stream().filter(a -> a.contains(TOKEN_MAX_LIFETIME_POSTFIX)).map(a -> a.substring(0, a.indexOf(TOKEN_MAX_LIFETIME_POSTFIX))) .collect(Collectors.toList()); } catch (AliasServiceException e) { log.errorEvictingTokens(e); } return allAliases; }
Source:
public int compareTo(Version o) { Integer majorInteger = new Integer(major); Integer minorInteger = new Integer(minor); Integer maintenanceInteger = new Integer(maintenance); Integer oMajorInteger = new Integer(o.major); Integer oMinorInteger = new Integer(o.minor); Integer oMaintenanceInteger = new Integer(o.maintenance); if (majorInteger.compareTo(oMajorInteger) == 0 && minorInteger.compareTo(oMinorInteger) == 0 && maintenanceInteger.compareTo(oMaintenanceInteger) == 0) { return 0; } else if (majorInteger.compareTo(oMajorInteger) == 0 && minorInteger.compareTo(oMinorInteger) == 0) { return maintenanceInteger.compareTo(oMaintenanceInteger); } else if (majorInteger.compareTo(oMajorInteger) == 0) { return minorInteger.compareTo(oMinorInteger); } return majorInteger.compareTo(oMajorInteger); }

Target:
public int compareTo(Version o) { if (major == o.major && minor == o.minor && maintenance == o.maintenance) { return 0; } else if (major == o.major && minor == o.minor) { return compareInts(maintenance, o.maintenance); } else if (major == o.major) { return compareInts(minor, o.minor); } return compareInts(major, o.major); }
Source:
private static void persistTopology(VDS vds, Map<String, VdsNetworkInterface> nicsByName) { InterfaceDao interfaceDAO = DbFacade.getInstance().getInterfaceDao(); List<VdsNetworkInterface> dbIfaces = interfaceDAO.getAllInterfacesForVds(vds.getId()); List<String> updatedIfaces = new ArrayList<String>(); List<VdsNetworkInterface> dbIfacesToBatch = new ArrayList<>(); Map<String, VdsNetworkInterface> hostNicsByNames = Entities.entitiesByName(vds.getInterfaces()); for (VdsNetworkInterface dbIface : dbIfaces) { if (hostNicsByNames.containsKey(dbIface.getName())) { VdsNetworkInterface vdsIface = hostNicsByNames.get(dbIface.getName()); vdsIface.setId(dbIface.getId()); vdsIface.setLabels(dbIface.getLabels()); dbIfacesToBatch.add(vdsIface); updatedIfaces.add(vdsIface.getName()); } else { interfaceDAO.removeInterfaceFromVds(dbIface.getId()); interfaceDAO.removeStatisticsForVds(dbIface.getId()); } } if (nicsByName != null) { updateInterfacesWithUserConfiguration(dbIfacesToBatch, nicsByName); updateInterfacesWithUserConfiguration(vds.getInterfaces(), nicsByName); } if (!dbIfacesToBatch.isEmpty()) { interfaceDAO.massUpdateInterfacesForVds(dbIfacesToBatch); } for (VdsNetworkInterface vdsIface : vds.getInterfaces()) { if (!updatedIfaces.contains(vdsIface.getName())) { interfaceDAO.saveInterfaceForVds(vdsIface); interfaceDAO.saveStatisticsForVds(vdsIface.getStatistics()); } } }

Target:
private static void persistTopology(VDS vds, Map<String, VdsNetworkInterface> nicsByName) { InterfaceDao interfaceDAO = DbFacade.getInstance().getInterfaceDao(); List<VdsNetworkInterface> dbIfaces = interfaceDAO.getAllInterfacesForVds(vds.getId()); List<String> updatedIfaces = new ArrayList<String>(); List<VdsNetworkInterface> dbIfacesToBatch = new ArrayList<>(); Map<String, VdsNetworkInterface> hostNicsByNames = Entities.entitiesByName(vds.getInterfaces()); for (VdsNetworkInterface dbIface : dbIfaces) { if (hostNicsByNames.containsKey(dbIface.getName())) { VdsNetworkInterface vdsIface = hostNicsByNames.get(dbIface.getName()); vdsIface.setId(dbIface.getId()); vdsIface.setLabels(dbIface.getLabels()); vdsIface.setQosOverridden(dbIface.isQosOverridden()); dbIfacesToBatch.add(vdsIface); updatedIfaces.add(vdsIface.getName()); } else { interfaceDAO.removeInterfaceFromVds(dbIface.getId()); interfaceDAO.removeStatisticsForVds(dbIface.getId()); } } if (nicsByName != null) { updateInterfacesWithUserConfiguration(dbIfacesToBatch, nicsByName); updateInterfacesWithUserConfiguration(vds.getInterfaces(), nicsByName); } if (!dbIfacesToBatch.isEmpty()) { interfaceDAO.massUpdateInterfacesForVds(dbIfacesToBatch); } for (VdsNetworkInterface vdsIface : vds.getInterfaces()) { if (!updatedIfaces.contains(vdsIface.getName())) { interfaceDAO.saveInterfaceForVds(vdsIface); interfaceDAO.saveStatisticsForVds(vdsIface.getStatistics()); } } }
Source:
public static void setTransparency( Element elem, int alpha ) { float ieVersion = getIEVersion(); if ( ieVersion >= 5.5 && ieVersion < 7.0 ) { elem = DOM.getChild( elem, 0 ); if ( map.containsKey( elem ) ) { if ( alpha == 100 ) { DOM.setStyleAttribute( elem, "filter", map.get( elem ) + "" ); } else { DOM.setStyleAttribute( elem, "filter", map.get( elem ) + ", progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ");" ); } } else { map.put( elem, DOM.getStyleAttribute( elem, "filter" ) ); if ( alpha == 100 ) { DOM.setStyleAttribute( elem, "filter", map.get( elem ) + "" ); } else { DOM.setStyleAttribute( elem, "filter", map.get( elem ) + ", progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ");" ); } } } else if ( ieVersion >= 7.0 ) { DOM.setStyleAttribute( elem, "filter", "alpha(opacity=" + alpha + ")" ); } else { DOM.setStyleAttribute( elem, "MozOpacity", "" + ( new Integer( alpha ).floatValue() / 100 ) + "" ); DOM.setStyleAttribute( elem, "opacity", "" + ( new Integer( alpha ).floatValue() / 100 ) + "" ); } }

Target:
public static void setTransparency( Element elem, int alpha ) { float ieVersion = getIEVersion(); if ( ieVersion >= 5.5 && ieVersion < 7.0 ) { elem = DOM.getChild( elem, 0 ); if ( map.containsKey( elem ) ) { if ( alpha == 100 ) { DOM.setStyleAttribute( elem, "filter", map.get( elem ) + "" ); } else { DOM.setStyleAttribute( elem, "filter", map.get( elem ) + ", progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ");" ); } } else { map.put( elem, DOM.getStyleAttribute( elem, "filter" ) ); if ( alpha == 100 ) { DOM.setStyleAttribute( elem, "filter", map.get( elem ) + "" ); } else { DOM.setStyleAttribute( elem, "filter", map.get( elem ) + ", progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ");" ); } } } else if ( ieVersion >= 7.0 ) { DOM.setStyleAttribute( elem, "filter", "alpha(opacity=" + alpha + ")" ); } else { DOM.setStyleAttribute( elem, "opacity", "" + ( new Integer( alpha ).floatValue() / 100 ) + "" ); } }
Source:
public String toString() { final ByteArrayOutputStream out = new ByteArrayOutputStream(); this.getSnapshot().dump(out); try { return out.toString(Charset.defaultCharset().name()); } catch (UnsupportedEncodingException e) { return super.toString(); } }

Target:
public String toString() { final ByteArrayOutputStream out = new ByteArrayOutputStream(); this.getSnapshot().dump(out); try { return out.toString(StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { return super.toString(); } }
Source:
public void testCreateAccount_WithMD5Password() throws JSONException { String userName = "TEST_USER_NAME"; String userNickName = "TEST_USER_NICK_NAME"; String userPassword = "93189e2c4c7b1a2c7b16a24d5daa98a9"; String userEmail = "TEST_USER_EMAIL"; long enbale = 1; JSONObject accountJSON = new JSONObject(); accountJSON.put(AccountJSONEnum.USERNAME, userName); accountJSON.put(AccountJSONEnum.NICK_NAME, userNickName); accountJSON.put(AccountJSONEnum.PASSWORD, userPassword); accountJSON.put(AccountJSONEnum.EMAIL, userEmail); accountJSON.put(AccountJSONEnum.ENABLE, enbale); Response response = mClient.target(BASE_URL) .path("accounts") .request() .post(Entity.text(accountJSON.toString())); AccountObject account = AccountObject.get(userName); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); assertEquals(userName, account.getUsername()); assertEquals(userNickName, account.getNickName()); assertEquals(userPassword, account.getPassword()); assertEquals(userEmail, account.getEmail()); assertEquals(true, account.getEnable()); }

Target:
public void testCreateAccount_WithMD5Password() throws JSONException { String userName = "TEST_USER_NAME"; String userNickName = "TEST_USER_NICK_NAME"; String userPassword = "93189e2c4c7b1a2c7b16a24d5daa98a9"; String userEmail = "TEST_USER_EMAIL"; int enbale = 1; JSONObject accountJSON = new JSONObject(); accountJSON.put(AccountJSONEnum.USERNAME, userName); accountJSON.put(AccountJSONEnum.NICK_NAME, userNickName); accountJSON.put(AccountJSONEnum.PASSWORD, userPassword); accountJSON.put(AccountJSONEnum.EMAIL, userEmail); accountJSON.put(AccountJSONEnum.ENABLE, enbale); Response response = mClient.target(BASE_URL) .path("accounts") .request() .post(Entity.text(accountJSON.toString())); AccountObject account = AccountObject.get(userName); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); assertEquals(userName, account.getUsername()); assertEquals(userNickName, account.getNickName()); assertEquals(userPassword, account.getPassword()); assertEquals(userEmail, account.getEmail()); assertEquals(true, account.getEnable()); }
Source:
public String getTempFileNames(TopicPartition topicPart) { if (tempFileNames.containsKey(topicPart)) { return tempFileNames.get(topicPart); } else { return null; } }

Target:
public String getTempFileNames(TopicPartition topicPart) { return tempFileNames.get(topicPart); }
Source:
public void deleteGroup(String key, IPerson deleter) { if (!canDeleteGroup(deleter, key)) { throw new RuntimeAuthorizationException(deleter, IPermission.DELETE_GROUP_ACTIVITY, key); } log.info("Deleting group with key " + key); IEntityGroup group = GroupService.findGroup(key); Iterator<IEntityGroup> iter = group.getParentGroups().iterator(); while (iter.hasNext()) { IEntityGroup parent = (IEntityGroup) iter.next(); parent.removeChild(group); parent.updateMembers(); } group.delete(); }

Target:
public void deleteGroup(String key, IPerson deleter) { if (!canDeleteGroup(deleter, key)) { throw new RuntimeAuthorizationException(deleter, IPermission.DELETE_GROUP_ACTIVITY, key); } log.info("Deleting group with key " + key); IEntityGroup group = GroupService.findGroup(key); for (IEntityGroup parent : group.getParentGroups()) { parent.removeChild(group); parent.updateMembers(); } group.delete(); }
Source:
public void evaluateIntermediate(int groupId, BlockBuilder output) { if (blockBuilders == null) { if (rawInputs == null) { return; } blockBuilders = new ObjectBigArray<>(); for (GroupIdPage groupIdPage : rawInputs) { Page page = groupIdPage.getPage(); GroupByIdBlock groupIdsBlock = groupIdPage.getGroupByIdBlock(); for (int position = 0; position < page.getPositionCount(); position++) { long currentGroupId = groupIdsBlock.getGroupId(position); blockBuilders.ensureCapacity(currentGroupId); RowBlockBuilder rowBlockBuilder = blockBuilders.get(currentGroupId); if (rowBlockBuilder == null) { rowBlockBuilder = new RowBlockBuilder(spillingTypes, null, (int) groupIdsBlock.getGroupCount()); } BlockBuilder currentOutput = rowBlockBuilder.beginBlockEntry(); for (int channel = 0; channel < spillingTypes.size(); channel++) { spillingTypes.get(channel).appendTo(page.getBlock(channel), position, currentOutput); } rowBlockBuilder.closeEntry(); blockBuilders.set(currentGroupId, rowBlockBuilder); } } rawInputs = null; rawInputsSize = 0; } BlockBuilder singleArrayBlockWriter = output.beginBlockEntry(); checkState(rawInputs == null && blockBuilders != null); checkState(singleArrayBlockWriter instanceof SingleArrayBlockWriter); RowBlock rowBlock = (RowBlock) blockBuilders.get((long) groupId).build(); for (int i = 0; i < rowBlock.getPositionCount(); i++) { singleArrayBlockWriter.appendStructure(rowBlock.getBlock(i)); } output.closeEntry(); }

Target:
public void evaluateIntermediate(int groupId, BlockBuilder output) { checkState(output instanceof ArrayBlockBuilder); if (blockBuilders == null) { checkState(rawInputs != null); blockBuilders = new ObjectBigArray<>(); for (int i = 0; i < rawInputsLength; i++) { GroupIdPage groupIdPage = rawInputs.get(i); Page page = groupIdPage.getPage(); GroupByIdBlock groupIdsBlock = groupIdPage.getGroupByIdBlock(); for (int position = 0; position < page.getPositionCount(); position++) { long currentGroupId = groupIdsBlock.getGroupId(position); blockBuilders.ensureCapacity(currentGroupId); RowBlockBuilder rowBlockBuilder = blockBuilders.get(currentGroupId); if (rowBlockBuilder == null) { rowBlockBuilder = new RowBlockBuilder(spillingTypes, null, (int) groupIdsBlock.getGroupCount()); } BlockBuilder currentOutput = rowBlockBuilder.beginBlockEntry(); for (int channel = 0; channel < spillingTypes.size(); channel++) { spillingTypes.get(channel).appendTo(page.getBlock(channel), position, currentOutput); } rowBlockBuilder.closeEntry(); blockBuilders.set(currentGroupId, rowBlockBuilder); } } rawInputs = null; rawInputsLength = 0; } BlockBuilder singleArrayBlockWriter = output.beginBlockEntry(); checkState(rawInputs == null && blockBuilders != null); RowBlock rowBlock = (RowBlock) blockBuilders.get(groupId).build(); for (int i = 0; i < rowBlock.getPositionCount(); i++) { singleArrayBlockWriter.appendStructure(rowBlock.getBlock(i)); } output.closeEntry(); }
Source:
public void scheduleTasks() { ScheduledExecutorService scheduledExecutorService = CoreUtils.createExecutor(); scheduledExecutorService.scheduleWithFixedDelay(new Runnable() { public void run() { dbCleanUpTask(); jwksRegenerationTask(); } }, configurationService.get().getDbCleanupIntervalInHours(), configurationService.get().getDbCleanupIntervalInHours(), TimeUnit.HOURS); }

Target:
public void scheduleTasks() { dbCleanUpTask(); jwksRegenerationTask(); }
Source:
public List<String> getDependencies() { List<String> dependencies = new ArrayList<String>(); dependencies.add(AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGID-namespace"); dependencies.add(AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGroupName-namespace"); dependencies.add(AttributesManager.NS_RESOURCE_ATTR_DEF + ":unixGID-namespace" + ":*"); dependencies.add(AttributesManager.NS_GROUP_ATTR_DEF + ":unixGID-namespace" + ":*"); dependencies.add(AttributesManager.NS_GROUP_ATTR_DEF + ":unixGroupName-namespace:*"); return dependencies; }

Target:
public List<String> getDependencies() { List<String> dependencies = new ArrayList<String>(); dependencies.add(AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGID-namespace"); dependencies.add(AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGroupName-namespace"); return dependencies; }
Source:
JSONArray getPlatformPluginUpdates() { try { return getPlatformPluginsForUpdate(getCurrentLevel(), Jenkins.getVersion()); } catch (IOException e) { throw new RuntimeException(e); } }

Target:
JSONArray getPlatformPluginUpdates() { final VersionNumber version = getCurrentLevel(); if (version == null) { return null; } return getPlatformPluginsForUpdate(version, Jenkins.getVersion()); }
Source:
public boolean isMain() { return main; }

Target:
public boolean isMain() { return name.equals("main") && getArity() == 1; }
Source:
public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) { if (!rawType.isEnum()) { return null; } final Class<Enum<?>> type = (Class<Enum<?>>) rawType; final Enum<?>[] constants = type.getEnumConstants(); final String parameterName = getParameterNameFromAnnotations(annotations).orElse("Parameter"); return new ParamConverter<T>() { @Override public T fromString(String value) { if (Strings.isNullOrEmpty(value)) { return null; } Enum<?> constant = Enums.fromStringFuzzy(value, constants); if (constant != null) { return (T) constant; } throw new WebApplicationException(getErrorResponse(String.format("%s must be one of [%s]", parameterName, Joiner.on(", ").join(constants)))); } @Override public String toString(T value) { return value.toString(); } protected Response getErrorResponse(String message) { return Response .status(400) .entity(new ErrorMessage(400, message)) .type(MediaType.APPLICATION_JSON_TYPE) .build(); } }; }

Target:
public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) { if (!rawType.isEnum()) { return null; } final Class<Enum<?>> type = (Class<Enum<?>>) rawType; final Enum<?>[] constants = type.getEnumConstants(); final String parameterName = getParameterNameFromAnnotations(annotations).orElse("Parameter"); return new ParamConverter<T>() { @Override public T fromString(String value) { if (Strings.isNullOrEmpty(value)) { return null; } final Enum<?> constant = Enums.fromStringFuzzy(value, constants); if (constant != null) { return (T) constant; } final String errMsg = String.format("%s must be one of [%s]", parameterName, JOINER.join(constants)); throw new WebApplicationException(getErrorResponse(errMsg)); } @Override public String toString(T value) { return value.toString(); } protected Response getErrorResponse(String message) { return Response .status(400) .entity(new ErrorMessage(400, message)) .type(MediaType.APPLICATION_JSON_TYPE) .build(); } }; }
Source:
public void pre(Span span, Exchange exchange, Endpoint endpoint) { span.setTag(Tags.COMPONENT.getKey(), CAMEL_COMPONENT + URI.create(endpoint.getEndpointUri()).getScheme()); span.setTag("camel.uri", endpoint.getEndpointUri()); }

Target:
public void pre(Span span, Exchange exchange, Endpoint endpoint) { span.setTag(Tags.COMPONENT.getKey(), CAMEL_COMPONENT + URI.create(endpoint.getEndpointUri()).getScheme()); span.setTag("camel.uri", URISupport.sanitizeUri(endpoint.getEndpointUri())); }
Source:
void enablePreview() { mPreview = new Preview.Builder() .setTargetName("Preview") .build(); Log.d(TAG, "enablePreview"); mPreview.setPreviewSurfaceProvider( (resolution, surfaceReleaseFuture) -> { mResolution = resolution; mSurfaceReleaseFuture = surfaceReleaseFuture; return CallbackToFutureAdapter.getFuture( completer -> { completer.addCancellationListener(() -> { Preconditions.checkState(mSurfaceCompleter == completer); mSurfaceCompleter = null; mSurfaceReleaseFuture = null; }, ContextCompat.getMainExecutor(mTextureView.getContext())); mSurfaceCompleter = completer; tryToProvidePreviewSurface(); return "provide preview surface"; }); }); mPreviewFrameCount.set(0); mViewIdlingResource.increment(); if (bindToLifecycleSafely(mPreview, R.id.PreviewToggle) == null) { mPreview = null; return; } }

Target:
void enablePreview() { mPreview = new Preview.Builder() .setTargetName("Preview") .build(); Log.d(TAG, "enablePreview"); mPreview.setPreviewSurfaceProvider( (resolution, surfaceReleaseFuture) -> { mResolution = resolution; mSurfaceReleaseFuture = surfaceReleaseFuture; return CallbackToFutureAdapter.getFuture( completer -> { completer.addCancellationListener(() -> { Preconditions.checkState(mSurfaceCompleter == completer); mSurfaceCompleter = null; mSurfaceReleaseFuture = null; }, ContextCompat.getMainExecutor(mTextureView.getContext())); mSurfaceCompleter = completer; tryToProvidePreviewSurface(); return "provide preview surface"; }); }); resetViewIdlingResource(); if (bindToLifecycleSafely(mPreview, R.id.PreviewToggle) == null) { mPreview = null; return; } }
Source:
protected SSLContext getSslContext(ElasticSearchClientConfig config) { checkDeprecatedProperties(); String trustStorePath = StringUtils.defaultIfBlank(config.getOption(TRUST_STORE_PATH_OPT), config.getOption(DEPRECATED_TRUST_STORE_PATH_OPT)); String trustStorePassword = StringUtils.defaultIfBlank(config.getOption(TRUST_STORE_PASSWORD_OPT), config.getOption(DEPRECATED_TRUST_STORE_PASSWORD_OPT)); String trustStoreType = StringUtils.defaultIfBlank(config.getOption(TRUST_STORE_TYPE_OPT), config.getOption(DEPRECATED_TRUST_STORE_TYPE_OPT)); String keyStorePath = config.getOption(KEY_STORE_PATH_OPT); String keyStorePassword = config.getOption(KEY_STORE_PASSWORD_OPT); String keyStoreType = config.getOption(KEY_STORE_TYPE_OPT); try { KeyStore trustStore = loadKeyStore(trustStorePath, trustStorePassword, trustStoreType); KeyStore keyStore = loadKeyStore(keyStorePath, keyStorePassword, keyStoreType); if (trustStore == null && keyStore == null) { return null; } SSLContextBuilder sslContextBuilder = SSLContexts.custom(); if (trustStore != null) { sslContextBuilder.loadTrustMaterial(trustStore, null); } if (keyStore != null) { sslContextBuilder.loadKeyMaterial(keyStore, keyStorePassword.toCharArray()); } return sslContextBuilder.build(); } catch (GeneralSecurityException | IOException e) { throw new NuxeoException("Cannot setup SSL for RestClient: " + config, e); } }

Target:
protected SSLContext getSslContext(ElasticSearchClientConfig config) { checkDeprecatedProperties(); String trustStorePath = StringUtils.defaultIfBlank(config.getOption(TRUST_STORE_PATH_OPT), config.getOption(DEPRECATED_TRUST_STORE_PATH_OPT)); String trustStorePassword = StringUtils.defaultIfBlank(config.getOption(TRUST_STORE_PASSWORD_OPT), config.getOption(DEPRECATED_TRUST_STORE_PASSWORD_OPT)); String trustStoreType = StringUtils.defaultIfBlank(config.getOption(TRUST_STORE_TYPE_OPT), config.getOption(DEPRECATED_TRUST_STORE_TYPE_OPT)); String keyStorePath = config.getOption(KEY_STORE_PATH_OPT); String keyStorePassword = config.getOption(KEY_STORE_PASSWORD_OPT); String keyStoreType = config.getOption(KEY_STORE_TYPE_OPT); try { KeyStore trustStore = loadKeyStore(trustStorePath, trustStorePassword, trustStoreType); KeyStore keyStore = loadKeyStore(keyStorePath, keyStorePassword, keyStoreType); if (trustStore == null && keyStore == null) { return null; } SSLContextBuilder sslContextBuilder = SSLContexts.custom(); if (trustStore != null) { sslContextBuilder.loadTrustMaterial(trustStore, null); } if (keyStore != null) { sslContextBuilder.loadKeyMaterial(keyStore, StringUtils.isBlank(keyStorePassword) ? null : keyStorePassword.toCharArray()); } return sslContextBuilder.build(); } catch (GeneralSecurityException | IOException e) { throw new NuxeoException("Cannot setup SSL for RestClient: " + config, e); } }
Source:
public void testAccessDenied() throws Exception { MockWebServer server = mockWebServer(); server.enqueue(new MockResponse().setBody(payloadFromResource("/access-denied.json"))); DigitalOceanApi api = api(server.getUrl("/")); ImageApi imageApi = api.getImageApi(); try { imageApi.list(); fail("Request should have failed"); } catch (Exception ex) { assertTrue(ex instanceof AuthorizationException, "Exception should be an AuthorizationException"); assertEquals(ex.getMessage(), "Access Denied"); } finally { api.close(); server.shutdown(); } }

Target:
public void testAccessDenied() throws Exception { MockWebServer server = mockWebServer(); server.enqueue(new MockResponse().setBody(payloadFromResource("/access-denied.json"))); DigitalOceanApi api = api(server.getUrl("/")); ImageApi imageApi = api.getImageApi(); try { imageApi.list(); fail("Request should have failed"); } catch (Exception ex) { assertTrue(ex instanceof AuthorizationException, "Exception should be an AuthorizationException"); assertEquals(ex.getMessage(), ACCESS_DENIED); } finally { api.close(); server.shutdown(); } }
Source:
public static void stopSenderInVMsAsync(String senderId, VM... vms) { List<AsyncInvocation> tasks = new LinkedList<>(); for (VM vm : vms) { tasks.add(vm.invokeAsync(() -> stopSender(senderId))); } for (AsyncInvocation invocation : tasks) { try { invocation.await(); } catch (InterruptedException e) { fail("Stopping senders was interrupted"); } } }

Target:
public static void stopSenderInVMsAsync(String senderId, VM... vms) { List<AsyncInvocation<Void>> tasks = new LinkedList<>(); for (VM vm : vms) { tasks.add(vm.invokeAsync(() -> stopSender(senderId))); } for (AsyncInvocation invocation : tasks) { try { invocation.await(); } catch (InterruptedException e) { fail("Stopping senders was interrupted"); } } }
Source:
private void processRequest(final ChannelHandlerContext ctx, final TNiftyTransport messageTransport) { final int responseSequenceId = dispatcherSequenceId.incrementAndGet(); if ((responseSequenceId > lastResponseWrittenId.get() + queuedResponseLimit) && ((Boolean) ctx.getAttachment() != Boolean.TRUE)) { ctx.setAttachment(Boolean.TRUE); ctx.getChannel().setReadable(false); } else if ((Boolean) ctx.getAttachment() == Boolean.TRUE) { ctx.setAttachment(Boolean.FALSE); ctx.getChannel().setReadable(true); } exe.execute(new Runnable() { @Override public void run() { TProtocol inProtocol = inProtocolFactory.getProtocol(messageTransport); TProtocol outProtocol = outProtocolFactory.getProtocol(messageTransport); try { processorFactory.getProcessor(messageTransport).process( inProtocol, outProtocol ); synchronized (responseMap) { ChannelBuffer response = messageTransport.getOutputBuffer(); int currentResponseId = lastResponseWrittenId.get() + 1; if (responseSequenceId != currentResponseId) { responseMap.put(responseSequenceId, response); } else { writeResponse(ctx, response, messageTransport.getTransportType()); } } } catch (TException e1) { log.error("Exception while invoking!", e1); closeChannel(ctx); } } private void writeResponse(final ChannelHandlerContext ctx, final ChannelBuffer outputBuffer, final ThriftTransportType transportType) { synchronized (responseMap) { ChannelBuffer response = outputBuffer; int currentResponseId = lastResponseWrittenId.get() + 1; if (responseSequenceId != currentResponseId) { responseMap.put(responseSequenceId, response); } else { do { response = addFraming(response, transportType); Channels.write(ctx.getChannel(), response); lastResponseWrittenId.incrementAndGet(); ++currentResponseId; response = responseMap.remove(currentResponseId); } while (null != response); } } } }); }

Target:
private void processRequest(final ChannelHandlerContext ctx, final TNiftyTransport messageTransport) { final int requestSequenceId = dispatcherSequenceId.incrementAndGet(); synchronized (responseMap) { if ((requestSequenceId > lastResponseWrittenId.get() + queuedResponseLimit) && !isChannelReadBlocked(ctx)) { blockChannelReads(ctx); } } exe.execute(new Runnable() { @Override public void run() { TProtocol inProtocol = inProtocolFactory.getProtocol(messageTransport); TProtocol outProtocol = outProtocolFactory.getProtocol(messageTransport); try { processorFactory.getProcessor(messageTransport).process( inProtocol, outProtocol ); writeResponse(ctx, messageTransport, requestSequenceId); } catch (TException e1) { log.error("Exception while invoking!", e1); closeChannel(ctx); } } }); }
Source:
public GitHubPRCause check(GitHubPRTrigger gitHubPRTrigger, @Nonnull GHPullRequest remotePR, @CheckForNull GitHubPRPullRequest localPR, TaskListener listener) throws IOException { if (isNull(number)) { listener.error(DISPLAY_NAME + ": number is null -> Bad configured event, skipping other checks."); return new GitHubPRCause(remotePR, "Bad configured " + DISPLAY_NAME + " event.", true); } if (isNull(remotePR)) { listener.error(DISPLAY_NAME + ": number is null -> Bad configured event, skipping other checks."); return new GitHubPRCause(remotePR, "Bad configured " + DISPLAY_NAME + " event.", true); } if (remotePR.getNumber() == getNumber()) { if (match) { return new GitHubPRCause(remotePR, "Number is matching " + remotePR.getNumber(), isSkip()); } } else if (!match) { return new GitHubPRCause(remotePR, "Number is not matching " + remotePR.getNumber(), isSkip()); } return null; }

Target:
public GitHubPRCause check(GitHubPRTrigger gitHubPRTrigger, @Nonnull GHPullRequest remotePR, @CheckForNull GitHubPRPullRequest localPR, TaskListener listener) throws IOException { if (isNull(number)) { listener.error(DISPLAY_NAME + ": number is null -> Bad configured event, skipping other checks."); return new GitHubPRCause(remotePR, "Bad configured " + DISPLAY_NAME + " event.", true); } if (isNull(remotePR)) { listener.error(DISPLAY_NAME + ": number is null -> Bad configured event, skipping other checks."); return new GitHubPRCause(remotePR, "Bad configured " + DISPLAY_NAME + " event.", true); } if (remotePR.getNumber() == getNumber()) { if (match) { return new GitHubPRCause(remotePR, "PR Number is matching #" + remotePR.getNumber(), isSkip()); } } else if (!match) { return new GitHubPRCause(remotePR, "PR Number is not matching #" + remotePR.getNumber(), isSkip()); } return null; }
Source:
private static void executeDeleteQuery(Connection conn, String query, int tenantId) throws Exception { PreparedStatement prepStmt = null; try { prepStmt = conn.prepareStatement(query); prepStmt.setInt(1, tenantId); prepStmt.executeUpdate(); } catch (SQLException e) { String errMsg = "Error executing query " + query + " for tenant: " + tenantId; log.error(errMsg, e); throw new Exception(errMsg, e); } finally { if (prepStmt != null) { prepStmt.close(); } } }

Target:
private void executeDeleteQuery(Connection conn, String query, int tenantId) throws SQLException { try (PreparedStatement prepStmt = conn.prepareStatement(query)) { prepStmt.setInt(1, tenantId); prepStmt.executeUpdate(); } catch (SQLException e) { String errMsg = "Error executing query " + query + " for tenant: " + tenantId; log.error(errMsg, e); throw e; } }
Source:
public void testSpecialCharactersInId() { StubSecureCredentialsStore store = new StubSecureCredentialsStore("<LINK_0> 1"); assertEquals("<LINK_0> 1", store.getId()); assertEquals("http:\\2f\\2fci.mylyn.org\\2ftest 1", store.getSecurePreferences().name()); store = new StubSecureCredentialsStore("<LINK_1>\u00E7\u00F1\u00FC"); assertEquals("<LINK_1>\u00E7\u00F1\u00FC", store.getId()); assertEquals("http%3A%2F%2Fci.mylyn.org%2F%C3%A7%C3%B1%C3%BC", store.getSecurePreferences().name()); store = new StubSecureCredentialsStore("\uABCD \u1F00"); assertEquals("\uABCD \u1F00", store.getId()); assertEquals("%EA%AF%8D++%E1%BC%80", store.getSecurePreferences().name()); }

Target:
public void testSpecialCharactersInId() { StubSecureCredentialsStore store = createStubSecureCredentialsStore("<LINK_0> 1"); assertEquals("<LINK_0> 1", store.getId()); assertEquals("http:\\2f\\2fci.mylyn.org\\2ftest 1", store.getSecurePreferences().name()); store = createStubSecureCredentialsStore("<LINK_1>\u00E7\u00F1\u00FC"); assertEquals("<LINK_1>\u00E7\u00F1\u00FC", store.getId()); assertEquals("http%3A%2F%2Fci.mylyn.org%2F%C3%A7%C3%B1%C3%BC", store.getSecurePreferences().name()); store = createStubSecureCredentialsStore("\uABCD \u1F00"); assertEquals("\uABCD \u1F00", store.getId()); assertEquals("%EA%AF%8D++%E1%BC%80", store.getSecurePreferences().name()); }
Source:
public void loadTree(final File treeFile) throws FileNotFoundException { String fileString = null; try (Scanner sc = new Scanner(treeFile).useDelimiter("\\Z")) { fileString = sc.next(); } catch (FileNotFoundException e) { throw e; } PhylogeneticTreeParser np = new PhylogeneticTreeParser(fileString); tree = np.getRoot(); notifyChanged(); }

Target:
public void loadTree(final File treeFile) throws FileNotFoundException { String fileString = null; try (Scanner sc = new Scanner(treeFile).useDelimiter("\\Z")) { fileString = sc.next(); } catch (FileNotFoundException e) { throw e; } tree = PhylogeneticTreeParser.parse(fileString); notifyChanged(); }
Source:
public <P> RecipientListRouterSpec recipient(String channelName, GenericSelector<P> selector) { MessageSelector messageSelector; if (selector instanceof MessageSelector) { messageSelector = (MessageSelector) selector; } else { messageSelector = new MethodInvokingSelector(new LambdaMessageProcessor(selector, null)); } this.target.addRecipient(channelName, messageSelector); return _this(); }

Target:
public <P> RecipientListRouterSpec recipient(String channelName, GenericSelector<P> selector) { MessageSelector messageSelector; if (selector instanceof MessageSelector) { messageSelector = (MessageSelector) selector; } else { messageSelector = isLambda(selector) ? new MethodInvokingSelector(new LambdaMessageProcessor(selector, null)) : new MethodInvokingSelector(selector); } this.target.addRecipient(channelName, messageSelector); return _this(); }
Source:
public RefactoringStatus checkInitialConditions(IProgressMonitor monitor) throws CoreException, OperationCanceledException { SubMonitor subMonitor = SubMonitor.convert(monitor, 12); RefactoringStatus status = super.checkInitialConditions(subMonitor.split(8)); if (status.hasError()) { return status; } if (selectedRegion == null) { status.addFatalError(Messages.ExtractConstantRefactoring_LiteralMustBeSelected); return status; } IASTExpression selectedExpression = findSelectedExpression(subMonitor.split(1)); if (selectedExpression == null) { status.addFatalError(Messages.ExtractConstantRefactoring_LiteralMustBeSelected); return status; } if (!isExtractableExpression(selectedExpression)) { status.addFatalError(Messages.ExtractConstantRefactoring_LiteralMustBeSelected); } Collection<IASTLiteralExpression> literalExpressionCollection = findAllLiterals(subMonitor.split(1)); if (literalExpressionCollection.isEmpty()) { status.addFatalError(Messages.ExtractConstantRefactoring_LiteralMustBeSelected); return status; } target = selectedExpression; if (info.getName().isEmpty()) { info.setName(getDefaultName(target)); } info.setMethodContext(NodeHelper.findMethodContext(target, refactoringContext, subMonitor.split(1))); IScope containingScope = CPPVisitor.getContainingScope(target); IASTTranslationUnit ast = target.getTranslationUnit(); info.setNameUsedChecker((String name) -> { IBinding[] bindingsForName = containingScope.find(name, ast); return bindingsForName.length != 0; }); subMonitor.split(1); return status; }

Target:
public RefactoringStatus checkInitialConditions(IProgressMonitor monitor) throws CoreException, OperationCanceledException { SubMonitor subMonitor = SubMonitor.convert(monitor, 12); RefactoringStatus status = super.checkInitialConditions(subMonitor.split(8)); if (status.hasError()) { return status; } if (selectedRegion == null) { status.addFatalError(Messages.ExtractConstantRefactoring_LiteralMustBeSelected); return status; } IASTExpression selectedExpression = findSelectedExpression(subMonitor.split(1)); if (selectedExpression == null) { status.addFatalError(Messages.ExtractConstantRefactoring_LiteralMustBeSelected); return status; } if (!isExtractableExpression(selectedExpression)) { status.addFatalError(Messages.ExtractConstantRefactoring_LiteralMustBeSelected); } Collection<IASTLiteralExpression> literalExpressionCollection = findAllLiterals(subMonitor.split(1)); if (literalExpressionCollection.isEmpty()) { status.addFatalError(Messages.ExtractConstantRefactoring_LiteralMustBeSelected); return status; } target = selectedExpression; if (info.getName().isEmpty()) { info.setName(getDefaultName(target)); } info.setMethodContext(NodeHelper.findMethodContext(target, refactoringContext, subMonitor.split(1))); subMonitor.split(1); IScope containingScope = CPPVisitor.getContainingScope(target); IASTTranslationUnit ast = target.getTranslationUnit(); info.setNameUsedChecker((String name) -> { IBinding[] bindingsForName = containingScope.find(name, ast); return bindingsForName.length != 0; }); return status; }
Source:
public String deconstructSearchQuery(String searchQuery) { ArrayList<String> features = new ArrayList<>(); if (searchQuery.isEmpty()) { features.add("is null"); return features.toString(); } switch(searchQuery) { case "": features.add("is empty"); break; case "*": features.add("is just *"); break; case "?": features.add("is just ?"); break; case "~": features.add("is just ~"); break; case "searchTerms": features.add("is searchTerms"); break; } if (features.size() > 0) { return features.toString(); } if (searchQuery.contains("@")) { features.add("has @"); } if (searchQuery.contains("prefix:")) { features.add("is prefix"); } if (searchQuery.contains("insource:")) { features.add("is insource"); } if (searchQuery.contains("incategory:")) { features.add("is incategory"); } if (searchQuery.contains("intitle:")) { features.add("is intitle"); } if (searchQuery.substring(0, 1).equals("~")) { features.add("forces search results"); } if (searchQuery.substring(searchQuery.length() - 1).equals("?")) { features.add("ends with ?"); } for (SearchQueryFeatureRegex f : SearchQueryFeatureRegex.values()) { if (f.getPattern().matcher(searchQuery).find()) { features.add(f.getDescription()); } } int doubleQuotesCount = searchQuery.length() - searchQuery.replace("\"", "").length(); if (doubleQuotesCount > 0) { if (doubleQuotesCount == 1) { features.add("has one double quote"); } features.add((doubleQuotesCount % 2) == 0 ? "has even double quotes" : "has odd double quotes"); } if (features.size() == 0) { features.add("is simple"); } return features.toString(); }

Target:
public String deconstructSearchQuery(String searchQuery) { ArrayList<String> features = new ArrayList<>(); if (searchQuery == null) { features.add("is null"); return features.toString(); } switch(searchQuery) { case "": features.add("is empty"); break; case "*": features.add("is just *"); break; case "?": features.add("is just ?"); break; case "~": features.add("is just ~"); break; case "searchTerms": features.add("is searchTerms"); break; } if (features.size() > 0) { return features.toString(); } if (searchQuery.contains("@")) { features.add("has @"); } if (searchQuery.contains("prefix:")) { features.add("is prefix"); } if (searchQuery.contains("insource:")) { features.add("is insource"); } if (searchQuery.contains("incategory:")) { features.add("is incategory"); } if (searchQuery.contains("intitle:")) { features.add("is intitle"); } if (searchQuery.substring(0, 1).equals("~")) { features.add("forces search results"); } if (searchQuery.endsWith("?")) { features.add("ends with ?"); } for (SearchQueryFeatureRegex f : SearchQueryFeatureRegex.values()) { if (f.getPattern().matcher(searchQuery).find()) { features.add(f.getDescription()); } } int doubleQuotesCount = searchQuery.length() - searchQuery.replace("\"", "").length(); if (doubleQuotesCount > 0) { if (doubleQuotesCount == 1) { features.add("has one double quote"); } features.add((doubleQuotesCount % 2) == 0 ? "has even double quotes" : "has odd double quotes"); } if (features.size() == 0) { features.add("is simple"); } return features.toString(); }
Source:
public List<HeadersRequest> split(int maxCount) { if (this.hash != null) return Collections.<HeadersRequest>singletonList(this); List<HeadersRequest> ret = new ArrayList<>(); while(count > 0) { int reqSize = Math.min(maxCount, count); ret.add(new HeadersRequestImpl(start, reqSize, reverse)); count -= reqSize; if (reverse) start -= reqSize; else start += reqSize; } return ret; }

Target:
public List<HeadersRequest> split(int maxCount) { if (this.hash != null) return Collections.<HeadersRequest>singletonList(this); List<HeadersRequest> ret = new ArrayList<>(); int remaining = count; while(remaining > 0) { int reqSize = Math.min(maxCount, remaining); ret.add(new HeadersRequestImpl(start, reqSize, reverse)); remaining -= reqSize; start = reverse ? start - reqSize : start + reqSize; } return ret; }