auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private void setSiriusSheetLabelProvider(SWTBotView propertiesView) { IPage currentPage = ((org.eclipse.ui.views.properties.PropertySheet) propertiesView.getReference().getView(false)).getCurrentPage(); Option<Object> valueOption = ReflectionHelper.getFieldValueWithoutException(currentPage, "registry"); assertTrue(valueOption.get() instanceof TabbedPropertyRegistry); TabbedPropertyRegistry tabbedPropertyRegistry = (TabbedPropertyRegistry) valueOption.get(); String contributorId = (String) ReflectionHelper.getFieldValueWithoutException(tabbedPropertyRegistry, "contributorId").get(); oldPropertyViewLabelProvider = ReflectionHelper.getFieldValueWithoutException(tabbedPropertyRegistry, "labelProvider").get(); Object newLabelProvider = null; if (DiagramUIPlugin.ID.equals(contributorId)) { newLabelProvider = new SiriusSheetLabelProvider(); } else if ("org.eclipse.sirius.table.ui.EditorID".equals(contributorId) || DTreeEditor.ID.equals(contributorId)) { newLabelProvider = new DTableLabelProvider(); } if (newLabelProvider != null) { ReflectionHelper.setFieldValueWithoutException(tabbedPropertyRegistry, "labelProvider", newLabelProvider); } }

Target:
private Object setSiriusSheetLabelProvider(SWTBotView propertiesView) { Object oldLabelProvider; IPage currentPage = ((org.eclipse.ui.views.properties.PropertySheet) propertiesView.getReference().getView(false)).getCurrentPage(); Option<Object> valueOption = ReflectionHelper.getFieldValueWithoutException(currentPage, "registry"); assertTrue(valueOption.get() instanceof TabbedPropertyRegistry); TabbedPropertyRegistry tabbedPropertyRegistry = (TabbedPropertyRegistry) valueOption.get(); String contributorId = (String) ReflectionHelper.getFieldValueWithoutException(tabbedPropertyRegistry, "contributorId").get(); oldLabelProvider = ReflectionHelper.getFieldValueWithoutException(tabbedPropertyRegistry, "labelProvider").get(); Object newLabelProvider = null; if (DiagramUIPlugin.ID.equals(contributorId)) { newLabelProvider = new SiriusSheetLabelProvider(); } else if ("org.eclipse.sirius.table.ui.EditorID".equals(contributorId) || DTreeEditor.ID.equals(contributorId)) { newLabelProvider = new DTableLabelProvider(); } if (newLabelProvider != null) { ReflectionHelper.setFieldValueWithoutException(tabbedPropertyRegistry, "labelProvider", newLabelProvider); } return oldLabelProvider; }
Source:
public boolean getIsNamespaceEnabled() throws AzureBlobFileSystemException { if (!isNamespaceEnabledSet) { if (this.abfsConfiguration.getAbfsAuthorizer() != null) { LOG.debug("Authorizer is set. Account MUST be Namespace enabled."); isNamespaceEnabled = true; isNamespaceEnabledSet = true; return isNamespaceEnabled; } LOG.debug("Get root ACL status"); try (AbfsPerfInfo perfInfo = startTracking("getIsNamespaceEnabled", "getAclStatus")) { AbfsRestOperation op = client.getAclStatus(AbfsHttpConstants.FORWARD_SLASH + AbfsHttpConstants.ROOT_PATH); perfInfo.registerResult(op.getResult()); isNamespaceEnabled = true; perfInfo.registerSuccess(true); } catch (AbfsRestOperationException ex) { if (HttpURLConnection.HTTP_BAD_REQUEST != ex.getStatusCode()) { throw ex; } isNamespaceEnabled = false; } isNamespaceEnabledSet = true; } return isNamespaceEnabled; }

Target:
public boolean getIsNamespaceEnabled() throws AzureBlobFileSystemException { if (!isNamespaceEnabledSet) { LOG.debug("Get root ACL status"); try (AbfsPerfInfo perfInfo = startTracking("getIsNamespaceEnabled", "getAclStatus")) { AbfsRestOperation op = client.getAclStatus(AbfsHttpConstants.FORWARD_SLASH + AbfsHttpConstants.ROOT_PATH); perfInfo.registerResult(op.getResult()); isNamespaceEnabled = true; perfInfo.registerSuccess(true); } catch (AbfsRestOperationException ex) { if (HttpURLConnection.HTTP_BAD_REQUEST != ex.getStatusCode()) { throw ex; } isNamespaceEnabled = false; } isNamespaceEnabledSet = true; } return isNamespaceEnabled; }
Source:
public ListBoxModel doFillPriorityIdItems(@AncestorInPath Item item) { Project project = null; ListBoxModel items = new ListBoxModel().add(""); if(item instanceof Project) { project = (Project) item; final JiraProjectProperty jiraProjectProperty = (JiraProjectProperty) project.getProperty(JiraProjectProperty.class); JiraSite site = jiraProjectProperty.getSite(); if(null != site) { JiraSession session = site.getSession(); if (session != null) { for (Priority priority : session.getPriorities()) { items.add("[" + site.getName() + "] " + priority.getName(), String.valueOf(priority.getId())); } } } } return items; }

Target:
public ListBoxModel doFillPriorityIdItems(@AncestorInPath Item item) { Project project = null; ListBoxModel items = new ListBoxModel().add(""); if(item instanceof Project) { project = (Project) item; final JiraProjectProperty jiraProjectProperty = (JiraProjectProperty) project.getProperty(JiraProjectProperty.class); JiraSite site = jiraProjectProperty.getSite(); if(site != null) { JiraSession session = site.getSession(); if (session != null) { for (Priority priority : session.getPriorities()) { items.add("[" + site.getName() + "] " + priority.getName(), String.valueOf(priority.getId())); } } } } return items; }
Source:
protected Vector<URL> searchResourcesInBundles(String name) { Vector<URL> urlList = new Vector<URL>(); for (Bundle b : m_bundles) { try { Enumeration<URL> en = b.getResources(name); if (en != null && en.hasMoreElements()) { while (en.hasMoreElements()) { URL url = en.nextElement(); urlList.add(url); } } } catch (Exception e) { } } return urlList; }

Target:
protected Vector<URL> searchResourcesInBundles(String name) { Vector<URL> urlList = new Vector<URL>(); for (Bundle b : m_bundles) { try { Enumeration resources = b.getResources(name); while (resources != null && resources.hasMoreElements()) { URL url = (URL) resources.nextElement(); urlList.add(url); } } catch (Exception e) { } } return urlList; }
Source:
public void update(final Iterable<Directive> dirs) throws IOException { final XMLDocument xml = new XMLDocument( new Xembler(dirs).applyQuietly(this.read().node()) ); this.item.put( new AttributeUpdates().with(DyRepo.ATTR_MEMO, xml.toString()) ); }

