auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private <T> boolean hasApparentlyEqualsAndWarn(Collection<? extends T> items, T newItem) { T oldItem = findApparentlyEquals(items, newItem); if (oldItem!=null) { LOG.warn("Adding to "+this+", "+newItem+" appears identical to existing "+oldItem+"; will remove after adding"); return true; } else { return false; } }

Target:
private <T> boolean hasApparentlyEqualsAndWarn(Collection<? extends T> items, T newItem) { T oldItem = findApparentlyEquals(items, newItem); if (oldItem!=null) { if (isRebinding()) { LOG.warn("Adding to "+this+", "+newItem+" appears identical to existing "+oldItem+"; will remove after adding. " + "Underlying addition should be checked as this behavior will likely be removed without further notice."); return true; } else { LOG.warn("Adding to "+this+", "+newItem+" appears identical to existing "+oldItem+"; may get removed on rebind. " + "If unintended, addition should be removed. If intended, enricher should be modified so difference is apparent."); return false; } } else { return false; } }
Source:
public void setupRoutes() { path(controllerBasePath(), () -> { before("", mimeType, this::setContentType); before("", mimeType, authHelper::checkUserAnd403); before("", mimeType, this::verifyContentType); before("/*", mimeType, this::setContentType); before("/*", mimeType, this::verifyContentType); get(ConfigRepos.INDEX_PATH, mimeType, this::listRepos); before(ConfigRepos.REPO_PATH, mimeType, (request, response) -> { authHelper.checkUserHasPermissions(currentUsername(), getAction(request), CONFIG_REPO, request.params(":id")); }); get(ConfigRepos.REPO_PATH, mimeType, this::showRepo); before(ConfigRepos.STATUS_PATH, mimeType, (request, response) -> { authHelper.checkUserHasPermissions(currentUsername(), getAction(request), CONFIG_REPO, request.params(":id")); }); get(ConfigRepos.STATUS_PATH, mimeType, this::inProgress); before(ConfigRepos.TRIGGER_UPDATE_PATH, mimeType, (request, response) -> { authHelper.checkUserHasPermissions(currentUsername(), getAction(request), CONFIG_REPO, request.params(":id")); }); post(ConfigRepos.TRIGGER_UPDATE_PATH, mimeType, this::triggerUpdate); before(ConfigRepos.DEFINITIONS_PATH, mimeType, (request, response) -> { authHelper.checkUserHasPermissions(currentUsername(), getAction(request), CONFIG_REPO, request.params(":id")); }); get(ConfigRepos.DEFINITIONS_PATH, mimeType, this::definedConfigs); }); }

Target:
public void setupRoutes() { path(controllerBasePath(), () -> { before("", mimeType, this::setContentType); before("", mimeType, authHelper::checkUserAnd403); before("", mimeType, this::verifyContentType); before("/*", mimeType, this::setContentType); before("/*", mimeType, this::verifyContentType); before(ConfigRepos.REPO_PATH, mimeType, this::authorize); before(ConfigRepos.STATUS_PATH, mimeType, this::authorize); before(ConfigRepos.TRIGGER_UPDATE_PATH, mimeType, this::authorize); before(ConfigRepos.DEFINITIONS_PATH, mimeType, this::authorize); get(ConfigRepos.INDEX_PATH, mimeType, this::listRepos); get(ConfigRepos.REPO_PATH, mimeType, this::showRepo); get(ConfigRepos.STATUS_PATH, mimeType, this::inProgress); post(ConfigRepos.TRIGGER_UPDATE_PATH, mimeType, this::triggerUpdate); get(ConfigRepos.DEFINITIONS_PATH, mimeType, this::definedConfigs); }); }
Source:
private Drawable getDefaultAppDrawable(ComponentName componentName, UserHandle userHandle) { try { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { LauncherApps launcher = (LauncherApps) ctx.getSystemService(Context.LAUNCHER_APPS_SERVICE); List<LauncherActivityInfo> icons = launcher.getActivityList(componentName.getPackageName(), userHandle.getRealHandle()); for (LauncherActivityInfo info : icons) { if (info.getComponentName().equals(componentName)) { Drawable icon = info.getBadgedIcon(0); if(iconsPackPackageName.equalsIgnoreCase("squircle") || iconsPackPackageName.equalsIgnoreCase("square") || iconsPackPackageName.equalsIgnoreCase("circle")) { return DrawableUtils.handleAdaptiveIcons(ctx, icon); } else { return icon; } } } return icons.get(0).getBadgedIcon(0); } else { return pm.getActivityIcon(componentName); } } catch (NameNotFoundException | IndexOutOfBoundsException e) { Log.e(TAG, "Unable to found component " + componentName.toString() + e); return null; } }

Target:
private Drawable getDefaultAppDrawable(ComponentName componentName, UserHandle userHandle) { try { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { LauncherApps launcher = (LauncherApps) ctx.getSystemService(Context.LAUNCHER_APPS_SERVICE); List<LauncherActivityInfo> icons = launcher.getActivityList(componentName.getPackageName(), userHandle.getRealHandle()); for (LauncherActivityInfo info : icons) { if (info.getComponentName().equals(componentName)) { Drawable icon = info.getBadgedIcon(0); if(DrawableUtils.isIconsPackAdaptive(iconsPackPackageName)) { return DrawableUtils.handleAdaptiveIcons(ctx, icon); } else { return icon; } } } return icons.get(0).getBadgedIcon(0); } else { return pm.getActivityIcon(componentName); } } catch (NameNotFoundException | IndexOutOfBoundsException e) { Log.e(TAG, "Unable to found component " + componentName.toString() + e); return null; } }
Source:
public <T> CompletableFuture<T> runScript(ScriptingManagerImpl scriptManager, ScriptMetadata metadata, CacheScriptBindings binding) { Cache<?, ?> masterCacheNode = (Cache<?, ?>) binding.get(SystemBindings.CACHE.toString()); if (masterCacheNode == null) { throw log.distributedTaskNeedCacheInBinding(metadata.name()); } DefaultExecutorService des = new DefaultExecutorService(masterCacheNode); try { List<Future<T>> tasks = des.submitEverywhere(new DistributedScript<T>(metadata)); List<CompletableFuture<T>> all = new ArrayList<>(tasks.size()); for(Future<T> task : tasks) { all.add(CompletableFutures.connect((NotifyingFuture<T>) task)); } return (CompletableFuture<T>) CompletableFutures.combine(all); } finally { des.shutdown(); } }

