auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void deletePageContents(@NonNull ReadingListPage page) { PageTitle pageTitle = ReadingListPage.toPageTitle(page); reqPageLead(CacheControl.FORCE_CACHE, OfflineCacheInterceptor.SAVE_HEADER_DELETE, pageTitle) .subscribeOn(Schedulers.io()) <START> .observeOn(AndroidSchedulers.mainThread()) <END> .subscribe(leadRsp -> { PageLead lead = leadRsp.body(); if (lead != null) { List<String> imageUrls = pageImageUrlParser.parse(lead); if (!TextUtils.isEmpty(pageTitle.getThumbUrl())) { imageUrls.add(pageTitle.getThumbUrl()); } for (String url : imageUrls) { try { Request request = makeImageRequest(pageTitle.getWikiSite(), url) .addHeader(OfflineCacheInterceptor.SAVE_HEADER, OfflineCacheInterceptor.SAVE_HEADER_DELETE) .build(); OkHttpConnectionFactory.getClient().newCall(request).execute(); } catch (IOException ignore) { } } } }, L::d); reqPageSections(CacheControl.FORCE_CACHE, OfflineCacheInterceptor.SAVE_HEADER_DELETE, pageTitle) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(sectionsRsp -> { PageRemaining sections = sectionsRsp.body(); if (sections != null) { for (String url : pageImageUrlParser.parse(sections)) { try { Request request = makeImageRequest(pageTitle.getWikiSite(), url) .addHeader(OfflineCacheInterceptor.SAVE_HEADER, OfflineCacheInterceptor.SAVE_HEADER_DELETE) .build(); OkHttpConnectionFactory.getClient().newCall(request).execute(); } catch (IOException ignore) { } } } }, L::d); }</code><technical_language>Is this necessary? This entire service is happening in a background thread, need interact UI</technical_language>

Target:
private void deletePageContents(@NonNull ReadingListPage page) { PageTitle pageTitle = ReadingListPage.toPageTitle(page); reqPageLead(CacheControl.FORCE_CACHE, OfflineCacheInterceptor.SAVE_HEADER_DELETE, pageTitle) .subscribeOn(Schedulers.io()) .subscribe(leadRsp -> { PageLead lead = leadRsp.body(); if (lead != null) { List<String> imageUrls = pageImageUrlParser.parse(lead); if (!TextUtils.isEmpty(pageTitle.getThumbUrl())) { imageUrls.add(pageTitle.getThumbUrl()); } for (String url : imageUrls) { Request request = makeImageRequest(pageTitle.getWikiSite(), url) .addHeader(OfflineCacheInterceptor.SAVE_HEADER, OfflineCacheInterceptor.SAVE_HEADER_DELETE) .build(); OkHttpConnectionFactory.getClient().newCall(request).execute(); } } }, L::d); reqPageSections(CacheControl.FORCE_CACHE, OfflineCacheInterceptor.SAVE_HEADER_DELETE, pageTitle) .subscribeOn(Schedulers.io()) .subscribe(sectionsRsp -> { PageRemaining sections = sectionsRsp.body(); if (sections != null) { for (String url : pageImageUrlParser.parse(sections)) { Request request = makeImageRequest(pageTitle.getWikiSite(), url) .addHeader(OfflineCacheInterceptor.SAVE_HEADER, OfflineCacheInterceptor.SAVE_HEADER_DELETE) .build(); OkHttpConnectionFactory.getClient().newCall(request).execute(); } } }, L::d); }
Source:
<code>public void mergeLoginMethods(String rawToken, User existantUser, MethodType type) { <START> LoginMethod Login = LoginMethod.newLogin(existantUser, existantUser.getEmail(), rawToken, type); <END> existantUser.add(Login); loginMethods.save(Login); access.login(existantUser); }</code><technical_language>variables start case</technical_language>

Target:
public void mergeLoginMethods(String rawToken, User existantUser, MethodType type) { LoginMethod login = LoginMethod.newLogin(existantUser, existantUser.getEmail(), rawToken, type); existantUser.add(login); loginMethods.save(login); access.login(existantUser); }
Source:
<code><START> static <E extends Enum<E>> Optional<Class<?>> ifEnum(Type type) { <END> return Optional.of(type) .map(GenericTypes::getErasedType) .filter(Class::isEnum) .map(c -> (Class<E>) c); }</code><technical_language>/ this Optional<Class<E>></technical_language>

Target:
static <E extends Enum<E>> Optional<Class<E>> ifEnum(Type type) { return Optional.of(type) .map(GenericTypes::getErasedType) .filter(Class::isEnum) .map(c -> (Class<E>) c); }
Source:
<code>public void testCostDefault() { Double jobCost = JobHistoryFileParserBase.calculateJobCost(100L, Constants.DEFAULT_COMPUTE_TCO, Constants.DEFAULT_MACHINE_MEMORY); assertEquals(1.413850E-10, jobCost, 0.0001); jobCost = JobHistoryFileParserBase.calculateJobCost(10000000000000L, Constants.DEFAULT_COMPUTE_TCO, Constants.DEFAULT_MACHINE_MEMORY); assertEquals(14.128503, jobCost, 0.0001); jobCost = JobHistoryFileParserBase.calculateJobCost(100L, 20.0, 512L); assertEquals(1.413850E-10, jobCost, 0.0001); jobCost = JobHistoryFileParserBase.calculateJobCost(10000000000000L, 20.0, 512L); <START> assertEquals(4521.122685, jobCost, 0.0001); <END> }</code><technical_language>I multiple tests largely redundant exercise formula is difference in works tests. live one</technical_language>

Target:
public void testCostDefault() { Double jobCost = JobHistoryFileParserBase.calculateJobCost(100L, 0.0, 0L); assertEquals(0.0, jobCost, 0.0001); jobCost = JobHistoryFileParserBase.calculateJobCost(100L, 20.0, 512L); assertEquals(1.413850E-10, jobCost, 0.0001); }
Source:
<code>ByteBuffer pollCachedNioBuffer() { <START> return cachedNioBuffers.pollLast(); <END> }</code><technical_language>nice</technical_language>

Target:
ByteBuffer pollCachedNioBuffer() { return cachedNioBuffers != null ? cachedNioBuffers.pollLast() : null; }
Source:
<code>public EntityLaunchListener(SystemServiceEnricher enricher) { <START> this.enricher = enricher; <END> }</code><technical_language>do this.enricher = checkNotNull(enricher, "enricher"), risking subsequent NPEs</technical_language>