Target:
public void update(final Iterable<Directive> dirs) throws IOException { this.item.put( new AttributeUpdates().with( DyRepo.ATTR_MEMO, new XMLDocument( new Xembler(dirs).applyQuietly(this.read().node()) ).toString() ) ); }
Source:
private static Condition fromRssi(final Integer rssi) { if (rssi == RSSI_NONE) { return Condition.NONE; } else if (rssi <= RSSI_LOW_CEILING) { return Condition.BAD; } else if (rssi <= RSSI_MEDIUM_CEILING) { return Condition.FAIR; } return Condition.GOOD; }

Target:
public static Condition fromRssi(final Integer rssi) { if (rssi == RSSI_NONE) { return Condition.NONE; } else if (rssi <= RSSI_LOW_CEILING) { return Condition.BAD; } else if (rssi <= RSSI_MEDIUM_CEILING) { return Condition.FAIR; } return Condition.GOOD; }
Source:
private void discardContent(Queue<HttpObject> contents, int expectedDiscardCount) throws InterruptedException { if (expectedDiscardCount != -1) { assertEquals("Objects that will be discarded are more than expected", expectedDiscardCount, contents.size()); } boolean endMarkerFound = false; for (HttpObject object : contents) { assertFalse("There should have been only a single end marker", endMarkerFound); endMarkerFound = object instanceof LastHttpContent; ReferenceCountUtil.release(object); } assertTrue("There should have been an end marker", endMarkerFound); }

Target:
private void discardContent(Queue<HttpObject> contents, int expectedDiscardCount) throws InterruptedException { assertEquals("Objects that will be discarded are more than expected", expectedDiscardCount, contents.size()); boolean endMarkerFound = false; for (HttpObject object : contents) { assertFalse("There should have been only a single end marker", endMarkerFound); endMarkerFound = object instanceof LastHttpContent; ReferenceCountUtil.release(object); } assertTrue("There should have been an end marker", endMarkerFound); }
Source:
protected void onMethodInvocationFound(MethodInvocationTree mit) { Tree parent = mit.parent(); while(parent != null && !parent.is(Tree.Kind.METHOD)) { parent = parent.parent(); } if(parent != null) { MethodTree methodTree = (MethodTree) parent; Symbol.MethodSymbol symbol = methodTree.symbol(); if("run".equals(symbol.name()) && symbol.parameterTypes().isEmpty() && symbol.owner().type().isSubtypeOf("java.lang.Runnable")) { return; } } reportIssue(MethodsHelper.methodName(mit), "Call the method Thread.start() to execute the content of the run() method in a dedicated thread."); }

Target:
protected void onMethodInvocationFound(MethodInvocationTree mit) { Tree parent = mit.parent(); while (parent != null && !parent.is(Tree.Kind.METHOD)) { parent = parent.parent(); } if (parent != null && RUNNABLE_RUN_METHOD_MATCHER.matches((MethodTree) parent)) { return; } reportIssue(MethodsHelper.methodName(mit), "Call the method Thread.start() to execute the content of the run() method in a dedicated thread."); }
Source:
public Object toAvro(Schema schema, BlobProperty input) { switch (schema.getType()) { case NULL: if (input == null) { return null; } throw new RuntimeServiceException(CANNOT_MAP_TO + schema.getType()); case UNION: for (Schema s : schema.getTypes()) { try { return service.toAvro(s, input); } catch (RuntimeServiceException e) { } } throw new RuntimeServiceException(CANNOT_MAP_TO + schema.getType()); case RECORD: GenericRecord record = new GenericData.Record(schema); for (Field f : schema.getFields()) { if ("data".equals(f.name())) { Blob blob = (Blob) input.getValue(); try { record.put(f.name(), ByteBuffer.wrap(blob.getByteArray())); } catch (IOException e) { e.printStackTrace(); } } else { record.put(f.name(), service.toAvro(f.schema(), input.get(service.decodeName(f.name())))); } input.getValueForWrite(); } return record; default: throw new RuntimeServiceException(CANNOT_MAP_TO + schema.getType()); } }

Target:
public Object toAvro(Schema schema, BlobProperty input) { switch (schema.getType()) { case NULL: if (input == null) { return null; } throw new NonNullValueException(); case UNION: for (Schema s : schema.getTypes()) { try { return service.toAvro(s, input); } catch (NonNullValueException e) { } } throw new RuntimeServiceException(CANNOT_MAP_TO + schema.getType()); case RECORD: GenericRecord record = new GenericData.Record(schema); for (Field f : schema.getFields()) { if ("data".equals(f.name())) { Blob blob = (Blob) input.getValue(); try { record.put(f.name(), ByteBuffer.wrap(blob.getByteArray())); } catch (IOException e) { throw new RuntimeServiceException(CANNOT_MAP_TO + schema.getType(), e); } } else { record.put(f.name(), service.toAvro(f.schema(), input.get(service.decodeName(f.name())))); } } return record; default: throw new RuntimeServiceException(CANNOT_MAP_TO + schema.getType()); } }
Source:
public static void main(String... a) throws Exception { TestBase test = TestBase.createCaller().init(); FilePathEncrypt.register(); for (int i = 0; i < 100; i++) { ((TestFileSystem)test).testConcurrent("encrypt:0007:" + test.getBaseDir() + "/fs"); test.println("Done pass #" + i); } }

Target:
public static void main(String... a) throws Exception { TestBase test = TestBase.createCaller().init(); test.testFromMain(); }
Source:
public DuoAuthenticationHandler duoAuthenticationHandler() { final List<DuoSecurityMultifactorProperties> duos = casProperties.getAuthn().getMfa().getDuo(); if (duos.isEmpty()) { throw new BeanCreationException("No configuration/settings could be found for Duo Security. Review settings and ensure the correct syntax is used"); } final String name = duos.get(0).getName(); if (duos.size() > 1) { LOGGER.debug("Multiple Duo Security providers are available; Duo authentication handler is named after [{}]", name); } final DuoAuthenticationHandler h = new DuoAuthenticationHandler(name, servicesManager, duoPrincipalFactory(), duoMultifactorAuthenticationProvider()); return h; }

