auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
protected <P> APIResponse doRequest(final String method, final String url, final P payload) throws GeneralException { HttpURLConnection connection = null; InputStream inputStream = null; if (METHOD_PATCH.equals(method)) { allowPatchRequestsIfNeeded(); } try { connection = getConnection(url, payload, method); int status = connection.getResponseCode(); if (APIResponse.isSuccessStatus(status)) { inputStream = connection.getInputStream(); } else { inputStream = connection.getErrorStream(); } return new APIResponse(readToEnd(inputStream), status); } catch (IOException ioe) { throw new GeneralException(ioe); } finally { saveClose(inputStream); if (connection != null) { connection.disconnect(); } } }

Target:
protected <P> APIResponse doRequest(final String method, final String url, final P payload) throws GeneralException { HttpURLConnection connection = null; InputStream inputStream = null; if (METHOD_PATCH.equalsIgnoreCase(method)) { allowPatchRequestsIfNeeded(); } try { connection = getConnection(url, payload, method); int status = connection.getResponseCode(); if (APIResponse.isSuccessStatus(status)) { inputStream = connection.getInputStream(); } else { inputStream = connection.getErrorStream(); } return new APIResponse(readToEnd(inputStream), status); } catch (IOException ioe) { throw new GeneralException(ioe); } finally { saveClose(inputStream); if (connection != null) { connection.disconnect(); } } }
Source:
protected boolean setAndValidateDiskProfiles() { setDiskProfileParameters(); final Map<Guid, DiskProfileValidator> diskProfileValidationMap = new HashMap<>(); for (final DiskImage diskImage : diskInfoDestinationMap.values()) { if (!diskProfileValidationMap.containsKey(diskImage.getDiskProfileId())) { diskProfileValidationMap.put(diskImage.getDiskProfileId(), new DiskProfileValidator(diskImage.getDiskProfileId())); } if (!validate(diskProfileValidationMap.get(diskImage.getDiskProfileId()) .isStorageDomainValid(diskImage.getStorageIds() .get(0)))) { return false; } } return true; }

Target:
protected boolean setAndValidateDiskProfiles() { setDiskProfileParameters(); final Set<Guid> diskProfilesSet = new HashSet<>(); for (final DiskImage diskImage : diskInfoDestinationMap.values()) { if (!diskProfilesSet.contains(diskImage.getDiskProfileId())) { diskProfilesSet.add(diskImage.getDiskProfileId()); if (!validate(new DiskProfileValidator(diskImage.getDiskProfileId()) .isStorageDomainValid(diskImage.getStorageIds() .get(0)))) { return false; } } } return true; }
Source:
public void interface_extension_with_overwritten_property() { Binder<InterfaceWithOverwrittenMethod> binder = new Binder<>(InterfaceWithOverwrittenMethod.class); }

Target:
public void interface_extension_with_overwritten_property() { Binder<TestInterfaceWithOverwrittenMethod> binder = new Binder<>( TestInterfaceWithOverwrittenMethod.class); IntegerTextField field = new IntegerTextField(); binder.bind(field, "property"); TestInterfaceWithOverwrittenMethod bean = new TestInterfaceWithOverwrittenMethod() { @Override public int getProperty() { return 5; } }; binder.setBean(bean); assertEquals(Integer.valueOf(5), field.getValue()); }
Source:
public GetInformationAboutUsersCurrentPlaybackRequest.Builder getInformationAboutUsersCurrentPlayback() { return new GetInformationAboutUsersCurrentPlaybackRequest.Builder(accessToken) .setDefaults(httpManager, scheme, host, port) .additionalTypes("episode"); }

Target:
public GetInformationAboutUsersCurrentPlaybackRequest.Builder getInformationAboutUsersCurrentPlayback() { return new GetInformationAboutUsersCurrentPlaybackRequest.Builder(accessToken) .setDefaults(httpManager, scheme, host, port); }
Source:
public Refund refund(APIContext apiContext, Refund refund) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } if (refund == null) { throw new IllegalArgumentException("refund cannot be null"); } apiContext.setRequestId(null); Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/sale/{0}/refund"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = refund.toJSON(); Refund refund1 = configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Refund.class); apiContext.setRequestId(null); return refund1; }

Target:
public Refund refund(APIContext apiContext, Refund refund) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } if (refund == null) { throw new IllegalArgumentException("refund cannot be null"); } apiContext.setRequestId(null); Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/sale/{0}/refund"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = refund.toJSON(); Refund refundResponse = configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Refund.class); apiContext.setRequestId(null); return refundResponse; }
Source:
public FireDepartmentMetrics getMetrics(String datasource) { List<FireChief> chiefsOfDatasource = chiefs.get(datasource); if (chiefsOfDatasource == null || chiefsOfDatasource.size() == 0) { return null; } return chiefsOfDatasource.get(0).getMetrics(); }

Target:
public FireDepartmentMetrics getMetrics(String datasource) { List<FireChief> chiefs = this.chiefs.get(datasource); if (chiefs == null) { return null; } FireDepartmentMetrics snapshot = null; for (FireChief chief : chiefs) { if (snapshot == null) { snapshot = chief.getMetrics().snapshot(); } else { snapshot.merge(chief.getMetrics()); } } return snapshot; }
Source:
private void writeToFileStorage(Multimap<String, Serializable> map, boolean unlockFlush){ long startTime = System.currentTimeMillis(); log.debug("Flush queue. flushId {}. Current queue size is {}", startTime, map.size()); try { for (String logFilePath : map.keySet()) { Collection<Serializable> fileQueue = map.get(logFilePath); if (fileQueue.isEmpty()) { continue; } OutputStream os = null; LogWriterOutput objectOutput = null; try { if (fileStorage.exists(logFilePath)) { os = fileStorage.append(logFilePath); } else { os = fileStorage.create(logFilePath); } os = new BufferedOutputStream(os); objectOutput = getOutput(os); for(Serializable serializable: fileQueue){ objectOutput.writeObject(serializable); } } finally { try { Closeables.closeQuietly(objectOutput); Closeables.close(os, true); } catch (IOException e) { log.error(e.getMessage(), e); } } } }catch (Exception e){ log.error("Error during saving data to fileStorage", e); } finally { log.debug("Flush queue finished. flushId {}.Flush took: {}", startTime, (System.currentTimeMillis() - startTime)); if (unlockFlush) synchronized (lock){ lock.notifyAll(); } } }