Target:
public EntityLaunchListener(SystemServiceEnricher enricher) { this.enricher = checkNotNull(enricher, "enricher"); }
Source:
<code>public void validate() throws Exception { if (toInteger(hasTag("setconf")) + toInteger(hasTag("getconf")) + toInteger(hasTag("auth")) + toInteger(hasTag("get")) + toInteger(hasTag("set")) > 1) { <START> throw new Exception("The message tag must be either setconf, getconf, auth or set"); <END> } if (hasTag("setconf")) { if (getText() == null) { throw new Exception("The setconf message must contain a text."); } } else if (hasTag("getconf")) { if (getText() != null) { throw new Exception("The getconf message should not contain a text."); } if (getTags().size() != 1) { throw new Exception("The getconf message should be the only tag."); } } else if (hasTag("set") || hasTag("get")) { if (getText() == null) { throw new Exception("The get/set message must contain a text."); } if (getTags().size() != 1) { throw new Exception("The get/set message should be the only tag."); } } else if (hasTag("auth")) { if (!"reload".equalsIgnoreCase(getText())) { throw new Exception("The auth message can only accept a text \"reload\"."); } if (getTags().size() != 1) { throw new Exception("The auth message should be the only tag."); } } else { throw new Exception("The message tag must be either setconf, getconf, auth or set"); } super.validate(); }</code><technical_language>+ get</technical_language>

Target:
public void validate() throws Exception { Set<String> allowedTags = new TreeSet<>(Arrays.asList("setconf", "getconf", "auth", "get", "set")); Set<String> tagCopy = new TreeSet<>(allowedTags); tagCopy.retainAll(getTags()); if (tagCopy.size() > 1) { throw new Exception("The message tag must be one of '" + allowedTags.toString() + "'"); } if (hasTag("setconf")) { if (getText() == null) { throw new Exception("The setconf message must contain a text."); } } else if (hasTag("getconf")) { if (getText() != null) { throw new Exception("The getconf message should not contain a text."); } if (getTags().size() != 1) { throw new Exception("The getconf message should be the only tag."); } } else if (hasTag("set") || hasTag("get")) { if (getText() == null) { throw new Exception("The get/set message must contain a text."); } if (getTags().size() != 1) { throw new Exception("The get/set message should be the only tag."); } } else if (hasTag("auth")) { if (!"reload".equalsIgnoreCase(getText())) { throw new Exception("The auth message can only accept a text \"reload\"."); } if (getTags().size() != 1) { throw new Exception("The auth message should be the only tag."); } } else { throw new Exception("The message tag must be either setconf, getconf, auth or set"); } super.validate(); }
Source:
<code>private void autoShareProjects(File repositoryDir) { IPath workingDirPath = new Path(repositoryDir.getAbsolutePath()) .removeLastSegments(1); Map<IProject, File> connections = new HashMap<IProject, File>(); IProject[] projects = ResourcesPlugin.getWorkspace().getRoot() .getProjects(); for (IProject project : projects) { RepositoryProvider provider = RepositoryProvider .getProvider(project); if (provider != null) continue; IPath location = project.getLocation(); if (location == null) continue; if (!workingDirPath.isPrefixOf(location)) continue; RepositoryFinder f = new RepositoryFinder(project); try { Collection<RepositoryMapping> mappings = f .find(new NullProgressMonitor()); <START> if (mappings.size() == 1) { <END> connections.put(project, repositoryDir); } } catch (CoreException e) { continue; } } if (!connections.isEmpty()) { ConnectProviderOperation operation = new ConnectProviderOperation( connections); JobUtil.scheduleUserJob(operation, CoreText.Activator_AutoShareJobName, JobFamilies.AUTO_SHARE); } }</code><technical_language>style nit: braces single line block</technical_language>

Target:
private void autoShareProjects(File repositoryDir) { IPath workingDirPath = new Path(repositoryDir.getAbsolutePath()) .removeLastSegments(1); Map<IProject, File> connections = new HashMap<IProject, File>(); IProject[] projects = ResourcesPlugin.getWorkspace().getRoot() .getProjects(); for (IProject project : projects) { RepositoryProvider provider = RepositoryProvider .getProvider(project); if (provider != null) continue; IPath location = project.getLocation(); if (location == null) continue; if (!workingDirPath.isPrefixOf(location)) continue; RepositoryFinder f = new RepositoryFinder(project); try { Collection<RepositoryMapping> mappings = f .find(new NullProgressMonitor()); if (mappings.size() == 1) connections.put(project, repositoryDir); } catch (CoreException e) { continue; } } if (!connections.isEmpty()) { ConnectProviderOperation operation = new ConnectProviderOperation( connections); JobUtil.scheduleUserJob(operation, CoreText.Activator_AutoShareJobName, JobFamilies.AUTO_SHARE); } }
Source:
<code>public void testTopologyLevelClassCastExceptionDirect() { final ProcessorNode node = new ProcessorNode("name", new ClassCastProcessor(), Collections.emptySet()); <START> try { <END> node.process("aKey", "aValue"); } catch (final StreamsException e) { assertThat(e.getCause(), instanceOf(ClassCastException.class)); assertThat(e.getMessage(), containsString("default serdes")); assertThat(e.getMessage(), containsString("input types")); throw e; } }</code><technical_language>rewrite test assertThrows()</technical_language>

Target:
public void testTopologyLevelClassCastExceptionDirect() { final ProcessorNode<Object, Object> node = new ProcessorNode<Object, Object>("name", new ClassCastProcessor(), Collections.<String>emptySet()); final StreamsException se = assertThrows(StreamsException.class, () -> node.process("aKey", "aValue")); assertThat(se.getCause(), instanceOf(ClassCastException.class)); assertThat(se.getMessage(), containsString("default Serdes")); assertThat(se.getMessage(), containsString("input types")); }
Source:
<code>public static void beforeInitMilestonePluginsStarted() { <START> LOG.info("\n\n LOCKABLE RESOURCES COMPATABILITY INIT \n\n"); <END> List<LockableResource> resources = LockableResourcesManager.get().getResources(); for (LockableResource resource : resources) { List<StepContext> queuedContexts = resource.getQueuedContexts(); if (queuedContexts.size() > 0) { for (StepContext queuedContext : queuedContexts) { List<String> resourcesNames = new ArrayList<String>(); resourcesNames.add(resource.getName()); LockableResourcesStruct resourceHolder = new LockableResourcesStruct(resourcesNames, "", 0); LockableResourcesManager.get().queueContext(queuedContext, resourceHolder, resource.getName()); } } } }</code><technical_language>FINE level</technical_language>