Target:
public <T> CompletableFuture<T> runScript(ScriptingManagerImpl scriptManager, ScriptMetadata metadata, CacheScriptBindings binding) { Cache<?, ?> masterCacheNode = (Cache<?, ?>) binding.get(SystemBindings.CACHE.toString()); if (masterCacheNode == null) { throw log.distributedTaskNeedCacheInBinding(metadata.name()); } DefaultExecutorService des = new DefaultExecutorService(masterCacheNode); try { List<Future<T>> tasks = des.submitEverywhere(new DistributedScript<T>(metadata)); List<CompletableFuture<T>> all = new ArrayList<>(tasks.size()); tasks.forEach(task -> all.add(CompletableFutures.toCompletableFuture((NotifyingFuture<T>) task))); return (CompletableFuture<T>) CompletableFutures.sequence(all); } finally { des.shutdown(); } }
Source:
public String toString() { ToStringHelper helper = toStringHelper(this) .add("name", name) .add("ordinalPosition", ordinalPosition) .add("type", type); return helper.toString(); }

Target:
public String toString() { return toStringHelper(this) .add("name", name) .add("ordinalPosition", ordinalPosition) .add("type", type) .toString(); }
Source:
public void testFailingScheduleOrUpdateConsumers() throws Exception { final SchedulerBase scheduler = SchedulerTestingUtils.newSchedulerBuilder(new JobGraph()).build(); scheduler.start(ComponentMainThreadExecutorServiceAdapter.forMainThread()); scheduler.startScheduling(); final ExecutionGraph eg = scheduler.getExecutionGraph(); assertEquals(JobStatus.RUNNING, eg.getState()); ExecutionGraphTestUtils.switchAllVerticesToRunning(eg); IntermediateResultPartitionID intermediateResultPartitionId = new IntermediateResultPartitionID(); ExecutionAttemptID producerId = new ExecutionAttemptID(); ResultPartitionID resultPartitionId = new ResultPartitionID(intermediateResultPartitionId, producerId); try { eg.scheduleOrUpdateConsumers(resultPartitionId); fail("Expected ExecutionGraphException."); } catch (ExecutionGraphException e) { } assertEquals(JobStatus.RUNNING, eg.getState()); }

Target:
public void testFailingScheduleOrUpdateConsumers() throws Exception { final SchedulerBase scheduler = SchedulerTestingUtils.newSchedulerBuilder(new JobGraph()).build(); scheduler.initialize(ComponentMainThreadExecutorServiceAdapter.forMainThread()); scheduler.startScheduling(); final ExecutionGraph eg = scheduler.getExecutionGraph(); assertEquals(JobStatus.RUNNING, eg.getState()); ExecutionGraphTestUtils.switchAllVerticesToRunning(eg); IntermediateResultPartitionID intermediateResultPartitionId = new IntermediateResultPartitionID(); ExecutionAttemptID producerId = new ExecutionAttemptID(); ResultPartitionID resultPartitionId = new ResultPartitionID(intermediateResultPartitionId, producerId); try { scheduler.scheduleOrUpdateConsumers(resultPartitionId); fail("Expected ExecutionGraphException."); } catch (RuntimeException e) { assertThat(e.getCause(), instanceOf(ExecutionGraphException.class)); } assertEquals(JobStatus.RUNNING, eg.getState()); }
Source:
public final int asInt() { if (value == null) { assert NullHandling.replaceWithDefault(); return 0; } final Integer theInt = Ints.tryParse(value); return theInt == null ? 0 : theInt; }

Target:
public final int asInt() { if (value == null) { assert NullHandling.replaceWithDefault(); return 0; } final Integer theInt = Ints.tryParse(value); assert NullHandling.replaceWithDefault() || theInt != null; return theInt == null ? 0 : theInt; }
Source:
public <T extends AppPage> T goToPreviousPage(Class<T> typeOfPreviousPage) { browser.driver.navigate().back(); waitForPageToLoad(); switchToNewWindow(); return changePageType(typeOfPreviousPage); }

Target:
public <T extends AppPage> T goToPreviousPage(Class<T> typeOfPreviousPage) { browser.driver.navigate().back(); waitForPageToLoad(); return changePageType(typeOfPreviousPage); }
Source:
private static boolean[] readBooleanArray(BytesObjectInput in) throws IOException { byte type = in.readByte(); int len; switch (type) { case ID_ARRAY_EMPTY: return new boolean[]{}; case ID_ARRAY_SMALL: return readBooleans(mkBooleanArray(in.readUnsignedByte(), ID_SMALL), in); case ID_ARRAY_MEDIUM: return readBooleans(mkBooleanArray(in.readUnsignedShort(), ID_MEDIUM), in); case ID_ARRAY_LARGE: return readBooleans(new boolean[in.readInt()], in); default: throw new IOException("Unknown array type: " + Integer.toHexString(type)); } }

Target:
private static boolean[] readBooleanArray(BytesObjectInput in) throws IOException { byte type = in.readByte(); switch (type) { case ID_ARRAY_EMPTY: return new boolean[]{}; case ID_ARRAY_SMALL: return readBooleans(mkBooleanArray(in.readUnsignedByte() + 1), in); case ID_ARRAY_MEDIUM: return readBooleans(mkBooleanArray(in.readUnsignedShort() + 1), in); case ID_ARRAY_LARGE: return readBooleans(new boolean[in.readInt()], in); default: throw new IOException("Unknown array type: " + Integer.toHexString(type)); } }
Source:
public boolean chkAuthorization(String userName, Object accessObj, String[] userRoles) throws QuadrigaStorageException, QuadrigaAccessException { boolean haveAccess; String projectOwner; String collaboratorName; String collaboratorRoleId; List<IQuadrigaRole> collaboratorRoles; ArrayList<String> roles; haveAccess = false; IProject project; String projectId = null; if (accessObj.getClass().equals(String.class)) { projectId = (String) accessObj; project = projectManager.getProjectDetails(projectId); } else { project = (IProject) accessObj; } projectOwner = project.getOwner().getUserName(); if (userName.equals(projectOwner)) { haveAccess = true; } if (!haveAccess) { if (userRoles.length > 0) { roles = getAccessRoleList(userRoles); List<IProjectCollaborator> projectCollaborators = project.getProjectCollaborators(); if (projectCollaborators != null) { for (IProjectCollaborator projectCollaborator : projectCollaborators) { ICollaborator collaborator = projectCollaborator.getCollaborator(); collaboratorName = collaborator.getUserObj().getUserName(); if (userName.equals(collaboratorName)) { collaboratorRoles = collaborator.getCollaboratorRoles(); for (IQuadrigaRole collabRole : collaboratorRoles) { collaboratorRoleId = collabRole.getId(); if (roles.contains(collaboratorRoleId)) { haveAccess = true; return haveAccess; } } } } } } } return haveAccess; }