Target:
private void writeToFileStorage(Multimap<String, Serializable> map, boolean unlockFlush){ long startTime = System.currentTimeMillis(); log.debug("Flush queue. flushId {}. Current queue size is {}", startTime, map.size()); try { for (String logFilePath : map.keySet()) { Collection<Serializable> fileQueue = map.get(logFilePath); if (fileQueue.isEmpty()) { continue; } OutputStream os = null; LogWriterOutput objectOutput = null; try { if (fileStorage.exists(logFilePath)) { os = fileStorage.append(logFilePath); } else { os = fileStorage.create(logFilePath); } os = new BufferedOutputStream(os); objectOutput = getOutput(os); for(Serializable serializable: fileQueue){ objectOutput.writeObject(serializable); } }catch (Exception e){ log.error("Error during saving data with path to fileStorage", logFilePath, e); } finally { try { Closeables.closeQuietly(objectOutput); Closeables.close(os, true); } catch (IOException e) { log.error(e.getMessage(), e); } } } } finally { log.debug("Flush queue finished. flushId {}.Flush took: {}", startTime, (System.currentTimeMillis() - startTime)); if (unlockFlush) synchronized (lock){ lock.notifyAll(); } } }
Source:
public boolean addUser(Login user) throws UserLoginException { System.out.println("Inside loginserviceimpl of adduser()"); boolean isCreateUser = false; String passwordHash = null; String saltValue = null; System.out.println("before the dao call"+isCreateUser); try{ saltValue = passwordService.generateRandomSalt(); System.out.println("salt value from the loginserviceimpl" + saltValue); passwordHash = new String(passwordService.calculateHash(saltValue.getBytes(), user.getPassword().getBytes())); System.out.println("After generating password hash from impl class-------"); }catch(PasswordServiceException e){ throw new UserLoginException("Error while calculating hash.", e); } catch (IOException ex) { java.util.logging.Logger.getLogger(LoginServiceImpl.class.getName()).log(Level.SEVERE, null, ex); } System.out.println("generated passwordhash from loginserviceimpl...." + passwordHash); UserLogin userLoginEntity = new UserLogin(); System.out.println("user name for userlogin entity---"+user.getUserName()); userLoginEntity.setUserName(user.getUserName()); System.out.println("saltvalue for userlogin entity---"+saltValue); userLoginEntity.setSha1(passwordHash); userLoginEntity.setSalt(saltValue); isCreateUser = userLoginDAO.createUser(userLoginEntity); System.out.println("after the dao call"+isCreateUser); return isCreateUser; }

Target:
public boolean addUser(Login user) throws UserLoginException { boolean isCreateUser = false; String passwordHash = null; String saltValue = null; try { saltValue = passwordService.generateRandomSalt(); passwordHash = new String(passwordService.calculateHash(saltValue.getBytes(), user.getPassword().getBytes())); } catch (PasswordServiceException e) { throw new UserLoginException("Error while calculating hash.", e); } UserLogin userLoginEntity = new UserLogin(); userLoginEntity.setUserName(user.getUserName()); userLoginEntity.setSha1(passwordHash); userLoginEntity.setSalt(saltValue); isCreateUser = userLoginDAO.createUser(userLoginEntity); return isCreateUser; }
Source:
public DeployVirtualMachineOptions apply(CloudStackTemplateOptions templateOptions, Map<String, Network> networks, String zoneId, DeployVirtualMachineOptions options) { checkArgument(templateOptions.getSecurityGroupIds().isEmpty(), "security groups cannot be specified for locations (zones) that use advanced networking"); if (templateOptions.getNetworks().size() > 0) { options.networkIds(templateOptions.getNetworks()); } else if (templateOptions.getIpsToNetworks().isEmpty()) { checkArgument(!networks.isEmpty(), "please setup a network for zone: " + zoneId); Network defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), and(defaultNetworkInZone(zoneId), supportsStaticNAT())), null); if (defaultNetworkInZone == null) { defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), isIsolatedNetwork()), null); } if (defaultNetworkInZone == null) { throw new IllegalArgumentException("please choose a specific network in zone " + zoneId + ": " + networks); } else { options.networkId(defaultNetworkInZone.getId()); } } return options; }

Target:
public DeployVirtualMachineOptions apply(CloudStackTemplateOptions templateOptions, Map<String, Network> networks, String zoneId, DeployVirtualMachineOptions options) { checkArgument(templateOptions.getSecurityGroupIds().isEmpty(), "security groups cannot be specified for locations (zones) that use advanced networking"); if (!templateOptions.getNetworks().isEmpty()) { options.networkIds(templateOptions.getNetworks()); } else if (templateOptions.getIpsToNetworks().isEmpty()) { checkArgument(!networks.isEmpty(), "please setup a network for zone: " + zoneId); Network defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), and(defaultNetworkInZone(zoneId), supportsStaticNAT())), null); if (defaultNetworkInZone == null) { defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), isIsolatedNetwork()), null); } if (defaultNetworkInZone == null) { throw new IllegalArgumentException("please choose a specific network in zone " + zoneId + ": " + networks); } else { options.networkId(defaultNetworkInZone.getId()); } } return options; }
Source:
public static String getHumanishName(String aPath) { if ("".equals(aPath)) { throw new IllegalArgumentException(); } String path = aPath; int s = path.lastIndexOf('/'); if (s != -1) path = path.substring(s + 1); if (path.endsWith(DOT_GIT)) { if (path.equals(DOT_GIT)) throw new IllegalArgumentException(); path = path.substring(0, path.length() - DOT_GIT.length()); } return path; }