Target:
public static void beforeInitMilestonePluginsStarted() { LOG.fine("\n\n LOCKABLE RESOURCES COMPATABILITY INIT \n\n"); List<LockableResource> resources = LockableResourcesManager.get().getResources(); for (LockableResource resource : resources) { List<StepContext> queuedContexts = resource.getQueuedContexts(); if (queuedContexts.size() > 0) { for (StepContext queuedContext : queuedContexts) { List<String> resourcesNames = new ArrayList<String>(); resourcesNames.add(resource.getName()); LockableResourcesStruct resourceHolder = new LockableResourcesStruct(resourcesNames, "", 0); LockableResourcesManager.get().queueContext(queuedContext, resourceHolder, resource.getName()); } queuedContexts.clear(); } } }
Source:
<code>public Flux<?> adapt(final SubscribableChannel boundElement, MethodParameter parameter) { ResolvableType resolvableType = ResolvableType.forMethodParameter(parameter); final Class<?> argumentClass = (resolvableType.getGeneric(0).getRawClass() != null) ? (resolvableType .getGeneric(0).getRawClass()) : Object.class; final Object monitor = new Object(); if (Message.class.isAssignableFrom(argumentClass)) { return Flux.create(emitter -> { MessageHandler messageHandler = message -> { synchronized (monitor) { emitter.next(message); } }; boundElement.subscribe(messageHandler); emitter.setCancellation(() -> boundElement.unsubscribe(messageHandler)); }).publish().autoConnect(); } else { return Flux.create(emitter -> { MessageHandler messageHandler = message -> { synchronized (monitor) { <START> if (argumentClass.equals(Object.class) <END> || argumentClass.isAssignableFrom(message .getPayload().getClass())) { emitter.next(message.getPayload()); } else { emitter.next(this.messageConverter.fromMessage(message, argumentClass)); } } }; boundElement.subscribe(messageHandler); emitter.setCancellation(() -> boundElement.unsubscribe(messageHandler)); }).publish().autoConnect(); } }</code><technical_language>redundant, argumentClass is Object.class</technical_language>

Target:
public Flux<?> adapt(final SubscribableChannel boundElement, MethodParameter parameter) { ResolvableType resolvableType = ResolvableType.forMethodParameter(parameter); final Class<?> argumentClass = (resolvableType.getGeneric(0).getRawClass() != null) ? (resolvableType .getGeneric(0).getRawClass()) : Object.class; final Object monitor = new Object(); if (Message.class.isAssignableFrom(argumentClass)) { return Flux.create(emitter -> { MessageHandler messageHandler = message -> { synchronized (monitor) { emitter.next(message); } }; boundElement.subscribe(messageHandler); emitter.setCancellation(() -> boundElement.unsubscribe(messageHandler)); }).publish().autoConnect(); } else { return Flux.create(emitter -> { MessageHandler messageHandler = message -> { synchronized (monitor) { if (argumentClass.isAssignableFrom(message .getPayload().getClass())) { emitter.next(message.getPayload()); } else { emitter.next(this.messageConverter.fromMessage(message, argumentClass)); } } }; boundElement.subscribe(messageHandler); emitter.setCancellation(() -> boundElement.unsubscribe(messageHandler)); }).publish().autoConnect(); } }
Source:
<code>public void addListener(AbstractCacheListener listener){ <START> if(cacheListeners == null){ <END> cacheListeners = new ArrayList<AbstractCacheListener>(); } cacheListeners.add(listener); }</code><technical_language>need check null if initialized empty list</technical_language>

Target:
public void addListener(AbstractCacheListener listener){ cacheListeners.add(listener); }
Source:
<code>private TaskData doInBackgroundLoadStatistics(TaskData... params) { Log.i(AnkiDroidApp.TAG, "doInBackgroundLoadStatistics"); Collection col = params[0].getCollection(); int type = params[0].getInt(); boolean wholeCollection = params[0].getBoolean(); Stats stats = new Stats(col, wholeCollection); <START> Stats.ChartPeriodType chartPeriodType = Stats.ChartPeriodType.valueOf(AnkiDroidApp.getSharedPrefs( <END> AnkiDroidApp.getInstance().getBaseContext()).getInt("statsType", Stats.TYPE_MONTH)); switch (type) { default: case Stats.TYPE_FORECAST: return new TaskData(stats.calculateDue(chartPeriodType)); case Stats.TYPE_REVIEW_COUNT: return new TaskData(stats.calculateDone(chartPeriodType, true)); case Stats.TYPE_REVIEW_TIME: return new TaskData(stats.calculateDone(chartPeriodType, false)); case Stats.TYPE_INTERVALS: return new TaskData(stats.calculateIntervals(chartPeriodType)); case Stats.TYPE_HOURLY_BREAKDOWN: return new TaskData(stats.calculateBreakdown(chartPeriodType)); case Stats.TYPE_WEEKLY_BREAKDOWN: return new TaskData(stats.calculateWeeklyBreakdown(chartPeriodType)); case Stats.TYPE_ANSWER_BUTTONS: return new TaskData(stats.calculateAnswerButtons(chartPeriodType)); case Stats.TYPE_CARDS_TYPES: return new TaskData(stats.calculateCardsTypes(chartPeriodType)); } }</code><technical_language>this stuff in DeckTask do anything? implementing AsyncTask I DeckTask basically include do statistics...</technical_language>