Target:
public Collection<AuthenticationHandler> duoAuthenticationHandler() { final List<DuoSecurityMultifactorProperties> duos = casProperties.getAuthn().getMfa().getDuo(); if (duos.isEmpty()) { throw new BeanCreationException("No configuration/settings could be found for Duo Security. Review settings and ensure the correct syntax is used"); } return duos.stream() .map(d -> new DuoAuthenticationHandler(d.getId(), servicesManager, duoPrincipalFactory(), duoMultifactorAuthenticationProviders(d)) ).collect(Collectors.toList()); }
Source:
protected boolean validate() { if (!super.validate()) { return false; } oldPool = vmPoolDao.get(getVmPool().getVmPoolId()); if (oldPool == null) { return failValidation(EngineMessage.VM_POOL_CANNOT_UPDATE_POOL_NOT_FOUND); } if (getParameters().getVmsCount() < 0) { return failValidation(EngineMessage.VM_POOL_CANNOT_DECREASE_VMS_FROM_POOL); } if (oldPool.getVmPoolType() != getParameters().getVmPool().getVmPoolType()) { return failValidation(EngineMessage.VM_POOL_CANNOT_CHANGE_POOL_TYPE); } if (oldPool.isStateful() != getParameters().getVmPool().isStateful()) { return failValidation(EngineMessage.VM_POOL_CANNOT_CHANGE_POOL_STATEFUL_OPTION); } if (!oldPool.getName().equals(getParameters().getVmPool().getName())) { return failValidation(EngineMessage.VM_POOL_CANNOT_CHANGE_POOL_NAME); } if (oldPool.isAutoStorageSelect() != (getParameters().getVmPool().isAutoStorageSelect())) { return failValidation(EngineMessage.VM_POOL_CANNOT_CHANGE_AUTO_STORAGE_SELECT); } return true; }

Target:
protected boolean validate() { if (!super.validate()) { return false; } oldPool = vmPoolDao.get(getVmPool().getVmPoolId()); if (oldPool == null) { return failValidation(EngineMessage.VM_POOL_CANNOT_UPDATE_POOL_NOT_FOUND); } if (getParameters().getVmsCount() < 0) { return failValidation(EngineMessage.VM_POOL_CANNOT_DECREASE_VMS_FROM_POOL); } if (oldPool.getVmPoolType() != getParameters().getVmPool().getVmPoolType()) { return failValidation(EngineMessage.VM_POOL_CANNOT_CHANGE_POOL_TYPE); } if (oldPool.isStateful() != getParameters().getVmPool().isStateful()) { return failValidation(EngineMessage.VM_POOL_CANNOT_CHANGE_POOL_STATEFUL_OPTION); } if (!oldPool.getName().equals(getParameters().getVmPool().getName())) { return failValidation(EngineMessage.VM_POOL_CANNOT_CHANGE_POOL_NAME); } if (oldPool.isAutoStorageSelect() != getParameters().getVmPool().isAutoStorageSelect()) { return failValidation(EngineMessage.VM_POOL_CANNOT_CHANGE_AUTO_STORAGE_SELECT); } return true; }
Source:
protected Query doBuild(LuceneSearchPredicateContext context) { Builder builder = new BooleanQuery.Builder(); values.forEach( value -> builder.add( termQuery( value ), Occur.SHOULD ) ); BooleanQuery query = builder.build(); return query; }

Target:
protected Query doBuild(LuceneSearchPredicateContext context) { Builder builder = new BooleanQuery.Builder(); for ( String value : values ) { builder.add( termQuery( value ), Occur.SHOULD ); } return builder.build(); }
Source:
public void getJobStatuses(Collection<Job> jobs) throws IOException, InterruptedException { if (jobs == null || jobs.isEmpty()) { return; } final Map<String, Job> qualifiedJobToInfo = new HashMap<>(); for(Job job : jobs) { qualifiedJobToInfo.put(getQualifiedJobName(new JobInstance(job.getJobName(), job.getJobId())), job); } try { byte[] response = httpGet(_apiEndpoint); ApplicationInfoWrapper appInfoWrapper = _objectMapper.readValue(response, ApplicationInfoWrapper.class); for (ApplicationInfo appInfo: appInfoWrapper.getApps()) { String qualifiedName = appInfo.getName(); JobStatus samzaStatus = yarnStateToSamzaStatus(YarnApplicationState.valueOf(appInfo.getState().toUpperCase())); Job job = qualifiedJobToInfo.get(qualifiedName); if (job != null && (job.getStatusDetail() == null || samzaStatus != JobStatus.STOPPED)) { job.setStatusDetail(appInfo.getState()); job.setStatus(samzaStatus); } } } catch (IOException e) { throw new RuntimeException("Failed to retrieve node info.", e); } }

Target:
public void getJobStatuses(Collection<Job> jobs) throws IOException, InterruptedException { if (jobs == null || jobs.isEmpty()) { return; } try { byte[] response = httpGet(apiEndpoint); YarnApplicationInfo yarnApplicationInfo = OBJECT_MAPPER.readValue(response, YarnApplicationInfo.class); Map<String, YarnApplicationInfo.YarnApplication> yarnApplications = yarnApplicationInfo.getApplications(); for (Job job: jobs) { String qualifiedJobName = YarnApplicationInfo.getQualifiedJobName(new JobInstance(job.getJobName(), job.getJobId())); YarnApplicationInfo.YarnApplication yarnApp = yarnApplications.get(qualifiedJobName); if (yarnApp == null) { job.setStatusDetail(JobStatus.UNKNOWN.toString()); job.setStatus(JobStatus.UNKNOWN); continue; } JobStatus samzaStatus = yarnStateToSamzaStatus(YarnApplicationState.valueOf(yarnApp.getState().toUpperCase())); if (job.getStatusDetail() == null || samzaStatus != JobStatus.STOPPED) { job.setStatusDetail(yarnApp.getState()); job.setStatus(samzaStatus); } } } catch (IOException e) { throw new RuntimeException("Failed to retrieve node info.", e); } }
Source:
private static void checkNokia(Options options, Context context) { List<Appstore> availableStores = options.availableStores; boolean hasNokia = false; if (availableStores != null && availableStores.size() > 0) { for (Appstore appstore : availableStores) { if (appstore.getAppstoreName().equals(NAME_NOKIA)) { hasNokia = true; break; } } } if (hasNokia) { if (!hasRequestedPermission(context, "com.nokia.payment.BILLING")) { throw new IllegalStateException("Nokia permission \"com.nokia.payment.BILLING\" NOT REQUESTED"); } } }

