auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void commitWithMessageShouldReturnTheTransaction() throws Exception { ByteArrayOutputStream bodyOutput = new ByteArrayOutputStream(); String responseString = "{ \"id\": \"foobar\" }"; MockRestAdapter<Transaction> adapter = new MockRestAdapter<>("foobar", responseString, null); adapter.request(new RepromiseFunction<UpholdRestAdapter, Transaction>() { @Override public Promise<Transaction> call(UpholdRestAdapter adapter) { Transaction transaction = Fixtures.loadTransaction(new HashMap<String, String>() {{ put("transactionStatus", "pending"); put("originCardId", "foo"); put("transactionId", "bar"); }}); transaction.setUpholdRestAdapter(adapter); return transaction.commit(new TransactionCommitRequest("foobar")); } }); Header otpHeader = null; Request request = adapter.getRequest(); Transaction transaction = adapter.getResult(); for (Header header : request.getHeaders()) { if (header.getName().compareToIgnoreCase("OTP-Token") == 0) { otpHeader = header; break; } } request.getBody().writeTo(bodyOutput); Assert.assertEquals(request.getUrl(), String.format("%s/v0/me/cards/foo/transactions/bar/commit", BuildConfig.API_SERVER_URL)); Assert.assertEquals(request.getMethod(), "POST"); Assert.assertNull(otpHeader); Assert.assertEquals(transaction.getId(), "foobar"); Assert.assertEquals(bodyOutput.toString(), "{\"message\":\"foobar\"}"); }

Target:
public void commitWithMessageShouldReturnTheTransaction() throws Exception { ByteArrayOutputStream bodyOutput = new ByteArrayOutputStream(); String responseString = "{ \"id\": \"foobar\" }"; MockRestAdapter<Transaction> adapter = new MockRestAdapter<>("foobar", responseString, null); adapter.request(new RepromiseFunction<UpholdRestAdapter, Transaction>() { @Override public Promise<Transaction> call(UpholdRestAdapter adapter) { Transaction transaction = Fixtures.loadTransaction(new HashMap<String, String>() {{ put("transactionStatus", "pending"); put("originCardId", "foo"); put("transactionId", "bar"); }}); transaction.setUpholdRestAdapter(adapter); return transaction.commit(new TransactionCommitRequest("foobar")); } }); Header otpHeader = null; Request request = adapter.getRequest(); Transaction transaction = adapter.getResult(); for (Header header : request.getHeaders()) { if ("OTP-Token".equalsIgnoreCase(header.getName())) { otpHeader = header; break; } } request.getBody().writeTo(bodyOutput); Assert.assertEquals(request.getUrl(), String.format("%s/v0/me/cards/foo/transactions/bar/commit", BuildConfig.API_SERVER_URL)); Assert.assertEquals(request.getMethod(), "POST"); Assert.assertNull(otpHeader); Assert.assertEquals(transaction.getId(), "foobar"); Assert.assertEquals(bodyOutput.toString(), "{\"message\":\"foobar\"}"); }
Source:
public boolean performDexOpt(String packageName) { enforceSystemOrRoot("Only the system can request dexopt be performed"); PackageParser.Package p; synchronized (mPackages) { p = mPackages.get(packageName); if (p == null) { return false; } p.mLastPackageUsageTimeInMills = System.currentTimeMillis(); mPackageUsage.write(); if (p.mDexOptUnneeded) { return false; } } synchronized (mInstallLock) { return performDexOptLI(p, false , false , true ) == DEX_OPT_PERFORMED; } }

Target:
public boolean performDexOpt(String packageName) { enforceSystemOrRoot("Only the system can request dexopt be performed"); PackageParser.Package p; synchronized (mPackages) { p = mPackages.get(packageName); if (p == null) { return false; } p.mLastPackageUsageTimeInMills = System.currentTimeMillis(); mPackageUsage.write(); if (!p.mDexOptNeeded) { return false; } } synchronized (mInstallLock) { return performDexOptLI(p, false , false , true ) == DEX_OPT_PERFORMED; } }
Source:
private static boolean getRebuildProjectAfterImportPreference() { IScopeContext[] scopes = { ConfigurationScope.INSTANCE, DefaultScope.INSTANCE }; IPreferencesService preferencesService = Platform.getPreferencesService(); String defaultValue = String.valueOf(Boolean.FALSE); String rebuildProjectsPreference = preferencesService.getString(IDEWorkbenchPlugin.IDE_WORKBENCH, PREF_REBUILD_PROJECTS_AFTER_IMPORT, defaultValue, scopes); boolean booleanValue = Boolean.valueOf(rebuildProjectsPreference).booleanValue(); return booleanValue; }

Target:
private static boolean getRebuildProjectAfterImportPreference() { IScopeContext[] scopes = { null }; IPreferencesService preferencesService = Platform.getPreferencesService(); boolean defaultValue = false; boolean rebuildProjectsPreference = preferencesService.getBoolean(IDEWorkbenchPlugin.IDE_WORKBENCH, PREF_REBUILD_PROJECTS_AFTER_IMPORT, defaultValue, scopes); return rebuildProjectsPreference; }
Source:
public boolean isPurchased(String sku) { if (!Utility.isEmulator()) { return true; } if (purchases != null) { switch (sku) { case ITEM_DONATION: return purchases.get(ITEM_DONATION); case ITEM_PRO: return (purchases.get(ITEM_DONATION) || purchases.get(ITEM_PRO)); case ITEM_WEATHER_DATA: return (purchases.get(ITEM_DONATION) || purchases.get(ITEM_PRO) || purchases.get(ITEM_WEATHER_DATA)); case ITEM_WEB_RADIO: return (purchases.get(ITEM_DONATION) || purchases.get(ITEM_PRO) || purchases.get(ITEM_WEB_RADIO)); case ITEM_ACTIONS: return (purchases.get(ITEM_DONATION) || purchases.get(ITEM_PRO) || purchases.get(ITEM_ACTIONS)); } } return false; }

