auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testWriteCommitProcTime() throws Exception { setupProcessors(0, 0); Request req1 = createWriteRequest(1l, 2); processRequestWithWait(req1); commitWithWait(req1); <START> <END> Map<String, Object> values = ServerMetrics.getAllValues(); Assert.assertEquals(1L, values.get("cnt_write_commitproc_time_ms")); checkTimeMetric((long)values.get("max_write_commitproc_time_ms"), 0l, 1000l); Request req2 = createWriteRequest(1l, 2); processRequestWithWait(req2); Thread.sleep(1000); commitWithWait(req2); values = ServerMetrics.getAllValues(); Assert.assertEquals(2L, values.get("cnt_write_commitproc_time_ms")); checkTimeMetric((long)values.get("max_write_commitproc_time_ms"), 1000L, 2000L); }</code><technical_language>This is lead flaky test. If join threads properly here, I suggest remove this validation</technical_language>

Target:
public void testWriteCommitProcTime() throws Exception { setupProcessors(0, 0); Request req1 = createWriteRequest(1l, 2); processRequestWithWait(req1); commitWithWait(req1); Map<String, Object> values = MetricsUtils.currentServerMetrics(); Assert.assertEquals(1L, values.get("cnt_write_commitproc_time_ms")); checkTimeMetric((long)values.get("max_write_commitproc_time_ms"), 0l, 1000l); Request req2 = createWriteRequest(1l, 2); processRequestWithWait(req2); Thread.sleep(1000); commitWithWait(req2); values = MetricsUtils.currentServerMetrics(); Assert.assertEquals(2L, values.get("cnt_write_commitproc_time_ms")); checkTimeMetric((long)values.get("max_write_commitproc_time_ms"), 1000L, 2000L); }
Source:
<code>public void deleteFolder(String path) { List<String> objects = getAllObjects(ensureTrailingSlashPresent(path)); <START> for(String objectName : objects) { <END> deleteObject(objectName); } deleteObject(ensureTrailingSlashPresent(path)); }</code><technical_language>answered order of deletion important S3 perspective objects independent of other. case naming pattern is some tools. E.g. for presenting S3 bucket contents some file-system object structure, folders for a tree. consdier case 3 object in S3 buckt * /a/ * /a/b/ * /a/b/c happen if delete /a/b/ this method fails exception. /a/b/c navigable /a/? simplify thinking in corner cases I suggest sort objects number of parts in path delete in order. this do: Ordering<String> ordering = Ordering.from(Comparator.comparingInt(object -> -Splitter.on('/').omitEmptyStrings().splitToList(object).size())); ordering.sortedCopy(objects) .forEach(o -> deleteObject(ensureTrailingSlashPresent(o)));</technical_language>

Target:
public void deleteFolder(String path) { List<String> objects = getAllObjects(path); Ordering<String> ordering = Ordering .from(Comparator .comparingInt(object -> -PATH_SPLITTER.splitToList(object).size())); ordering.sortedCopy(objects).forEach(o -> deleteObject(o)); deleteObject(ensureTrailingSlashPresent(path)); }
Source:
<code>public FieldNode deepResolveField(@NotNull FieldInfo field) { ClassNode cls = resolveClass(field.getDeclClass()); if (cls == null) { return null; } FieldNode resolved; DexNode declDex = cls.dex(); resolved = declDex.deepResolveField(cls, field); if (resolved != null){ return resolved; } <START> for (DexNode dexNode : dexNodes) { <END> if(dexNodes == declDex) { continue; } resolved = dexNode.deepResolveField(cls, field); if (resolved != null){ return resolved; } } return null; }</code><technical_language>search in other dex nodes needed</technical_language>

Target:
public FieldNode deepResolveField(@NotNull FieldInfo field) { ClassNode cls = resolveClass(field.getDeclClass()); if (cls == null) { return null; } return cls.dex().deepResolveField(cls, field); }
Source:
<code>public void foreach(Processor processor) throws FileNotFoundException, IOException { File myWar = GerritLauncher.getDistributionArchive(); if (myWar.isFile()) { try (ZipFile zf = new ZipFile(myWar)) { Enumeration<? extends ZipEntry> e = zf.entries(); while (e.hasMoreElements()) { ZipEntry ze = e.nextElement(); if (ze.isDirectory()) { continue; } if (ze.getName().startsWith(PLUGIN_DIR) && ze.getName().endsWith(JAR)) { String pluginJarName = new File(ze.getName()).getName(); String pluginName = pluginJarName.substring(0, pluginJarName.length() - JAR.length()); final InputStream in = zf.getInputStream(ze); processor.process(pluginName, in); <START> in.close(); <END> } } } } }</code><technical_language>a try-with-resources block</technical_language>

Target:
public void foreach(Processor processor) throws FileNotFoundException, IOException { File myWar = GerritLauncher.getDistributionArchive(); if (myWar.isFile()) { try (ZipFile zf = new ZipFile(myWar)) { Enumeration<? extends ZipEntry> e = zf.entries(); while (e.hasMoreElements()) { ZipEntry ze = e.nextElement(); if (ze.isDirectory()) { continue; } if (ze.getName().startsWith(PLUGIN_DIR) && ze.getName().endsWith(JAR)) { String pluginJarName = new File(ze.getName()).getName(); String pluginName = pluginJarName.substring(0, pluginJarName.length() - JAR.length()); try (InputStream in = zf.getInputStream(ze)) { processor.process(pluginName, in); } } } } } }
Source:
<code>public WirelessDebuggingEnabler(Context context, SwitchWidgetController switchWidget, <START> OnEnabledListener listener) { <END> mContext = context; mSwitchWidget = switchWidget; mSwitchWidget.setListener(this); mListener = listener; setupSwitchController(); }</code><technical_language>long</technical_language>