Target:
private static void checkNokia(Options options, Context context) { List<Appstore> availableStores = options.availableStores; boolean hasNokia = false; if (availableStores != null && !availableStores.isEmpty()) { for (Appstore appstore : availableStores) { if (appstore.getAppstoreName().equals(NAME_NOKIA)) { hasNokia = true; break; } } } if (hasNokia) { if (!hasRequestedPermission(context, "com.nokia.payment.BILLING")) { throw new IllegalStateException("Nokia permission \"com.nokia.payment.BILLING\" NOT REQUESTED"); } } }
Source:
public ColumnRef resolveColumn(String schemaName, String tableName, String colName) throws SQLException { if (tableName == null) { int theColumnPosition = -1; TableRef theTableRef = null; Iterator<TableRef> iterator = tables.iterator(); while (iterator.hasNext()) { TableRef tableRef = iterator.next(); try { PColumn column = tableRef.getTable().getPColumnForColumnName(colName); if (theTableRef != null) { throw new AmbiguousColumnException(colName); } theTableRef = tableRef; theColumnPosition = column.getPosition(); } catch (ColumnNotFoundException e) { } } if (theTableRef != null) { return new ColumnRef(theTableRef, theColumnPosition); } throw new ColumnNotFoundException(colName); } else { try { TableRef tableRef = resolveTable(schemaName, tableName); PColumn column = tableRef.getTable().getPColumnForColumnName(colName); return new ColumnRef(tableRef, column.getPosition()); } catch (TableNotFoundException e) { ColumnFamilyRef cfRef = resolveColumnFamily(schemaName, tableName); PColumn column = cfRef.getFamily().getPColumnForColumnName(colName); return new ColumnRef(cfRef.getTableRef(), column.getPosition()); } } }

Target:
public ColumnRef resolveColumn(String schemaName, String tableName, String colName) throws SQLException { if (tableName == null) { int theColumnPosition = -1; TableRef theTableRef = null; Iterator<TableRef> iterator = tables.iterator(); while (iterator.hasNext()) { TableRef tableRef = iterator.next(); try { PColumn column = tableRef.getTable().getColumnForColumnName(colName); if (theTableRef != null) { throw new AmbiguousColumnException(colName); } theTableRef = tableRef; theColumnPosition = column.getPosition(); } catch (ColumnNotFoundException e) { } } if (theTableRef != null) { return new ColumnRef(theTableRef, theColumnPosition); } throw new ColumnNotFoundException(colName); } else { try { TableRef tableRef = resolveTable(schemaName, tableName); PColumn column = tableRef.getTable().getColumnForColumnName(colName); return new ColumnRef(tableRef, column.getPosition()); } catch (TableNotFoundException e) { ColumnFamilyRef cfRef = resolveColumnFamily(schemaName, tableName); PColumn column = cfRef.getFamily().getPColumnForColumnName(colName); return new ColumnRef(cfRef.getTableRef(), column.getPosition()); } } }
Source:
private void normalizeIntensities() { normalizedXIntensities = new float[numberOfSnps]; normalizedYIntensities = new float[numberOfSnps]; for (int i = 0; i < rawXIntensities.length; i++) { final int rawX = rawXIntensities[i]; final int rawY = rawYIntensities[i]; final int normId; int normIndex = -1; if ((allNormalizationIds != null) && (allNormalizationIds.length > i)) { normId = allNormalizationIds[i]; normIndex = getAllNormIndex(normId); } if (normIndex != -1) { final InfiniumTransformation xform = normalizationTransformations[normIndex]; final float tempX = rawX - xform.getOffsetX(); final float tempY = rawY - xform.getOffsetY(); final float theta = xform.getTheta(); double tempX2 = Math.cos(theta) * tempX + Math.sin(theta) * tempY; double tempY2 = -Math.sin(theta) * tempX + Math.cos(theta) * tempY; double tempX3 = tempX2 - xform.getShear() * tempY2; if (tempX3 < 0) { tempX3 = 0; } if (tempY2 < 0) { tempY2 = 0; } normalizedXIntensities[i] = (float) (tempX3 / xform.getScaleX()); normalizedYIntensities[i] = (float) (tempY2 / xform.getScaleY()); } else { normalizedXIntensities[i] = rawXIntensities[i]; normalizedYIntensities[i] = rawYIntensities[i]; } } }

Target:
private void normalizeIntensities() { normalizedXIntensities = new float[numberOfSnps]; normalizedYIntensities = new float[numberOfSnps]; for (int i = 0; i < rawXIntensities.length; i++) { final int rawX = rawXIntensities[i]; final int rawY = rawYIntensities[i]; final int normId; int normIndex = -1; if (allNormalizationIds.length > i) { normId = allNormalizationIds[i]; normIndex = getAllNormIndex(normId); } if (normIndex != -1) { final InfiniumTransformation xform = normalizationTransformations[normIndex]; final float tempX = rawX - xform.getOffsetX(); final float tempY = rawY - xform.getOffsetY(); final float theta = xform.getTheta(); double tempX2 = Math.cos(theta) * tempX + Math.sin(theta) * tempY; double tempY2 = -Math.sin(theta) * tempX + Math.cos(theta) * tempY; double tempX3 = tempX2 - xform.getShear() * tempY2; if (tempX3 < 0) { tempX3 = 0; } if (tempY2 < 0) { tempY2 = 0; } normalizedXIntensities[i] = (float) (tempX3 / xform.getScaleX()); normalizedYIntensities[i] = (float) (tempY2 / xform.getScaleY()); } else { normalizedXIntensities[i] = rawXIntensities[i]; normalizedYIntensities[i] = rawYIntensities[i]; } } }
Source:
public void showNPCReset(final Player player, final NPC npc) { npc.despawn(); Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { @Override public void run() { npc.spawn(npc.getStoredLocation()); } }, 1); }

Target:
public void showNPCReset(final Player player, final NPC npc) { ((CraftPlayer)player).getHandle().playerConnection.sendPacket (new PacketPlayOutEntityDestroy(npc.getEntity().getEntityId())); Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { @Override public void run() { if (player.isOnline() && player.isValid() && npc.isSpawned() && npc.getEntity().getType() == EntityType.PLAYER) { NMS.sendPlayerlistPacket(true, player, npc); ((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutNamedEntitySpawn (((CraftPlayer) npc.getEntity()).getHandle())); } } }, 1); Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { @Override public void run() { if (player.isOnline() && player.isValid() && npc.isSpawned() && npc.getEntity().getType() == EntityType.PLAYER) { NMS.sendPlayerlistPacket(false, player, npc); } } }, 61); }
Source:
protected <T> PrioritizedListenableFutureTask<T> newTaskFor(Runnable runnable, T value) { Preconditions.checkArgument( allowRegularTasks || runnable instanceof PrioritizedRunnable, "task does not implement PrioritizedRunnable" ); return PrioritizedListenableFutureTask.create( ListenableFutureTask.create(runnable, value), getPriority(runnable), config.isFifo() ); }