Target:
public boolean isPurchased(String sku) { if (Utility.isEmulator()) { return true; } if (purchases != null) { switch (sku) { case ITEM_DONATION: return purchases.get(ITEM_DONATION); case ITEM_PRO: return (purchases.get(ITEM_DONATION) || purchases.get(ITEM_PRO)); case ITEM_WEATHER_DATA: return (purchases.get(ITEM_DONATION) || purchases.get(ITEM_PRO) || purchases.get(ITEM_WEATHER_DATA)); case ITEM_WEB_RADIO: return (purchases.get(ITEM_DONATION) || purchases.get(ITEM_PRO) || purchases.get(ITEM_WEB_RADIO)); case ITEM_ACTIONS: return (purchases.get(ITEM_DONATION) || purchases.get(ITEM_PRO) || purchases.get(ITEM_ACTIONS)); } } return false; }
Source:
public void testBase() { createDocuments(); assertTrue(trashService.folderAllowsDelete(fold)); assertTrue(trashService.checkDeletePermOnParents(Arrays.asList(doc1, doc2))); assertTrue(trashService.canDelete(Collections.singletonList(fold), principal, false)); assertTrue(trashService.canDelete(Collections.singletonList(doc1), principal, false)); assertTrue(trashService.canDelete(Collections.singletonList(doc2), principal, false)); assertFalse(trashService.canPurgeOrUntrash(Collections.singletonList(fold), principal)); assertFalse(trashService.canPurgeOrUntrash(Collections.singletonList(doc1), principal)); assertFalse(trashService.canPurgeOrUntrash(Collections.singletonList(doc2), principal)); TrashInfo info = (TrashInfo) trashService.getTrashInfo(Arrays.asList(fold, doc1, doc3), principal, false, false); assertEquals(3, info.docs.size()); assertEquals(2, info.rootRefs.size()); assertEquals(new HashSet<>(Arrays.asList(new Path("/fold"), new Path("/doc3"))), info.rootPaths); DocumentModel above = trashService.getAboveDocument(doc1, Collections.singleton(new Path("/fold/doc1"))); assertEquals(above.getPathAsString(), fold.getId(), above.getId()); above = trashService.getAboveDocument(doc1, Collections.singleton(new Path("/fold/doc1"))); assertEquals(above.getPathAsString(), fold.getId(), above.getId()); }

Target:
public void testBase() { createDocuments(); assertTrue(trashService.folderAllowsDelete(fold)); assertTrue(trashService.checkDeletePermOnParents(Arrays.asList(doc1, doc2))); assertTrue(trashService.canDelete(Collections.singletonList(fold), principal, false)); assertTrue(trashService.canDelete(Collections.singletonList(doc1), principal, false)); assertTrue(trashService.canDelete(Collections.singletonList(doc2), principal, false)); assertFalse(trashService.canPurgeOrUntrash(Collections.singletonList(fold), principal)); assertFalse(trashService.canPurgeOrUntrash(Collections.singletonList(doc1), principal)); assertFalse(trashService.canPurgeOrUntrash(Collections.singletonList(doc2), principal)); TrashInfo info = trashService.getTrashInfo(Arrays.asList(fold, doc1, doc3), principal, false, false); assertEquals(3, info.docs.size()); assertEquals(2, info.rootRefs.size()); assertEquals(new HashSet<>(Arrays.asList(new Path("/fold"), new Path("/doc3"))), info.rootPaths); DocumentModel above = trashService.getAboveDocument(doc1, Collections.singleton(new Path("/fold/doc1"))); assertEquals(above.getPathAsString(), fold.getId(), above.getId()); above = trashService.getAboveDocument(doc1, Collections.singleton(new Path("/fold/doc1"))); assertEquals(above.getPathAsString(), fold.getId(), above.getId()); }
Source:
public Set<? extends NodeMetadata> createNodesInGroup(String group, int count, final Template template) throws RunNodesException { Set<? extends NodeMetadata> nodes = super.createNodesInGroup(group, count, template); String region = AWSUtils.getRegionFromLocationOrNull(template.getLocation()); if (client.getTagApiForRegion(region).isPresent()) { Map<String, String> common = metadataAndTagsAsValuesOfEmptyString(template.getOptions()); if (common.size() > 0 || !template.getOptions().getNodeNames().isEmpty() || generateInstanceNames) { return addTagsAndNamesToInstancesInRegion(common, template.getOptions().getNodeNames(), nodes, region, group); } } return nodes; }

Target:
public Set<? extends NodeMetadata> createNodesInGroup(String group, int count, final Template template) throws RunNodesException { Set<? extends NodeMetadata> nodes = super.createNodesInGroup(group, count, template); String region = AWSUtils.getRegionFromLocationOrNull(template.getLocation()); if (client.getTagApiForRegion(region).isPresent()) { Map<String, String> common = metadataAndTagsAsValuesOfEmptyString(template.getOptions()); if (generateInstanceNames || !common.isEmpty() || !template.getOptions().getNodeNames().isEmpty()) { return addTagsAndNamesToInstancesInRegion(common, template.getOptions().getNodeNames(), nodes, region, group); } } return nodes; }
Source:
private static IkeIdentification parseIkeIdentification(@NonNull String identityStr) { if (identityStr.contains("@")) { if (identityStr.startsWith("@#")) { final String hexStr = identityStr.substring(2); return new IkeKeyIdIdentification(HexDump.hexStringToByteArray(hexStr)); } else if (identityStr.startsWith("@") && !identityStr.startsWith("@@")) { return new IkeFqdnIdentification(identityStr.substring(1)); } else if (identityStr.startsWith("@@")) { return new IkeRfc822AddrIdentification(identityStr.substring(2)); } else { return new IkeRfc822AddrIdentification(identityStr); } } else { if (InetAddresses.isNumericAddress(identityStr)) { final InetAddress addr = InetAddresses.parseNumericAddress(identityStr); if (addr instanceof Inet4Address) { return new IkeIpv4AddrIdentification((Inet4Address) addr); } else if (addr instanceof Inet6Address) { return new IkeIpv6AddrIdentification((Inet6Address) addr); } else { throw new IllegalArgumentException("IP version not supported"); } } else { if (identityStr.contains(":")) { return new IkeKeyIdIdentification(identityStr.getBytes()); } else { return new IkeFqdnIdentification(identityStr); } } } }