Target:
public boolean chkAuthorization(String userName, Object accessObj, String[] userRoles) throws QuadrigaStorageException, QuadrigaAccessException { IProject project; if (accessObj instanceof String) { String projectId = (String) accessObj; project = projectManager.getProjectDetails(projectId); } else { try { project = (IProject) accessObj; } catch (ClassCastException cce) { throw new IllegalObjectException(cce); } } String projectOwner = project.getOwner().getUserName(); if (userName.equals(projectOwner)) { return true; } else { if (userRoles.length > 0) { List<String> roles = Arrays.asList(userRoles); List<IProjectCollaborator> projectCollaborators = project.getProjectCollaborators(); if (projectCollaborators != null) { for (IProjectCollaborator projectCollaborator : projectCollaborators) { ICollaborator collaborator = projectCollaborator.getCollaborator(); String collaboratorName = collaborator.getUserObj().getUserName(); if (userName.equals(collaboratorName)) { List<IQuadrigaRole> collaboratorRoles = collaborator.getCollaboratorRoles(); for (IQuadrigaRole collabRole : collaboratorRoles) { if (roles.contains(collabRole.getId())) { return true; } } } } } } } return false; }
Source:
public void registerRequest(final Request request) { requests.add(request); request.addMessageObserver(new MessageObserverAdapter() { @Override public void onCancel() { requests.remove(request); System.out.println(request + " cancelled"); } @Override public void onReject() { requests.remove(request); System.out.println(request + " rejected"); } @Override public void onResponse(Response response) { requests.remove(request); System.out.println(request + " answered"); } @Override public void onSendError(Throwable error) { requests.remove(request); System.out.println(request + " can not be sent"); } @Override public void onTimeout() { requests.remove(request); System.out.println(request + " timed-out"); } }); }

Target:
public void registerRequest(final Request request) { requests.add(request); request.addMessageObserver(new MessageObserverAdapter() { @Override public void onCancel() { requests.remove(request); } @Override public void onReject() { requests.remove(request); } @Override public void onResponse(Response response) { requests.remove(request); } @Override public void onSendError(Throwable error) { requests.remove(request); } @Override public void onTimeout() { requests.remove(request); } }); }
Source:
public static GlueDatabase create(UdbContext udbContext, UdbConfiguration configuration) { String glueDbName = udbContext.getUdbDbName(); if (glueDbName == null || glueDbName.isEmpty()) { throw new IllegalArgumentException( "Glue database name cannot be empty: " + glueDbName); } else if (configuration.get(Property.GLUE_REGION) == null) { throw new IllegalArgumentException("GlueUdb Error: AWS region cannot be empty."); } return new GlueDatabase(udbContext, configuration, glueDbName); }

Target:
public static GlueDatabase create(UdbContext udbContext, UdbConfiguration configuration) { String glueDbName = udbContext.getUdbDbName(); if (glueDbName == null || glueDbName.isEmpty()) { throw new IllegalArgumentException( "Glue database name cannot be empty: " + glueDbName); } else if (configuration.get(Property.GLUE_REGION) == null) { throw new IllegalArgumentException("GlueUdb Error: Please setup aws region."); } return new GlueDatabase(udbContext, configuration, glueDbName); }
Source:
public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == EditHandler.RESULT_REFRESH_PAGE) { section = data.getParcelableExtra(EditSectionActivity.EXTRA_SECTION); ViewAnimations.crossFade(webView, loadProgress); setState(STATE_NO_FETCH); performActionForState(state); } }

Target:
public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == EditHandler.RESULT_REFRESH_PAGE) { int sectionId = data.getIntExtra(EditSectionActivity.EXTRA_SECTION,-1); section = page.getSections().get(sectionId); ViewAnimations.crossFade(webView, loadProgress); setState(STATE_NO_FETCH); performActionForState(state); } }
Source:
public void flushCache() throws IOException { RestResponse r = adminSession.get("/config/server/caches/groups"); CacheInfo result = newGson().fromJson(r.getReader(), new TypeToken<CacheInfo>() {}.getType()); assertTrue(result.entries.mem.longValue() > 0); r = adminSession.post("/config/server/caches/groups/flush"); assertEquals(HttpStatus.SC_OK, r.getStatusCode()); r.consume(); r = adminSession.get("/config/server/caches/groups"); result = newGson().fromJson(r.getReader(), new TypeToken<CacheInfo>() {}.getType()); assertNull(result.entries.mem); }

Target:
public void flushCache() throws IOException { RestResponse r = adminSession.get("/config/server/caches/groups"); CacheInfo result = newGson().fromJson(r.getReader(), CacheInfo.class); assertTrue(result.entries.mem.longValue() > 0); r = adminSession.post("/config/server/caches/groups/flush"); assertEquals(HttpStatus.SC_OK, r.getStatusCode()); r.consume(); r = adminSession.get("/config/server/caches/groups"); result = newGson().fromJson(r.getReader(), CacheInfo.class); assertNull(result.entries.mem); }
Source:
SweepBatch getBatchForPartition(ShardAndStrategy shardStrategy, long partitionFine, long minTsExclusive, long maxTsExclusive) { if (inconsistentBounds(minTsExclusive, maxTsExclusive)) { return SweepBatch.of(ImmutableList.of(), minTsExclusive); } SweepableCellsTable.SweepableCellsRow row = computeRow(partitionFine, shardStrategy); RowColumnRangeIterator resultIterator = getRowColumnRange(row, partitionFine, minTsExclusive, maxTsExclusive); Multimap<Long, WriteInfo> startTsWrites = HashMultimap.create(); long lastSweptTs = 0L; while (resultIterator.hasNext() && startTsWrites.size() < SWEEP_BATCH_SIZE) { Map.Entry<Cell, Value> entry = resultIterator.next(); SweepableCellsTable.SweepableCellsColumn col = computeColumn(entry); lastSweptTs = getTimestamp(row, col); startTsWrites.putAll(lastSweptTs, getWrites(row, col, entry.getValue())); } List<Long> committedTs = getCommittedTimestampsAndCleanupAborted(startTsWrites); committedTs.sort(Comparator.reverseOrder()); if (exhaustedAllColumns(resultIterator)) { lastSweptTs = lastGuaranteedSwept(partitionFine, maxTsExclusive); } Map<CellReference, WriteInfo> writesToSweepFor = new HashMap<>(); committedTs.stream() .map(startTsWrites::get) .flatMap(Collection::stream) .forEach(write -> writesToSweepFor .putIfAbsent(write.writeRef().cellReference(), write)); return SweepBatch.of(writesToSweepFor.values(), lastSweptTs); }