Target:
public static String getHumanishName(String aPath) throws IllegalArgumentException { if ("".equals(aPath)) throw new IllegalArgumentException(); if (aPath.equals(DOT_GIT)) throw new IllegalArgumentException(); String[] elements = aPath.split("/"); String lastSegment = elements[elements.length - 1]; String result = lastSegment; if (lastSegment.endsWith(DOT_GIT)) result = lastSegment.substring(0, lastSegment.length() - DOT_GIT.length()); if (result.equals("")) result = elements[elements.length - 2]; if ("".equals(result)) throw new IllegalArgumentException(); return result; }
Source:
private void configureSSLServerSocket(SSLServerSocket sslServerSocket) { SSLParameters sslParameters = sslServerSocket.getSSLParameters(); sslParameters.setNeedClientAuth(true); if (cipherSuites != null) { LOG.debug("Setup cipher suites for server socket: {}", Arrays.toString(cipherSuites)); sslParameters.setCipherSuites(cipherSuites); } sslServerSocket.setSSLParameters(sslParameters); }

Target:
private void configureSSLServerSocket(SSLServerSocket sslServerSocket) { SSLParameters sslParameters = sslServerSocket.getSSLParameters(); sslParameters.setNeedClientAuth(true); LOG.debug("Setup cipher suites for server socket: {}", Arrays.toString(cipherSuites)); sslParameters.setCipherSuites(cipherSuites); sslServerSocket.setSSLParameters(sslParameters); }
Source:
public void loggedInUserPropertyFalseTest() throws Exception { context.turnOffAuthorisationSystem(); configurationService.setProperty("webui.user.assumelogin", false); context.restoreAuthSystemState(); String token = getAuthToken(admin.getEmail(), password); getClient(token).perform(get("/api/authn/status") .header("X-On-Behalf-Of", eperson.getID())) .andExpect(status().isBadRequest()); context.turnOffAuthorisationSystem(); configurationService.setProperty("webui.user.assumelogin", true); context.restoreAuthSystemState(); }

Target:
public void loggedInUserPropertyFalseTest() throws Exception { configurationService.setProperty("webui.user.assumelogin", false); String token = getAuthToken(admin.getEmail(), password); getClient(token).perform(get("/api/authn/status") .header("X-On-Behalf-Of", eperson.getID())) .andExpect(status().isBadRequest()); }
Source:
private void startUpdateTask(final String taskName, final String fileName) { try { this.getContainer().run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { synchronized (BatchImportTraceWizard.this) { SubMonitor sm; sm = SubMonitor.convert(monitor); sm.setTaskName(taskName); sm.setWorkRemaining(TOTALWORK); if (updateFiles(sm, fileName).getSeverity() == IStatus.CANCEL) { ; } sm.done(); } } }); } catch (InvocationTargetException e) { } catch (InterruptedException e) { } finally { } }

Target:
private void startUpdateTask(final String taskName, final String fileName) { try { this.getContainer().run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { synchronized (BatchImportTraceWizard.this) { SubMonitor sm; sm = SubMonitor.convert(monitor); sm.setTaskName(taskName); sm.setWorkRemaining(TOTALWORK); if (updateFiles(sm, fileName).getSeverity() == IStatus.CANCEL) { } sm.done(); } } }); } catch (InvocationTargetException e) { } catch (InterruptedException e) { } finally { } }
Source:
public Map<String, Object> modelAttributes(String identifier, Species species, List<BioentityPropertyName> orderedPropertyNames, String entityName, Map<BioentityPropertyName, Set<String>> propertyValuesByType) { addDesignElements(identifier, propertyValuesByType); Map<String, Object> result = new HashMap<>(); result.put("entityBriefName", StringUtils.isEmpty(entityName) ? identifier : entityName); result.put("entityFullName", StringUtils.isEmpty(entityName) ? identifier : MessageFormat.format("{0} ({1})", identifier, entityName)); result.put("bioEntityDescription", getBioEntityDescription(propertyValuesByType)); result.put("propertyNames", propertiesWeWillDisplay(orderedPropertyNames, propertyValuesByType)); result.put("bioentityProperties", GSON.toJson(bioentityProperties(identifier, species, orderedPropertyNames, propertyValuesByType))); result.put("gene_id",identifier); return result; }

Target:
public Map<String, Object> modelAttributes(String identifier, Species species, List<BioentityPropertyName> orderedPropertyNames, String entityName, Map<BioentityPropertyName, Set<String>> propertyValuesByType) { addDesignElements(identifier, propertyValuesByType); Map<String, Object> result = new HashMap<>(); result.put("entityBriefName", StringUtils.isEmpty(entityName) ? identifier : entityName); result.put("entityFullName", StringUtils.isEmpty(entityName) ? identifier : MessageFormat.format("{0} ({1})", identifier, entityName)); result.put("bioEntityDescription", getBioEntityDescription(propertyValuesByType)); result.put("propertyNames", propertiesWeWillDisplay(orderedPropertyNames, propertyValuesByType)); result.put("bioentityProperties", GSON.toJson(bioentityProperties(identifier, species, orderedPropertyNames, propertyValuesByType))); return result; }
Source:
public int errorType() { final String errorType = headers.get(ERROR_TYPE); if (errorType == null) { throw new IllegalStateException("Message is not an error"); } try { return Integer.parseInt(errorType); } catch (NumberFormatException e) { throw new IllegalStateException("Error type must be a number"); } }

Target:
public int errorType() { String errorType = headers.get(ERROR_TYPE); if (errorType == null) { return -1; } try { return Integer.parseInt(errorType); } catch (NumberFormatException e) { throw new IllegalStateException("Error type must be a number"); } }
Source:
@BeforeClass public static void beforeClass() throws UnknownHostException, MalformedURLException { String ipAddress = startAppiumServer(); if (service == null || !service.isRunning()) { throw new AppiumServerHasNotBeenStartedLocallyException("An appium server node is not started!"); } DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Safari"); capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.IOS_XCUI_TEST); capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11.3"); capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 8"); driver = new IOSDriver<>(new URL("http://" + ipAddress + ":4723/wd/hub"), capabilities); }