Target:
private static IkeIdentification parseIkeIdentification(@NonNull String identityStr) { if (identityStr.contains("@")) { if (identityStr.startsWith("@#")) { final String hexStr = identityStr.substring(2); return new IkeKeyIdIdentification(HexDump.hexStringToByteArray(hexStr)); } else if (identityStr.startsWith("@@")) { return new IkeRfc822AddrIdentification(identityStr.substring(2)); } else if (identityStr.startsWith("@")) { return new IkeFqdnIdentification(identityStr.substring(1)); } else { return new IkeRfc822AddrIdentification(identityStr); } } else if (InetAddresses.isNumericAddress(identityStr)) { final InetAddress addr = InetAddresses.parseNumericAddress(identityStr); if (addr instanceof Inet4Address) { return new IkeIpv4AddrIdentification((Inet4Address) addr); } else if (addr instanceof Inet6Address) { return new IkeIpv6AddrIdentification((Inet6Address) addr); } else { throw new IllegalArgumentException("IP version not supported"); } } else { if (identityStr.contains(":")) { return new IkeKeyIdIdentification(identityStr.getBytes()); } else { return new IkeFqdnIdentification(identityStr); } } }
Source:
private static void makeCorrAttrFromAcctArtifact(List<CorrelationAttributeInstance> corrAttrInstances, BlackboardArtifact acctArtifact) throws TskCoreException, CentralRepoException { BlackboardAttribute accountTypeAttribute = acctArtifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ACCOUNT_TYPE)); String accountTypeStr = accountTypeAttribute.getValueString(); if (Account.Type.DEVICE.getTypeName().equalsIgnoreCase(accountTypeStr) == false) { CentralRepoAccountType crAccountType; try { crAccountType = CentralRepository.getInstance().getAccountTypeByName(accountTypeStr); } catch (CentralRepoException ex) { return; } int corrTypeId = crAccountType.getCorrelationTypeId(); CorrelationAttributeInstance.Type corrType = CentralRepository.getInstance().getCorrelationTypeById(corrTypeId); BlackboardAttribute accountIdAttribute = acctArtifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ID)); String accountIdStr = accountIdAttribute.getValueString(); CentralRepoAccount crAccount = CentralRepository.getInstance().getOrCreateAccount(crAccountType, accountIdStr); CorrelationAttributeInstance corrAttr = makeCorrAttr(acctArtifact, corrType, accountIdStr); if (corrAttr != null) { corrAttr.setAccountId(crAccount.getAccountId()); corrAttrInstances.add(corrAttr); } } }

Target:
private static void makeCorrAttrFromAcctArtifact(List<CorrelationAttributeInstance> corrAttrInstances, BlackboardArtifact acctArtifact) throws TskCoreException, CentralRepoException { BlackboardAttribute accountTypeAttribute = acctArtifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ACCOUNT_TYPE)); String accountTypeStr = accountTypeAttribute.getValueString(); Account.Type predefinedAccountType = Account.Type.PREDEFINED_ACCOUNT_TYPES.stream().filter(type -> type.getTypeName().equalsIgnoreCase(accountTypeStr)).findAny().orElse(null); if (Account.Type.DEVICE.getTypeName().equalsIgnoreCase(accountTypeStr) == false && predefinedAccountType != null) { CentralRepoAccountType crAccountType = CentralRepository.getInstance().getAccountTypeByName(accountTypeStr); int corrTypeId = crAccountType.getCorrelationTypeId(); CorrelationAttributeInstance.Type corrType = CentralRepository.getInstance().getCorrelationTypeById(corrTypeId); BlackboardAttribute accountIdAttribute = acctArtifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ID)); String accountIdStr = accountIdAttribute.getValueString(); CentralRepoAccount crAccount = CentralRepository.getInstance().getOrCreateAccount(crAccountType, accountIdStr); CorrelationAttributeInstance corrAttr = makeCorrAttr(acctArtifact, corrType, accountIdStr); if (corrAttr != null) { corrAttr.setAccountId(crAccount.getAccountId()); corrAttrInstances.add(corrAttr); } } }
Source:
private String refererSubstring(String referer) { int method_location = referer.indexOf("://"); int path_location; if(method_location == -1){ path_location = referer.indexOf("/"); } else { path_location = referer.indexOf("/", method_location+3); } if(path_location > -1){ return referer.substring(0, path_location); } return referer; }

Target:
private String refererSubstring(String referer) { int methodLocation = referer.indexOf("://"); int pathLocation; if(methodLocation == -1){ pathLocation = referer.indexOf("/"); } else { pathLocation = referer.indexOf("/", methodLocation+3); } if(pathLocation > -1){ return referer.substring(0, pathLocation); } return referer; }
Source:
public boolean containsAll(final Collection<?> c) { for (Object o : c) { if(indexOf(o) < 0) { return false; } } return true; }

Target:
public boolean containsAll(final Collection<?> c) { for (Object o : c) { if (!contains(o)) { return false; } } return true; }
Source:
public File merge(final TaskToolbox toolbox, final Map<DataSegment, File> segments, final File outDir) throws Exception { IndexMerger indexMerger = customIndexMerger != null ? customIndexMerger : toolbox.getIndexMergerV9(); FunctionalIterable<QueryableIndex> indexes = FunctionalIterable .create(segments.entrySet()) .transform( new Function<Map.Entry<DataSegment, File>, QueryableIndex>() { @Override public QueryableIndex apply(Map.Entry<DataSegment, File> input) { try { return toolbox.getIndexIO().loadSegment(input.getKey(), input.getValue()).asQueryableIndex(); } catch (Exception e) { throw Throwables.propagate(e); } } } ); return indexMerger.mergeQueryableIndex( Lists.newArrayList(indexes), rollup, aggregators.toArray(new AggregatorFactory[aggregators.size()]), outDir, indexSpec ); }

Target:
public File merge(final TaskToolbox toolbox, final Map<DataSegment, File> segments, final File outDir) throws Exception { IndexMerger indexMerger = customIndexMerger != null ? customIndexMerger : toolbox.getIndexMergerV9(); return indexMerger.mergeQueryableIndex( Lists.transform( ImmutableList.copyOf(segments.values()), new Function<File, QueryableIndex>() { @Override public QueryableIndex apply(@Nullable File input) { try { return toolbox.getIndexIO().loadIndex(input); } catch (Exception e) { throw Throwables.propagate(e); } } } ), rollup, aggregators.toArray(new AggregatorFactory[aggregators.size()]), outDir, indexSpec ); }
Source:
public void test() throws IOException { EntityType entityType1 = entityTestHarness.createDynamicRefEntityType("test1"); dataService.getMeta().addEntityType(entityType1); dataService.add( entityType1.getId(), entityTestHarness.createTestRefEntities(entityType1, 2).stream()); EntityType entityType2 = entityTestHarness.createDynamicRefEntityType("it_emx_test1"); Package it = packageFactory.create("it"); it.setLabel("it"); Package emx = packageFactory.create("it_emx"); emx.setLabel("it_emx"); emx.setParent(it); dataService.getMeta().addPackage(it); dataService.getMeta().addPackage(emx); entityType2.setPackage(emx); dataService.getMeta().addEntityType(entityType2); dataService.add( entityType2.getId(), entityTestHarness.createTestRefEntities(entityType2, 2).stream()); File actual = File.createTempFile("test", ".xlsx"); Package actualIt = dataService.getMeta().getPackage("it").get(); emxDownloadService.download(newArrayList(entityType1), newArrayList(actualIt), actual); Workbook workbook = new XSSFWorkbook(new FileInputStream(actual)); Workbook expected = new XSSFWorkbook( new FileInputStream( ResourceUtils.getFile( EmxExportServiceIT.class, "/xls/expectedDownloadResult.xlsx"))); assertThat(workbook, sameWorkbook(expected)); }