Target:
public WirelessDebuggingEnabler(Context context, SwitchWidgetController switchWidget, OnEnabledListener listener) { mContext = context; mSwitchWidget = switchWidget; mSwitchWidget.setListener(this); mListener = listener; mContentResolver = context.getContentResolver(); setupSwitchController(); mSettingsObserver = new ContentObserver(mHandler) { @Override public void onChange(boolean selfChange, Uri uri, int userId) { onWirelessDebuggingEnabled(isAdbWifiEnabled()); } }; }
Source:
<code>private void launchPinCreateScreen(LoginMode loginMode) { <START> launchPinCreateScreen(loginMode, null); <END> }</code><technical_language>Instead of passing null in for passwordFromAuth, move getIntent().getStringExtra(LoginActivity.PASSWORD_FROM_LOGIN) code here? remove need for if (passwordFromAuth != null) { line avoid null is a</technical_language>

Target:
private void launchPinCreateScreen(LoginMode loginMode) { Intent i = new Intent(this, CreatePinActivity.class); i.putExtra(LoginActivity.LOGIN_MODE, loginMode); startActivityForResult(i, CREATE_PIN); }
Source:
<code>public void resume() { checkRealm(); <START> pauseDepth--; <END> if (dirty && pauseDepth == 0) { scheduleUpdate(); } }</code><technical_language>Throw IllegalStateException is pauseDepth negative</technical_language>

Target:
public void resume() { checkRealm(); pauseDepth--; if (pauseDepth < 0) { throw new IllegalStateException( "Resume has unessesarily been called too often, so that the pauseDepth is below zero."); } else if (dirty && pauseDepth == 0) { scheduleUpdate(); } }
Source:
<code>static <R extends Response> R extractResponseAndNotifyResponseHandler(ResponseHandler responseHandler, NonBlockingRouterMetrics routerMetrics, ResponseInfo responseInfo, Deserializer<R> deserializer, Function<R, ServerErrorCode> errorExtractor, boolean shareMemory) { R response = null; ReplicaId replicaId = responseInfo.getRequestInfo().getReplicaId(); NetworkClientErrorCode networkClientErrorCode = responseInfo.getError(); if (networkClientErrorCode == null) { try { <START> DataInputStream dis = null; <END> if (shareMemory) { dis = new CommonUtils.ByteBufferDataInputStream(responseInfo.getResponse()); } else { dis = new DataInputStream(new ByteBufferInputStream(responseInfo.getResponse())); } response = deserializer.readFrom(dis); responseHandler.onEvent(replicaId, errorExtractor.apply(response)); } catch (Exception e) { logger.error("Response deserialization received unexpected error", e); routerMetrics.responseDeserializationErrorCount.inc(); } } else { responseHandler.onEvent(replicaId, networkClientErrorCode); } return response; }</code><technical_language>minor nit: need = null variable assigned in paths</technical_language>

Target:
static <R extends Response> R extractResponseAndNotifyResponseHandler(ResponseHandler responseHandler, NonBlockingRouterMetrics routerMetrics, ResponseInfo responseInfo, Deserializer<R> deserializer, Function<R, ServerErrorCode> errorExtractor, boolean shareMemory) { R response = null; ReplicaId replicaId = responseInfo.getRequestInfo().getReplicaId(); NetworkClientErrorCode networkClientErrorCode = responseInfo.getError(); if (networkClientErrorCode == null) { try { DataInputStream dis = shareMemory ? new ByteBufferDataInputStream(responseInfo.getResponse()) : new DataInputStream(new ByteBufferInputStream(responseInfo.getResponse())); response = deserializer.readFrom(dis); responseHandler.onEvent(replicaId, errorExtractor.apply(response)); } catch (Exception e) { logger.error("Response deserialization received unexpected error", e); routerMetrics.responseDeserializationErrorCount.inc(); } } else { responseHandler.onEvent(replicaId, networkClientErrorCode); } return response; }
Source:
<code>private List<Disk> getUnregisteredDisks() { Guid storagePoolId = getVds().getStoragePoolId(); Guid storageDomainId = getParameters().getStorageDomainId(); List<Disk> unregisteredDisks = new ArrayList<Disk>(); List<Guid> imagesFromVds = null; try { VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.GetImagesList, new GetImagesListVDSCommandParameters(storageDomainId, storagePoolId)); if (!vdsReturnValue.getSucceeded()) { log.warn("Failed to get a list of images for Storage Domain to register OVF disks."); return unregisteredDisks; } imagesFromVds = (List<Guid>) vdsReturnValue.getReturnValue(); } catch (VdcBLLException e) { <START> log.warnFormat("Failed to get a list of images for Storage Domain to register OVF disks. Error: {0}", e); <END> } for (Guid unregisteredDiskId : imagesFromVds) { populateUnregisteredDisksListWithUnregisteredDisk(storagePoolId, storageDomainId, unregisteredDisks, unregisteredDiskId); } return unregisteredDisks; }</code><technical_language>return here? unregisteredDisks empty, for redundant</technical_language>

Target:
private List<Disk> getUnregisteredDisks() { Guid storagePoolId = getVds().getStoragePoolId(); Guid storageDomainId = getParameters().getStorageDomainId(); List<Disk> unregisteredDisks = new ArrayList<Disk>(); List<Guid> imagesFromVds = null; try { VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.GetImagesList, new GetImagesListVDSCommandParameters(storageDomainId, storagePoolId)); if (!vdsReturnValue.getSucceeded()) { log.warn("Failed to get a list of images for Storage Domain to register OVF disks."); return unregisteredDisks; } imagesFromVds = (List<Guid>) vdsReturnValue.getReturnValue(); } catch (VdcBLLException e) { log.warnFormat("Failed to get a list of images for Storage Domain to register OVF disks. Error: {0}", e); return unregisteredDisks; } for (Guid unregisteredDiskId : imagesFromVds) { populateUnregisteredDisksListWithUnregisteredDisk(storagePoolId, storageDomainId, unregisteredDisks, unregisteredDiskId); } return unregisteredDisks; }
Source:
<code>public CachedSchemaRegistryClientBuilder addSchemaParser(Codec codec) { <START> if (CoreUtils.isNullOrEmpty(codec.schemaType())) { <END> throw logger.logExceptionAsError( new IllegalArgumentException("Serialization type cannot be null or empty.")); } if (this.typeParserMap.containsKey(codec.schemaType())) { throw logger.logExceptionAsError( new IllegalArgumentException("Multiple parse methods for single serialization type may not be added.")); } this.typeParserMap.put(codec.schemaType(), codec::parseSchemaString); return this; }</code><technical_language>Check if codec is null checking codec.schemaType</technical_language>