Target:
@BeforeClass public static void beforeClass() throws UnknownHostException, MalformedURLException { String ipAddress = startAppiumServer(); if (service == null || !service.isRunning()) { throw new AppiumServerHasNotBeenStartedLocallyException("An appium server node is not started!"); } DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Safari"); capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.IOS_XCUI_TEST); capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11.3"); capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 8"); driver = new IOSDriver<>(new URL("http://" + ipAddress + ":" + PORT + "/wd/hub"), capabilities); }
Source:
public void setUp() { cp = new ClassPath(getPath("ant_project")); }

Target:
public void setUp() { cp = new ClassPath(TestUtils.getPath(getClass(), "ant_project")); }
Source:
public RestParameter( String name, Object object) { this.name = name; if (object instanceof Collection) { StringBuilder stringBuilder = new StringBuilder(); String separator = ""; for (Object element : (Collection) object) { stringBuilder.append(separator).append(element); separator = ","; } stringValue = stringBuilder.toString(); } else if (object != null) { this.stringValue = object.toString(); } else { stringValue = ""; } }

Target:
public RestParameter( String name, Object object) { this.name = name; if (object instanceof Collection) { StringBuilder stringBuilder = new StringBuilder(); String separator = ""; for (Object element : (Collection<?>) object) { stringBuilder.append(separator).append(element); separator = ","; } stringValue = stringBuilder.toString(); } else if (object != null) { this.stringValue = object.toString(); } else { stringValue = ""; } }
Source:
public static boolean remuxFile(java.io.File inputFile, java.io.File outputFile, int outputFormat, boolean isTV) { java.io.FileInputStream inputStream = null; java.io.BufferedOutputStream outputStream = null; Remuxer2 remuxer = null; try { inputStream = new java.io.FileInputStream(inputFile); outputStream = new java.io.BufferedOutputStream(new java.io.FileOutputStream(outputFile)); remuxer = openRemuxer(REMUX_TS, outputFormat, isTV ? StreamFormat.ATSC : StreamFormat.FREE, SubFormat.UNKNOWN, TuneStringType.CHANNEL, 0, 0, 0, 0, 0, outputStream); if (remuxer == null) return false; byte[] buf = new byte[8084]; int numRead = 0; while ((numRead = inputStream.read(buf)) != -1) { if (remuxer.pushInitData(buf, 0, numRead)) break; } inputStream.close(); inputStream = new java.io.FileInputStream(inputFile); while ((numRead = inputStream.read(buf)) != -1) { remuxer.pushRemuxData(buf, 0, numRead); } } catch (Exception e) { System.out.println("ERROR with remuxing of: " + e); e.printStackTrace(System.out); return false; } finally { if (inputStream != null) { try { inputStream.close(); } catch (Exception e) { } } if (outputStream != null) { try { outputStream.close(); } catch (Exception e) { } } if (remuxer != null) remuxer.close(); } return true; }

Target:
public static boolean remuxFile(java.io.File inputFile, java.io.File outputFile, int outputFormat, boolean isTV) { java.io.FileInputStream inputStream = null; java.io.BufferedOutputStream outputStream = null; Remuxer2 remuxer = null; try { inputStream = new java.io.FileInputStream(inputFile); outputStream = new java.io.BufferedOutputStream(new java.io.FileOutputStream(outputFile)); remuxer = openRemuxer(REMUX_TS, outputFormat, isTV ? StreamFormat.ATSC : StreamFormat.FREE, SubFormat.UNKNOWN, TuneStringType.CHANNEL, 0, 0, 0, 0, 0, outputStream); if (remuxer == null) return false; byte[] buf = new byte[43 * 188]; int numRead = 0; while ((numRead = inputStream.read(buf)) != -1) { if (remuxer.pushInitData(buf, 0, numRead)) break; } inputStream.close(); inputStream = new java.io.FileInputStream(inputFile); while ((numRead = inputStream.read(buf)) != -1) { remuxer.pushRemuxData(buf, 0, numRead); } } catch (Exception e) { System.out.println("ERROR with remuxing of: " + e); e.printStackTrace(System.out); return false; } finally { if (inputStream != null) { try { inputStream.close(); } catch (Exception e) { } } if (outputStream != null) { try { outputStream.close(); } catch (Exception e) { } } if (remuxer != null) remuxer.close(); } return true; }
Source:
public PageFunctionCompiler(Metadata metadata, int expressionCacheSize) { this.metadata = requireNonNull(metadata, "metadata is null"); this.determinismEvaluator = new DeterminismEvaluator(metadata.getFunctionRegistry()); if (expressionCacheSize > 0) { projectionCache = CacheBuilder.newBuilder().recordStats().maximumSize(expressionCacheSize).build( new CacheLoader<RowExpression, Supplier<PageProjection>>() { @Override public Supplier<PageProjection> load(RowExpression projection) throws Exception { return compileProjectionInternal(projection, Optional.empty()); } }); projectionCacheStats = new CacheStatsMBean(projectionCache); } else { projectionCache = null; projectionCacheStats = null; } if (expressionCacheSize > 0) { filterCache = CacheBuilder.newBuilder().recordStats().maximumSize(expressionCacheSize).build( new CacheLoader<RowExpression, Supplier<PageFilter>>() { @Override public Supplier<PageFilter> load(RowExpression projection) throws Exception { return compileFilterInternal(projection, Optional.empty()); } }); filterCacheStats = new CacheStatsMBean(filterCache); } else { filterCache = null; filterCacheStats = null; } }