Target:
public void test() throws IOException { EntityType entityType1 = entityTestHarness.createDynamicRefEntityType("test1"); dataService.getMeta().addEntityType(entityType1); dataService.add( entityType1.getId(), entityTestHarness.createTestRefEntities(entityType1, 2).stream()); EntityType entityType2 = entityTestHarness.createDynamicRefEntityType("it_emx_test1"); Package it = packageFactory.create("it"); it.setLabel("it"); Package emx = packageFactory.create("it_emx"); emx.setLabel("it_emx"); emx.setParent(it); dataService.getMeta().addPackage(it); dataService.getMeta().addPackage(emx); entityType2.setPackage(emx); dataService.getMeta().addEntityType(entityType2); dataService.add( entityType2.getId(), entityTestHarness.createTestRefEntities(entityType2, 2).stream()); Path actual = Files.createTempFile("test", ".xlsx"); Package actualIt = dataService.getMeta().getPackage("it").get(); emxDownloadService.export(newArrayList(entityType1), newArrayList(actualIt), actual); try (XSSFWorkbook actualWorkbook = new XSSFWorkbook(Files.newInputStream(actual))) { try (Workbook expected = new XSSFWorkbook( new FileInputStream( ResourceUtils.getFile( EmxExportServiceIT.class, "/xls/expectedDownloadResult.xlsx")))) { assertThat(actualWorkbook, sameWorkbook(expected)); } } }
Source:
public void setKeyIdentifierType(String type) { if (Arrays.stream(VALID_KEY_IDENTIFIER_TYPES.split("\\s*,\\s*")).noneMatch(type.toUpperCase()::equals)) { throw new SlimFixtureException(false, "Invalid key identifier type: " + type.toUpperCase() + ". Valid options: " + Arrays.toString(VALID_KEY_IDENTIFIER_TYPES.split("\\s*,\\s*"))); } signatureKeyIdentifierType = getIntValueFromField(WSConstants.class, type.toUpperCase()); }

Target:
public void setKeyIdentifierType(String type) { if (Arrays.stream(VALID_KEY_IDENTIFIER_TYPES.split("\\s*,\\s*")).noneMatch(type.toUpperCase()::equals)) { throw new SlimFixtureException(false, "Invalid key identifier type: " + type.toUpperCase() + ". Valid options: " +VALID_KEY_IDENTIFIER_TYPES); } signatureKeyIdentifierType = getIntValueFromField(WSConstants.class, type.toUpperCase()); }
Source:
public IRepositoryServerProvider getRepositoryServerProvider() throws CoreException { if (repositoryServerProviderElement == null) return null; Object object = repositoryServerProviderElement .createExecutableExtension("class"); IRepositoryServerProvider provider = null; if (object instanceof IRepositoryServerProvider) { provider = (IRepositoryServerProvider) object; } return provider; }

Target:
public IRepositoryServerProvider getRepositoryServerProvider() throws CoreException { if (repositoryServerProviderElement == null) return null; Object object = repositoryServerProviderElement .createExecutableExtension("class"); IRepositoryServerProvider provider = null; if (object instanceof IRepositoryServerProvider) provider = (IRepositoryServerProvider) object; return provider; }
Source:
public boolean removeSecurityGroup(String id) { checkNotNull(id, "id"); ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id); String zone = zoneAndId.getZone(); String groupId = zoneAndId.getId(); Optional<? extends SecurityGroupApi> sgApi = client.getSecurityGroupExtensionForZone(zone); if (!sgApi.isPresent()) { return false; } if (sgApi.get().get(groupId) != null) { sgApi.get().delete(groupId); groupCreator.invalidate(new ZoneSecurityGroupNameAndPorts(zone, groupId, ImmutableSet.<Integer> of())); return true; } return false; }

Target:
public boolean removeSecurityGroup(String id) { checkNotNull(id, "id"); ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id); String zone = zoneAndId.getZone(); String groupId = zoneAndId.getId(); Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupExtensionForZone(zone); if (!sgApi.isPresent()) { return false; } if (sgApi.get().get(groupId) == null) { return false; } sgApi.get().delete(groupId); groupCreator.invalidate(new ZoneSecurityGroupNameAndPorts(zone, groupId, ImmutableSet.<Integer> of())); return true; }
Source:
public ClientJobState(JobState jobState) { List<TaskState> taskStates = jobState.getTasks(); this.tasks = new HashMap<>(taskStates.size()); jobInfo = (JobInfoImpl) jobState.getJobInfo(); owner = jobState.getOwner(); type = jobState.getType(); this.name = jobState.getName(); this.description = jobState.getDescription(); this.projectName = jobState.getProjectName(); this.priority = jobState.getPriority(); this.inputSpace = jobState.getInputSpace(); this.outputSpace = jobState.getOutputSpace(); this.maxNumberOfExecution = jobState.getMaxNumberOfExecution(); this.clientJobSerializationHelper = new ClientJobSerializationHelper(); this.setOnTaskError(jobState.getOnTaskErrorProperty().getValue()); this.genericInformation = jobState.getGenericInformation(); List<ClientTaskState> clientTaskStates = new ArrayList<>(taskStates.size()); for (TaskState ts : taskStates) { clientTaskStates.add(new ClientTaskState(ts)); } addTasks(clientTaskStates); }