Target:
private TaskData doInBackgroundLoadStatistics(TaskData... params) { Log.i(AnkiDroidApp.TAG, "doInBackgroundLoadStatistics"); Collection col = params[0].getCollection(); int type = params[0].getInt(); boolean wholeCollection = params[0].getBoolean(); Stats stats = new Stats(col, wholeCollection); int chartPeriodType = AnkiDroidApp.getSharedPrefs( AnkiDroidApp.getInstance().getBaseContext()).getInt("statsType", Stats.TYPE_MONTH); switch (type) { default: case Stats.TYPE_FORECAST: return new TaskData(stats.calculateDue(chartPeriodType)); case Stats.TYPE_REVIEW_COUNT: return new TaskData(stats.calculateDone(chartPeriodType, true)); case Stats.TYPE_REVIEW_TIME: return new TaskData(stats.calculateDone(chartPeriodType, false)); case Stats.TYPE_INTERVALS: return new TaskData(stats.calculateIntervals(chartPeriodType)); case Stats.TYPE_HOURLY_BREAKDOWN: return new TaskData(stats.calculateBreakdown(chartPeriodType)); case Stats.TYPE_WEEKLY_BREAKDOWN: return new TaskData(stats.calculateWeeklyBreakdown(chartPeriodType)); case Stats.TYPE_ANSWER_BUTTONS: return new TaskData(stats.calculateAnswerButtons(chartPeriodType)); case Stats.TYPE_CARDS_TYPES: return new TaskData(stats.calculateCardsTypes(chartPeriodType)); } }
Source:
<code>File getSurefireTempDir() { File result = IS_OS_WINDOWS ? createSurefireBootDirectoryInTemp() : createSurefireBootDirectoryInBuild(); try { File canonical = result.getCanonicalFile(); if ( !result.equals( canonical ) ) { <START> logger.debug( "Canonicalized tempDir path " + result + " to " + canonical ); <END> } return canonical; } catch ( IOException err ) { logger.error( "Could not canonicalize tempDir path '" + result + "'", err ); } return result; }</code><technical_language>simple quotation marks is IOException avoids white spaces: logger.debug( "Canonicalized surefire tempDir path '" + result + "' '" + canonical + "'." )</technical_language>

Target:
File getSurefireTempDir() { File result = IS_OS_WINDOWS ? createSurefireBootDirectoryInTemp() : createSurefireBootDirectoryInBuild(); try { File canonical = result.getCanonicalFile(); if ( !result.equals( canonical ) ) { logger.debug( "Canonicalized tempDir path '" + result + "' to '" + canonical + "'" ); } return canonical; } catch ( IOException e ) { logger.error( "Could not canonicalize tempDir path '" + result + "'", e ); } return result; }
Source:
<code>private Set<Plugin> addMissingDependencies(Map<Plugin, List<Plugin>> plugins) { if (!plugins.containsKey(this)) { <START> plugins.put(this, getNeededDependencies()); <END> } for (Plugin p : plugins.get(this)) { if (plugins.get(p) == null) { p.addMissingDependencies(plugins); } } Set<Plugin> allDependencies = new HashSet<Plugin>(); for (List<Plugin> pluginDependencies : plugins.values()) { allDependencies.addAll(pluginDependencies); } allDependencies.remove(this); return allDependencies; }</code><technical_language>check dependencies correctly. If dependencies "myplugin-0.2" "myplugin-04", added list I</technical_language>

Target:
private void addMissingDependencies(Map<Plugin, List<Plugin>> plugins) { boolean alreadyAdded = false; Optional<Plugin> plugin = plugins.keySet().stream().filter(item -> item.name.equals(this.name)).findFirst(); if (plugin.isPresent()) { if(new VersionNumber(plugin.get().version).isOlderThan(new VersionNumber(this.version))) { plugins.remove(plugin.get()); } else { alreadyAdded = true; } } if(!alreadyAdded) { plugins.put(this, getNeededDependencies()); for (Plugin p : plugins.get(this)) { Optional<Plugin> old = plugins.keySet().stream().filter(item -> item.name.equals(p.name)).findFirst(); if (!old.isPresent() || new VersionNumber(old.get().version).isOlderThan(new VersionNumber(p.version))) { p.addMissingDependencies(plugins); } } } }
Source:
<code>public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof EventDeclaration)) { return false; } EventDeclaration other = (EventDeclaration) obj; if (context == null) { if (other.context != null) { return false; } } else if (!context.equals(other.context)) { return false; } if (fields == null) { if (other.fields != null) { return false; } } else if (!fields.equals(other.fields)) { return false; } if (id == null) { if (other.id != null) { return false; } } else if (!id.equals(other.id)) { return false; } if (name == null) { if (other.name != null) { return false; } } else if (!name.equals(other.name)) { return false; } if (stream == null) { if (other.stream != null) { return false; } } else if (!stream.equals(other.stream)) { <START> return false; <END> } return true; }</code><technical_language>needs consider customAttributes</technical_language>

Target:
public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof EventDeclaration)) { return false; } EventDeclaration other = (EventDeclaration) obj; if (context == null) { if (other.context != null) { return false; } } else if (!context.equals(other.context)) { return false; } if (fields == null) { if (other.fields != null) { return false; } } else if (!fields.equals(other.fields)) { return false; } if (id == null) { if (other.id != null) { return false; } } else if (!id.equals(other.id)) { return false; } if (name == null) { if (other.name != null) { return false; } } else if (!name.equals(other.name)) { return false; } if (stream == null) { if (other.stream != null) { return false; } } else if (!stream.equals(other.stream)) { return false; } if (!customAttributes.equals(other.customAttributes)) { return false; } return true; }
Source:
<code>public String readableString() { StringBuilder serviceConfigurationsToStringBuilder = new StringBuilder(); for (ServiceConfiguration serviceConfiguration : serviceConfigurations) { serviceConfigurationsToStringBuilder .append("- "); if(serviceConfiguration instanceof HumanReadable) { serviceConfigurationsToStringBuilder .append(((HumanReadable)serviceConfiguration).readableString()) .append("\n"); } else { serviceConfigurationsToStringBuilder .append(serviceConfiguration.getClass().getName()) .append("\n"); } } if(serviceConfigurationsToStringBuilder.length() > 0) { serviceConfigurationsToStringBuilder.deleteCharAt(serviceConfigurationsToStringBuilder.length() -1); } StringBuilder cacheConfigurationListenerToStringBuilder = new StringBuilder(); <START> for (CacheConfigurationChangeListener cacheConfigurationChangeListener : cacheConfigurationListenerList) { <END> cacheConfigurationListenerToStringBuilder .append("- ") .append(cacheConfigurationChangeListener.getClass().getName()) .append("\n"); } if(!cacheConfigurationListenerList.isEmpty()) { cacheConfigurationListenerToStringBuilder.deleteCharAt(cacheConfigurationListenerToStringBuilder.length() -1); } return "keyType: " + keyType.getName() + "\n " + "valueType: " + valueType.getName() + "\n " + "serviceConfigurations:\n " + serviceConfigurationsToStringBuilder.toString().replace("\n", "\n ") + "\n " + "evictionAdvisor: " + ((evictionAdvisor != null) ? evictionAdvisor.getClass().getName() : "") + "\n " + "expiry: " + ((expiry != null) ? expiry.getClass().getSimpleName() : "") + "\n " + "resourcePools: " + "\n " + ((resourcePools instanceof HumanReadable) ? ((HumanReadable)resourcePools).readableString() : "").replace("\n", "\n "); }</code><technical_language>internal get notified configuration updated - pretty sense in human readable format</technical_language>