Target:
public CachedSchemaRegistryClientBuilder addSchemaParser(Codec codec) { Objects.requireNonNull(codec, "'codec' cannot be null."); if (CoreUtils.isNullOrEmpty(codec.schemaType())) { throw logger.logExceptionAsError( new IllegalArgumentException("Serialization type cannot be null or empty.")); } if (this.typeParserMap.containsKey(codec.schemaType())) { throw logger.logExceptionAsError( new IllegalArgumentException("Multiple parse methods for single serialization type may not be added.")); } this.typeParserMap.put(codec.schemaType(), codec::parseSchemaString); return this; }
Source:
<code>protected void onUpdateElement(Rule oldElement, Rule element) throws IllegalArgumentException { try { validateModuleIDs(element, element.getModules(Module.class)); resolveConfigurations(element); <START> } catch (Exception e) { <END> logger.debug("The new version of updated rule '{}' is invalid", element.getUID(), e); } }</code><technical_language>catch generic Exceptions. this more specific</technical_language>

Target:
protected void onUpdateElement(Rule oldElement, Rule element) throws IllegalArgumentException { String uid = element.getUID(); try { resolveConfigurations(element); } catch (IllegalArgumentException e) { logger.debug("The new version of updated rule '{}' is invalid", uid, e); } }
Source:
<code>public void handleCommand(ChannelUID channelUID, Command command) { logger.trace("Command '{}' received for channel '{}'", command, channelUID); if (channelUID.getId().equals(CHANNEL_STATE)) { if (command instanceof OnOffType) { try { String binaryState = null; if (command.equals(OnOffType.ON)) { binaryState = "1"; } else if (command.equals(OnOffType.OFF)) { binaryState = "0"; } String soapHeader = "\"urn:Belkin:service:basicevent:1#SetBinaryState\""; String content = "<?xml version=\"1.0\"?>" + "<s:Envelope xmlns:s=\"<LINK_1>\" s:encodingStyle=\"<LINK_0>\">" + "<s:Body>" + "<u:SetBinaryState xmlns:u=\"urn:Belkin:service:basicevent:1\">" + "<BinaryState>" + binaryState + "</BinaryState>" + "</u:SetBinaryState>" + "</s:Body>" + "</s:Envelope>"; String wemoURL = getWemoURL("basicevent"); if (wemoURL != null) { <START> String wemoCallResponse = WemoHttpCall.executeCall(wemoURL, soapHeader, content); <END> } } catch (Exception e) { logger.error("Failed to send command '{}' for device '{}' ", command, getThing().getUID(), e); } } } }</code><technical_language>assigned variable is</technical_language>

Target:
public void handleCommand(ChannelUID channelUID, Command command) { logger.trace("Command '{}' received for channel '{}'", command, channelUID); if (channelUID.getId().equals(CHANNEL_STATE)) { if (command instanceof OnOffType) { try { String binaryState = null; if (command.equals(OnOffType.ON)) { binaryState = "1"; } else if (command.equals(OnOffType.OFF)) { binaryState = "0"; } String soapHeader = "\"urn:Belkin:service:basicevent:1#SetBinaryState\""; String content = "<?xml version=\"1.0\"?>" + "<s:Envelope xmlns:s=\"<LINK_1>\" s:encodingStyle=\"<LINK_0>\">" + "<s:Body>" + "<u:SetBinaryState xmlns:u=\"urn:Belkin:service:basicevent:1\">" + "<BinaryState>" + binaryState + "</BinaryState>" + "</u:SetBinaryState>" + "</s:Body>" + "</s:Envelope>"; String wemoURL = getWemoURL("basicevent"); if (wemoURL != null) { WemoHttpCall.executeCall(wemoURL, soapHeader, content); } } catch (Exception e) { logger.error("Failed to send command '{}' for device '{}' ", command, getThing().getUID(), e); } } } }
Source:
<code>public void currentWithError() throws SystemException { <START> doThrow(new SystemException()).when(mgr).getTransaction(); <END> TransactionSupport.current(); }</code><technical_language>this a call getTransactionThrowsSystemException</technical_language>

Target:
public void currentWithError() throws SystemException { getTransactionThrowsSystemException(); TransactionSupport.current(); }
Source:
<code>private IPersonAttributesGroupStoreDefinition getOrCreateStore() { List<IPersonAttributesGroupStoreDefinition> stores = personAttributesGroupStoreDefinitionDao.getPersonAttributesGroupStoreDefinitions(); if (stores.size() == 0) { return personAttributesGroupStoreDefinitionDao.createPersonAttributesGroupStoreDefinition("Default", "Default Person Attribute Group Store"); } else { <START> return stores.get(0); <END> } }</code><technical_language>Undetected error condition multiple IPersonAttributesGroupStoreDefinitions? a failure-inducing error, odd state of affairs worth logging</technical_language>

Target:
private IPersonAttributesGroupStoreDefinition getOrCreateStore() { Set<IPersonAttributesGroupStoreDefinition> stores = personAttributesGroupStoreDefinitionDao.getPersonAttributesGroupStoreDefinitions(); if (stores.size() == 0) { return personAttributesGroupStoreDefinitionDao.createPersonAttributesGroupStoreDefinition("Default", "Default Person Attribute Group Store"); } else { return stores.iterator().next(); } }
Source:
<code>private static void writeBytesIntoSmooshedChannel( long numBytesToPutInFile, final byte[] buffer, final SmooshedWriter smooshChannel, final InputStream is ) throws IOException { while (numBytesToPutInFile > 0) { <START> int bytesRead = is.read(buffer, 0, Math.min(buffer.length, (int) numBytesToPutInFile)); <END> smooshChannel.write((ByteBuffer) ByteBuffer.wrap(buffer).limit(bytesRead)); numBytesToPutInFile -= bytesRead; } }</code><technical_language>Unsafe cast int, lead exception, suggested Ints.saturatedCast(numBytesToPutInFile)</technical_language>

Target:
private static void writeBytesIntoSmooshedChannel( long numBytesToPutInFile, final byte[] buffer, final SmooshedWriter smooshChannel, final InputStream is ) throws IOException { ByteBuffer holderBuffer = ByteBuffer.wrap(buffer); while (numBytesToPutInFile > 0) { int bytesRead = is.read(buffer, 0, Math.min(buffer.length, Ints.saturatedCast(numBytesToPutInFile))); if (bytesRead != -1) { smooshChannel.write((ByteBuffer) holderBuffer.clear().limit(bytesRead)); numBytesToPutInFile -= bytesRead; } else { throw new ISE("Could not write [%d] bytes into smooshChannel.", numBytesToPutInFile); } } }
Source:
<code>public void beforeAll(final ExtensionContext context) { if (!started) { started = true; try { support.before(); } catch (final RuntimeException e) { } <START> context.getRoot().getStore(GLOBAL).put("dropwizard-startup", this); <END> } }</code><technical_language>Is this store accessed</technical_language>