Target:
public ClientJobState(JobState jobState) { List<TaskState> taskStates = jobState.getTasks(); this.tasks = new HashMap<>(taskStates.size()); jobInfo = (JobInfoImpl) jobState.getJobInfo(); owner = jobState.getOwner(); type = jobState.getType(); this.name = jobState.getName(); this.description = jobState.getDescription(); this.projectName = jobState.getProjectName(); this.priority = jobState.getPriority(); this.inputSpace = jobState.getInputSpace(); this.outputSpace = jobState.getOutputSpace(); this.maxNumberOfExecution = jobState.getMaxNumberOfExecution(); this.clientJobSerializationHelper = new ClientJobSerializationHelper(); this.setOnTaskError(jobState.getOnTaskErrorProperty().getValue()); this.genericInformation = new HashMap<>(jobState.getGenericInformation()); List<ClientTaskState> clientTaskStates = new ArrayList<>(taskStates.size()); for (TaskState ts : taskStates) { clientTaskStates.add(new ClientTaskState(ts)); } addTasks(clientTaskStates); }
Source:
@Nullable public String getClientID() { for (FormGroup formGroup : form) { for (FormField formField : formGroup.getFields()) { if (formField.getId().equals("clientID")) { return formField.getValue().toString(); } } } return null; }

Target:
@Nullable public String getClientID() { return getValueFromField(FormField.CLIENT_ID); }
Source:
private boolean doLoginCheck(UsernamePasswordCredentials credentials) { String username = credentials.getUsername(); String password = allowedUsersMap.get(username); boolean loginCheckOk = false; if (password != null){ if(password.equals(credentials.getPassword())){ String userGroup = userGroups.get(username); if (userGroup != null){ userGroupCredentials = new UserGroupCredentials(credentials.getEndpoint(),userGroup); sharedState.put(SecurityConstants.ATTRIBUTE_CREDENTIALS, credentials); loginCheckOk = true; } else { logger.log(Level.WARNING, "User Group not found for user " + username); loginCheckOk = false; } } } else { logger.log(Level.WARNING, "User details not found for " + username); loginCheckOk = false; } return loginCheckOk; }

Target:
private void doLoginCheck(UsernamePasswordCredentials credentials) throws FailedLoginException { String username = credentials.getUsername(); String password = ALLOWED_USERS_MAP.get(username); if (password != null) { if (password.equals(credentials.getPassword())) { String userGroup = USER_GROUPS.get(username); if (userGroup != null) { userGroupCredentials = new UserGroupCredentials(credentials.getEndpoint(), userGroup); sharedState.put(SecurityConstants.ATTRIBUTE_CREDENTIALS, credentials); } else { logger.log(Level.WARNING, "User Group not found for user " + username); throw new FailedLoginException("User Group not found for user " + username); } } } else { logger.log(Level.WARNING, "User details not found for " + username); throw new FailedLoginException("User details not found for " + username); } }
Source:
public void shoudNotSaveItem_withExisitingItem() { final InMemoryDatabaseTemplate databaseTemplate = new InMemoryDatabaseTemplate(databaseSchemaHolder); final StubItem stubItem = dataGenerator.randomStubItem(); databaseTemplate.create(stubItem); ItemConstraintViolationException actaulException = null; try { databaseTemplate.create(stubItem); } catch (final ItemConstraintViolationException e) { actaulException = e; } assertNotNull(actaulException); }

Target:
public void shoudNotSaveItem_withExisitingItem() { final InMemoryDatabaseTemplate databaseTemplate = new InMemoryDatabaseTemplate(databaseSchemaHolder); final StubItem stubItem = dataGenerator.randomStubItem(); databaseTemplate.create(stubItem); ItemConstraintViolationException actualException = null; try { databaseTemplate.create(stubItem); } catch (final ItemConstraintViolationException e) { actualException = e; } assertNotNull(actualException); }
Source:
public PageWithPosition poll() { PageWithPosition result = null; for (MergeSource mergeSource : mergeSources) { PageWithPosition current = mergeSource.getPage(); if (current == null) { if (mergeSource.isFinished()) { continue; } else { return null; } } if (result == null) { result = current; } else { int compareResult = comparator.compareTo(current.getPage(), current.getPosition(), result.getPage(), result.getPosition()); if (compareResult < 0) { result = current; } } } return result; }

Target:
public PageWithPosition poll() { if (!isQueueInitialized()) { List<PageWithPosition> initialRows = new ArrayList<>(); for (MergeSource mergeSource : mergeSources) { PageWithPosition page = mergeSource.getPage(); if (page == null) { if (mergeSource.isFinished()) { continue; } else { return null; } } initialRows.add(page); } mergeQueue.addAll(initialRows); } else { MergeSource mergeSource = mergeSources.get(lastPooledIndex); PageWithPosition page = mergeSource.getPage(); if (page == null && !mergeSource.isFinished()) { return null; } if (page != null) { mergeQueue.add(page); } } PageWithPosition result = mergeQueue.poll(); if (result == null) { return null; } lastPooledIndex = result.getStreamIndex(); return result; }
Source:
public void start(final Environment env) throws IOException { startThread(new CommandRunnable() { @Override public void run() throws Exception { PrintWriter p = toPrintWriter(out); try { parseCommandLine(); final ProjectAccess projectAccess = db.projects(); Project.NameKey parentNameKey = new Project.NameKey(parentName); final List<Project.NameKey> grandParents = new ArrayList<Project.NameKey>(); if (parentName != null) { final ProjectState projectState = projectCache.get(parentNameKey); if (projectState == null) { throw new Failure(1, "parent project " + parentName + " does not exist \n"); } else { Project.NameKey grandParent = projectState.getProject().getParent(); while (grandParent != null && !grandParent.equals(wildProject)) { grandParents.add(grandParent); grandParent = projectCache.get(grandParent).getProject().getParent(); } } } else { parentName = wildProject.get(); parentNameKey = new Project.NameKey(parentName); } for (String child : children) { final Project.NameKey childNameKey = new Project.NameKey(child); Project projectChild = projectAccess.get(childNameKey); if (projectChild != null && !child.equals(wildProject.get()) && !child.equals(parentName) && (!grandParents.contains(childNameKey))) { projectChild.setParent(parentNameKey); projectAccess.update(Collections.singleton(projectChild)); } else { p.print("It was not possible to set the parent project " + parentName + " to the following project : " + child + "\n"); p.flush(); } } projectCache.evict(); } catch (Throwable e) { p.print("Error when trying to set a parent to a project: " + e.getMessage() + "\n"); p.flush(); } } }); }