Target:
public PageFunctionCompiler(Metadata metadata, int expressionCacheSize) { this.metadata = requireNonNull(metadata, "metadata is null"); this.determinismEvaluator = new DeterminismEvaluator(metadata.getFunctionRegistry()); if (expressionCacheSize > 0) { projectionCache = CacheBuilder.newBuilder() .recordStats() .maximumSize(expressionCacheSize) .build(CacheLoader.from(projection -> compileProjectionInternal(projection, Optional.empty()))); projectionCacheStats = new CacheStatsMBean(projectionCache); } else { projectionCache = null; projectionCacheStats = null; } if (expressionCacheSize > 0) { filterCache = CacheBuilder.newBuilder() .recordStats() .maximumSize(expressionCacheSize) .build(CacheLoader.from(filter -> compileFilterInternal(filter, Optional.empty()))); filterCacheStats = new CacheStatsMBean(filterCache); } else { filterCache = null; filterCacheStats = null; } }
Source:
public void testSendAndReceiveNoOriginalContentType() throws Exception { Binder binder = getBinder(); BindingProperties producerBindingProperties = createProducerBindingProperties(createProducerProperties()); DirectChannel moduleOutputChannel = createBindableChannel("output", producerBindingProperties); QueueChannel moduleInputChannel = new QueueChannel(); Binding<MessageChannel> producerBinding = binder.bindProducer("bar.0", moduleOutputChannel, producerBindingProperties.getProducer()); Binding<MessageChannel> consumerBinding = binder.bindConsumer("bar.0", "testSendAndReceiveNoOriginalContentType", moduleInputChannel, createConsumerProperties()); binderBindUnbindLatency(); Message<?> message = MessageBuilder.withPayload("foo").setHeader(MessageHeaders.CONTENT_TYPE,MimeTypeUtils.TEXT_PLAIN).build(); moduleOutputChannel.send(message); Message<?> inbound = receive(moduleInputChannel); assertThat(inbound).isNotNull(); assertThat(inbound.getPayload()).isEqualTo("foo".getBytes()); assertThat(inbound.getHeaders().get(BinderHeaders.BINDER_ORIGINAL_CONTENT_TYPE)).isNull(); assertThat(inbound.getHeaders().get(MessageHeaders.CONTENT_TYPE).toString()).isEqualTo(MimeTypeUtils.TEXT_PLAIN_VALUE); producerBinding.unbind(); consumerBinding.unbind(); }

Target:
public void testSendAndReceiveNoOriginalContentType() throws Exception { Binder binder = getBinder(); BindingProperties producerBindingProperties = createProducerBindingProperties( createProducerProperties()); DirectChannel moduleOutputChannel = createBindableChannel("output", producerBindingProperties); QueueChannel moduleInputChannel = new QueueChannel(); Binding<MessageChannel> producerBinding = binder.bindProducer("bar.0", moduleOutputChannel, producerBindingProperties.getProducer()); Binding<MessageChannel> consumerBinding = binder.bindConsumer("bar.0", "testSendAndReceiveNoOriginalContentType", moduleInputChannel, createConsumerProperties()); binderBindUnbindLatency(); Message<?> message = MessageBuilder.withPayload("foo") .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN).build(); moduleOutputChannel.send(message); Message<?> inbound = receive(moduleInputChannel); assertThat(inbound).isNotNull(); assertThat(inbound.getPayload()).isEqualTo("foo".getBytes()); assertThat(inbound.getHeaders().get(MessageHeaders.CONTENT_TYPE).toString()) .isEqualTo(MimeTypeUtils.TEXT_PLAIN_VALUE); producerBinding.unbind(); consumerBinding.unbind(); }
Source:
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { DMNModelInstrumentedBase obj = createModelObject(); assignAttributes(reader, obj); if (extensionRegisters.size() == 0) { while (reader.hasMoreChildren()) { reader.moveDown(); String nodeName = reader.getNodeName(); reader.moveUp(); } } else { while (reader.hasMoreChildren()) { reader.moveDown(); String nodeName = reader.getNodeName(); if (EXTERNAL_LINKS.equals(nodeName)) { while (reader.hasMoreChildren()) { reader.moveDown(); nodeName = reader.getNodeName(); Object object = getObject(reader, context, obj); reader.moveUp(); assignChildElement(obj, nodeName, object); } } else { try { Object object = getObject(reader, context, obj); assignChildElement(obj, nodeName, object); } catch (CannotResolveClassException e) { LOG.debug("Tried to convert the extension element child {}, but no converter is registered for this child.", nodeName); } } reader.moveUp(); } } return obj; }

Target:
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { DMNModelInstrumentedBase obj = createModelObject(); assignAttributes(reader, obj); if (extensionRegisters.size() == 0) { while (reader.hasMoreChildren()) { reader.moveDown(); String nodeName = reader.getNodeName(); reader.moveUp(); } } else { while (reader.hasMoreChildren()) { reader.moveDown(); String nodeName = reader.getNodeName(); if (Objects.equals(EXTERNAL_LINKS, nodeName)) { while (reader.hasMoreChildren()) { reader.moveDown(); nodeName = reader.getNodeName(); Object object = getObject(reader, context, obj); reader.moveUp(); assignChildElement(obj, nodeName, object); } } else { try { Object object = getObject(reader, context, obj); assignChildElement(obj, nodeName, object); } catch (CannotResolveClassException e) { LOG.debug("Tried to convert the extension element child {}, but no converter is registered for this child.", nodeName); } } reader.moveUp(); } } return obj; }
Source:
public void testFullGroupItem() { Item baseItem = mock(Item.class); GroupFunction mockFunction = mock(GroupFunction.class); Item resItem = itemRegistry.newItemBuilder("Group", "test") .withCategory("category") .withGroups("a", "b") .withLabel("label") .withBaseItem(baseItem) .withGroupFunction(mockFunction) .build(); assertEquals(GroupItem.class, resItem.getClass()); GroupItem res = (GroupItem) resItem; verifyNoMoreInteractions(mockFactory); assertEquals("category", res.getCategory()); assertEquals(Arrays.asList("a", "b"), res.getGroupNames()); assertEquals("label", res.getLabel()); assertSame(mockFunction, res.getFunction()); assertSame(baseItem, res.getBaseItem()); }