Target:
public void beforeAll(final ExtensionContext context) { if (started.compareAndSet(false, true)) { try { support.before(); } catch (final RuntimeException e) { } context.getRoot().getStore(GLOBAL).put("dropwizard-startup", this); } }
Source:
<code>public Options getOptions() { return new Options() <START> .addOption(MEMORY_OPTION) <END> .addOption(READABLE_OPTION) .addOption(SUMMARIZE_OPTION) .addOption(GROUP_BY_WORKER_OPTION); }</code><technical_language>nit: sort lines alphabetically</technical_language>

Target:
public Options getOptions() { return new Options() .addOption(GROUP_BY_WORKER_OPTION) .addOption(MEMORY_OPTION) .addOption(READABLE_OPTION) .addOption(SUMMARIZE_OPTION); }
Source:
<code>public Map<Map.Entry<Long, Long>, Void> apply(Set<Map.Entry<Long, Long>> request) { CacheDescriptor cacheDescriptor = offHeapTimestampCache.cacheDescriptor.get(); if (cacheDescriptor.currentSize().get() >= offHeapTimestampCache.maxSize.getAsLong()) { offHeapTimestampCache.taggedMetricRegistry.counter(CACHE_NUKE).inc(); offHeapTimestampCache.clear(); } cacheDescriptor = offHeapTimestampCache.cacheDescriptor.get(); try { List<Long> toWrite = request.stream().map(Map.Entry::getKey).collect(Collectors.toList()); Map<Long, Long> response = offHeapTimestampCache.timestampStore.get( cacheDescriptor.entryFamily(), toWrite); int sizeIncrease = Sets.difference(request, response.entrySet()).size(); <START> offHeapTimestampCache.timestampStore.put(cacheDescriptor.entryFamily(), ImmutableMap.copyOf(request)); <END> cacheDescriptor.currentSize().addAndGet(sizeIncrease); } catch (SafeIllegalArgumentException exception) { log.warn("Clear called concurrently, writing failed", exception); } finally { offHeapTimestampCache.inflightRequests.clear(); } return KeyedStream.of(request.stream()).map(value -> (Void) null).collectToMap(); }</code><technical_language>nit: move this next cacheDescriptor.currentSize..</technical_language>

Target:
public Map<Map.Entry<Long, Long>, Void> apply(Set<Map.Entry<Long, Long>> request) { CacheDescriptor cacheDescriptor = offHeapTimestampCache.cacheDescriptor.get(); if (cacheDescriptor.currentSize().get() >= offHeapTimestampCache.maxSize.getAsLong()) { offHeapTimestampCache.taggedMetricRegistry.counter(CACHE_NUKE).inc(); offHeapTimestampCache.clear(); } cacheDescriptor = offHeapTimestampCache.cacheDescriptor.get(); Set<Map.Entry<ByteString, ByteString>> serializedRequest = request.stream() .map(this::serializeEntry) .collect(Collectors.toSet()); try { List<ByteString> toWrite = serializedRequest.stream() .map(Map.Entry::getKey) .collect(Collectors.toList()); Map<ByteString, ByteString> response = offHeapTimestampCache.persistentStore.get(cacheDescriptor.handle(), toWrite); int sizeIncrease = Sets.difference(request, response.entrySet()).size(); cacheDescriptor.currentSize().addAndGet(sizeIncrease); offHeapTimestampCache.persistentStore.put( cacheDescriptor.handle(), ImmutableMap.copyOf(serializedRequest)); } catch (SafeIllegalArgumentException exception) { log.warn("Clear called concurrently, writing failed", exception); } return KeyedStream.of(request.stream()).<Void>map(value -> null).collectToMap(); }
Source:
<code>private void checkForChangedCCZ() { Intent i = new Intent(getApplicationContext(), UpdateActivity.class); <START> startActivity(i); <END> }</code><technical_language>this update activity is launched, user out of it? Is okay</technical_language>

Target:
private void checkForChangedCCZ() { alreadyCheckedForAppFilesChange = true; Intent i = new Intent(getApplicationContext(), UpdateActivity.class); startActivity(i); }
Source:
<code>private boolean deleteCertificate(String hashToken) { boolean deleteStatus = false; try { SimpleCertificateResponseMessageType response = service .deleteCertificateFromTrustStore(selectedTSCertificate.getAlias(), hashToken); deleteStatus = response.isStatus(); if (deleteStatus) { refreshCerts(); selectedTSCertificate = null; } else { <START> HelperUtil.addMessageError("deletePassKeyErrorMsg", response.getMessage()); <END> } } catch (CertificateManagerException ex) { LOG.error("Unable to delete certificate {}", ex.getLocalizedMessage(), ex); HelperUtil.addMessageError("deletePassKeyErrorMsg", ex.getLocalizedMessage()); } return deleteStatus; }</code><technical_language>static variable</technical_language>

Target:
private boolean deleteCertificate(String hashToken) { boolean deleteStatus = false; try { SimpleCertificateResponseMessageType response = service .deleteCertificateFromTrustStore(selectedTSCertificate.getAlias(), hashToken); deleteStatus = response.isStatus(); if (deleteStatus) { refreshCerts(); selectedTSCertificate = null; } else { HelperUtil.addMessageError(DELETE_PASS_ERR_MSG_ID, response.getMessage()); } } catch (CertificateManagerException ex) { LOG.error("Unable to delete certificate {}", ex.getLocalizedMessage(), ex); HelperUtil.addMessageError(DELETE_PASS_ERR_MSG_ID, ex.getLocalizedMessage()); } return deleteStatus; }
Source:
<code><START> public Optional<Decorrelated> decorrelate(PlanNode reference) <END> { checkArgument(reference instanceof GroupReference); return lookup.resolve(reference).accept(this, reference); }</code><technical_language>If this a GroupReference, argument</technical_language>