Target:
public void start(final Environment env) throws IOException { startThread(new CommandRunnable() { @Override public void run() throws Exception { PrintWriter p = toPrintWriter(err); try { parseCommandLine(); final ProjectAccess projectAccess = db.projects(); Project.NameKey parentNameKey; final List<Project.NameKey> grandParents = new ArrayList<Project.NameKey>(); if (projectControl != null) { parentNameKey = new Project.NameKey(projectControl.getProject().getName()); Project.NameKey grandParent = projectControl.getProject().getParent(); while (grandParent != null && !grandParent.equals(wildProject)) { grandParents.add(grandParent); grandParent = projectCache.get(grandParent).getProject().getParent(); } } else { parentNameKey = new Project.NameKey(wildProject.get()); } for (ProjectControl childPC : children) { Project child = childPC.getProject(); final Project.NameKey childNameKey = new Project.NameKey(child.getName()); if (!childNameKey.equals(wildProject) && !childNameKey.equals(parentNameKey) && (!grandParents.contains(childNameKey))) { child.setParent(parentNameKey); projectAccess.update(Collections.singleton(child)); } else { p.print("It was not possible to set the parent project " + parentNameKey.get() + " to the following project : " + child.getName() + "\n"); p.flush(); } } projectCache.evictAll(); } catch (Throwable e) { p.print("Error when trying to set a parent to a project: " + e.getMessage() + "\n"); p.flush(); } } }); }
Source:
default boolean anyExists() { return flatData(RelativePath.empty().get(), Pager.builder().withPageSize(1).orderBy(Order.unspecified()) .build()).hasNext(); }

Target:
default boolean anyExists() { return flatData(RelativePath.empty().get(), Pager.single()).hasNext(); }
Source:
public void testReentrantLock(boolean fair) throws Exception { for (int i = 0; i < NODES_CNT; i++) { final IgniteLock lock = createReentrantLock(i, fair ? "lock1" : "lock2", fair); GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { return !lock.isLocked(); } }, 500L); lock.lock(); assertTrue(lock.isLocked()); assertTrue(lock.isHeldByCurrentThread()); lock.lock(); assertTrue(lock.isLocked()); assertTrue(lock.isHeldByCurrentThread()); lock.unlock(); assertTrue(lock.isLocked()); assertTrue(lock.isHeldByCurrentThread()); lock.unlock(); assertFalse(lock.isLocked()); assertFalse(lock.isHeldByCurrentThread()); } }

Target:
private void testReentrantLock(boolean fair) throws Exception { for (int i = 0; i < NODES_CNT; i++) { final IgniteLock lock = createReentrantLock(i, fair ? "fair lock" : "unfair lock", fair); assertEquals(0, lock.getHoldCount()); GridTestUtils.waitForCondition(() -> !lock.isLocked(), 500L); lock.lock(); assertEquals(1, lock.getHoldCount()); assertTrue(lock.isLocked()); assertTrue(lock.isHeldByCurrentThread()); lock.lock(); assertEquals(2, lock.getHoldCount()); assertTrue(lock.isLocked()); assertTrue(lock.isHeldByCurrentThread()); lock.unlock(); assertEquals(1, lock.getHoldCount()); assertTrue(lock.isLocked()); assertTrue(lock.isHeldByCurrentThread()); lock.unlock(); assertEquals(0, lock.getHoldCount()); assertFalse(lock.isLocked()); assertFalse(lock.isHeldByCurrentThread()); } }
Source:
public LoggerContext configure(Props props) { LoggerContext ctx = helper.getRootContext(); ctx.reset(); configureRootLogger(props); helper.apply(logLevelConfig, props); helper.enableJulChangePropagation(ctx); configureDirectToConsoleLoggers(ctx, STARTUP_LOGGER_NAME); extendConfigure(); return ctx; }

Target:
public LoggerContext configure(Props props) { LoggerContext ctx = helper.getRootContext(); ctx.reset(); helper.enableJulChangePropagation(ctx); configureRootLogger(props); helper.apply(logLevelConfig, props); configureDirectToConsoleLoggers(ctx, STARTUP_LOGGER_NAME); extendConfigure(); return ctx; }
Source:
public void insertPastState(long stateStartTime, long stateEndTime, int quark, ITmfStateValue value) throws TimeRangeException { final int nbAttributes = ((ITmfStateSystem) fPartialSS).getNbAttributes(); if (!fInitialized) { fCheckpointQuark = fPartialSS.createCheckpoint(CHECKPOINT_NAME); fQuarksAdded.clear(); rebuildQuarks(nbAttributes, Boolean.TRUE); fCheckpoints.add(fPartialInput.getStartTime()); fInitialized = true; } if (quark == fCheckpointQuark) { fQuarksAdded.clear(); rebuildQuarks(nbAttributes, Boolean.TRUE); fCheckpoints.add(stateEndTime); return; } if (stateEndTime > fLatestTime) { fLatestTime = stateEndTime; } boolean insert = false; if (quark >= fQuarksAdded.size()) { rebuildQuarks(nbAttributes, Boolean.FALSE); insert = true; } if (fQuarksAdded.get(quark)) { fQuarksAdded.set(quark, Boolean.FALSE); insert = true; } if (insert) { fInnerHistory.insertPastState(stateStartTime, stateEndTime, quark, value); } }

Target:
public void insertPastState(long stateStartTime, long stateEndTime, int quark, ITmfStateValue value) throws TimeRangeException { int nbAttributes = ((ITmfStateSystem) fPartialSS).getNbAttributes(); if (!fInitialized) { fCheckpointQuark = fPartialSS.createCheckpoint(CHECKPOINT_NAME); fAddedQuarks.clear(); rebuildQuarks(nbAttributes, Boolean.TRUE); fCheckpoints.add(fPartialInput.getStartTime()); fInitialized = true; } if (quark == fCheckpointQuark) { fAddedQuarks.clear(); rebuildQuarks(nbAttributes, Boolean.TRUE); fCheckpoints.add(stateEndTime); return; } if (stateEndTime > fLatestTime) { fLatestTime = stateEndTime; } boolean insert = false; if (quark >= fAddedQuarks.size()) { rebuildQuarks(nbAttributes, Boolean.FALSE); insert = true; } if (fAddedQuarks.get(quark)) { fAddedQuarks.set(quark, Boolean.FALSE); insert = true; } if (insert) { fInnerHistory.insertPastState(stateStartTime, stateEndTime, quark, value); } }
Source:
public void testPushOptionsNotSupported() throws Exception { try (Git git = new Git(db); Git git2 = new Git(createBareRepository())) { final StoredConfig config = git.getRepository().getConfig(); RemoteConfig remoteConfig = new RemoteConfig(config, "test"); remoteConfig.addURI(new URIish( git2.getRepository().getDirectory().toURI().toURL())); remoteConfig.addFetchRefSpec( new RefSpec("+refs/heads/*:refs/remotes/origin/*")); remoteConfig.update(config); config.save(); writeTrashFile("f", "content of f"); git.add().addFilepattern("f").call(); RevCommit commit = git.commit().setMessage("adding f").call(); git.checkout().setName("not-pushed").setCreateBranch(true).call(); git.checkout().setName("branchtopush").setCreateBranch(true).call(); assertNull( git2.getRepository().resolve("refs/heads/branchtopush")); assertNull( git2.getRepository().resolve("refs/heads/not-pushed")); assertNull( git2.getRepository().resolve("refs/heads/master")); List<String> pushOptions = new ArrayList<>(); PushCommand pushCommand = git.push().setRemote("test") .setPushOptions(pushOptions); pushCommand.call(); assertEquals(commit.getId(), git2.getRepository().resolve("refs/heads/branchtopush")); assertNull(git2.getRepository().resolve("refs/heads/not-pushed")); assertNull(git2.getRepository().resolve("refs/heads/master")); } }