Target:
public void testFullGroupItem() { Item baseItem = mock(Item.class); GroupFunction mockFunction = mock(GroupFunction.class); Item resItem = itemRegistry.newItemBuilder("Group", "test") .withCategory("category") .withGroups(Arrays.asList("a", "b")) .withLabel("label") .withBaseItem(baseItem) .withGroupFunction(mockFunction) .build(); assertEquals(GroupItem.class, resItem.getClass()); GroupItem res = (GroupItem) resItem; verifyNoMoreInteractions(mockFactory); assertEquals("category", res.getCategory()); assertEquals(Arrays.asList("a", "b"), res.getGroupNames()); assertEquals("label", res.getLabel()); assertSame(mockFunction, res.getFunction()); assertSame(baseItem, res.getBaseItem()); }
Source:
private void updateMainList(List<AppInfo> apps) { if (apps != null) { if (apps.size() > 0) { footer.setVisibility(View.VISIBLE); } adapter.setAppInfos(apps); adapter.notifyDataSetChanged(); Date lastUpdateDate = null; for (int i = 0; i < apps.size(); i++) { Date dateObject = apps.get(i).getLastUpdate(); if (lastUpdateDate == null || lastUpdateDate.before(dateObject)) { lastUpdateDate = dateObject; } } if (lastUpdateDate != null) { statusText.setText(Preferences.getDateFormatLong(this).format(lastUpdateDate) + " " + timeFormat.format(lastUpdateDate)); } if (swipeRefresh != null) { swipeRefresh.setRefreshing(false); } } if (!(R.id.swipeRefresh == mainViewSwitcher.getCurrentView().getId())) { mainViewSwitcher.showNext(); } }

Target:
private void updateMainList(List<AppInfo> apps) { if (apps != null) { if (apps.size() > 0) { footer.setVisibility(View.VISIBLE); } adapter.setAppInfos(apps); adapter.notifyDataSetChanged(); Date lastUpdateDate = null; for (int i = 0; i < apps.size(); i++) { Date dateObject = apps.get(i).getLastUpdate(); if (lastUpdateDate == null || lastUpdateDate.before(dateObject)) { lastUpdateDate = dateObject; } } if (lastUpdateDate != null) { statusText.setText(Preferences.getDateFormatLong(this).format(lastUpdateDate) + " " + timeFormat.format(lastUpdateDate)); } } if (!(R.id.main_app_list == mainViewSwitcher.getCurrentView().getId())) { mainViewSwitcher.showNext(); } }
Source:
public static Map<String, String> load(final File secretsDir) throws DotRuntimeException { if (!secretsDir.exists()) { throw new DotRuntimeException("Unable to find any secrets under [" + SECRETS_DIR + "]"); } final File[] secretFiles = secretsDir.listFiles(); if (secretFiles == null || secretFiles.length == 0) { throw new DotRuntimeException("Unable to find any secrets under [" + SECRETS_DIR + "]"); } final Map<String, String> secrets = new HashMap<>(); for (final File file : secretFiles) { try { final String secret = new String(Files.readAllBytes(file.toPath())); final int index = secret.indexOf("="); if (index > 0){ secrets.put(file.getName(), secret.substring(index + 1)); } else { secrets.put(file.getName(), secret); } } catch (IOException e) { throw new DotRuntimeException( "Unable to load secret from file [" + file.getName() + "]", e); } } return secrets; }

Target:
public static Map<String, String> load(final File secretsDir) throws DotRuntimeException { if (!secretsDir.exists() || !secretsDir.canRead()) { throw new DotRuntimeException("Unable to find any secrets under [" + SECRETS_DIR + "]"); } final File[] secretFiles = secretsDir.listFiles(); if (secretFiles == null || secretFiles.length == 0) { throw new DotRuntimeException("Unable to find any secrets under [" + SECRETS_DIR + "]"); } final Map<String, String> secrets = new HashMap<>(); for (final File file : secretFiles) { try { secrets.put(file.getName(), new String(Files.readAllBytes(file.toPath()))); } catch (IOException e) { throw new DotRuntimeException( "Unable to load secret from file [" + file.getName() + "]", e); } } return secrets; }
Source:
public Injector getInjector(IClass iClass) { Annotation annotation = AnnotationHelper.findAnnotationSuperClasses(Guice.class, iClass.getRealClass()); if (annotation == null) { return null; } if (iClass instanceof TestClass) { iClass = ((TestClass)iClass).getIClass(); } if (!(iClass instanceof ClassImpl)) { return null; } Injector parentInjector = ((ClassImpl)iClass).getParentInjector(); Guice guice = (Guice) annotation; List<Module> moduleInstances = Lists.newArrayList(getModules(guice, parentInjector, iClass.getRealClass())); Injector injector = context.getInjector(moduleInstances); if (injector == null) { injector = parentInjector.createChildInjector(moduleInstances); context.addInjector(moduleInstances, injector); } return injector; }

Target:
Injector getInjector(IClass iClass) { Annotation annotation = AnnotationHelper.findAnnotationSuperClasses(Guice.class, iClass.getRealClass()); if (annotation == null) { return null; } if (iClass instanceof TestClass) { iClass = ((TestClass)iClass).getIClass(); } if (!(iClass instanceof ClassImpl)) { return null; } Injector parentInjector = ((ClassImpl)iClass).getParentInjector(); Guice guice = (Guice) annotation; List<Module> moduleInstances = Lists.newArrayList(getModules(guice, parentInjector, iClass.getRealClass())); Injector injector = context.getInjector(moduleInstances); if (injector == null) { injector = parentInjector.createChildInjector(moduleInstances); context.addInjector(moduleInstances, injector); } return injector; }
Source:
public void grabCliJar() throws IOException { jar = tmp.newFile("jenkins-cli.jar"); FileUtils.copyURLToFile(j.jenkins.getJnlpJars("jenkins-cli.jar").getURL(), jar); }