Target:
public Optional<Decorrelated> decorrelate(PlanNode reference) { return lookup.resolve(reference).accept(this, reference); }
Source:
<code>public List<String> getActiveProcessorsIDs(List<String> znodeIds) { String processorPath = keyBuilder.getProcessorsPath(); List<String> processorIds = new ArrayList<>(znodeIds.size()); if (znodeIds.size() > 0) { for (String child : znodeIds) { String fullPath = String.format("%s/%s", processorPath, child); processorIds.add(new ProcessorData(readProcessorData(fullPath)).getProcessorId()); } <START> Collections.sort(processorIds, new Comparator<String>() { <END> @Override public int compare(String o1, String o2) { return Integer.valueOf(o1) - Integer.valueOf(o2); } }); LOG.info("Found these children - " + znodeIds); LOG.info("Found these processorIds - " + processorIds); } return processorIds; }</code><technical_language>curious, why're sorting processorIds in getActiveProcessorsIDs api. getSortedActiveProcessorsIDs same(or sense merge both)</technical_language>

Target:
public List<String> getActiveProcessorsIDs(List<String> znodeIds) { String processorPath = keyBuilder.getProcessorsPath(); List<String> processorIds = new ArrayList<>(znodeIds.size()); if (znodeIds.size() > 0) { for (String child : znodeIds) { String fullPath = String.format("%s/%s", processorPath, child); processorIds.add(new ProcessorData(readProcessorData(fullPath)).getProcessorId()); } Collections.sort(processorIds); LOG.info("Found these children - " + znodeIds); LOG.info("Found these processorIds - " + processorIds); } return processorIds; }
Source:
<code>public List<CohortMembership> getMemberships(Date asOf) { return getMembers().stream() <START> .filter(m -> m.getStartDate().after(asOf)).collect(Collectors.toList()); <END> }</code><technical_language>This return a membership started of date</technical_language>

Target:
public List<CohortMembership> getMemberships(Date asOf) { return getMembers().stream() .filter(m -> !m.getStartDate().before(asOf)).collect(Collectors.toList()); }
Source:
<code>public void prerender() { AdapterAuthenticationProxyObjectFactory factory = new AdapterAuthenticationProxyObjectFactory(); AdapterAuthenticationProxy adapterAuthenticationProxy = factory.getAdapterAuthenticationProxy(); AuthenticateUserRequestType authRequest = new AuthenticateUserRequestType(); authRequest.setUserName("Default"); authRequest.setPassword("Default"); AuthenticateUserResponseType authResp = adapterAuthenticationProxy.authenticateUser(authRequest); if (authResp != null) { LOG.debug("UserLogin.prerender Authentication Service Avail: {}", adapterAuthenticationProxy, authResp.isIsAuthenticationAvailable()); if (!authResp.isIsAuthenticationAvailable()) { try { getUserSession().setAuthToken("NoOpToken"); FacesContext context = FacesContext.getCurrentInstance(); context.getExternalContext().redirect("faces/SearchPatient.jsp"); } catch (IOException ex) { <START> LOG.error("CPP GUI can not prerender UserLogin: ", ex); <END> } } } try { String agencyName = PropertyAccessor.getInstance().getProperty(PROPERTY_FILE_NAME_ADAPTER, PROPERTY_FILE_KEY_AGENCY); agencyLogo.setText(agencyName); } catch (PropertyAccessException ex) { LOG.error("CPP GUI can not access property: ", PROPERTY_FILE_KEY_AGENCY, ex.getLocalizedMessage(), ex); } }</code><technical_language>Parameterized Logging needed here</technical_language>

Target:
public void prerender() { AdapterAuthenticationProxyObjectFactory factory = new AdapterAuthenticationProxyObjectFactory(); AdapterAuthenticationProxy adapterAuthenticationProxy = factory.getAdapterAuthenticationProxy(); AuthenticateUserRequestType authRequest = new AuthenticateUserRequestType(); authRequest.setUserName("Default"); authRequest.setPassword("Default"); AuthenticateUserResponseType authResp = adapterAuthenticationProxy.authenticateUser(authRequest); if (authResp != null) { LOG.debug("UserLogin.prerender Authentication Service Avail: {}", adapterAuthenticationProxy, authResp.isIsAuthenticationAvailable()); if (!authResp.isIsAuthenticationAvailable()) { try { getUserSession().setAuthToken("NoOpToken"); FacesContext context = FacesContext.getCurrentInstance(); context.getExternalContext().redirect("faces/SearchPatient.jsp"); } catch (IOException ex) { LOG.error("CPP GUI can not prerender UserLogin: ", ex.getLocalizedMessage(), ex); } } } try { String agencyName = PropertyAccessor.getInstance().getProperty(PROPERTY_FILE_NAME_ADAPTER, PROPERTY_FILE_KEY_AGENCY); agencyLogo.setText(agencyName); } catch (PropertyAccessException ex) { LOG.error("CPP GUI can not access property: ", PROPERTY_FILE_KEY_AGENCY, ex.getLocalizedMessage(), ex); } }
Source:
<code>public DelegatingResourceDescription getRepresentationDescription(Representation rep) { <START> RefRepresentation refRep = new RefRepresentation(); <END> DelegatingResourceDescription description = new DelegatingResourceDescription(); description.addProperty("allergenType"); description.addProperty("codedAllergen"); description.addProperty("nonCodedAllergen"); return description; }</code><technical_language>do refRep for</technical_language>

Target:
public DelegatingResourceDescription getRepresentationDescription(Representation rep) { DelegatingResourceDescription description = new DelegatingResourceDescription(); if (rep instanceof DefaultRepresentation) { description.addProperty("allergenType", Representation.REF); description.addProperty("codedAllergen", Representation.REF); description.addProperty("nonCodedAllergen"); } else if (rep instanceof FullRepresentation) { description.addProperty("allergenType", Representation.DEFAULT); description.addProperty("codedAllergen", Representation.DEFAULT); description.addProperty("nonCodedAllergen"); } return description; }
Source:
<code><START> public void copyFolder(File src, File dest) <END> throws IOException { if (src.isDirectory()) { if (!dest.exists()) { dest.mkdir(); log.info("Directory copied from " + src + " to " + dest); } String files[] = src.list(); for (String file : files) { File srcFile = new File(src, file); File destFile = new File(dest, file); copyFolder(srcFile, destFile); } } else { InputStream in = new FileInputStream(src); OutputStream out = new FileOutputStream(dest); byte[] buffer = new byte[1024]; int length; while ((length = in.read(buffer)) > 0) { out.write(buffer, 0, length); } in.close(); out.close(); log.info("File copied from " + src + " to " + dest); } }</code><technical_language>rename src - sourceFile dest - destinationFile</technical_language>