Target:
public void testPushOptionsNotSupported() throws Exception { try (Git git = new Git(db); Git git2 = new Git(createBareRepository())) { final StoredConfig config = git.getRepository().getConfig(); RemoteConfig remoteConfig = new RemoteConfig(config, "test"); remoteConfig.addURI(new URIish( git2.getRepository().getDirectory().toURI().toURL())); remoteConfig.addFetchRefSpec( new RefSpec("+refs/heads/*:refs/remotes/origin/*")); remoteConfig.update(config); config.save(); final StoredConfig config2 = git2.getRepository().getConfig(); config2.setBoolean("receive", null, "pushoptions", false); config2.save(); writeTrashFile("f", "content of f"); git.add().addFilepattern("f").call(); RevCommit commit = git.commit().setMessage("adding f").call(); git.checkout().setName("not-pushed").setCreateBranch(true).call(); git.checkout().setName("branchtopush").setCreateBranch(true).call(); assertNull(git2.getRepository().resolve("refs/heads/branchtopush")); assertNull(git2.getRepository().resolve("refs/heads/not-pushed")); assertNull(git2.getRepository().resolve("refs/heads/master")); List<String> pushOptions = new ArrayList<>(); PushCommand pushCommand = git.push().setRemote("test") .setPushOptions(pushOptions); pushCommand.call(); assertEquals(commit.getId(), git2.getRepository().resolve("refs/heads/branchtopush")); assertNull(git2.getRepository().resolve("refs/heads/not-pushed")); assertNull(git2.getRepository().resolve("refs/heads/master")); } }
Source:
public BigtableOptions build() { if (bulkOptions == null) { int maxInflightRpcs = BulkOptions.BIGTABLE_MAX_INFLIGHT_RPCS_PER_CHANNEL_DEFAULT * dataChannelCount; bulkOptions = new BulkOptions.Builder().setMaxInflightRpcs(maxInflightRpcs).build(); } return new BigtableOptions( clusterAdminHost, tableAdminHost, dataHost, port, projectId, zoneId, clusterId, credentialOptions, userAgent, retryOptions, dataChannelCount, bulkOptions, usePlaintextNegotiation); }

Target:
public BigtableOptions build() { if (bulkOptions == null) { int maxInflightRpcs = BulkOptions.BIGTABLE_MAX_INFLIGHT_RPCS_PER_CHANNEL_DEFAULT * dataChannelCount; bulkOptions = new BulkOptions.Builder().setMaxInflightRpcs(maxInflightRpcs).build(); } else if (bulkOptions.getMaxInflightRpcs() <= 0) { int maxInflightRpcs = BulkOptions.BIGTABLE_MAX_INFLIGHT_RPCS_PER_CHANNEL_DEFAULT * dataChannelCount; bulkOptions = bulkOptions.toBuilder().setMaxInflightRpcs(maxInflightRpcs).build(); } return new BigtableOptions( clusterAdminHost, tableAdminHost, dataHost, port, projectId, zoneId, clusterId, credentialOptions, userAgent, retryOptions, dataChannelCount, bulkOptions, usePlaintextNegotiation); }
Source:
public WorkProcessor.ProcessorState<Page> process(Optional<WindowPartition> partitionOptional) { boolean finishing = !partitionOptional.isPresent(); if (finishing) { if (pageBuilder.isEmpty()) { return finished(); } Page page = pageBuilder.build(); pageBuilder.reset(); return ofResult(page, false); } WindowPartition partition = partitionOptional.get(); while (!pageBuilder.isFull()) { if (!partition.hasNext()) { return needsMoreData(); } partition.processNextRow(pageBuilder); } Page page = pageBuilder.build(); pageBuilder.reset(); return ofResult(page, !partition.hasNext()); }

Target:
public ProcessorState<Page> process(Optional<WindowPartition> partitionOptional) { boolean finishing = !partitionOptional.isPresent(); if (finishing) { if (pageBuilder.isEmpty()) { return finished(); } Page page = pageBuilder.build(); pageBuilder.reset(); return ofResult(page, false); } WindowPartition partition = partitionOptional.get(); while (!pageBuilder.isFull()) { if (!partition.hasNext()) { return needsMoreData(); } partition.processNextRow(pageBuilder); } Page page = pageBuilder.build(); pageBuilder.reset(); return ofResult(page, !partition.hasNext()); }
Source:
public Attribute getAttributeValue(PerunSessionImpl sess, User user, AttributeDefinition destinationAttributeDefinition) throws InternalErrorException { Attribute attribute = super.getAttributeValue(sess, user, destinationAttributeDefinition); Attribute destinationAttribute = new Attribute(destinationAttributeDefinition); Set<String> valuesWithoutDuplicities = new HashSet<>(); if (attribute != null) { Object value = attribute.getValue(); if (value != null && value instanceof Set) { Object[] valArray = ((Set) value).toArray(); if (valArray instanceof String[]) { for (String val: (String[]) valArray) { valuesWithoutDuplicities.add(val); } } } } Attribute attribute1 = null; try { attribute1 = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, user, SOURCE_ATTRIBUTE_FRIENDLY_NAME_EPSA_MA_URN); } catch (WrongAttributeAssignmentException | AttributeNotExistsException e) { log.error("cannot read " + SOURCE_ATTRIBUTE_FRIENDLY_NAME_EPSA_MA + " of user " + user.getId(), e); } if (attribute1 != null) { Object value = attribute1.getValue(); if (value != null && value instanceof Map) { Map<String, String> valueAsMap = (Map<String, String>) value; valuesWithoutDuplicities.addAll(valueAsMap.keySet()); } } destinationAttribute.setValue(new ArrayList<>(valuesWithoutDuplicities)); return destinationAttribute; }