Target:
SweepBatch getBatchForPartition(ShardAndStrategy shardStrategy, long partitionFine, long minTsExclusive, long maxTsExclusive) { if (inconsistentBounds(minTsExclusive, maxTsExclusive)) { return SweepBatch.of(ImmutableList.of(), minTsExclusive); } SweepableCellsTable.SweepableCellsRow row = computeRow(partitionFine, shardStrategy); RowColumnRangeIterator resultIterator = getRowColumnRange(row, partitionFine, minTsExclusive, maxTsExclusive); Multimap<Long, WriteInfo> writesByStartTs = getBatchOfWrites(row, resultIterator); List<Long> startTimestampsForCommitted = getCommittedTimestampsDescendingAndCleanupAborted(writesByStartTs); Collection<WriteInfo> writes = getWritesToSweep(writesByStartTs, startTimestampsForCommitted); long lastSweptTs = getLastSweptTs(writesByStartTs, resultIterator, partitionFine, maxTsExclusive); return SweepBatch.of(writes, lastSweptTs); }
Source:
public String toString() { StringBuilder sb = new StringBuilder(); sb.append("BlobProperties["); sb.append("BlobSize=").append(getBlobSize()); if (getContentType() != null) { sb.append(", ").append("ContentType=").append(getContentType()); } else { sb.append(", ").append("ContentType=Null"); } if (getOwnerId() != null) { sb.append(", ").append("OwnerId=").append(getOwnerId()); } else { sb.append(", ").append("OwnerId=Null"); } if (getServiceId() != null) { sb.append(", ").append("ServiceId=").append(getServiceId()); } else { sb.append(", ").append("ServiceId=Null"); } sb.append(", ").append("IsPrivate=").append(isPrivate()); sb.append(", ").append("CreationTimeInMs=").append(getCreationTimeInMs()); if (getTimeToLiveInSeconds() != Utils.Infinite_Time) { sb.append(", ").append("TimeToLiveInSeconds=").append(getTimeToLiveInSeconds()); } else { sb.append(", ").append("TimeToLiveInSeconds=Infinite"); } sb.append(", ").append("AccountId=").append(getAccountId()); sb.append(", ").append("ContainerId=").append(getContainerId()); sb.append(", ").append("IsEncrypted=").append(isEncrypted()); sb.append(", ").append("externalAssetTag=").append(getExternalAssetTag()); if (getContentEncoding() != null) { sb.append(", ").append("ContentEncoding=").append(getContentEncoding()); } else { sb.append(", ").append("ContentEncoding=Null"); } if (getFilename() != null) { sb.append(", ").append("Filename=").append(getFilename()); } else { sb.append(", ").append("Filename=Null"); } sb.append("]"); return sb.toString(); }

Target:
public String toString() { StringBuilder sb = new StringBuilder(); sb.append("BlobProperties["); sb.append("BlobSize=").append(getBlobSize()); sb.append(", ").append("ContentType=").append(getContentType()); sb.append(", ").append("OwnerId=").append(getOwnerId()); sb.append(", ").append("ServiceId=").append(getServiceId()); sb.append(", ").append("IsPrivate=").append(isPrivate()); sb.append(", ").append("CreationTimeInMs=").append(getCreationTimeInMs()); if (getTimeToLiveInSeconds() != Utils.Infinite_Time) { sb.append(", ").append("TimeToLiveInSeconds=").append(getTimeToLiveInSeconds()); } else { sb.append(", ").append("TimeToLiveInSeconds=Infinite"); } sb.append(", ").append("AccountId=").append(getAccountId()); sb.append(", ").append("ContainerId=").append(getContainerId()); sb.append(", ").append("IsEncrypted=").append(isEncrypted()); sb.append(", ").append("externalAssetTag=").append(getExternalAssetTag()); sb.append(", ").append("ContentEncoding=").append(getContentEncoding()); sb.append(", ").append("Filename=").append(getFilename()); sb.append("]"); return sb.toString(); }
Source:
public OAuth2IntrospectionAuthenticationToken(OAuth2AccessToken token, Map<String, Object> attributes, Collection<? extends GrantedAuthority> authorities) { this(token, attributes, authorities, null); setAuthenticated(true); }

Target:
public OAuth2IntrospectionAuthenticationToken(OAuth2AccessToken token, Map<String, Object> attributes, Collection<? extends GrantedAuthority> authorities) { this(token, attributes, authorities, null); }
Source:
public ResponseEntity<?> getSubscription(@PathVariable("id") final String subscriptionId, final NativeWebRequest request) { return status(OK).body(subscriptionService.getSubscription(subscriptionId)); }

Target:
public ResponseEntity<?> getSubscription(@PathVariable("id") final String subscriptionId, final NativeWebRequest request) throws NoSuchSubscriptionException, ServiceTemporarilyUnavailableException { return status(OK).body(subscriptionService.getSubscription(subscriptionId)); }
Source:
private List<CcJudgmentKeyword> extractKeywords(SourceCcJudgment sourceJudgment) { List<CcJudgmentKeyword> keywords = Lists.newArrayList(); if (CollectionUtils.isEmpty(sourceJudgment.getThemePhrases())) { return keywords; } for (String themePhrase : sourceJudgment.getThemePhrases()) { themePhrase = themePhrase.toLowerCase(); CcJudgmentKeyword keyword = ccJudgmentKeywordCreator.getOrCreateCcJudgmentKeyword(themePhrase); keywords.add(keyword); } return keywords; }