Target:
protected <T> PrioritizedListenableFutureTask<T> newTaskFor(Runnable runnable, T value) { Preconditions.checkArgument( allowRegularTasks || runnable instanceof PrioritizedRunnable, "task does not implement PrioritizedRunnable" ); return PrioritizedListenableFutureTask.create( ListenableFutureTask.create(runnable, value), runnable instanceof PrioritizedRunnable ? ((PrioritizedRunnable) runnable).getPriority() : defaultPriority, config.isFifo() ? queuePosition.decrementAndGet() : 0 ); }
Source:
public static void bootstrap(Level level) { LoggingUtil.hijackJDKLogging(); bootstrappingLock.lock(); try { if (!bootstrapped) { final Logger root = LoggingUtil.getLoggerContext().getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); root.detachAndStopAllAppenders(); final DropwizardLayout formatter = new DropwizardLayout(root.getLoggerContext(), TimeZone.getDefault()); formatter.start(); final ThresholdFilter filter = new ThresholdFilter(); filter.setLevel(level.toString()); filter.start(); final ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>(); appender.addFilter(filter); appender.setContext(root.getLoggerContext()); LayoutWrappingEncoder<ILoggingEvent> layoutEncoder = new LayoutWrappingEncoder<>(); layoutEncoder.setLayout(formatter); appender.setEncoder(layoutEncoder); appender.start(); root.addAppender(appender); bootstrapped = true; } } finally { bootstrappingLock.unlock(); } }

Target:
public static void bootstrap(Level level) { LoggingUtil.hijackJDKLogging(); bootstrappingLock.lock(); try { if (bootstrapped) { return; } final Logger root = LoggingUtil.getLoggerContext().getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); root.detachAndStopAllAppenders(); final DropwizardLayout formatter = new DropwizardLayout(root.getLoggerContext(), TimeZone.getDefault()); formatter.start(); final ThresholdFilter filter = new ThresholdFilter(); filter.setLevel(level.toString()); filter.start(); final ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>(); appender.addFilter(filter); appender.setContext(root.getLoggerContext()); LayoutWrappingEncoder<ILoggingEvent> layoutEncoder = new LayoutWrappingEncoder<>(); layoutEncoder.setLayout(formatter); appender.setEncoder(layoutEncoder); appender.start(); root.addAppender(appender); bootstrapped = true; } finally { bootstrappingLock.unlock(); } }
Source:
public List<Runnable> clearTasks() { synchronized (scheduledQueue.getModificationLock()) { synchronized (executeQueueRemoveLock) { List<Runnable> result = new ArrayList<Runnable>(executeQueue.size() + scheduledQueue.size()); Iterator<? extends TaskContainer> it = executeQueue.iterator(); while (it.hasNext()) { TaskContainer tc = it.next(); if (! tc.running) { result.add(tc.runnable); } } executeQueue.clear(); it = scheduledQueue.iterator(); while (it.hasNext()) { TaskContainer tc = it.next(); if (! tc.running) { result.add(tc.runnable); } } scheduledQueue.clear(); return result; } } }

Target:
public List<Runnable> clearTasks() { synchronized (scheduledQueue.getModificationLock()) { synchronized (executeQueueRemoveLock) { List<TaskContainer> containers = new ArrayList<TaskContainer>(executeQueue.size() + scheduledQueue.size()); Iterator<? extends TaskContainer> it = executeQueue.iterator(); while (it.hasNext()) { TaskContainer tc = it.next(); if (! tc.running) { int index = ListUtils.getInsertionEndIndex(containers, tc, true); containers.add(index, tc); } } executeQueue.clear(); it = scheduledQueue.iterator(); while (it.hasNext()) { TaskContainer tc = it.next(); if (! tc.running) { int index = ListUtils.getInsertionEndIndex(containers, tc, true); containers.add(index, tc); } } scheduledQueue.clear(); List<Runnable> result = new ArrayList<Runnable>(containers.size()); it = containers.iterator(); while (it.hasNext()) { result.add(it.next().runnable); } return result; } } }
Source:
public synchronized void sendMessageSync(String destAddress, String message) throws RecoverablePduException, UnrecoverablePduException, SmppTimeoutException, SmppChannelException, InterruptedException { if (getSession() != null && getSession().isBound()) { byte[] textBytes = CharsetUtil.encode(message, charsetName); SubmitSm submit = new SubmitSm(); submit.setSourceAddress(new Address(sourceTon, sourceNpi, sourceAddress)); submit.setDestAddress(new Address(destTon, destNpi, destAddress)); submit.setRegisteredDelivery(SmppConstants.REGISTERED_DELIVERY_SMSC_RECEIPT_REQUESTED); submit.setDataCoding((byte) dataCoding); submit.setShortMessage(textBytes); SubmitSmResp submitResponce = getSession().submit(submit, submitTimeout); Log.debug("SMS submited, msg_id: " + submitResponce.getMessageId()); } else { throw new SmppChannelException("Smpp session is not connected"); } }

Target:
public synchronized void sendMessageSync(String destAddress, String message) throws RecoverablePduException, UnrecoverablePduException, SmppTimeoutException, SmppChannelException, InterruptedException { if (getSession() != null && getSession().isBound()) { byte[] textBytes = CharsetUtil.encode(message, charsetName); SubmitSm submit = new SubmitSm(); submit.setSourceAddress(new Address(sourceTon, sourceNpi, sourceAddress)); submit.setDestAddress(new Address(destTon, destNpi, destAddress)); submit.setDataCoding(dataCoding); submit.setShortMessage(textBytes); SubmitSmResp submitResponce = getSession().submit(submit, submitTimeout); Log.debug("SMS submited, msg_id: " + submitResponce.getMessageId()); } else { throw new SmppChannelException("Smpp session is not connected"); } }
Source:
public void release(Jedis j, byte[] lockKey, byte[] lockValue) { if (lockValue != null) { j.watch(lockKey); byte[] prevousLockValue = j.get(lockKey); if (Arrays.equals(prevousLockValue, lockValue)) { Transaction transaction = j.multi(); transaction.del(lockKey); boolean succeed = transaction.exec() != null; if (!succeed) { LOG.warn( "Failed to release lock for key {}/{}, meaning the key probably expired because of acquiring the lock for too long {}ms (expiration at {}ms)", new String(lockKey), Hex.encodeHexString(lockValue), System.currentTimeMillis() - extractTime(lockValue), expiration); } } else { LOG.warn( "Nothing to release for key {}/{}, meaning the key probably expired because of acquiring the lock for too long {}ms (expiration at {}ms)", new String(lockKey), Hex.encodeHexString(lockValue), System.currentTimeMillis() - extractTime(lockValue), expiration); j.unwatch(); } } else { LOG.warn("Trying to release a lock for with a null value", new String(lockKey)); } }