Target:
public void copyFolder(File src, File dest) throws CarbonToolsIntegrationTestException { if (src.isDirectory()) { if (!dest.exists()) { dest.mkdir(); log.info("Directory copied from " + src + " to " + dest); } String files[] = src.list(); for (String file : files) { File srcFile = new File(src, file); File destFile = new File(dest, file); copyFolder(srcFile, destFile); } } else { try { InputStream in = new FileInputStream(src); OutputStream out = new FileOutputStream(dest); byte[] buffer = new byte[1024]; int length; while ((length = in.read(buffer)) > 0) { out.write(buffer, 0, length); } in.close(); out.close(); }catch (IOException ex){ log.error("Error while copying folder " + ex.getMessage()); throw new CarbonToolsIntegrationTestException("Error while copying folder ", ex); } log.info("File copied from " + src + " to " + dest); } }
Source:
<code>protected HttpClient createHttpClient() <START> throws Error { <END> int port = getPort(); Credentials credentials = null; AuthSchemeRegistry schemeRegistry = new AuthSchemeRegistry(); AuthScope authScope = new AuthScope(getHost(), port, AuthScope.ANY_REALM, AuthScope.ANY_SCHEME); if (timeout != -1) { HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, timeout); DefaultHttpClient.setDefaultHttpParams(httpParams); } if (user != null && user.length() > 0) { schemeRegistry.register(AuthPolicy.BASIC, new BasicSchemeFactory()); credentials = new UsernamePasswordCredentials(user, password); } else if (kerberos) { schemeRegistry.register(AuthPolicy.SPNEGO, new SPNegoSchemeFactory(true)); credentials = new Credentials() { @Override public Principal getUserPrincipal() { return null; } @Override public String getPassword() { return null; } }; } DefaultHttpClient client = new DefaultHttpClient( new BasicClientConnectionManager(createConnectionSocketFactoryRegistry()) ); client.setAuthSchemes(schemeRegistry); client.getCredentialsProvider().setCredentials(authScope, credentials); client.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES); if (compress) { return new HttpClient42(new DecompressingHttpClient(client)); } return new HttpClient42(client); }</code><technical_language>is this needed</technical_language>

Target:
protected HttpClient createHttpClient() { int port = getPort(); Credentials credentials = null; AuthSchemeRegistry schemeRegistry = new AuthSchemeRegistry(); AuthScope authScope = new AuthScope(getHost(), port, AuthScope.ANY_REALM, AuthScope.ANY_SCHEME); if (timeout != -1) { HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, timeout); DefaultHttpClient.setDefaultHttpParams(httpParams); } if (user != null && user.length() > 0) { schemeRegistry.register(AuthPolicy.BASIC, new BasicSchemeFactory()); credentials = new UsernamePasswordCredentials(user, password); } else if (kerberos) { schemeRegistry.register(AuthPolicy.SPNEGO, new SPNegoSchemeFactory(true)); credentials = new Credentials() { @Override public Principal getUserPrincipal() { return null; } @Override public String getPassword() { return null; } }; } DefaultHttpClient client = new DefaultHttpClient( new BasicClientConnectionManager(createConnectionSocketFactoryRegistry()) ); client.setAuthSchemes(schemeRegistry); client.getCredentialsProvider().setCredentials(authScope, credentials); client.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES); if (compress) { return new HttpClient42(new DecompressingHttpClient(client)); } return new HttpClient42(client); }
Source:
<code>public PrivateKey parsePrivateKey(final String key) throws IOException { try (final PemReader pemReader = new PemReader(new StringReader(key));) { final PemObject pemObject = pemReader.readPemObject(); final byte[] content = pemObject.getContent(); final PKCS8EncodedKeySpec privKeySpec = new PKCS8EncodedKeySpec(content); final KeyFactory factory = KeyFactory.getInstance("RSA", "BC"); return factory.generatePrivate(privKeySpec); } catch (NoSuchAlgorithmException | NoSuchProviderException e) { throw new IOException("No encryption provider available.", e); } catch (final InvalidKeySpecException e) { <START> throw new IOException("Invalid Key format or invalid password.", e); <END> } }</code><technical_language>password is removed, exception message needs updated</technical_language>

Target:
public PrivateKey parsePrivateKey(final String key) throws IOException { try (final PemReader pemReader = new PemReader(new StringReader(key));) { final PemObject pemObject = pemReader.readPemObject(); final byte[] content = pemObject.getContent(); final PKCS8EncodedKeySpec privKeySpec = new PKCS8EncodedKeySpec(content); final KeyFactory factory = KeyFactory.getInstance("RSA", "BC"); return factory.generatePrivate(privKeySpec); } catch (NoSuchAlgorithmException | NoSuchProviderException e) { throw new IOException("No encryption provider available.", e); } catch (final InvalidKeySpecException e) { throw new IOException("Invalid Key format.", e); } }
Source:
<code>protected boolean sieveMessage(MailAddress recipient, Mail aMail) throws MessagingException { try { ResourceLocator.UserSieveInformation userSieveInformation = resourceLocator.get(recipient); sieveMessageEvaluate(recipient, aMail, userSieveInformation); return true; } catch (ScriptNotFoundException e) { if (LOGGER.isInfoEnabled()) { <START> LOGGER.info("Can not locate SIEVE script for user " + recipient.asPrettyString()); <END> } return false; } catch (Exception ex) { if (LOGGER.isErrorEnabled()) { LOGGER.error("Cannot evaluate Sieve script for user " + recipient.asPrettyString(), ex); } return false; } }</code><technical_language>Changed placeholders</technical_language>