Target:
private List<CcJudgmentKeyword> extractKeywords(SourceCcJudgment sourceJudgment) { List<CcJudgmentKeyword> keywords = Lists.newArrayList(); if (CollectionUtils.isEmpty(sourceJudgment.getThemePhrases())) { return keywords; } for (String themePhrase : sourceJudgment.getThemePhrases()) { themePhrase = themePhrase.toLowerCase(Locale.ROOT); CcJudgmentKeyword keyword = ccJudgmentKeywordCreator.getOrCreateCcJudgmentKeyword(themePhrase); keywords.add(keyword); } return keywords; }
Source:
public void testBelatedTransactionDoesntLeak() throws Throwable { final ControlledCommandFactory ccf = ControlledCommandFactory.registerControlledCommandFactory(advancedCache(1), VersionedPrepareCommand.class); ccf.gate.close(); Cache receiver = cache(1); BlockingPrepareInterceptor interceptor = new BlockingPrepareInterceptor(); advancedCache(1).addInterceptor(interceptor, 1); final Object key = getKeyForCache(1); fork(() -> { try { cache(0).put(key, "v"); } catch (Throwable e) { } }); eventually(() -> ccf.blockTypeCommandsReceived.get() == 1); killMember(0); Thread.sleep(5000); ccf.gate.open(); interceptor.prepareExecuted.await(); log.trace("Finished waiting for belated prepare to complete"); final TransactionTable transactionTable = TestingUtil.getTransactionTable(receiver); assertEquals(0, transactionTable.getRemoteTxCount()); assertEquals(0, transactionTable.getLocalTxCount()); assertFalse(receiver.getAdvancedCache().getLockManager().isLocked(key)); }

Target:
public void testBelatedTransactionDoesntLeak() throws Throwable { final ControlledCommandFactory ccf = ControlledCommandFactory.registerControlledCommandFactory(advancedCache(1), VersionedPrepareCommand.class); ccf.gate.close(); Cache receiver = cache(1); BlockingPrepareInterceptor interceptor = new BlockingPrepareInterceptor(); advancedCache(1).addInterceptor(interceptor, 1); final Object key = getKeyForCache(1); fork(() -> { try { cache(0).put(key, "v"); } catch (Throwable e) { } }); eventuallyEquals(1, ccf.blockTypeCommandsReceived::get); killMember(0); Thread.sleep(5000); ccf.gate.open(); interceptor.prepareExecuted.await(); log.trace("Finished waiting for belated prepare to complete"); final TransactionTable transactionTable = TestingUtil.getTransactionTable(receiver); assertEquals(0, transactionTable.getRemoteTxCount()); assertEquals(0, transactionTable.getLocalTxCount()); assertFalse(receiver.getAdvancedCache().getLockManager().isLocked(key)); }
Source:
private static void sendToLoggers(LogLevel level, String tag, String msg) { boolean fileSucceeded = false; boolean consoleSucceeded = false; try { LogDomain domain = LogDomain.valueOf(tag); Database.getLog().getFile().log(level, domain, msg); fileSucceeded = true; Database.getLog().getConsole().log(level, domain, msg); consoleSucceeded = false; Logger custom = Database.getLog().getCustom(); if(custom != null) { custom.log(level, domain, msg); } } catch(Exception e) { if(fileSucceeded) { Database.getLog().getFile().log(LogLevel.ERROR, LogDomain.DATABASE, e.toString()); } if(consoleSucceeded) { Database.getLog().getConsole().log(LogLevel.ERROR, LogDomain.DATABASE, e.toString()); } } }

Target:
private static void sendToLoggers(LogLevel level, String tag, String msg) { boolean fileSucceeded = false; boolean consoleSucceeded = false; try { LogDomain domain = LogDomain.valueOf(tag); Database.getLog().getFile().log(level, domain, msg); fileSucceeded = true; Database.getLog().getConsole().log(level, domain, msg); consoleSucceeded = true; Logger custom = Database.getLog().getCustom(); if(custom != null) { custom.log(level, domain, msg); } } catch(Exception e) { if(fileSucceeded) { Database.getLog().getFile().log(LogLevel.ERROR, LogDomain.DATABASE, e.toString()); } if(consoleSucceeded) { Database.getLog().getConsole().log(LogLevel.ERROR, LogDomain.DATABASE, e.toString()); } } }
Source:
public void doRequireBundle(String bundle, String installLocation) { String version = null; try { Manifest manifestSource; InputStream srcStream; if (installLocation.endsWith(".jar")) { ZipFile zip = new ZipFile(installLocation); srcStream = zip.getInputStream(zip.getEntry("META-INF/MANIFEST.MF")); manifestSource = new Manifest(srcStream); zip.close(); } else { srcStream = new URL("file://" + installLocation + "/META-INF/MANIFEST.MF").openStream(); manifestSource = new Manifest(srcStream); } version = manifestSource.getMainAttributes().getValue("Bundle-Version"); } catch (Exception e) { e.printStackTrace(); return; } IFile fileManifest = project.getFile("META-INF/MANIFEST.MF"); Manifest manifest; try { manifest = new Manifest(fileManifest.getContents()); String value = manifest.getMainAttributes().getValue("Require-Bundle"); if (value == null) { manifest.getMainAttributes().putValue("Require-Bundle", bundle); } else { value += "," + bundle; if (version != null) { value += ";bundle-version=" + version; } manifest.getMainAttributes().putValue("Require-Bundle", value); } ByteArrayOutputStream bos = new ByteArrayOutputStream(); manifest.write(bos); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); fileManifest.setContents(bis, true, true, null); result = file; } catch (IOException e1) { e1.printStackTrace(); } catch (CoreException e1) { e1.printStackTrace(); } }

Target:
public void doRequireBundle(String bundle, String installLocation) { String version = null; InputStream srcStream = null; try { Manifest manifestSource; if (installLocation.endsWith(".jar")) { ZipFile zip = new ZipFile(installLocation); srcStream = zip.getInputStream(zip.getEntry("META-INF/MANIFEST.MF")); manifestSource = new Manifest(srcStream); zip.close(); } else { srcStream = new BufferedInputStream(new FileInputStream(installLocation + "/META-INF/MANIFEST.MF")); manifestSource = new Manifest(srcStream); } version = manifestSource.getMainAttributes().getValue("Bundle-Version"); if (version != null) { version = version.replaceFirst("\\.qualifier", ""); } } catch (Exception e) { e.printStackTrace(); return; } finally { try { srcStream.close(); } catch (Exception e) { } } IFile fileManifest = project.getFile("META-INF/MANIFEST.MF"); Manifest manifest; try { manifest = new Manifest(fileManifest.getContents()); String value = manifest.getMainAttributes().getValue("Require-Bundle"); if (value == null) { manifest.getMainAttributes().putValue("Require-Bundle", bundle); } else { value += "," + bundle; if (version != null) { value += ";bundle-version=" + version; } manifest.getMainAttributes().putValue("Require-Bundle", value); } ByteArrayOutputStream bos = new ByteArrayOutputStream(); manifest.write(bos); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); fileManifest.setContents(bis, true, true, null); result = file; } catch (IOException e1) { e1.printStackTrace(); } catch (CoreException e1) { e1.printStackTrace(); } }
Source:
private MemorySegment requestMemorySegment(int targetChannel) { MemorySegment segment; synchronized (availableMemorySegments) { if (isDestroyed) { throw new IllegalStateException("Buffer pool is destroyed."); } if (targetChannel != UNKNOWN_CHANNEL && subpartitionBuffersCount[targetChannel] >= maxBuffersPerChannel) { return null; } segment = availableMemorySegments.poll(); if (segment == null) { return null; } if (targetChannel != UNKNOWN_CHANNEL) { if (++subpartitionBuffersCount[targetChannel] == maxBuffersPerChannel) { unavailableSubpartitionsCount++; } } if (!checkAvailability()) { availabilityHelper.resetUnavailable(); } assert hasConsistentAvailability(); } return segment; }