Target:
public String readableString() { StringBuilder serviceConfigurationsToStringBuilder = new StringBuilder(); for (ServiceConfiguration serviceConfiguration : serviceConfigurations) { serviceConfigurationsToStringBuilder .append("- "); if(serviceConfiguration instanceof HumanReadable) { serviceConfigurationsToStringBuilder .append(((HumanReadable)serviceConfiguration).readableString()) .append("\n"); } else { serviceConfigurationsToStringBuilder .append(serviceConfiguration.getClass().getName()) .append("\n"); } } if(serviceConfigurationsToStringBuilder.length() > 0) { serviceConfigurationsToStringBuilder.deleteCharAt(serviceConfigurationsToStringBuilder.length() -1); } return "keyType: " + keyType.getName() + "\n" + "valueType: " + valueType.getName() + "\n" + "serviceConfigurations:\n " + serviceConfigurationsToStringBuilder.toString().replace("\n", "\n ") + "\n" + "evictionAdvisor: " + ((evictionAdvisor != null) ? evictionAdvisor.getClass().getName() : "") + "\n" + "expiry: " + ((expiry != null) ? expiry.getClass().getSimpleName() : "") + "\n" + "resourcePools: " + "\n " + ((resourcePools instanceof HumanReadable) ? ((HumanReadable)resourcePools).readableString() : "").replace("\n", "\n "); }
Source:
<code>private synchronized void updateInternal(TimelockAuthConfiguration authConfiguration) { <START> authServices = getAuthServices(authConfiguration); <END> }</code><technical_language>need synchronized anymore, needs set return authServices</technical_language>

Target:
private synchronized AuthServices updateInternal(TimelockAuthConfiguration authConfiguration) { return authServices.updateAndGet(ignored -> getAuthServices(authConfiguration)); }
Source:
<code>public void updateVmConfiguration(final INewAsyncCallback onUpdateAsyncCallback) { Snapshot snapshot = getEntity(); if (snapshot == null) { return; } AsyncDataProvider.getInstance().getVmConfigurationBySnapshot(new AsyncQuery(this, new INewAsyncCallback() { @Override public void onSuccess(Object target, Object returnValue) { SnapshotModel snapshotModel = (SnapshotModel) target; Snapshot snapshot = snapshotModel.getEntity(); VM vm = (VM) returnValue; if (vm != null && snapshot != null) { snapshotModel.setVm(vm); snapshotModel.setDisks(vm.getDiskList()); snapshotModel.setNics(vm.getInterfaces()); snapshotModel.setApps(Arrays.asList(snapshot.getAppList() != null ? snapshot.getAppList().split(",") : new String[]{})); Collections.sort(snapshotModel.getDisks(), new Linq.DiskByAliasComparer()); <START> Collections.sort(snapshotModel.getNics(), VmNetworkInterfaceComparator.BY_NAME); <END> } onUpdateAsyncCallback.onSuccess(snapshotModel, null); } }), snapshot.getId()); }</code><technical_language>This stay VmInterfaceComparer, VmNetworkInterfaceComparator class added anymore</technical_language>

Target:
public void updateVmConfiguration(final INewAsyncCallback onUpdateAsyncCallback) { Snapshot snapshot = getEntity(); if (snapshot == null) { return; } AsyncDataProvider.getInstance().getVmConfigurationBySnapshot(new AsyncQuery(this, new INewAsyncCallback() { @Override public void onSuccess(Object target, Object returnValue) { SnapshotModel snapshotModel = (SnapshotModel) target; Snapshot snapshot = snapshotModel.getEntity(); VM vm = (VM) returnValue; if (vm != null && snapshot != null) { snapshotModel.setVm(vm); snapshotModel.setDisks(vm.getDiskList()); snapshotModel.setNics(vm.getInterfaces()); snapshotModel.setApps(Arrays.asList(snapshot.getAppList() != null ? snapshot.getAppList().split(",") : new String[]{})); Collections.sort(snapshotModel.getDisks(), new Linq.DiskByAliasComparer()); Collections.sort(snapshotModel.getNics(), new Linq.VmInterfaceComparer()); } onUpdateAsyncCallback.onSuccess(snapshotModel, null); } }), snapshot.getId()); }
Source:
<code>public long getEventsInRange(long start, long end) { <START> long startCount; <END> if (start == stats.getStartTime()) { startCount = 0; } else { startCount = getEventCountAt(start - 1); } long endCount = getEventCountAt(end); return endCount - startCount; }</code><technical_language>removed stats.waitUntilBuilt(). Why</technical_language>

Target:
public long getEventsInRange(long start, long end) { stats.waitUntilBuilt(); long startCount; if (start == stats.getStartTime()) { startCount = 0; } else { startCount = getEventCountAt(start - 1); } long endCount = getEventCountAt(end); return endCount - startCount; }
Source:
<code><START> public List<Future<?>> getFutures() { <END> return futures; }</code><technical_language>This "package-private", i.e. access modifier</technical_language>

Target:
List<Future<?>> getFutures() { return futures; }
Source:
<code><START> public ProjectState() throws IOException { <END> config = new SimpleObjectProperty<>(); service = new SimpleObjectProperty<>(); metadata = new SimpleObjectProperty<>(); config.addListener((obs, oldVal, newVal) -> { if (newVal == null) { service.set(null); metadata.set(null); } else if (oldVal != newVal) { service.set(ProjectService.create(newVal)); } }); }</code><technical_language>Constructor throws exception is pretty ugly. Especially is created injected Guice</technical_language>

Target:
public ProjectState() { config = new SimpleObjectProperty<>(); }
Source:
<code>private void updateHaMaintenanceAvailability(List items) { if (items == null || items.size() != 1) { setHaMaintenanceAvailability(false); return; } VM vm = (VM) getSelectedItem(); if (vm == null || !vm.isHostedEngine() || vm.getVdsGroupCompatibilityVersion().compareTo(Version.v3_4) < 0) { setHaMaintenanceAvailability(false); return; } Frontend.getInstance().runQuery(VdcQueryType.GetVdsByVdsId, new IdQueryParameters(vm.getRunOnVds()), new AsyncQuery(this, new INewAsyncCallback() { @Override public void onSuccess(Object model, Object returnValue) { VdcQueryReturnValue response = (VdcQueryReturnValue) returnValue; if (response == null || !response.getSucceeded() || response.getReturnValue() == null) { setHaMaintenanceAvailability(false); } else { VDS vds = response.getReturnValue(); setHaMaintenanceAvailability(vds.getHighlyAvailableIsConfigured()); } } <START> }, true)); <END> }</code><technical_language>afraid query server for click, especially in vm screen. please a solution (you check performing command), server deal it</technical_language>