Target:
public void release(Jedis j, byte[] lockKey, byte[] lockValue) { if (lockValue != null) { j.watch(lockKey); byte[] previousLockValue = j.get(lockKey); if (Arrays.equals(previousLockValue, lockValue)) { Transaction transaction = j.multi(); transaction.del(lockKey); boolean succeed = transaction.exec() != null; if (!succeed) { LOG.warn( "Failed to release lock for key {}/{}, meaning the key probably expired because of acquiring the lock for too long {}ms (expiration at {}ms)", new String(lockKey), Hex.encodeHexString(lockValue), System.currentTimeMillis() - extractTime(lockValue), expiration); } } else { LOG.warn( "Nothing to release for key {}/{}, meaning the key probably expired because of acquiring the lock for too long {}ms (expiration at {}ms)", new String(lockKey), Hex.encodeHexString(lockValue), System.currentTimeMillis() - extractTime(lockValue), expiration); j.unwatch(); } } else { LOG.warn("Trying to release a lock for with a null value", new String(lockKey)); } }
Source:
protected Optional<Boolean> getVal(EntityAgeable container) { return Optional.of(!container.isChild()); }

Target:
protected Optional<Boolean> getVal(EntityAgeable container) { return OptBool.of(!container.isChild()); }
Source:
public static boolean isImpactingNotification(final Collection<Notification> notifications) { boolean isImpactingNotification = false; Set<EObject> alreadyDoneNotifiers = new HashSet<>(); for (Notification notification : notifications) { Object notifier = notification.getNotifier(); if (notifier instanceof EObject) { EObject eObjectNotifier = (EObject) notifier; if (!alreadyDoneNotifiers.contains(eObjectNotifier)) { Resource notifierResource = eObjectNotifier.eResource(); if (notifierResource != null) { if (impactingNotificationPredicates.isEmpty()) { alreadyDoneNotifiers.add(eObjectNotifier); } if (!new ResourceQuery(notifierResource).isAirdOrSrmResource() || isSpecificImpactingNotification(notification)) { isImpactingNotification = true; break; } } } } } return isImpactingNotification; }

Target:
public static boolean isImpactingNotification(final Collection<Notification> notifications) { Map<EObject, Boolean> notifierIsInAirdOrSrmResource = new HashMap<>(); Map<EObject, Resource> notifierWithResource = new HashMap<>(); Set<EObject> alreadyDoneNotifiers = new HashSet<>(); for (Notification notification : notifications) { Object notifier = notification.getNotifier(); if (notifier instanceof EObject) { EObject eObjectNotifier = (EObject) notifier; if (!alreadyDoneNotifiers.contains(eObjectNotifier) && isImpactingNotification(notification, eObjectNotifier, alreadyDoneNotifiers, notifierWithResource, notifierIsInAirdOrSrmResource)) { return true; } } } return false; }
Source:
public static ActivityObject buildActivityObject(Interaction interaction) { ActivityObject actObj = new ActivityObject(); actObj.setObjectType(interaction.getContenttype()); actObj.setUrl(interaction.getLink()); actObj.setId(interaction.getId()); actObj.setContent(interaction.getContent()); return actObj; }

Target:
public static ActivityObject buildActivityObject(Interaction interaction) { ActivityObject actObj = new ActivityObject(); actObj.setObjectType(interaction.getContenttype()); actObj.setUrl(interaction.getLink()); actObj.setId(formatId("post",interaction.getId())); actObj.setContent(interaction.getContent()); return actObj; }
Source:
public Optional<FlyingData> createFrom(DataHolder dataHolder) { if (supports(dataHolder)) { boolean isFlying = ((net.minecraft.entity.Entity) dataHolder).isAirBorne; if (dataHolder instanceof EntityPlayer) { isFlying = ((EntityPlayer) dataHolder).capabilities.allowFlying; } return Optional.<FlyingData>of(new SpongeFlyingData(isFlying)); } return Optional.absent(); }

Target:
public Optional<FlyingData> createFrom(DataHolder dataHolder) { final boolean isFlying; if (supports(dataHolder)) { if (dataHolder instanceof EntityPlayer) { isFlying = ((EntityPlayer) dataHolder).capabilities.isFlying; } else { isFlying = ((net.minecraft.entity.Entity) dataHolder).isAirBorne; } return Optional.<FlyingData>of(new SpongeFlyingData(isFlying)); } else { return Optional.absent(); } }
Source:
private RepositoryDirectoryValue.Builder fetchRepository( SkyKey skyKey, Path repoRoot, Environment env, Map<String, String> markerData, RepositoryFunction handler, Rule rule) throws InterruptedException, RepositoryFunctionException { setupRepositoryRoot(repoRoot); String repositoryName = ((RepositoryName) skyKey.argument()).getName(); env.getListener().post(new RepositoryFetching(repositoryName, false)); RepositoryDirectoryValue.Builder repoBuilder; try { repoBuilder = handler.fetch(rule, repoRoot, directories, env, markerData, skyKey); } catch (RepositoryFunctionException e) { env.getListener().post(new RepositoryFetching(repositoryName, true)); env.getListener().post(new RepositoryFailedEvent(repositoryName, e.getMessage())); env.getListener().handle(Event.error("Error fetching repository: " + e.getMessage())); throw e; } if (env.valuesMissing()) { env.getListener().post(new RepositoryFetching(repositoryName, false, "Restarting.")); return null; } env.getListener().post(new RepositoryFetching(repositoryName, true)); return Preconditions.checkNotNull(repoBuilder); }