Target:
public Attribute getAttributeValue(PerunSessionImpl sess, User user, AttributeDefinition destinationAttributeDefinition) throws InternalErrorException { Attribute attribute = super.getAttributeValue(sess, user, destinationAttributeDefinition); Attribute destinationAttribute = new Attribute(destinationAttributeDefinition); Set<String> valuesWithoutDuplicities = new HashSet<>(attribute.valueAsList()); Attribute manualEPSAAttr = null; try { manualEPSAAttr = sess.getPerunBl().getAttributesManagerBl() .getAttribute(sess, user, getSecondarySourceAttributeName()); } catch (WrongAttributeAssignmentException e) { throw new InternalErrorException("Wrong assignment of " + getSecondarySourceAttributeFriendlyName() + " for user " + user.getId(), e); } catch (AttributeNotExistsException e) { log.debug("Attribute " + getSecondarySourceAttributeFriendlyName() + " of user " + user.getId() + "does not exist, values will be skipped", e); } if (manualEPSAAttr != null) { Map<String, String> value = manualEPSAAttr.valueAsMap(); if (value != null) { valuesWithoutDuplicities.addAll(value.keySet()); } } destinationAttribute.setValue(new ArrayList<>(valuesWithoutDuplicities)); return destinationAttribute; }
Source:
public static void actool(Config config, File inDir, File outDir) throws IOException { List<Object> opts = new ArrayList<>(); String appIconSetName = null; String launchImagesName = null; final String appiconset = "appiconset"; final String launchimage = "launchimage"; for (String fileName : inDir.list()) { String ext = FilenameUtils.getExtension(fileName); if (ext.equals(appiconset)) { appIconSetName = FilenameUtils.getBaseName(fileName); } else if (ext.equals(launchimage)) { launchImagesName = FilenameUtils.getBaseName(fileName); } } if (appIconSetName != null || launchImagesName != null) { if (appIconSetName != null) { opts.add("--app-icon"); opts.add(appIconSetName); } if (launchImagesName != null) { opts.add("--launch-image"); opts.add(launchImagesName); } File partialInfoPlist = new File(inDir, "assetcatalog-partial-info.plist"); opts.add("--output-partial-info-plist"); opts.add(partialInfoPlist); } opts.add("--platform"); if (IOSTarget.isDeviceArch(config.getArch())) { opts.add("iphoneos"); } else if (IOSTarget.isSimulatorArch(config.getArch())) { opts.add("iphonesimulator"); } new Executor(config.getLogger(), getACTool()) .args(inDir, opts, "--output-format", "human-readable-text", "--minimum-deployment-target", "6.0", "--compile", outDir).exec(); }

Target:
public static void actool(Config config, File inDir, File outDir) throws IOException { List<Object> opts = new ArrayList<>(); String appIconSetName = null; String launchImagesName = null; final String appiconset = "appiconset"; final String launchimage = "launchimage"; for (String fileName : inDir.list()) { String ext = FilenameUtils.getExtension(fileName); if (ext.equals(appiconset)) { appIconSetName = FilenameUtils.getBaseName(fileName); } else if (ext.equals(launchimage)) { launchImagesName = FilenameUtils.getBaseName(fileName); } } if (appIconSetName != null || launchImagesName != null) { if (appIconSetName != null) { opts.add("--app-icon"); opts.add(appIconSetName); } if (launchImagesName != null) { opts.add("--launch-image"); opts.add(launchImagesName); } File partialInfoPlist = new File(inDir, "assetcatalog-partial-info.plist"); opts.add("--output-partial-info-plist"); opts.add(partialInfoPlist); } opts.add("--platform"); if (IOSTarget.isDeviceArch(config.getArch())) { opts.add("iphoneos"); } else if (IOSTarget.isSimulatorArch(config.getArch())) { opts.add("iphonesimulator"); } String minOSVersion = config.getOs().getMinVersion(); if (config.getIosInfoPList() != null) { String v = config.getIosInfoPList().getMinimumOSVersion(); if (v != null) { minOSVersion = v; } } new Executor(config.getLogger(), getACTool()) .args(inDir, opts, "--output-format", "human-readable-text", "--minimum-deployment-target", minOSVersion, "--compile", outDir).exec(); }
Source:
public void deleteUser(String userName) throws UserStoreException { Connection dbConnection = null; PreparedStatement preparedStatement = null; userName = UserCoreUtil.addDomainToName(userName, getMyDomainName()); String domain = UserCoreUtil.extractDomainFromName(userName); if (domain!=null){ domain = domain.toUpperCase(); } try { dbConnection = getDBConnection(); preparedStatement = dbConnection.prepareStatement(HybridJDBCConstants.REMOVE_USER_SQL); preparedStatement.setString(1, UserCoreUtil.removeDomainFromName(userName)); preparedStatement.setInt(2, tenantId); preparedStatement.setInt(3, tenantId); preparedStatement.setString(4, domain); preparedStatement.execute(); dbConnection.commit(); } catch (SQLException e) { String errorMessage = "Error occurred while deleting user :"+userName; throw new UserStoreException(errorMessage, e); } finally { DatabaseUtil.closeAllConnections(dbConnection, preparedStatement); } }

Target:
public void deleteUser(String userName) throws UserStoreException { Connection dbConnection = null; PreparedStatement preparedStatement = null; userName = UserCoreUtil.addDomainToName(userName, getMyDomainName()); String domain = UserCoreUtil.extractDomainFromName(userName); if (domain!=null){ domain = domain.toUpperCase(); } try { dbConnection = getDBConnection(); preparedStatement = dbConnection.prepareStatement(HybridJDBCConstants.REMOVE_USER_SQL); preparedStatement.setString(1, UserCoreUtil.removeDomainFromName(userName)); preparedStatement.setInt(2, tenantId); preparedStatement.setInt(3, tenantId); preparedStatement.setString(4, domain); preparedStatement.execute(); dbConnection.commit(); } catch (SQLException e) { String errorMessage = "Error occurred while deleting user : " + userName; if (log.isDebugEnabled()) { log.debug(errorMessage, e); } throw new UserStoreException(errorMessage, e); } finally { DatabaseUtil.closeAllConnections(dbConnection, preparedStatement); } }