Target:
private void updateHaMaintenanceAvailability(List items) { if (items == null || items.size() != 1) { setHaMaintenanceAvailability(false); return; } VM vm = (VM) getSelectedItem(); if (vm == null || !vm.isHostedEngine() || vm.getVdsGroupCompatibilityVersion().compareTo(Version.v3_4) < 0) { setHaMaintenanceAvailability(false); } else { setHaMaintenanceAvailability(true); } }
Source:
<code>public void setUp() throws CTFException { fTrace = new CtfTmfTrace(); int capacity = 2048; ByteBuffer bb = ByteBuffer.allocateDirect(capacity); StructDeclaration sDec = new StructDeclaration(1l); IntegerDeclaration intDec = IntegerDeclaration.INT_8_DECL; sDec.addField("cpu_id", intDec); sDec.addField("CpuId", intDec); <START> bb.put((byte) 2); bb.put((byte) 3); <END> StructDefinition def = sDec.createDefinition(null, ROOT, new BitBuffer(bb)); EventDeclaration dec = new EventDeclaration(); dec.setName("hi"); fEvents.add(new EventDefinition(dec, -1, 0, null, null, null, null, def, null)); fEvents.add(new EventDefinition(dec, 3, 0, null, null, null, null, def, null)); fEvents.add(new EventDefinition(dec, -1, 0, null, null, null, def, null, null)); fEvents.add(new EventDefinition(dec, -1, 0, null, null, null, null, null, null)); }</code><technical_language>values? Extract some properly named constant</technical_language>

Target:
public void setUp() throws CTFException { fTrace = new CtfTmfTrace(); int capacity = 2048; ByteBuffer bb = ByteBuffer.allocateDirect(capacity); StructDeclaration sDec = new StructDeclaration(1l); IntegerDeclaration intDec = IntegerDeclaration.INT_8_DECL; sDec.addField("cpu_id", intDec); sDec.addField("CpuId", intDec); bb.put((byte) 2); bb.put((byte) 3); StructDefinition def = sDec.createDefinition(null, ROOT, new BitBuffer(bb)); EventDeclaration dec = new EventDeclaration(); dec.setName("hi"); fEvents.add(new EventDefinition(dec, IEventDefinition.UNKNOWN_CPU, 0, null, null, null, null, def, null)); fEvents.add(new EventDefinition(dec, 3, 0, null, null, null, null, def, null)); fEvents.add(new EventDefinition(dec, IEventDefinition.UNKNOWN_CPU, 0, null, null, null, def, null, null)); fEvents.add(new EventDefinition(dec, IEventDefinition.UNKNOWN_CPU, 0, null, null, null, null, null, null)); fEvents.add(new EventDefinition(dec, 6, 0, null, null, null, null, null, null)); }
Source:
<code>public void initialize() { logger.debug("Initializing hue light handler."); final String configLightId = (String) getConfig().get(LIGHT_ID); if (configLightId != null) { lightId = configLightId; if (getHueBridgeHandler() != null) { ThingStatusInfo statusInfo = getBridge().getStatusInfo(); updateStatus(statusInfo.getStatus(), statusInfo.getStatusDetail(), statusInfo.getDescription()); FullLight fullLight = getLight(); if (fullLight != null) { updateProperty(Thing.PROPERTY_FIRMWARE_VERSION, fullLight.getSoftwareVersion()); String thingUID = fullLight.getModelID(); <START> if (thingUID.equals("PAR16 50 TW")) { <END> isOsramPar16 = true; } } } } }</code><technical_language>string moved HueBindingConstants</technical_language>

Target:
public void initialize() { logger.debug("Initializing hue light handler."); final String configLightId = (String) getConfig().get(LIGHT_ID); if (configLightId != null) { lightId = configLightId; if (getHueBridgeHandler() != null) { ThingStatusInfo statusInfo = getBridge().getStatusInfo(); updateStatus(statusInfo.getStatus(), statusInfo.getStatusDetail(), statusInfo.getDescription()); FullLight fullLight = getLight(); if (fullLight != null) { updateProperty(Thing.PROPERTY_FIRMWARE_VERSION, fullLight.getSoftwareVersion()); String thingUID = fullLight.getModelID(); if (thingUID.equals(OSRAM_PAR16_MODELID)) { isOsramPar16 = true; } } } } }
Source:
<code>protected void executeVmCommand() { ImagesHandler.setDiskAlias(getParameters().getDiskInfo(), getVm()); if (resizeDiskImageRequested()) { switch (getOldDisk().getDiskStorageType()) { case IMAGE: extendDiskImageSize(); break; case CINDER: extendCinderDiskSize(); break; } } else { try { boolean shouldUpdate = true; if (Objects.equals(getOldDisk().getDiskStorageType(), DiskStorageType.IMAGE) && amendDiskRequested()) { amendDiskImage(); shouldUpdate = getSucceeded(); } if (shouldUpdate) { <START> performDiskUpdate(false); <END> } } finally { freeLock(); } } }</code><technical_language>disk update run amend. switch order operations</technical_language>

Target:
protected void executeVmCommand() { ImagesHandler.setDiskAlias(getParameters().getDiskInfo(), getVm()); if (resizeDiskImageRequested()) { switch (getOldDisk().getDiskStorageType()) { case IMAGE: extendDiskImageSize(); break; case CINDER: extendCinderDiskSize(); break; } } else { try { performDiskUpdate(false); if (Objects.equals(getOldDisk().getDiskStorageType(), DiskStorageType.IMAGE) && amendDiskRequested()) { amendDiskImage(); } } finally { freeLock(); } } }
Source:
<code>public Optional<Charge> findByProviderAndTransactionIdFromDbOrLedger(String paymentGatewayName, String gatewayTransactionId) { Optional<ChargeEntity> maybeChargeEntity = chargeDao.findByProviderAndTransactionId(paymentGatewayName, gatewayTransactionId); if(maybeChargeEntity.isPresent()) { return maybeChargeEntity.map(Charge::from); } else{ return ledgerService.getTransactionForProviderAndGatewayTransactionId(paymentGatewayName,gatewayTransactionId) <START> .map(Charge::from); <END> } }</code><technical_language>slightly nicer (but ideal) do this? java public Optional<Charge> findByProviderAndTransactionIdFromDbOrLedger(String paymentGatewayName, String gatewayTransactionId) { return Optional.ofNullable(chargeDao.findByProviderAndTransactionId(paymentGatewayName, gatewayTransactionId) .map(Charge::from) .orElseGet(() -> findChargeFromLedger(paymentGatewayName, gatewayTransactionId).orElse(null))); } private Optional<Charge> findChargeFromLedger(String paymentGatewayName, String gatewayTransactionId) { return ledgerService.getTransactionForProviderAndGatewayTransactionId(paymentGatewayName,gatewayTransactionId).map(Charge::from); }</technical_language>