Target:
protected boolean sieveMessage(MailAddress recipient, Mail aMail) throws MessagingException { try { ResourceLocator.UserSieveInformation userSieveInformation = resourceLocator.get(recipient); sieveMessageEvaluate(recipient, aMail, userSieveInformation); return true; } catch (ScriptNotFoundException e) { LOGGER.info("Can not locate SIEVE script for user {}", recipient.asPrettyString()); return false; } catch (Exception ex) { LOGGER.error("Cannot evaluate Sieve script for user {}", recipient.asPrettyString(), ex); return false; } }
Source:
<code>private boolean handleSpecialTTEFunctions( JSType type, String propName, boolean isStatic, Set<String> classTemplateTypeNames) { FunctionType ftype = type.toMaybeFunctionType(); if (ftype == null) return false; boolean hasTTE = false; for (TemplateType templateKey : ftype.getTemplateTypeMap().getTemplateKeys()) { if (templateKey.getTypeTransformation() != null) { hasTTE = true; break; } } <START> boolean horribleAsyncHack = false; <END> JSDocInfo info = type.getJSDocInfo(); if (info != null) { boolean isUntypedOverride = info.isOverride() && info.getParameterCount() == 0 && info.getReturnType() == null; if (opts.partialInput && info != null && isUntypedOverride && propName.equals("then")) { horribleAsyncHack = true; } } if (!horribleAsyncHack && !hasTTE) return false; String templateTypeSig = isStatic ? getSignatureForStaticTTEFn(propName, ftype) : getSignatureForInstanceTTEFn(propName, classTemplateTypeNames, ftype); if (templateTypeSig == null) { emit(" "); emitBreak(); return false; } emit(templateTypeSig); emitBreak(); return true; }</code><technical_language>sounds hack is async. horribleHackForPartialModeWithOverrides</technical_language>

Target:
private boolean handleSpecialTTEFunctions( JSType type, String propName, boolean isStatic, Set<String> classTemplateTypeNames) { FunctionType ftype = type.toMaybeFunctionType(); if (ftype == null) return false; boolean hasTTE = false; for (TemplateType templateKey : ftype.getTemplateTypeMap().getTemplateKeys()) { if (templateKey.getTypeTransformation() != null) { hasTTE = true; break; } } boolean horribleHackForPartialModeWithOverrides = false; JSDocInfo info = type.getJSDocInfo(); if (info != null) { boolean isUntypedOverride = info.isOverride() && info.getParameterCount() == 0 && info.getReturnType() == null; if (opts.partialInput && isUntypedOverride && propName.equals("then")) { horribleHackForPartialModeWithOverrides = true; } } if (!horribleHackForPartialModeWithOverrides && !hasTTE) return false; String templateTypeSig = isStatic ? getSignatureForStaticTTEFn(propName, ftype) : getSignatureForInstanceTTEFn(propName, classTemplateTypeNames, ftype); if (templateTypeSig == null) { emit(" "); emitBreak(); return false; } emit(templateTypeSig); emitBreak(); return true; }
Source:
<code>public void refreshJobInfo(JobInfo info) { GroupInfo group = info.getGroupInfo(); if (group != null) { refreshGroup(group); } Object[] listenersArray = listeners.getListeners(); <START> for (Object element : listenersArray) { <END> IJobProgressManagerListener listener = (IJobProgressManagerListener) element; if (!isCurrentDisplaying(info.getJob(), listener.showsDebug())) { listener.refreshJobInfo(info); } } }</code><technical_language>inline listeners.getListeners()</technical_language>

Target:
public void refreshJobInfo(JobInfo info) { GroupInfo group = info.getGroupInfo(); if (group != null) { refreshGroup(group); } for (Object element : listeners.getListeners()) { IJobProgressManagerListener listener = (IJobProgressManagerListener) element; if (!isCurrentDisplaying(info.getJob(), listener.showsDebug())) { listener.refreshJobInfo(info); } } }
Source:
<code>public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getCurrentSelection(event); <START> TmfExperimentElement experiment = (TmfExperimentElement) ((StructuredSelection) selection).getFirstElement(); <END> Shell shell = HandlerUtil.getActiveShellChecked(event); CopyExperimentDialog dialog = new CopyExperimentDialog(shell, experiment); dialog.open(); return null; }</code><technical_language>need add a check: if (!(selection instanceof IStructuredSelection)) { return null; } This selection is null; Also, cast IStructuredSelection instead of StructuredSelection</technical_language>

Target:
public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getCurrentSelectionChecked(event); if (!(selection instanceof IStructuredSelection)) { return null; } TmfExperimentElement experiment = (TmfExperimentElement) ((IStructuredSelection) selection).getFirstElement(); Shell shell = HandlerUtil.getActiveShellChecked(event); CopyExperimentDialog dialog = new CopyExperimentDialog(shell, experiment); dialog.open(); return null; }
Source:
<code>public Object[][] provideKeys() { return new Object[][] { <START> new Object[] {0, 3, 0, 3, 0, 0}, new Object[] {3, 0, 3, 0, 0, 0}, new Object[] {1, 1, 1, 1, 0, 0}, new Object[] {0, 0, 0, 0, 0, 0}, new Object[] {0, 3, 0, 0, 0, 1}, new Object[] {3, 0, 0, 0, 0, 1}, new Object[] {1, 1, 0, 0, 0, 2}, new Object[] {0, 0, 0, 0, 0, 1}, new Object[] {0, 3, 0, 3, 1, 1}, new Object[] {3, 0, 3, 0, 1, 1}, new Object[] {1, 1, 1, 1, 2, 2}, new Object[] {0, 0, 0, 0, 1, 1} <END> }; }</code><technical_language>new Object[] is unnecessary</technical_language>

Target:
public Object[][] provideKeys() { return new Object[][] { {0, 3, 0, 3, 0, 0}, {3, 0, 3, 0, 0, 0}, {1, 1, 1, 1, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 3, 0, 0, 0, 1}, {3, 0, 0, 0, 0, 1}, {1, 1, 0, 0, 0, 2}, {0, 0, 0, 0, 0, 1}, {0, 3, 0, 3, 1, 1}, {3, 0, 3, 0, 1, 1}, {1, 1, 1, 1, 2, 2}, {0, 0, 0, 0, 1, 1} }; }
Source:
<code>private Map<String, AttributeValue> getAttributeMapFromCalibration(final Calibration calibration) { <START> final Map<String, AttributeValue> attributes = new HashMap<>(); <END> attributes.put(SENSE_ATTRIBUTE_NAME, new AttributeValue().withS(calibration.senseId)); attributes.put(DUST_OFFSET_ATTRIBUTE_NAME, new AttributeValue().withN(String.valueOf(calibration.dustOffset))); attributes.put(TESTED_AT_ATTRIBUTE_NAME, new AttributeValue().withN(String.valueOf(calibration.testedAt))); return attributes; }</code><technical_language>Maps.newHashMap()</technical_language>