Target:
public void grabCliJar() throws IOException { String jenkinsCLI = "jenkins-cli.jar"; jar = tmp.newFile(jenkinsCLI); FileUtils.copyURLToFile(j.jenkins.getJnlpJars(jenkinsCLI).getURL(), jar); }
Source:
private void analyzeReplDump(ASTNode ast) throws SemanticException { LOG.debug("ReplicationSemanticAnalyzer.analyzeReplDump: " + String.valueOf(dbNameOrPattern) + "." + String.valueOf(tblNameOrPattern) + " from " + String.valueOf(eventFrom) + " to " + String.valueOf(eventTo) + " maxEventLimit " + String.valueOf(maxEventLimit)); try { ctx.setResFile(ctx.getLocalTmpPath()); Task<ReplDumpWork> replDumpWorkTask = TaskFactory .get(new ReplDumpWork( dbNameOrPattern, tblNameOrPattern, eventFrom, eventTo, ErrorMsg.INVALID_PATH.getMsg(ast), maxEventLimit, ctx.getResFile().toUri().toString(), txnManager ), conf); rootTasks.add(replDumpWorkTask); if (dbNameOrPattern != null) { for (String dbName : Utils.matchesDb(db, dbNameOrPattern)) { if (tblNameOrPattern != null) { for (String tblName : Utils.matchesTbl(db, dbName, tblNameOrPattern)) { inputs.add(new ReadEntity(db.getTable(dbName, tblName))); } } else { inputs.add(new ReadEntity(db.getDatabase(dbName))); } } } setFetchTask(createFetchTask(dumpSchema)); } catch (Exception e) { LOG.warn("Error during analyzeReplDump", e); throw new SemanticException(e); } }

Target:
private void analyzeReplDump(ASTNode ast) throws SemanticException { LOG.debug("ReplicationSemanticAnalyzer.analyzeReplDump: " + String.valueOf(dbNameOrPattern) + "." + String.valueOf(tblNameOrPattern) + " from " + String.valueOf(eventFrom) + " to " + String.valueOf(eventTo) + " maxEventLimit " + String.valueOf(maxEventLimit)); try { ctx.setResFile(ctx.getLocalTmpPath()); Task<ReplDumpWork> replDumpWorkTask = TaskFactory .get(new ReplDumpWork( dbNameOrPattern, tblNameOrPattern, eventFrom, eventTo, ErrorMsg.INVALID_PATH.getMsg(ast), maxEventLimit, ctx.getResFile().toUri().toString() ), conf); rootTasks.add(replDumpWorkTask); if (dbNameOrPattern != null) { for (String dbName : Utils.matchesDb(db, dbNameOrPattern)) { if (tblNameOrPattern != null) { for (String tblName : Utils.matchesTbl(db, dbName, tblNameOrPattern)) { inputs.add(new ReadEntity(db.getTable(dbName, tblName))); } } else { inputs.add(new ReadEntity(db.getDatabase(dbName))); } } } setFetchTask(createFetchTask(dumpSchema)); } catch (Exception e) { LOG.warn("Error during analyzeReplDump", e); throw new SemanticException(e); } }
Source:
public SSLEngine wrapSslEngine(SSLEngine engine, ByteBufAllocator alloc, JdkApplicationProtocolNegotiator applicationNegotiator, boolean isServer) { if (Conscrypt.isEngineSupported(engine)) { return isServer ? ConscryptAlpnSslEngine.newServerEngine(engine, alloc, applicationNegotiator) : ConscryptAlpnSslEngine.newClientEngine(engine, alloc, applicationNegotiator); } if (jdkAlpnSupported()) { return new Java9SslEngine(engine, applicationNegotiator, isServer); } if (JettyAlpnSslEngine.isAvailable()) { return isServer ? JettyAlpnSslEngine.newServerEngine(engine, applicationNegotiator) : JettyAlpnSslEngine.newClientEngine(engine, applicationNegotiator); } throw new UnsupportedOperationException("ALPN not supported (used java version: " + PlatformDependent.javaVersion() + ", min java version: 9). Unable to wrap SSLEngine of type '" + engine.getClass().getName() + "')"); }

Target:
public SSLEngine wrapSslEngine(SSLEngine engine, ByteBufAllocator alloc, JdkApplicationProtocolNegotiator applicationNegotiator, boolean isServer) { if (Conscrypt.isEngineSupported(engine)) { return isServer ? ConscryptAlpnSslEngine.newServerEngine(engine, alloc, applicationNegotiator) : ConscryptAlpnSslEngine.newClientEngine(engine, alloc, applicationNegotiator); } if (JdkAlpnSslUtils.supportsAlpn()) { return new JdkAlpnSslEngine(engine, applicationNegotiator, isServer); } if (JettyAlpnSslEngine.isAvailable()) { return isServer ? JettyAlpnSslEngine.newServerEngine(engine, applicationNegotiator) : JettyAlpnSslEngine.newClientEngine(engine, applicationNegotiator); } throw new UnsupportedOperationException("ALPN not supported. Unable to wrap SSLEngine of type '" + engine.getClass().getName() + "')"); }
Source:
private static List<Pair> hopWindows(long tsMillis, long periodMillis, long sizeMillis) { ArrayList<Pair> ret = new ArrayList<>((int) (sizeMillis / periodMillis)); long lastStart = tsMillis - ((tsMillis + periodMillis) % periodMillis); for (long start = lastStart; start > tsMillis - sizeMillis; start -= periodMillis) { ret.add(new Pair(start, start + sizeMillis)); } return ret; }

Target:
private static List<Pair> hopWindows(long tsMillis, long periodMillis, long sizeMillis) { ArrayList<Pair> ret = new ArrayList<>(Math.toIntExact(sizeMillis / periodMillis)); long lastStart = tsMillis - ((tsMillis + periodMillis) % periodMillis); for (long start = lastStart; start > tsMillis - sizeMillis; start -= periodMillis) { ret.add(new Pair(start, start + sizeMillis)); } return ret; }
Source:
public void setupSearch() { new TeamWorldSearchItem("", getSelectedTeamDefinitions(), isIncludeCompletedCheckbox(), isIncludeCancelledCheckbox(), false, false, getSelectedVersionArtifact(), getSelectedUser(), getSelectedReleased(), getSelectedState()); }