Target:
private MemorySegment requestMemorySegment(int targetChannel) { MemorySegment segment; synchronized (availableMemorySegments) { if (isDestroyed) { throw new IllegalStateException("Buffer pool is destroyed."); } if (targetChannel != UNKNOWN_CHANNEL && subpartitionBuffersCount[targetChannel] >= maxBuffersPerChannel) { return null; } segment = availableMemorySegments.poll(); if (segment == null) { return null; } if (targetChannel != UNKNOWN_CHANNEL) { if (++subpartitionBuffersCount[targetChannel] == maxBuffersPerChannel) { unavailableSubpartitionsCount++; } } if (!checkAvailability()) { availabilityHelper.resetUnavailable(); } checkConsistentAvailability(); } return segment; }
Source:
public void testBinaryWithNotGenericInterceptor() throws Exception { IgniteConfiguration ccfg = Config.getServerConfiguration() .setCacheConfiguration(new CacheConfiguration("test").setInterceptor(new ThinBinaryValueInterceptor())); String castErr = "cannot be cast to"; String treeErr = "Tree is corrupted"; ListeningTestLogger srvLog = new ListeningTestLogger(log); LogListener lsnrCast = LogListener.matches(castErr). andMatches(str -> !str.contains(treeErr)).build(); srvLog.registerListener(lsnrCast); ccfg.setGridLogger(srvLog); try (Ignite ignored = Ignition.start(ccfg)) { try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(Config.SERVER)) ) { ClientCache<Integer, ThinBinaryValue> cache = client.cache("test"); try { cache.put(1, new ThinBinaryValue()); } catch (Exception e) { assertTrue(X.getFullStackTrace(e).contains(castErr)); } } } }

Target:
public void testBinaryWithNotGenericInterceptor() throws Exception { IgniteConfiguration ccfg = Config.getServerConfiguration() .setCacheConfiguration(new CacheConfiguration("test").setInterceptor(new ThinBinaryValueInterceptor())); String castErr = "cannot be cast to"; String treeErr = "Tree is corrupted"; ListeningTestLogger srvLog = new ListeningTestLogger(log); LogListener lsnrCast = LogListener.matches(castErr). andMatches(str -> !str.contains(treeErr)).build(); srvLog.registerListener(lsnrCast); ccfg.setGridLogger(srvLog); try (Ignite ignored = Ignition.start(ccfg)) { try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(Config.SERVER)) ) { ClientCache<Integer, ThinBinaryValue> cache = client.cache("test"); try { cache.put(1, new ThinBinaryValue()); assert false; } catch (Exception e) { assertTrue(X.getFullStackTrace(e).contains(castErr)); } } } }
Source:
public void sendHitResult( int time, int result, float x, float y, Color color, boolean end, HitObject hitObject, HitObjectType hitResultType, boolean expand, int repeat, Curve curve, boolean sliderHeldToEnd ) { int hitResult = handleHitResult(time, result, x, y, color, end, hitObject, hitResultType, repeat, (curve != null && !sliderHeldToEnd)); if (hitResult == HIT_MISS && (GameMod.RELAX.isActive() || GameMod.AUTOPILOT.isActive())) return; boolean hideResult = (hitResult == HIT_300 || hitResult == HIT_300G || hitResult == HIT_300K) && !Options.isPerfectHitBurstEnabled(); if (GameMod.PERFECT.isActive() && (hitResult == HIT_300 || hitResult == HIT_300G || hitResult == HIT_300K)) { hitResultList.add(new HitObjectResult(time, hitResult, x, y, color, hitResultType, curve, expand, hideResult)); } else { health.setHealth(0f); } }

Target:
public void sendHitResult( int time, int result, float x, float y, Color color, boolean end, HitObject hitObject, HitObjectType hitResultType, boolean expand, int repeat, Curve curve, boolean sliderHeldToEnd ) { int hitResult = handleHitResult(time, result, x, y, color, end, hitObject, hitResultType, repeat, (curve != null && !sliderHeldToEnd)); if (hitResult == HIT_MISS && (GameMod.RELAX.isActive() || GameMod.AUTOPILOT.isActive())) return; boolean hideResult = (hitResult == HIT_300 || hitResult == HIT_300G || hitResult == HIT_300K) && !Options.isPerfectHitBurstEnabled(); if (GameMod.PERFECT.isActive() && hitResult == HIT_300 || hitResult == HIT_300G || hitResult == HIT_300K) { hitResultList.add(new HitObjectResult(time, hitResult, x, y, color, hitResultType, curve, expand, hideResult)); } else if (!GameMod.PERFECT.isActive()) { hitResultList.add(new HitObjectResult(time, hitResult, x, y, color, hitResultType, curve, expand, hideResult)); } else { health.setHealth(0f); } }
Source:
private Answer executeRequest(TrashNetworkVspCommand cmd) { try { isNuageVspGuruLoaded(); _nuageVspGuruClient.trash(cmd.getDomainUuid(), cmd.getNetworkUuid(), cmd.isL3Network(), cmd.isSharedNetwork(), cmd.getVpcUuid(), cmd.getDomainTemplateName()); return new TrashNetworkVspAnswer(cmd, true, "Deleted Nuage VSP network mapping to " + cmd.getNetworkUuid()); } catch (Exception e) { s_logger.error("Failure during " + cmd, e); return new TrashNetworkVspAnswer(cmd, e); } }