Target:
private RepositoryDirectoryValue.Builder fetchRepository( SkyKey skyKey, Path repoRoot, Environment env, Map<String, String> markerData, RepositoryFunction handler, Rule rule) throws InterruptedException, RepositoryFunctionException { setupRepositoryRoot(repoRoot); String repositoryName = ((RepositoryName) skyKey.argument()).getName(); env.getListener().post(new RepositoryFetching(repositoryName, false)); RepositoryDirectoryValue.Builder repoBuilder; try { repoBuilder = handler.fetch(rule, repoRoot, directories, env, markerData, skyKey); } catch (RepositoryFunctionException e) { env.getListener().post(new RepositoryFetching(repositoryName, true)); env.getListener().post(new RepositoryFailedEvent(repositoryName, e.getMessage())); env.getListener().handle(Event.error("Error fetching repository: " + e.getMessage())); throw new RepositoryFunctionException( new AlreadyReportedRepositoryAccessException( e.getCause()), e.isTransient() ? Transience.TRANSIENT : Transience.PERSISTENT); } if (env.valuesMissing()) { env.getListener().post(new RepositoryFetching(repositoryName, false, "Restarting.")); return null; } env.getListener().post(new RepositoryFetching(repositoryName, true)); return Preconditions.checkNotNull(repoBuilder); }
Source:
public boolean removeSecurityGroup(String id) { final NetworkConfiguration networkConfiguration = api.getVirtualNetworkApi().get(); if (networkConfiguration != null) { for (VirtualNetworkSite virtualNetworkSite : networkConfiguration.virtualNetworkConfiguration().virtualNetworkSites()) { for (NetworkConfiguration.Subnet subnet : virtualNetworkSite.subnets()) { final String virtualNetworkName = virtualNetworkSite.name(); final String subnetName = subnet.name(); if (virtualNetworkName != null && subnetName != null) { NetworkSecurityGroup networkSecurityGroupAppliedToSubnet = api.getNetworkSecurityGroupApi() .getNetworkSecurityGroupAppliedToSubnet(virtualNetworkName, subnetName); if (networkSecurityGroupAppliedToSubnet != null) { if (!networkSecurityGroupAppliedToSubnet.name().equals(id)) { logger.debug("Removing a networkSecurityGroup %s is already applied to subnet '%s' ...", id, subnetName); String removeFromSubnetRequestId = api.getNetworkSecurityGroupApi().removeFromSubnet (virtualNetworkName, subnetName, networkSecurityGroupAppliedToSubnet.name()); String operationDescription = format("Remove existing networkSecurityGroup(%s) from subnet(%s)", id, subnetName); waitForOperationCompletion(removeFromSubnetRequestId, operationDescription); } } } } } } String deleteRequestId = api.getNetworkSecurityGroupApi().delete(id); if (!operationSucceeded.apply(deleteRequestId)) { return false; } return true; }

Target:
public boolean removeSecurityGroup(String id) { final NetworkConfiguration networkConfiguration = api.getVirtualNetworkApi().getNetworkConfiguration(); if (networkConfiguration != null) { for (VirtualNetworkSite virtualNetworkSite : networkConfiguration.virtualNetworkConfiguration().virtualNetworkSites()) { for (NetworkConfiguration.Subnet subnet : virtualNetworkSite.subnets()) { final String virtualNetworkName = virtualNetworkSite.name(); final String subnetName = subnet.name(); if (virtualNetworkName != null && subnetName != null) { NetworkSecurityGroup networkSecurityGroupAppliedToSubnet = api.getNetworkSecurityGroupApi() .getNetworkSecurityGroupAppliedToSubnet(virtualNetworkName, subnetName); if (networkSecurityGroupAppliedToSubnet != null) { if (!networkSecurityGroupAppliedToSubnet.name().equals(id)) { logger.debug("Removing a networkSecurityGroup %s is already applied to subnet '%s' ...", id, subnetName); String removeFromSubnetRequestId = api.getNetworkSecurityGroupApi().removeFromSubnet (virtualNetworkName, subnetName, networkSecurityGroupAppliedToSubnet.name()); if (operationSucceededPredicate.apply(removeFromSubnetRequestId)) { final String message = generateIllegalStateExceptionMessage(removeFromSubnetRequestId, azureComputeConstants.operationTimeout()); logger.warn(message); throw new IllegalStateException(message); } } } } } } } String deleteRequestId = api.getNetworkSecurityGroupApi().delete(id); return operationSucceededPredicate.apply(deleteRequestId); }
Source:
public String notifyLayerListeners(ILayerListener.EventType type, HttpServletRequest request, IModule module) throws IOException { StringBuffer sb = new StringBuffer(); Object[] refs; if(PlatformAggregatorProvider.getPlatformAggregator() != null){ refs = PlatformAggregatorProvider.getPlatformAggregator().getServiceReferences(ILayerListener.class.getName(), "(name="+aggr.getName()+")"); if (refs != null) { for (Object ref : refs) { ILayerListener listener = (ILayerListener)PlatformAggregatorProvider.getPlatformAggregator().getService(ref); try { Set<String> dependentFeatures = new HashSet<String>(); String str = listener.layerBeginEndNotifier(type, request, type == ILayerListener.EventType.BEGIN_MODULE ? Arrays.asList(new IModule[]{module}) : layerListenerModuleList, dependentFeatures); if (dependentFeatures.size() != 0) { moduleList.getDependentFeatures().addAll(dependentFeatures); } if (str != null) { sb.append(str); } } finally { PlatformAggregatorProvider.getPlatformAggregator().ungetService(ref); } } } } return sb.length() != 0 ? sb.toString() : null; }

Target:
protected String notifyLayerListeners(ILayerListener.EventType type, HttpServletRequest request, IModule module) throws IOException { StringBuffer sb = new StringBuffer(); Object[] refs = null; if(aggr.getPlatformServices() != null){ try { refs = aggr.getPlatformServices().getServiceReferences(ILayerListener.class.getName(), "(name="+aggr.getName()+")"); } catch (PlatformServicesException e) { if (log.isLoggable(Level.SEVERE)) { log.log(Level.SEVERE, e.getMessage(), e); } } if (refs != null) { for (Object ref : refs) { ILayerListener listener = (ILayerListener)aggr.getPlatformServices().getService(ref); try { Set<String> dependentFeatures = new HashSet<String>(); String str = listener.layerBeginEndNotifier(type, request, type == ILayerListener.EventType.BEGIN_MODULE ? Arrays.asList(new IModule[]{module}) : layerListenerModuleList, dependentFeatures); if (dependentFeatures.size() != 0) { moduleList.getDependentFeatures().addAll(dependentFeatures); } if (str != null) { sb.append(str); } } finally { aggr.getPlatformServices().ungetService(ref); } } } } return sb.length() != 0 ? sb.toString() : null; }
Source:
public Optional<Long> lastSequenceNumberFor(String aggregateIdentifier) { String sql = "SELECT max(" + schema.sequenceNumberColumn() + ") FROM " + schema.domainEventTable() + " WHERE " + schema.aggregateIdentifierColumn() + " = ?"; return Optional.ofNullable(transactionManager.fetchInTransaction( () -> executeQuery(getConnection(), connection -> { PreparedStatement stmt = connection.prepareStatement(sql); stmt.setString(1, aggregateIdentifier); return stmt; }, resultSet -> { if (resultSet.next()) { final Long value = resultSet.getObject(1, Long.class); if (false == resultSet.wasNull()) { return value; } } return null; }, e -> new EventStoreException( format("Failed to read events for aggregate [%s]", aggregateIdentifier), e )))); }