Target:
public void setupSearch() { searchItem = new TeamWorldSearchItem("", getSelectedTeamDefinitions(), isIncludeCompletedCheckbox(), isIncludeCancelledCheckbox(), false, false, getSelectedVersionArtifact(), getSelectedUser(), getSelectedReleased(), getSelectedState()); }
Source:
public boolean isBelowGuaranteedConsumption() { return ResAllocsUtil.isLess(totals.asResAllocs(), totalResAllocs); }

Target:
public boolean isBelowGuaranteedConsumption() { return tierSlas.getTierSla(tierNumber) .flatMap(tierSla -> tierSla.getResAllocs(name)) .map(bucketRes -> ResAllocsUtil.isLess(totals.asResAllocs(), bucketRes)) .orElse(true); }
Source:
public void checkHttpProxy() { { String host = "my_host"; Map<String, Object> httpProxyMap = ImmutableMap.<String, Object>of("host", host); ConfigSource conf = config.deepCopy().set("http_proxy", httpProxyMap); S3PluginTask task = conf.loadConfig(S3PluginTask.class); assertHttpProxy(new HttpProxy(host, Optional.<Integer>absent(), Optional.<Boolean>absent(), Optional.<String>absent(), Optional.<String>absent()), task.getHttpProxy().get()); } { String host = "my_host"; int port = 8080; boolean useSsl = true; Map<String, Object> httpProxyMap = ImmutableMap.<String, Object>of( "host", host, "port", 8080, "https", true); ConfigSource conf = config.deepCopy().set("http_proxy", httpProxyMap); S3PluginTask task = conf.loadConfig(S3PluginTask.class); assertHttpProxy(new HttpProxy(host, Optional.of(port), Optional.of(true), Optional.<String>absent(), Optional.<String>absent()), task.getHttpProxy().get()); } { String host = "my_host"; int port = 8080; boolean useSsl = true; String user = "my_user"; String password = "my_pass"; Map<String, Object> httpProxyMap = ImmutableMap.<String, Object>of( "host", host, "port", 8080, "https", true, "user", user, "password", password); ConfigSource conf = config.deepCopy().set("http_proxy", httpProxyMap); S3PluginTask task = conf.loadConfig(S3PluginTask.class); assertHttpProxy(new HttpProxy(host, Optional.of(port), Optional.of(true), Optional.of(user), Optional.of(password)), task.getHttpProxy().get()); } }

Target:
public void checkHttpProxy() { { String host = "my_host"; ConfigSource conf = config.deepCopy().set("host", host); HttpProxy httpProxy = conf.loadConfig(HttpProxy.class); assertHttpProxy(host, Optional.<Integer>absent(), true, Optional.<String>absent(), Optional.<String>absent(), httpProxy); } { String host = "my_host"; ConfigSource conf = config.deepCopy() .set("host", host) .set("https", true); HttpProxy httpProxy = conf.loadConfig(HttpProxy.class); assertHttpProxy(host, Optional.<Integer>absent(), true, Optional.<String>absent(), Optional.<String>absent(), httpProxy); } { String host = "my_host"; ConfigSource conf = config.deepCopy() .set("host", host) .set("https", false); HttpProxy httpProxy = conf.loadConfig(HttpProxy.class); assertHttpProxy(host, Optional.<Integer>absent(), false, Optional.<String>absent(), Optional.<String>absent(), httpProxy); } { String host = "my_host"; int port = 8080; ConfigSource conf = config.deepCopy() .set("host", host) .set("port", port); HttpProxy httpProxy = conf.loadConfig(HttpProxy.class); assertHttpProxy(host, Optional.of(port), true, Optional.<String>absent(), Optional.<String>absent(), httpProxy); } { String host = "my_host"; int port = 8080; String user = "my_user"; String password = "my_pass"; ConfigSource conf = config.deepCopy() .set("host", host) .set("port", port) .set("user", user) .set("password", password); HttpProxy httpProxy = conf.loadConfig(HttpProxy.class); assertHttpProxy(host, Optional.of(port), true, Optional.of(user), Optional.of(password), httpProxy); } }
Source:
protected void setInitialCheckedState() { try { for (IDebugTarget target2 : getDebugTargets()) { IJavaDebugTarget target = target2.getAdapter(IJavaDebugTarget.class); if (target != null) { IJavaThread filteredThread= fPage.getBreakpoint().getThreadFilter(target); if (filteredThread != null) { fCheckHandler.checkThread(filteredThread, true); } } } } catch (CoreException e) { JDIDebugUIPlugin.log(e); } }

Target:
protected void setInitialCheckedState() { try { for (IDebugTarget debugTarget : getDebugTargets()) { IJavaDebugTarget target = debugTarget.getAdapter(IJavaDebugTarget.class); if (target != null) { IJavaThread filteredThread= fPage.getBreakpoint().getThreadFilter(target); if (filteredThread != null) { fCheckHandler.checkThread(filteredThread, true); } } } } catch (CoreException e) { JDIDebugUIPlugin.log(e); } }
Source:
private void removeNotesView(Card[] cards) { List<Integer> posList = new ArrayList<>(); long reviewerCardId = getReviewerCardId(); for (Card card : cards) { int pos = getPosition(getCards(), card.getId()); if (card.getId() == reviewerCardId) { mReloadRequired = true; } if (pos >= 0 && pos < getCards().size()) { posList.add(pos); } } Collections.sort(posList, Collections.reverseOrder()); for (int delPos : posList) { getCards().remove(delPos); } updateList(); }

Target:
private void removeNotesView(Card[] cards) { List<Integer> posList = new ArrayList<>(); long reviewerCardId = getReviewerCardId(); Map<Long, Integer> idToPos = getPositionMap(getCards()); for (Card card : cards) { int pos = idToPos.containsKey(card.getId()) ? idToPos.get(card.getId()) : -1; if (card.getId() == reviewerCardId) { mReloadRequired = true; } if (pos >= 0 && pos < getCards().size()) { posList.add(pos); } } Collections.sort(posList, Collections.reverseOrder()); for (int delPos : posList) { getCards().remove(delPos); } updateList(); }