Target:
private Answer executeRequest(TrashNetworkVspCommand cmd) { try { isNuageVspGuruLoaded(); _nuageVspGuruClient.trash(cmd.getDomainUuid(), cmd.getNetworkUuid(), cmd.isL3Network(), cmd.isSharedNetwork(), cmd.getVpcUuid(), cmd.getDomainTemplateName()); return new Answer(cmd, true, "Deleted network mapping to " + cmd.getNetworkUuid() + " on Nuage VSD " + _hostName); } catch (ExecutionException | ConfigurationException e) { s_logger.error("Failure during " + cmd + " on Nuage VSD " + _hostName, e); return new Answer(cmd, e); } }
Source:
protected IStatus run(IProgressMonitor monitor) { try { SessionNegotiation.Status status = negotiation.start(monitor); switch (status) { case CANCEL: return Status.CANCEL_STATUS; case ERROR: NotificationPanel.showError( MessageFormat.format( Messages.NegotiationHandler_session_local_error_message, negotiation.getErrorMessage()), Messages.NegotiationHandler_session_local_error_title); return new Status( IStatus.ERROR, SarosComponent.PLUGIN_ID, negotiation.getErrorMessage()); case OK: break; case REMOTE_CANCEL: NotificationPanel.showInformation( MessageFormat.format( Messages.NegotiationHandler_remote_canceled_invitation_text, peer), Messages.NegotiationHandler_remote_canceled_invitation); return new Status( IStatus.CANCEL, SarosComponent.PLUGIN_ID, MessageFormat.format( Messages.NegotiationHandler_remote_canceled_invitation_text, peer)); case REMOTE_ERROR: NotificationPanel.showError( MessageFormat.format( Messages.NegotiationHandler_remote_error_during_invitation_text, peer, negotiation.getErrorMessage()), Messages.NegotiationHandler_remote_error_during_invitation); return new Status( IStatus.ERROR, SarosComponent.PLUGIN_ID, MessageFormat.format( Messages.NegotiationHandler_remote_error_during_invitation_text, peer, negotiation.getErrorMessage())); } } catch (Exception e) { LOG.error("This exception is not expected here: ", e); return new Status(IStatus.ERROR, SarosComponent.PLUGIN_ID, e.getMessage(), e); } sessionManager.startSharingProjects(negotiation.getPeer()); return Status.OK_STATUS; }

Target:
protected IStatus run(IProgressMonitor monitor) { try { SessionNegotiation.Status status = negotiation.start(monitor); String message; switch (status) { case CANCEL: return Status.CANCEL_STATUS; case ERROR: message = MessageFormat.format( Messages.NegotiationHandler_session_local_error_message, negotiation.getErrorMessage()); NotificationPanel.showError( message, Messages.NegotiationHandler_session_local_error_title); return new Status(IStatus.ERROR, SarosComponent.PLUGIN_ID, message); case OK: break; case REMOTE_CANCEL: message = MessageFormat.format( Messages.NegotiationHandler_session_remote_cancel_message, peer); NotificationPanel.showInformation( message, Messages.NegotiationHandler_session_remote_cancel_title); return new Status(IStatus.CANCEL, SarosComponent.PLUGIN_ID, message); case REMOTE_ERROR: message = MessageFormat.format( Messages.NegotiationHandler_session_remote_error_message, peer, negotiation.getErrorMessage()); NotificationPanel.showError( message, Messages.NegotiationHandler_session_remote_error_title); return new Status(IStatus.ERROR, SarosComponent.PLUGIN_ID, message); } } catch (Exception e) { LOG.error("This exception is not expected here: ", e); return new Status(IStatus.ERROR, SarosComponent.PLUGIN_ID, e.getMessage(), e); } sessionManager.startSharingProjects(negotiation.getPeer()); return Status.OK_STATUS; }
Source:
public void multifilePartial() throws Exception { String expected = DeclarationGeneratorTests.getTestFileText(input("singleton.d.ts")); assertThatProgram( ImmutableList.of(input("missing_imported_base.js")), ImmutableList.of(input("named_base_exporter.js"), input("default_base_exporter.js"))) .generatesDeclarations(expected); }

Target:
public void multifilePartial() throws Exception { String expected = DeclarationGeneratorTests.getTestFileText(input("total.d.ts")); assertThatProgram( ImmutableList.of(input("missing_imported_base.js")), ImmutableList.of(input("named_base_exporter.js"), input("default_base_exporter.js"))) .generatesDeclarations(expected); }
Source:
public void listsDocs() throws IOException { final Bucket bucket = this.mockBucket("lists", "lists-exists"); final List<String> expected = Lists.newArrayList(bucket.list("")); final List<String> names = new AwsDocs(bucket).names(); MatcherAssert.assertThat(names, Matchers.equalTo(expected)); MatcherAssert.assertThat(names, Matchers.hasItem("sub/test")); }

Target:
public void listsDocs() throws IOException { final String label = "lists"; final String name = "lists-exists"; final Bucket bucket = this.mockBucket(label, name); final List<String> expected = Arrays.asList(name, "sub/file"); final List<String> names = new AwsDocs(bucket, label).names(); MatcherAssert.assertThat(names, Matchers.equalTo(expected)); }
Source:
private void flatDelete(PDOMLinkage linkage) throws CoreException { linkage.storeValue(record + DEFAULTVAL, null); super.delete(linkage); }

Target:
private void flatDelete(PDOMLinkage linkage) throws CoreException { super.delete(linkage); }
Source:
public void imageDownload(Process process, URI userHome, String atsPpnBand, final String ordnerEndung) throws IOException { Project project = process.getProject(); URI tifOrdner = getImagesTifDirectory(true, process); if (fileService.fileExist(tifOrdner) && fileService.getSubUris(tifOrdner).size() > 0) { URI zielTif = userHome.resolve(File.separator + atsPpnBand + ordnerEndung); if (project.isUseDmsImport()) { if (!fileService.fileExist(zielTif)) { fileService.createDirectory(userHome, atsPpnBand + ordnerEndung); } } else { User user = Helper.getCurrentUser(); try { if (user != null) { fileService.createDirectoryForUser(zielTif, user.getLogin()); } else { throw new IOException("noLoggedUser"); } } catch (Exception e) { Helper.setFehlerMeldung("Export canceled, error", "could not create destination directory"); logger.error("could not create destination directory", e); } } ArrayList<URI> dateien = fileService.getSubUris(Helper.dataFilter, tifOrdner); for (URI file : dateien) { if (fileService.isFile(file)) { URI target = zielTif.resolve(File.separator + fileService.getFileNameWithExtension(file)); fileService.copyFile(file, target); } } } }