Target:
private Map<String, AttributeValue> getAttributeMapFromCalibration(final Calibration calibration) { final Map<String, AttributeValue> attributes = Maps.newHashMap(); attributes.put(SENSE_ATTRIBUTE_NAME, new AttributeValue().withS(calibration.senseId)); attributes.put(DUST_OFFSET_ATTRIBUTE_NAME, new AttributeValue().withN(String.valueOf(calibration.dustOffset))); attributes.put(TESTED_AT_ATTRIBUTE_NAME, new AttributeValue().withN(String.valueOf(calibration.testedAt))); return attributes; }
Source:
<code>protected void processParameters(HasPreferences holder, JMethod listenerMethod, JInvocation call, List<? extends VariableElement> userParameters) { JVar preferenceParam = listenerMethod.param(classes().PREFERENCE, "preference"); JVar newValueParam = listenerMethod.param(classes().OBJECT, "newValue"); for (VariableElement variableElement : userParameters) { <START> TypeMirror typeMirror = variableElement.asType(); <END> String type = typeMirror.toString(); if (isPreferenceOrSubclass(typeMirror)) { call.arg(castPreferenceIfNecessary(holder, preferenceParam, typeMirror)); } else if (type.equals(CanonicalNameConstants.OBJECT)) { call.arg(newValueParam); } else if (type.equals(CanonicalNameConstants.INTEGER) || type.equals(int.class.getName()) || type.equals(CanonicalNameConstants.FLOAT) || type.equals(float.class.getName()) || type.equals(CanonicalNameConstants.LONG) || type.equals(long.class.getName())) { JClass wrapperClass = type.startsWith("java") ? holder.refClass(type) : JType.parse(holder.codeModel(), type.replace(".class", "")).boxify(); call.arg(wrapperClass.staticInvoke("valueOf").arg(JExpr.cast(holder.classes().STRING, newValueParam))); } else { JClass userParamClass = codeModelHelper.typeMirrorToJClass(variableElement.asType(), holder); call.arg(JExpr.cast(userParamClass, newValueParam)); if (type.equals(CanonicalNameConstants.STRING_SET)) { codeModelHelper.addSuppressWarnings(listenerMethod, "unchecked"); } } } }</code><technical_language>this lne moved castPreferenceIfNecessary(), this is present in handlers</technical_language>

Target:
protected void processParameters(HasPreferences holder, JMethod listenerMethod, JInvocation call, List<? extends VariableElement> userParameters) { JVar preferenceParam = listenerMethod.param(classes().PREFERENCE, "preference"); JVar newValueParam = listenerMethod.param(classes().OBJECT, "newValue"); for (VariableElement variableElement : userParameters) { String type = variableElement.asType().toString(); if (isTypeOrSubclass(CanonicalNameConstants.PREFERENCE, variableElement)) { call.arg(castArgumentIfNecessary(holder, CanonicalNameConstants.PREFERENCE, preferenceParam, variableElement)); } else if (type.equals(CanonicalNameConstants.OBJECT)) { call.arg(newValueParam); } else if (type.equals(CanonicalNameConstants.INTEGER) || type.equals(int.class.getName()) || type.equals(CanonicalNameConstants.FLOAT) || type.equals(float.class.getName()) || type.equals(CanonicalNameConstants.LONG) || type.equals(long.class.getName())) { JClass wrapperClass = type.startsWith("java") ? holder.refClass(type) : JType.parse(holder.codeModel(), type.replace(".class", "")).boxify(); call.arg(wrapperClass.staticInvoke("valueOf").arg(JExpr.cast(holder.classes().STRING, newValueParam))); } else { JClass userParamClass = codeModelHelper.typeMirrorToJClass(variableElement.asType(), holder); call.arg(JExpr.cast(userParamClass, newValueParam)); if (type.equals(CanonicalNameConstants.STRING_SET)) { codeModelHelper.addSuppressWarnings(listenerMethod, "unchecked"); } } } }
Source:
<code>public String getXRegistryAuthHeaderValue(@Nullable String registry, @Nullable AuthConfigs paramAuthConfigs) { String normalizedRegistry = DEFAULT_REGISTRY_SYNONYMS.contains(registry) ? DEFAULT_REGISTRY : registry; AuthConfig authConfig = null; if (paramAuthConfigs != null && paramAuthConfigs.getConfigs() != null) { authConfig = normalizeDockerHubRegistryUrl(paramAuthConfigs.getConfigs()).get(normalizedRegistry); } if (authConfig == null) { authConfig = normalizeDockerHubRegistryUrl(initialAuthConfig.getAuthConfigs().getConfigs()).get(normalizedRegistry); } if (authConfig == null) { <START> authConfig = dynamicAuthResolver.getDynamicXRegistryAuth(registry); <END> } String authConfigJson; if (authConfig == null) { authConfigJson = "{}"; } else { authConfigJson = JsonHelper.toJson(authConfig); } return Base64.getEncoder().encodeToString(authConfigJson.getBytes()); }</code><technical_language>Resolver is declared dynamic, declare in method name</technical_language>

Target:
public String getXRegistryAuthHeaderValue(@Nullable String registry, @Nullable AuthConfigs paramAuthConfigs) { String normalizedRegistry = DEFAULT_REGISTRY_SYNONYMS.contains(registry) ? DEFAULT_REGISTRY : registry; AuthConfig authConfig = null; if (paramAuthConfigs != null && paramAuthConfigs.getConfigs() != null) { authConfig = normalizeDockerHubRegistryUrl(paramAuthConfigs.getConfigs()).get(normalizedRegistry); } if (authConfig == null) { authConfig = normalizeDockerHubRegistryUrl(initialAuthConfig.getAuthConfigs().getConfigs()).get(normalizedRegistry); } if (authConfig == null) { authConfig = dynamicAuthResolver.getXRegistryAuth(registry); } String authConfigJson; if (authConfig == null) { authConfigJson = "{}"; } else { authConfigJson = JsonHelper.toJson(authConfig); } return Base64.getEncoder().encodeToString(authConfigJson.getBytes()); }
Source:
<code>public boolean isResourceAuthorized(IResource resource, PageParameters pageParameters) { <START> return checkResource(resource.getClass().getAnnotation(AuthorizeResource.class)) || checkResource( <END> resource.getClass().getPackage().getAnnotation(AuthorizeResource.class)); }</code><technical_language>simplify a bit extract resource.getClass() a local variable</technical_language>

Target:
public boolean isResourceAuthorized(IResource resource, PageParameters pageParameters) { Class<? extends IResource> resourceClass = resource.getClass(); return checkResource(resourceClass.getAnnotation(AuthorizeResource.class)) || checkResource( resourceClass.getPackage().getAnnotation(AuthorizeResource.class)); }