Target:
public Optional<Charge> findByProviderAndTransactionIdFromDbOrLedger(String paymentGatewayName, String gatewayTransactionId) { return Optional.ofNullable(chargeDao.findByProviderAndTransactionId(paymentGatewayName, gatewayTransactionId) .map(Charge::from) .orElseGet(() -> findChargeFromLedger(paymentGatewayName, gatewayTransactionId).orElse(null))); }
Source:
<code>public boolean canAccessTarget(JobStatus target, SubResource subResource, Access required) { boolean principalNameMatch = target.getPrincipalName().equals(principalName); String ownerId = target.getOwnerId(); boolean ownerOk = ownerId != null && allowedOrgIds.contains(ownerId); if (!ownerOk) { return false; } if (JobStatus.TargetType.OWNER.name().equalsIgnoreCase(target.getTargetType()) && !ownerId.equals(target.getTargetId())) { return false; } if ("user".equalsIgnoreCase(principalType)) { if (principalNameMatch) { return Access.ALL.provides(required); } else { return Access.READ_ONLY.provides(required); } } else if ("consumer".equalsIgnoreCase(principalType)) { return Access.ALL.provides(required) && principalNameMatch; } <START> else { <END> return false; } }</code><technical_language>a picky, save a couple of lines else is required -- return false</technical_language>

Target:
public boolean canAccessTarget(JobStatus target, SubResource subResource, Access required) { boolean principalNameMatch = target.getPrincipalName().equals(principalName); String ownerId = target.getOwnerId(); boolean ownerOk = ownerId != null && allowedOrgIds.contains(ownerId); if (!ownerOk) { return false; } if (JobStatus.TargetType.OWNER.name().equalsIgnoreCase(target.getTargetType()) && !ownerId.equals(target.getTargetId())) { return false; } if ("user".equalsIgnoreCase(principalType)) { if (principalNameMatch) { return Access.ALL.provides(required); } else { return Access.READ_ONLY.provides(required); } } else if ("consumer".equalsIgnoreCase(principalType)) { return Access.ALL.provides(required) && principalNameMatch; } return false; }
Source:
<code>private void applyChangesFromList(View rootView, List<ViewVisitor> changes) { synchronized (mCurrentEdits) { final int size = changes.size(); for (int i = 0; i < size; i++) { final ViewVisitor visitor = changes.get(i); try { final EditBinding binding = new EditBinding(rootView, visitor, mUiThreadHandler); mCurrentEdits.add(binding); } catch (ViewVisitor.LayoutUpdateException e) { <START> mEditErrorMessage.sendErrorMessage(e.getErrorInfo()); <END> } } } }</code><technical_language>This early catch error- continue visiting time system updates global view layout, throw in there, too</technical_language>

Target:
private void applyChangesFromList(View rootView, List<ViewVisitor> changes) { synchronized (mCurrentEdits) { final int size = changes.size(); for (int i = 0; i < size; i++) { final ViewVisitor visitor = changes.get(i); final EditBinding binding = new EditBinding(rootView, visitor, mUiThreadHandler); mCurrentEdits.add(binding); } } }
Source:
<code>public void train(int diseaseGroupId, List<DiseaseOccurrence> occurrences) throws MachineWeightingPredictorException { try { <START> webService.sendTrainingData(diseaseGroupId, occurrences); <END> } catch (WebServiceClientException|JsonProcessingException e) { LOGGER.error(e.getMessage()); throw new MachineWeightingPredictorException(TRAINING_FAILURE); } }</code><technical_language>Log message? DiseaseExtentGenerator.DISEASE_GROUP_AND_OCCURRENCES_MESSAGE (which is level MachineWeightingPredictor)</technical_language>

Target:
public void train(int diseaseGroupId, List<DiseaseOccurrence> occurrences) throws MachineWeightingPredictorException { try { LOGGER.info(String.format(TRAINING_MESSAGE, diseaseGroupId, occurrences.size())); webService.sendTrainingData(diseaseGroupId, occurrences); } catch (WebServiceClientException|JsonProcessingException e) { LOGGER.error(e.getMessage()); throw new MachineWeightingPredictorException(TRAINING_FAILURE); } }
Source:
<code>private Map<String, SystemStreamMetadata> fetchSystemStreamMetadata(Set<String> topics) { Map<SystemStreamPartition, String> allOldestOffsets = new HashMap<>(); Map<SystemStreamPartition, String> allNewestOffsets = new HashMap<>(); Map<SystemStreamPartition, String> allUpcomingOffsets = new HashMap<>(); LOG.info("Fetching SystemStreamMetadata for topics on system {}", topics, systemName); topics.forEach(topic -> { List<PartitionInfo> partitionInfos = threadSafeKafkaConsumer.execute(consumer -> consumer.partitionsFor(topic)); if (partitionInfos == null) { String msg = String.format("Partition info not(yet?) available for system %s topic %s", systemName, topic); throw new SamzaException(msg); } List<TopicPartition> topicPartitions = partitionInfos.stream() .map(partitionInfo -> new TopicPartition(partitionInfo.topic(), partitionInfo.partition())) .collect(Collectors.toList()); <START> OffsetsMaps offsetsForTopic = fetchTopicPartitionsMetadata(topicPartitions); <END> allOldestOffsets.putAll(offsetsForTopic.getOldestOffsets()); allNewestOffsets.putAll(offsetsForTopic.getNewestOffsets()); allUpcomingOffsets.putAll(offsetsForTopic.getUpcomingOffsets()); }); return assembleMetadata(allOldestOffsets, allNewestOffsets, allUpcomingOffsets); }</code><technical_language>potential side effects splitting partitionsFor fetchTopicPartitionsMetadata separate synchronized blocks? I a full understanding for is thread-safe Kafka Consumer, I reducing granularity of synchronized blocks individual Kafka consumer method calls expose some of thread-safety issues. Pardon ignorance if understanding is wrong</technical_language>