Target:
public void imageDownload(Process process, URI userHome, String atsPpnBand, final String ordnerEndung) throws IOException { Project project = process.getProject(); URI tifOrdner = getImagesTifDirectory(true, process); if (fileService.fileExist(tifOrdner) && fileService.getSubUris(tifOrdner).size() > 0) { URI zielTif = userHome.resolve(File.separator + atsPpnBand + ordnerEndung); if (project.isUseDmsImport()) { if (!fileService.fileExist(zielTif)) { fileService.createDirectory(userHome, atsPpnBand + ordnerEndung); } } else { User user = Helper.getCurrentUser(); try { if (user != null) { fileService.createDirectoryForUser(zielTif, user.getLogin()); } else { throw new IOException("No logged user!"); } } catch (Exception e) { Helper.setFehlerMeldung("Export canceled, error", "could not create destination directory"); logger.error("could not create destination directory", e); } } ArrayList<URI> dateien = fileService.getSubUris(Helper.dataFilter, tifOrdner); for (URI file : dateien) { if (fileService.isFile(file)) { URI target = zielTif.resolve(File.separator + fileService.getFileNameWithExtension(file)); fileService.copyFile(file, target); } } } }
Source:
public boolean validate(Object value, Object context) { if (validation) { MutableBoolean validated = new MutableBoolean(); resolve(value, context, (session, docRef) -> { if (session.exists(docRef)) { validated.setTrue(); } }); return validated.isTrue(); } return true; }

Target:
public boolean validate(Object value, Object context) { if (!validation) { return true; } MutableBoolean validated = new MutableBoolean(); resolve(value, context, (session, docRef) -> { if (session.exists(docRef)) { validated.setTrue(); } }); return validated.isTrue(); }
Source:
public void testCreateMultipleElementsAndCloseWithoutSaving() { assertTrue(diagram.getOwnedDiagramElements().isEmpty()); for (int i = 0; i < 35; i++) { editor.activateTool("Package"); editor.click(new Point(2, 2)); SWTBotUtils.waitAllUiEvents(); } SWTBotSiriusHelper.close(editor, true); bot.waitUntilWidgetAppears(Conditions.shellIsActive("Save")); final SWTBotShell uncontrolShell = bot.shell("Save"); uncontrolShell.activate(); SWTBotButton no = bot.button("No"); bot.waitUntilWidgetAppears(new ItemEnabledCondition(no)); no.click(); SWTBotUtils.waitAllUiEvents(); diagram = (DDiagram) getRepresentationWithName(localSession.getOpenedSession(), ENTITIES_DESC_NAME, "root" + " package entities"); assertEquals("The diagram should be empty", 0, diagram.getDiagramElements().size()); }

Target:
public void testCreateMultipleElementsAndCloseWithoutSaving() { assertEquals("The diagram should be empty", 0, diagram.getOwnedDiagramElements().size()); for (int i = 0; i < 35; i++) { editor.activateTool("Package"); editor.click(new Point(2, 2)); SWTBotUtils.waitAllUiEvents(); } SWTBotSiriusHelper.close(editor, true); bot.waitUntilWidgetAppears(Conditions.shellIsActive("Save")); final SWTBotShell uncontrolShell = bot.shell("Save"); uncontrolShell.activate(); SWTBotButton no = bot.button("No"); bot.waitUntilWidgetAppears(new ItemEnabledCondition(no)); no.click(); SWTBotUtils.waitAllUiEvents(); diagram = (DDiagram) getRepresentationWithName(localSession.getOpenedSession(), ENTITIES_DESC_NAME, "root" + " package entities"); assertEquals("The diagram should be empty after having closed without saving.", 0, diagram.getDiagramElements().size()); }
Source:
public void close() { try { closer.close(); } catch (IOException e) { throw Throwables.propagate(e); } }

Target:
public void close() { try { closer.close(); } catch (IOException e) { throw new RuntimeException(e); } }
Source:
void visitLeafNode(final ObjectNode parent, final Path.Element element) throws ScimException { JsonNode node = parent.path(element.getAttribute()); if(! node.isMissingNode()) { setPathPresent(true); } }

Target:
void visitLeafNode(final ObjectNode parent, final Path.Element element) throws ScimException { JsonNode node = parent.path(element.getAttribute()); if(node.isArray() && element.getValueFilter() != null) { node = filterArray((ArrayNode) node, element.getValueFilter(), false); } if(node.isArray()) { if(((ArrayNode)node).size() > 0) { setPathPresent(true); } } else if(! node.isMissingNode()) { setPathPresent(true); } }
Source:
protected void sendEvent(CoreSession session, DocumentRef ref, Calendar retainUntil) { DocumentModel doc = session.getDocument(ref); DocumentEventContext ctx = new DocumentEventContext(session, null, doc); ctx.setProperty(CoreEventConstants.REPOSITORY_NAME, session.getRepositoryName()); ctx.setProperty(CoreEventConstants.SESSION_ID, session.getSessionId()); ctx.setProperty("category", DocumentEventCategories.EVENT_DOCUMENT_CATEGORY); ctx.setProperty(CoreEventConstants.RETAIN_UNTIL, retainUntil); ctx.setProperty("comment", retainUntil.toInstant().toString()); Event event = ctx.newEvent(DocumentEventTypes.RETENTION_EXPIRED); Framework.getService(EventService.class).fireEvent(event); }

Target:
protected void sendEvent(CoreSession session, DocumentRef ref, Calendar retainUntil) { DocumentModel doc = session.getDocument(ref); DocumentEventContext ctx = new DocumentEventContext(session, null, doc); ctx.setProperty(CoreEventConstants.REPOSITORY_NAME, session.getRepositoryName()); ctx.setProperty(CoreEventConstants.SESSION_ID, session.getSessionId()); ctx.setProperty(DocumentEventContext.CATEGORY_PROPERTY_KEY, DocumentEventCategories.EVENT_DOCUMENT_CATEGORY); ctx.setProperty(CoreEventConstants.RETAIN_UNTIL, retainUntil); ctx.setProperty(DocumentEventContext.COMMENT_PROPERTY_KEY, retainUntil.toInstant().toString()); Event event = ctx.newEvent(DocumentEventTypes.RETENTION_EXPIRED); Framework.getService(EventService.class).fireEvent(event); }