Target:
public Optional<Long> lastSequenceNumberFor(String aggregateIdentifier) { String sql = "SELECT max(" + schema.sequenceNumberColumn() + ") FROM " + schema.domainEventTable() + " WHERE " + schema.aggregateIdentifierColumn() + " = ?"; return Optional.ofNullable(transactionManager.fetchInTransaction( () -> executeQuery(getConnection(), connection -> { PreparedStatement stmt = connection.prepareStatement(sql); stmt.setString(1, aggregateIdentifier); return stmt; }, resultSet -> JdbcUtils.nextAndExtract(resultSet, 1, Long.class), e -> new EventStoreException(format("Failed to read events for aggregate [%s]", aggregateIdentifier), e) ))); }
Source:
private static void readAndSeekTrace(CtfTestTrace testTrace, String testName, boolean inGlobalSummary) { assumeTrue(testTrace.exists()); Performance perf = Performance.getDefault(); PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + '#' + testName); perf.tagAsSummary(pm, TEST_SUITE_NAME + ':' + testName, Dimension.CPU_TIME); if (inGlobalSummary) { perf.tagAsGlobalSummary(pm, TEST_SUITE_NAME + ':' + testName, Dimension.CPU_TIME); } for (int loops = 0; loops < LOOP_COUNT; loops++) { try (CTFTrace trace = testTrace.getTrace(); CTFTraceReader traceReader = new CTFTraceReader(trace);) { EventDefinition firstEvent = traceReader.getCurrentEventDef(); final long startTime = firstEvent.getTimestamp(); long endTime = startTime; while (traceReader.hasMoreEvents()) { EventDefinition ev = traceReader.getCurrentEventDef(); endTime = ev.getTimestamp(); traceReader.advance(); } List<Long> seekTimestamps = new LinkedList<>(); final long range = endTime - 4277198419110L; for (int i = 0; i < NB_SEEKS; i++) { seekTimestamps.add(startTime + (RND.nextLong() % range)); } pm.start(); for (Long ts : seekTimestamps) { traceReader.seek(ts); traceReader.advance(); } pm.stop(); } catch (CTFReaderException e) { fail(); } } pm.commit(); }

Target:
private static void readAndSeekTrace(CtfTestTrace testTrace, String testName, boolean inGlobalSummary) { assumeTrue(testTrace.exists()); Performance perf = Performance.getDefault(); PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + '#' + testName); perf.tagAsSummary(pm, TEST_SUITE_NAME + ':' + testName, Dimension.CPU_TIME); if (inGlobalSummary) { perf.tagAsGlobalSummary(pm, TEST_SUITE_NAME + ':' + testName, Dimension.CPU_TIME); } for (int loop = 0; loop < LOOP_COUNT; loop++) { try (CTFTrace trace = testTrace.getTrace(); CTFTraceReader traceReader = new CTFTraceReader(trace);) { EventDefinition firstEvent = traceReader.getCurrentEventDef(); final long startTime = firstEvent.getTimestamp(); long endTime = startTime; while (traceReader.hasMoreEvents()) { EventDefinition ev = traceReader.getCurrentEventDef(); endTime = ev.getTimestamp(); traceReader.advance(); } List<Long> seekTimestamps = new LinkedList<>(); final long range = endTime - startTime; for (int i = 0; i < NB_SEEKS; i++) { seekTimestamps.add(startTime + (RND.nextLong() % range)); } pm.start(); for (Long ts : seekTimestamps) { traceReader.seek(ts); traceReader.advance(); } pm.stop(); } catch (CTFReaderException e) { fail("Test failed at iteration " + loop + ':' + e.getMessage()); } } pm.commit(); }
Source:
private boolean hasAccess(PID pid, String datastream) { if (datastream.equals("IMAGE_JP2000") || datastream == null) { datastream = JP2_ACCESS_COPY.getId(); } Permission permission = DatastreamPermissionUtil.getPermissionForDatastream(datastream); AgentPrincipals agent = AgentPrincipals.createFromThread(); LOG.debug("Checking if user has access to belonging to object {}.", agent.getUsername(), datastream, pid); return accessControlService.hasAccess(pid, agent.getPrincipals(), permission); }

Target:
private boolean hasAccess(PID pid, String datastream) { if (datastream == null) { datastream = JP2_ACCESS_COPY.getId(); } Permission permission = DatastreamPermissionUtil.getPermissionForDatastream(datastream); AgentPrincipals agent = AgentPrincipals.createFromThread(); LOG.debug("Checking if user has access to belonging to object {}.", agent.getUsername(), datastream, pid); return accessControlService.hasAccess(pid, agent.getPrincipals(), permission); }
Source:
public List<ModuleDefinition> findDefinitions(ModuleType type) { List<ModuleDefinition> results = new ArrayList<ModuleDefinition>(); String path = Paths.build(Paths.MODULES, type.toString()); try { List<String> children = zooKeeperConnection.getClient().getChildren().forPath(path); for (String child : children) { byte[] data = zooKeeperConnection.getClient().getData().forPath( Paths.build(Paths.MODULES, type.toString(), child)); if (data != null && data.length > 0) { ModuleDefinition composed = this.findDefinition(child, type); if (composed != null) { results.add(composed); } } } } catch (Exception e) { ZooKeeperUtils.wrapAndThrowIgnoring(e, KeeperException.NoNodeException.class); } return results; }

Target:
public List<ModuleDefinition> findDefinitions(ModuleType type) { List<ModuleDefinition> results = new ArrayList<>(); String path = Paths.build(Paths.MODULES, type.toString()); try { List<String> children = zooKeeperConnection.getClient().getChildren().forPath(path); for (String child : children) { byte[] data = zooKeeperConnection.getClient().getData().forPath( Paths.build(Paths.MODULES, type.toString(), child)); if (data != null && data.length > 0) { ModuleDefinition composed = this.findDefinition(child, type); if (composed != null) { results.add(composed); } else { throw new NoSuchModuleException(child, type); } } } } catch (Exception e) { ZooKeeperUtils.wrapAndThrowIgnoring(e, KeeperException.NoNodeException.class); } return results; }