Target:
private Map<String, SystemStreamMetadata> fetchSystemStreamMetadata(Set<String> topics) { Map<SystemStreamPartition, String> allOldestOffsets = new HashMap<>(); Map<SystemStreamPartition, String> allNewestOffsets = new HashMap<>(); Map<SystemStreamPartition, String> allUpcomingOffsets = new HashMap<>(); LOG.info("Fetching SystemStreamMetadata for topics on system {}", topics, systemName); topics.forEach(topic -> { OffsetsMaps offsetsForTopic = threadSafeKafkaConsumer.execute(consumer -> { List<PartitionInfo> partitionInfos = consumer.partitionsFor(topic); if (partitionInfos == null) { String msg = String.format("Partition info not(yet?) available for system %s topic %s", systemName, topic); throw new SamzaException(msg); } List<TopicPartition> topicPartitions = partitionInfos.stream() .map(partitionInfo -> new TopicPartition(partitionInfo.topic(), partitionInfo.partition())) .collect(Collectors.toList()); return fetchTopicPartitionsMetadata(topicPartitions); }); allOldestOffsets.putAll(offsetsForTopic.getOldestOffsets()); allNewestOffsets.putAll(offsetsForTopic.getNewestOffsets()); allUpcomingOffsets.putAll(offsetsForTopic.getUpcomingOffsets()); }); return assembleMetadata(allOldestOffsets, allNewestOffsets, allUpcomingOffsets); }
Source:
<code>private static void checkInstallConfig(AtlasDbConfig config) { if (config.getSweepBatchSize() != null || config.getSweepCellBatchSize() != null || config.getSweepReadLimit() != null || config.getSweepCandidateBatchHint() != null || config.getSweepDeleteBatchHint() != null) { <START> log.error("Your configuration specifies sweep parameters on the install config." <END> + " Please use the runtime config to specify them."); } }</code><technical_language>mention</technical_language>

Target:
private static void checkInstallConfig(AtlasDbConfig config) { if (config.getSweepBatchSize() != null || config.getSweepCellBatchSize() != null || config.getSweepReadLimit() != null || config.getSweepCandidateBatchHint() != null || config.getSweepDeleteBatchHint() != null) { log.error("Your configuration specifies sweep parameters on the install config. They will be ignored." + " Please use the runtime config to specify them."); } }
Source:
<code>public void authenticate(String username, final String password, final AsyncCallback<LoginResult> callback) { LoginResult result = new LoginResult(); if (username == null || "".equals(username.trim()) || password == null || "".equals(password)) { result.success = false; callback.onSuccess(result); return; } username = username.trim(); final AuthRequest req = AuthRequest.forUser(username); req.setPassword(password); final AuthResult res; try { res = accountManager.authenticate(req); } catch (AccountException e) { result.success = false; callback.onSuccess(result); return; } result.success = true; result.isNew = res.isNew(); try { webSession.get().login(res, false); <START> } catch (OrmException e) { <END> result.success = false; callback.onSuccess(result); return; } callback.onSuccess(result); }</code><technical_language>log this exception server's log file, administrator browser sign-in</technical_language>

Target:
public void authenticate(String username, final String password, final AsyncCallback<LoginResult> callback) { LoginResult result = new LoginResult(); if (username == null || "".equals(username.trim()) || password == null || "".equals(password)) { result.success = false; callback.onSuccess(result); return; } username = username.trim(); final AuthRequest req = AuthRequest.forUser(username); req.setPassword(password); final AuthResult res; try { res = accountManager.authenticate(req); } catch (AccountException e) { result.success = false; callback.onSuccess(result); return; } result.success = true; result.isNew = res.isNew(); try { webSession.get().login(res, false); } catch (OrmException e) { log.error("Unable to log in", e); result.success = false; callback.onSuccess(result); return; } callback.onSuccess(result); }
Source:
<code>private Guid createVmCheckpoint() { <START> if (isBackupContainsRawDisksOnly()) { <END> return null; } final VmCheckpoint vmCheckpoint = new VmCheckpoint(); vmCheckpoint.setId(Guid.newGuid()); vmCheckpoint.setParentId(getParameters().getVmBackup().getFromCheckpointId()); vmCheckpoint.setVmId(getParameters().getVmBackup().getVmId()); vmCheckpoint.setCreationDate(new Date()); final List<VmCheckpoint> checkpoints = vmCheckpointDao.getAllForVm(getVmId()); if (!checkpoints.isEmpty()) { vmCheckpoint.setParentId(checkpoints.get(checkpoints.size() - 1).getId()); } TransactionSupport.executeInNewTransaction(() -> { vmCheckpointDao.save(vmCheckpoint); getParameters().getVmBackup().getDisks().stream() .filter(DiskImage::isQcowFormat) .forEach(disk -> vmCheckpointDao.addDiskToCheckpoint(vmCheckpoint.getId(), disk.getId())); return null; }); persistCommandIfNeeded(); return vmCheckpoint.getId(); }</code><technical_language>this check move calling code? if (!isBackupContainsRawDisksOnly()) { log.info("not creating checkpoint } else { ... }</technical_language>

Target:
private Guid createVmCheckpoint() { final VmCheckpoint vmCheckpoint = new VmCheckpoint(); vmCheckpoint.setId(Guid.newGuid()); vmCheckpoint.setParentId(getParameters().getVmBackup().getFromCheckpointId()); vmCheckpoint.setVmId(getParameters().getVmBackup().getVmId()); vmCheckpoint.setCreationDate(new Date()); final List<VmCheckpoint> checkpoints = vmCheckpointDao.getAllForVm(getVmId()); if (!checkpoints.isEmpty()) { vmCheckpoint.setParentId(checkpoints.get(checkpoints.size() - 1).getId()); } TransactionSupport.executeInNewTransaction(() -> { vmCheckpointDao.save(vmCheckpoint); getParameters().getVmBackup().getDisks().stream() .filter(DiskImage::isQcowFormat) .forEach(disk -> vmCheckpointDao.addDiskToCheckpoint(vmCheckpoint.getId(), disk.getId())); return null; }); persistCommandIfNeeded(); return vmCheckpoint.getId(); }