auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>Response getKeyMetadata() { CacheEntry<byte[], byte[]> ce = cache.getCacheEntry(key); if (ce != null) { long version = 0; EntryVersion entryVersion = ce.getMetadata().version(); <START> if (entryVersion != null && entryVersion instanceof NumericVersion) { <END> version = ((NumericVersion) entryVersion).getVersion(); } byte[] v = ce.getValue(); int lifespan = ce.getLifespan() < 0 ? -1 : (int) ce.getLifespan() / 1000; int maxIdle = ce.getMaxIdle() < 0 ? -1 : (int) ce.getMaxIdle() / 1000; if (header.op == HotRodOperation.GET_WITH_METADATA) { return new GetWithMetadataResponse(header.version, header.messageId, header.cacheName, header.clientIntel, header.op, OperationStatus.Success, header.topologyId, v, version, ce.getCreated(), lifespan, ce.getLastUsed(), maxIdle); } else { int offset = ((Integer) operationDecodeContext).intValue(); return new GetStreamResponse(header.version, header.messageId, header.cacheName, header.clientIntel, header.op, OperationStatus.Success, header.topologyId, v, offset, version, ce.getCreated(), lifespan, ce.getLastUsed(), maxIdle); } } else { if (header.op == HotRodOperation.GET_WITH_METADATA) { return new GetWithMetadataResponse(header.version, header.messageId, header.cacheName, header.clientIntel, header.op, OperationStatus.KeyDoesNotExist, header.topologyId); } else { return new GetStreamResponse(header.version, header.messageId, header.cacheName, header.clientIntel, header.op, OperationStatus.KeyDoesNotExist, header.topologyId); } } }</code><technical_language>I handle SimpleClusteredVersion well? a long version field in it</technical_language>

Target:
Response getKeyMetadata() { CacheEntry<byte[], byte[]> ce = cache.getCacheEntry(key); if (ce != null) { EntryVersion entryVersion = ce.getMetadata().version(); long version = extractVersion(entryVersion); byte[] v = ce.getValue(); int lifespan = ce.getLifespan() < 0 ? -1 : (int) ce.getLifespan() / 1000; int maxIdle = ce.getMaxIdle() < 0 ? -1 : (int) ce.getMaxIdle() / 1000; if (header.op == HotRodOperation.GET_WITH_METADATA) { return new GetWithMetadataResponse(header.version, header.messageId, header.cacheName, header.clientIntel, header.op, OperationStatus.Success, header.topologyId, v, version, ce.getCreated(), lifespan, ce.getLastUsed(), maxIdle); } else { int offset = ((Integer) operationDecodeContext).intValue(); return new GetStreamResponse(header.version, header.messageId, header.cacheName, header.clientIntel, header.op, OperationStatus.Success, header.topologyId, v, offset, version, ce.getCreated(), lifespan, ce.getLastUsed(), maxIdle); } } else { if (header.op == HotRodOperation.GET_WITH_METADATA) { return new GetWithMetadataResponse(header.version, header.messageId, header.cacheName, header.clientIntel, header.op, OperationStatus.KeyDoesNotExist, header.topologyId); } else { return new GetStreamResponse(header.version, header.messageId, header.cacheName, header.clientIntel, header.op, OperationStatus.KeyDoesNotExist, header.topologyId); } } }
Source:
<code><START> public @Nullable MemoizedMessage lastSeenQuery() { <END> return lastSeenQuery; }</code><technical_language>Optional here</technical_language>

Target:
public MemoizedMessage lastSeenQuery() { assertNotNull(lastSeenQuery); return lastSeenQuery; }
Source:
<code><START> AuthenticationResult(String accessToken, String refreshToken, Date expires, boolean isBroad, <END> UserInfo userInfo, String tenantId, String idToken, Date extendedExpires) { mCode = null; mAccessToken = accessToken; mRefreshToken = refreshToken; mExpiresOn = expires; mIsMultiResourceRefreshToken = isBroad; mStatus = AuthenticationStatus.Succeeded; mUserInfo = userInfo; mTenantId = tenantId; mIdToken = idToken; if (extendedExpires != null) { mExtendedExpiresOn = extendedExpires; } }</code><technical_language>creating new constructors here</technical_language>

Target:
AuthenticationResult(String accessToken, String refreshToken, Date expires, boolean isBroad, UserInfo userInfo, String tenantId, String idToken, Date extendedExpires) { mCode = null; mAccessToken = accessToken; mRefreshToken = refreshToken; mExpiresOn = expires; mIsMultiResourceRefreshToken = isBroad; mStatus = AuthenticationStatus.Succeeded; mUserInfo = userInfo; mTenantId = tenantId; mIdToken = idToken; mExtendedExpiresOn = extendedExpires; }
Source:
<code>public Releaser increment() { if (refCount.getAndIncrement() <= 0) { <START> refCount.decrementAndGet(); <END> throw new ISE("Already closed!"); } return new Releaser() { boolean released = false; @Override public void close() { if (!released) { decrement(); released = true; } else { log.warn(new ISE("Already closed"), "Already closed"); } } }; }</code><technical_language>more threads call increment() closed holders, some threads pass this checking accidently operations atomic</technical_language>

Target:
public Releaser increment() { while (true) { int count = this.refCount.get(); if (count <= 0) { throw new ISE("Already closed!"); } if (refCount.compareAndSet(count, count + 1)) { break; } } return new Releaser() { boolean released = false; @Override public void close() { if (!released) { decrement(); released = true; } else { log.warn(new ISE("Already closed"), "Already closed"); } } }; }
Source:
<code>public ChromeOptions setEnableDownloading(boolean enableDownloading, String downloadPath){ if (enableDownloading){ setCapability(ENABLE_DOWNLOADING, downloadPath); }else { <START> setCapability(ENABLE_DOWNLOADING, ""); <END> } return this; }</code><technical_language>Setting capability null remove map, is more desirable</technical_language>

Target:
public ChromeOptions setEnableDownloading(boolean enableDownloading, String downloadPath){ if (enableDownloading) { setCapability(ENABLE_DOWNLOAD_TO, downloadPath); }else { setCapability(ENABLE_DOWNLOAD_TO, (Objects) null); } return this; }
Source:
<code>private static void checkAccount2Enabled() { if (!isAccount2Enabled()) { <START> throw new BadRequestException(Messages.INVALID_REQUEST); <END> } }</code><technical_language>404,</technical_language>

Target:
private static void checkAccount2Enabled() { if (!Profile.isFeatureEnabled(Profile.Feature.ACCOUNT2)) { throw new NotFoundException(); } }
Source:
<code>private Map<String, Pair<WorkspaceMetacardImpl, Long>> executeWorkspaceTasks( List<WorkspaceTask> workspaceTasks, long timeout, TimeUnit timeoutUnit) { Map<String, Pair<WorkspaceMetacardImpl, Long>> results = new ConcurrentHashMap<>(); workspaceTasks .stream() <START> .map(new ForkJoinPool(MAX_THREADS)::submit) <END> .map(task -> getTaskResult(task, timeout, timeoutUnit)) .filter(Objects::nonNull) .forEach( pair -> results.put( pair.getLeft().getId(), new ImmutablePair<>(pair.getLeft(), pair.getRight()))); return results; }</code><technical_language>I I for yesterday: <LINK_0> I need class. need move class this code access it. I similar issues XML transformers security manager</technical_language>

Target:
private Map<String, Pair<WorkspaceMetacardImpl, Long>> executeWorkspaceTasks( List<WorkspaceTask> workspaceTasks, long timeout, TimeUnit timeoutUnit) { Map<String, Pair<WorkspaceMetacardImpl, Long>> results = new ConcurrentHashMap<>(); workspaceTasks .stream() .map(ForkJoinPoolFactory.getNewForkJoinPool(null, false)::submit) .map(task -> getTaskResult(task, timeout, timeoutUnit)) .filter(Objects::nonNull) .forEach( pair -> results.put( pair.getLeft().getId(), new ImmutablePair<>(pair.getLeft(), pair.getRight()))); return results; }
Source:
<code>@Test public void userIdCausePrintTest() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); TaskListener listener = new StreamTaskListener(baos); Cause causeA = new Cause.UserIdCause(null); causeA.print(listener); assertTrue(baos.toString().isEmpty()); baos.reset(); Cause causeB = new Cause.UserIdCause(); causeB.print(listener); assertThat(baos.toString(), containsString("SYSTEM")); baos.reset(); Cause causeC = new Cause.UserIdCause("abc123"); causeC.print(listener); assertTrue(baos.toString().isEmpty()); baos.reset(); <START> } <END></code><technical_language>covered 3 special cases regular case existing user</technical_language>

Target:
@Test public void userIdCausePrintTest() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); TaskListener listener = new StreamTaskListener(baos); Cause causeA = new Cause.UserIdCause(null); causeA.print(listener); assertEquals(baos.toString().trim(),"Started by user unknown or anonymous"); baos.reset(); Cause causeB = new Cause.UserIdCause(); causeB.print(listener); assertThat(baos.toString(), containsString("SYSTEM")); baos.reset(); Cause causeC = new Cause.UserIdCause("abc123"); causeC.print(listener); assertEquals(baos.toString().trim(),"Started by user unknown or anonymous"); baos.reset(); User user = User.getById("foo", true); Cause causeD = new Cause.UserIdCause(user.getId()); causeD.print(listener); assertThat(baos.toString(), containsString(user.getDisplayName())); baos.reset(); }
Source:
<code>public static byte[] readBytes(int numBytes, ByteArrayInputStream inputStream) { byte[] data = new byte[numBytes]; <START> inputStream.read(data, 0, numBytes); <END> return data; }</code><technical_language>Check if inputStream is null</technical_language>

Target:
public static byte[] readBytes(int numBytes, ByteArrayInputStream inputStream) { if (inputStream == null) throw new NullPointerException("Input stream cannot be null."); if (numBytes < 0) throw new IllegalArgumentException("Number of bytes to read must be great than 0."); byte[] data = new byte[numBytes]; inputStream.read(data, 0, numBytes); return data; }
Source:
<code>protected FactModelTree createTopLevelFactModelTree(String factName, DMNType type, SortedMap<String, FactModelTree> hiddenFacts, FactModelTree.Type fmType) throws WrongDMNTypeException { <START> return isToBeManagedAsCollection((BaseDMNTypeImpl) type) ? createFactModelTreeForCollection(new HashMap<>(), factName, type, hiddenFacts, fmType, new ArrayList<>()) : createFactModelTreeForNoCollection(new HashMap<>(), factName, factName, type.getName(), type, hiddenFacts, fmType, new ArrayList<>()); <END> }</code><technical_language>@danielezonca is cast, is set _BaseDMNTypeImpl_ for "type" instead of _DMNType_</technical_language>

Target:
protected FactModelTree createTopLevelFactModelTree(String factName, DMNType type, SortedMap<String, FactModelTree> hiddenFacts, FactModelTree.Type fmType) throws WrongDMNTypeException { return isToBeManagedAsCollection(type) ? createFactModelTreeForCollection(new HashMap<>(), factName, type, hiddenFacts, fmType, new ArrayList<>()) : createFactModelTreeForNoCollection(new HashMap<>(), factName, factName, type.getName(), type, hiddenFacts, fmType, new ArrayList<>()); }
Source:
<code>public static OSInAppMessageController getController() { OneSignalDbHelper dbHelper = OneSignal.getDBHelperInstance(); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR2) { <START> sharedInstance = new OSInAppMessageDummyController(dbHelper); <END> } if (sharedInstance == null) sharedInstance = new OSInAppMessageController(dbHelper); return sharedInstance; }</code><technical_language>Pass null instead, if</technical_language>

Target:
public static OSInAppMessageController getController() { OneSignalDbHelper dbHelper = OneSignal.getDBHelperInstance(); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR2) { sharedInstance = new OSInAppMessageDummyController(null); } if (sharedInstance == null) sharedInstance = new OSInAppMessageController(dbHelper); return sharedInstance; }
Source:
<code>public void write(SerializedPage page) throws IOException { PageDataOutput pageDataOutput = new PageDataOutput(page); long writtenSize = pageDataOutput.size(); if (maxBufferedBytes - bufferedBytes < writtenSize) { dataSink.write(bufferedPages); <START> addStripeOffset(bufferedBytes); <END> bufferedPages.clear(); bufferedBytes = 0; retainedBytes = 0; } bufferedPages.add(pageDataOutput); bufferedBytes += writtenSize; retainedBytes += page.getRetainedSizeInBytes(); }</code><technical_language>stripe offset added adding a new stripe</technical_language>

Target:
public void write(SerializedPage page) throws IOException { PageDataOutput pageDataOutput = new PageDataOutput(page); long writtenSize = pageDataOutput.size(); if (maxBufferedBytes - bufferedBytes < writtenSize) { flushStripe(); } bufferedPages.add(pageDataOutput); bufferedBytes += writtenSize; retainedBytes += page.getRetainedSizeInBytes(); }
Source:
<code>public boolean addReplica(ReplicaId replicaId) { if (partitionToPartitionInfo.containsKey(replicaId.getPartitionId())) { logger.error("{} already exists in replication manager, rejecting adding replica request.", replicaId.getPartitionId()); return false; } List<? extends ReplicaId> peerReplicas = replicaId.getPeerReplicaIds(); List<RemoteReplicaInfo> remoteReplicaInfos = new ArrayList<>(); if (peerReplicas != null) { remoteReplicaInfos = populateRemoteReplicaAndPartitionInfos(peerReplicas, replicaId); } logger.info("Assigning thread for {}", replicaId.getPartitionId()); <START> addRemoteReplicaInfoToReplicaThread(remoteReplicaInfos, true); <END> logger.info("{} is successfully added into replication manager", replicaId.getPartitionId()); return true; }</code><technical_language>Move logic if (peerReplicas != null) {</technical_language>

Target:
public boolean addReplica(ReplicaId replicaId) { if (partitionToPartitionInfo.containsKey(replicaId.getPartitionId())) { logger.error("{} already exists in replication manager, rejecting adding replica request.", replicaId.getPartitionId()); return false; } List<? extends ReplicaId> peerReplicas = replicaId.getPeerReplicaIds(); List<RemoteReplicaInfo> remoteReplicaInfos = new ArrayList<>(); if (!peerReplicas.isEmpty()) { remoteReplicaInfos = createRemoteReplicaInfos(peerReplicas, replicaId); updatePartitionInfoMaps(remoteReplicaInfos, replicaId); } logger.info("Assigning thread for {}", replicaId.getPartitionId()); addRemoteReplicaInfoToReplicaThread(remoteReplicaInfos, true); logger.info("{} is successfully added into replication manager", replicaId.getPartitionId()); return true; }
Source:
<code>public String toString() { <START> return fTestClass.getName() + " '" + fName + "' with parameters " <END> + Arrays.toString(fParameters); }</code><technical_language>If fName is null, toString() include 'null'. Is intentional? do want allow this class a null fName (vs empty string)</technical_language>

Target:
public String toString() { return fTestClass.getName() + " '" + fName + "' with parameters " + fParameters; }
Source:
<code>protected void delete(Context context, UUID id) throws AuthorizeException { Item item = null; try { item = is.find(context, id); if (is.isInProgressSubmission(context, item)) { throw new UnprocessableEntityException("The item cannot be deleted. " + "It's part of a in-progress submission."); } if (item.getTemplateItemOf() != null) { throw new UnprocessableEntityException("The item cannot be deleted. " + "It's a template for a collection"); } } catch (SQLException e) { throw new RuntimeException(e.getMessage(), e); } try { <START> is.delete(context, item); <END> is.removeAllBundles(context, item); } catch (SQLException | IOException e) { throw new RuntimeException(e.getMessage(), e); } }</code><technical_language>this is needed done internally in ItemService.delete <LINK_0></technical_language>

Target:
protected void delete(Context context, UUID id) throws AuthorizeException { Item item = null; try { item = is.find(context, id); if (is.isInProgressSubmission(context, item)) { throw new UnprocessableEntityException("The item cannot be deleted. " + "It's part of a in-progress submission."); } if (item.getTemplateItemOf() != null) { throw new UnprocessableEntityException("The item cannot be deleted. " + "It's a template for a collection"); } } catch (SQLException e) { throw new RuntimeException(e.getMessage(), e); } try { is.delete(context, item); } catch (SQLException | IOException e) { throw new RuntimeException(e.getMessage(), e); } }
Source:
<code>private CMISSessionFacade getSessionFacade() throws Exception { if (sessionFacade == null) { sessionFacade = sessionFacadeFactory.create(); sessionFacade.initSession(); } <START> LOG.info("getSessionFacade {}", sessionFacade); <END> return sessionFacade; }</code><technical_language>Reduce logging level debug trace</technical_language>

Target:
private CMISSessionFacade getSessionFacade() throws Exception { if (sessionFacade == null) { sessionFacade = sessionFacadeFactory.create(); sessionFacade.initSession(); } return sessionFacade; }
Source:
<code>private static List<StringConstant> antMatchersPatterns(MethodInvocationTree mit) { List<StringConstant> argumentsAsString = mit.arguments().stream() .map(StringConstant::of) .collect(Collectors.toList()); <START> return argumentsAsString.stream().allMatch(Objects::nonNull) ? argumentsAsString : Collections.emptyList(); <END> }</code><technical_language>considering cases literals? I consider cases, wrong, considering myVar: java http.authorizeRequests().antMatchers("/admin/**", myVar, "/admin/login"); // Noncompliant Therefore, I simply skip null values</technical_language>

Target:
private static List<StringConstant> antMatchersPatterns(MethodInvocationTree mit) { return mit.arguments().stream() .map(StringConstant::of) .filter(Objects::nonNull) .collect(Collectors.toList()); }
Source:
<code><START> public ValueMatcher makeValueMatcher(String dimension,final String value) <END> { Integer dimIndexObject = index.getDimensionIndex(dimension); if (dimIndexObject == null) { return new BooleanValueMatcher(Strings.isNullOrEmpty(value)); } final IncrementalIndex.DimDim dimDim = index.getDimension(dimension); if (!dimDim.contains(value)) { if (Strings.isNullOrEmpty(value)) { final int dimIndex = dimIndexObject; return new ValueMatcher() { @Override public boolean matches() { String[][] dims = holder.getKey().getDims(); if (dimIndex >= dims.length || dims[dimIndex] == null) { return true; } return false; } }; } return new BooleanValueMatcher(false); } final int dimIndex = dimIndexObject; final String id = dimDim.get(value); return new ValueMatcher() { @Override public boolean matches() { String[][] dims = holder.getKey().getDims(); if (dimIndex >= dims.length || dims[dimIndex] == null) { return false; } for (String dimVal : dims[dimIndex]) { if (dimDim.compareCannonicalValues(id, dimVal)) { return true; } } return Strings.isNullOrEmpty(value); } }; }</code><technical_language>missing space ,</technical_language>

Target:
public ValueMatcher makeValueMatcher(String dimension, final String value) { Integer dimIndexObject = index.getDimensionIndex(dimension); if (dimIndexObject == null) { return new BooleanValueMatcher(Strings.isNullOrEmpty(value)); } final IncrementalIndex.DimDim dimDim = index.getDimension(dimension); if (!dimDim.contains(value)) { if (Strings.isNullOrEmpty(value)) { final int dimIndex = dimIndexObject; return new ValueMatcher() { @Override public boolean matches() { String[][] dims = holder.getKey().getDims(); if (dimIndex >= dims.length || dims[dimIndex] == null) { return true; } return false; } }; } return new BooleanValueMatcher(false); } final int dimIndex = dimIndexObject; final String id = dimDim.get(value); return new ValueMatcher() { @Override public boolean matches() { String[][] dims = holder.getKey().getDims(); if (dimIndex >= dims.length || dims[dimIndex] == null) { return Strings.isNullOrEmpty(value); } for (String dimVal : dims[dimIndex]) { if (dimDim.compareCannonicalValues(id, dimVal)) { return true; } } return false; } }; }
Source:
<code>public void setUp() throws Exception { root = Files.createTempDirectory("jgit-security").toFile(); permissions.add(new RuntimePermission("*")); permissions.add(new SecurityPermission("*")); permissions.add(new AuthPermission("*")); permissions.add(new ReflectPermission("*")); permissions.add(new PropertyPermission("*", "read,write")); permissions.add(new LoggingPermission("control", null)); permissions.add(new FilePermission( System.getProperty("java.home") + "/-", "read")); String tempDir = System.getProperty("java.io.tmpdir"); permissions.add(new FilePermission(tempDir, "read,write,delete")); permissions .add(new FilePermission(tempDir + "/-", "read,write,delete")); String classPath = System.getProperty("java.class.path"); if (classPath != null) { for (String path : <START> classPath.split(";")) <END> { permissions.add(new FilePermission(path, "read")); } } String jgitSourcesRoot = new File(System.getProperty("user.dir")) .getParent(); permissions.add(new FilePermission(jgitSourcesRoot + "/-", "read")); permissions.add( new FilePermission(root.getPath() + "/-", "read,write,delete")); permissions.add(new FilePermission( System.getProperty("user.home") + "/.gitconfig", "read,write")); originalSecurityManager = System.getSecurityManager(); System.setSecurityManager(new SecurityManager() { @Override public void checkPermission(Permission requested) { for (Permission permission : permissions) { if (permission.implies(requested)) { return; } } super.checkPermission(requested); } }); }</code><technical_language>s/;/File.pathSeparator/ This works Windows, *nix ":" path separator</technical_language>

Target:
public void setUp() throws Exception { root = Files.createTempDirectory("jgit-security").toFile(); permissions.add(new RuntimePermission("*")); permissions.add(new SecurityPermission("*")); permissions.add(new AuthPermission("*")); permissions.add(new ReflectPermission("*")); permissions.add(new PropertyPermission("*", "read,write")); permissions.add(new LoggingPermission("control", null)); permissions.add(new FilePermission( System.getProperty("java.home") + "/-", "read")); String tempDir = System.getProperty("java.io.tmpdir"); permissions.add(new FilePermission(tempDir, "read,write,delete")); permissions .add(new FilePermission(tempDir + "/-", "read,write,delete")); String classPath = System.getProperty("java.class.path"); if (classPath != null) { for (String path : classPath.split(File.pathSeparator)) { permissions.add(new FilePermission(path, "read")); } } String jgitSourcesRoot = new File(System.getProperty("user.dir")) .getParent(); permissions.add(new FilePermission(jgitSourcesRoot + "/-", "read")); permissions.add( new FilePermission(root.getPath() + "/-", "read,write,delete")); permissions.add(new FilePermission( System.getProperty("user.home") + "/.gitconfig", "read,write")); originalSecurityManager = System.getSecurityManager(); System.setSecurityManager(new SecurityManager() { @Override public void checkPermission(Permission requested) { for (Permission permission : permissions) { if (permission.implies(requested)) { return; } } super.checkPermission(requested); } }); }
Source:
<code>private void configure(Builder<Class<?>> builder) { builder.add( AtlasModule.class, AtlasLoggingModule.class, AtlasWebModule.class, SearchModule.class, QueryModule.class, MongoContentPersistenceModule.class, CassandraPersistenceModule.class, AtlasFetchModule.class, RemoteSiteModule.class, HealthModule.class, RadioPlayerModule.class, XmlTvModule.class, RemoteSiteHealthModule.class, EquivModule.class, <START> ChildRefUpdateModule.class <END> ); if(runProcessingOnly()) { builder.add( ManualScheduleRebuildModule.class, InterlinkingDeltaModule.class, EquivTaskModule.class ); if (Configurer.get("youview.upload.enabled").toBoolean()) { builder.add(YouViewUploadModule.class); } builder.addAll(new RemoteSiteModuleConfigurer().enabledModules()); } else { builder.add( AtlasFeedsModule.class, QueryWebModule.class, ApplicationModule.class ); } }</code><technical_language>Move this if (runProcessingOnly())</technical_language>

Target:
private void configure(Builder<Class<?>> builder) { builder.add( AtlasModule.class, AtlasLoggingModule.class, AtlasWebModule.class, SearchModule.class, QueryModule.class, MongoContentPersistenceModule.class, CassandraPersistenceModule.class, AtlasFetchModule.class, RemoteSiteModule.class, HealthModule.class, RadioPlayerModule.class, XmlTvModule.class, RemoteSiteHealthModule.class, EquivModule.class ); if(runProcessingOnly()) { builder.add( ManualScheduleRebuildModule.class, InterlinkingDeltaModule.class, EquivTaskModule.class, ChildRefUpdateModule.class ); if (Configurer.get("youview.upload.enabled").toBoolean()) { builder.add(YouViewUploadModule.class); } builder.addAll(new RemoteSiteModuleConfigurer().enabledModules()); } else { builder.add( AtlasFeedsModule.class, QueryWebModule.class, ApplicationModule.class ); } }
Source:
<code>void stopRegularScan(ScanClient client) { if (client == null) { return; } for (ScanClient c : mRegularScanClients) { <START> if (c.scannerId == client.scannerId) { client = c; <END> int deliveryMode = getDeliveryMode(client); if (deliveryMode == DELIVERY_MODE_ON_FOUND_LOST) { for (ScanFilter filter : client.filters) { int entriesToFree = getNumOfTrackingAdvertisements(client.settings); if (!manageAllocationOfTrackingAdvertisement(entriesToFree, false)) { Log.e(TAG, "Error freeing for onfound/onlost filter resources " + entriesToFree); try { mService.onScanManagerErrorCallback(client.scannerId, ScanCallback.SCAN_FAILED_INTERNAL_ERROR); } catch (RemoteException e) { Log.e(TAG, "failed on onScanManagerCallback at freeing", e); } } } } break; } } mRegularScanClients.remove(client); if (numRegularScanClients() == 0) { if (DBG) { Log.d(TAG, "stop scan"); } gattClientScanNative(false); } removeScanFilters(client.scannerId); }</code><technical_language>change this to: if (c.scannerId != client.scannerId) { continue; } // do rest reduce nesting</technical_language>

Target:
void stopRegularScan(ScanClient client) { if (client == null) { return; } for (ScanClient c : mRegularScanClients) { if (c.scannerId != client.scannerId) { continue; } client = c; int deliveryMode = getDeliveryMode(client); if (deliveryMode == DELIVERY_MODE_ON_FOUND_LOST) { for (ScanFilter filter : client.filters) { int entriesToFree = getNumOfTrackingAdvertisements(client.settings); if (!manageAllocationOfTrackingAdvertisement(entriesToFree, false)) { Log.e(TAG, "Error freeing for onfound/onlost filter resources " + entriesToFree); try { mService.onScanManagerErrorCallback(client.scannerId, ScanCallback.SCAN_FAILED_INTERNAL_ERROR); } catch (RemoteException e) { Log.e(TAG, "failed on onScanManagerCallback at freeing", e); } } } } break; } mRegularScanClients.remove(client); if (numRegularScanClients() == 0) { if (DBG) { Log.d(TAG, "stop scan"); } gattClientScanNative(false); } removeScanFilters(client.scannerId); }
Source:
<code>public static List<JavaTypeDefinition> getMethodExplicitTypeArugments(Node node) { <START> List<JavaTypeDefinition> result = new ArrayList<>(); <END> ASTMemberSelector memberSelector = node.getFirstChildOfType(ASTMemberSelector.class); if (memberSelector == null) { return result; } ASTTypeArguments typeArguments = memberSelector.getFirstChildOfType(ASTTypeArguments.class); if (typeArguments == null) { return result; } for (int childIndex = 0; childIndex < typeArguments.jjtGetNumChildren(); ++childIndex) { result.add(((TypeNode) typeArguments.jjtGetChild(childIndex)).getTypeDefinition()); } return result; }</code><technical_language>move this allocation line 540..</technical_language>

Target:
public static List<JavaTypeDefinition> getMethodExplicitTypeArugments(Node node) { ASTMemberSelector memberSelector = node.getFirstChildOfType(ASTMemberSelector.class); if (memberSelector == null) { return Collections.emptyList(); } ASTTypeArguments typeArguments = memberSelector.getFirstChildOfType(ASTTypeArguments.class); if (typeArguments == null) { return Collections.emptyList(); } List<JavaTypeDefinition> result = new ArrayList<>(); for (int childIndex = 0; childIndex < typeArguments.jjtGetNumChildren(); ++childIndex) { result.add(((TypeNode) typeArguments.jjtGetChild(childIndex)).getTypeDefinition()); } return result; }
Source:
<code>private void parseTestTools(PendingCertifiedProductEntity product, PendingCertificationResultEntity cert, int toolColumnBegin) { for(CSVRecord row : getRecord()) { String testToolName = row.get(toolColumnBegin).trim(); String testToolVersion = row.get(toolColumnBegin+1).trim(); if(!StringUtils.isEmpty(testToolName)) { PendingCertificationResultTestToolEntity ttEntity = new PendingCertificationResultTestToolEntity(); ttEntity.setTestToolName(testToolName); ttEntity.setTestToolVersion(testToolVersion); TestToolDTO testTool = testToolDao.getByName(testToolName); if(testTool != null) { if(testTool.isRetired() && product.getIcs().equals("false")) { <START> product.getErrorMessages().add("Test tool '" + testToolName + "' has been retired for a product with Ics=false. Please remove it from the upload file and add a different test tool if necessary."); <END> } ttEntity.setTestToolId(testTool.getId()); } cert.getTestTools().add(ttEntity); } } }</code><technical_language>Ics ICS in "...for a product Ics=false"</technical_language>

Target:
private void parseTestTools(PendingCertifiedProductEntity product, PendingCertificationResultEntity cert, int toolColumnBegin) { for(CSVRecord row : getRecord()) { String testToolName = row.get(toolColumnBegin).trim(); String testToolVersion = row.get(toolColumnBegin+1).trim(); if(!StringUtils.isEmpty(testToolName)) { PendingCertificationResultTestToolEntity ttEntity = new PendingCertificationResultTestToolEntity(); ttEntity.setTestToolName(testToolName); ttEntity.setTestToolVersion(testToolVersion); TestToolDTO testTool = testToolDao.getByName(testToolName); if(testTool != null) { if(testTool.isRetired() && product.getIcs().equals("false")) { product.getErrorMessages().add("Test tool '" + testToolName + "' has been retired for a product with ICS=false. Please remove it from the upload file and add a different test tool if necessary."); } ttEntity.setTestToolId(testTool.getId()); } cert.getTestTools().add(ttEntity); } } }
Source:
<code>public static Object[][] sampleQueries() { return new Object[][] { { selectFrom("foo").all().whereColumn("k").isEqualTo(bindMarker()), new Object[] {1}, "SELECT * FROM foo WHERE k=?", true }, { deleteFrom("foo").whereColumn("k").isEqualTo(bindMarker()), new Object[] {1}, "DELETE FROM foo WHERE k=?", true }, { deleteFrom("foo").whereColumn("k").isEqualTo(bindMarker()).ifExists(), new Object[] {1}, "DELETE FROM foo WHERE k=? IF EXISTS", false }, { <START> insertInto("foo").value("a", bindMarker()).value("b", bindMarker()), <END> new Object[] {1, "a"}, "INSERT INTO foo (a,b) VALUES (?,?)", true }, { insertInto("foo").value("k", tuple(bindMarker(), function("generate_id"))), new Object[] {1}, "INSERT INTO foo (k) VALUES ((?,generate_id()))", false }, { update("foo").setColumn("v", bindMarker()).whereColumn("k").isEqualTo(bindMarker()), new Object[] {3, 1}, "UPDATE foo SET v=? WHERE k=?", true }, { update("foo") .setColumn("v", function("non_idempotent_func")) .whereColumn("k") .isEqualTo(bindMarker()), new Object[] {1}, "UPDATE foo SET v=non_idempotent_func() WHERE k=?", false }, }; }</code><technical_language>this query is idempotent? I this DELETE</technical_language>

Target:
public static Object[][] sampleQueries() { return new Object[][] { { selectFrom("foo").all().whereColumn("k").isEqualTo(bindMarker("k")), ImmutableMap.of("k", 1), "SELECT * FROM foo WHERE k=:k", true }, { deleteFrom("foo").whereColumn("k").isEqualTo(bindMarker("k")), ImmutableMap.of("k", 1), "DELETE FROM foo WHERE k=:k", true }, { deleteFrom("foo").whereColumn("k").isEqualTo(bindMarker("k")).ifExists(), ImmutableMap.of("k", 1), "DELETE FROM foo WHERE k=:k IF EXISTS", false }, { insertInto("foo").value("a", bindMarker("a")).value("b", bindMarker("b")), ImmutableMap.of("a", 1, "b", "b"), "INSERT INTO foo (a,b) VALUES (:a,:b)", true }, { insertInto("foo").value("k", tuple(bindMarker("field1"), function("generate_id"))), ImmutableMap.of("field1", 1), "INSERT INTO foo (k) VALUES ((:field1,generate_id()))", false }, { update("foo").setColumn("v", bindMarker("v")).whereColumn("k").isEqualTo(bindMarker("k")), ImmutableMap.of("v", 3, "k", 1), "UPDATE foo SET v=:v WHERE k=:k", true }, { update("foo") .setColumn("v", function("non_idempotent_func")) .whereColumn("k") .isEqualTo(bindMarker("k")), ImmutableMap.of("k", 1), "UPDATE foo SET v=non_idempotent_func() WHERE k=:k", false }, }; }
Source:
<code>public FunctionImplementationType getFunctionImplementationType() { <START> switch (routineCharacteristics.getLanguage()) { case SQL: return FunctionImplementationType.SQL; case JAVA: return FunctionImplementationType.THRIFT; <END> default: throw new UnsupportedOperationException(format("Unsupported language %s", routineCharacteristics.getLanguage())); } }</code><technical_language>a static map easier</technical_language>

Target:
public FunctionImplementationType getFunctionImplementationType() { if (routineCharacteristics.getLanguage().equals(SQL)) { return FunctionImplementationType.SQL; } return FunctionImplementationType.THRIFT; }
Source:
<code>public void theGetMBusEncryptionKeyStatusByChannelResponseIsReturned(final Map<String, String> settings) throws Throwable { final GetMbusEncryptionKeyStatusByChannelAsyncRequest asyncRequest = GetMbusEncryptionKeyStatusByChannelRequestFactory .fromScenarioContext(); final GetMbusEncryptionKeyStatusByChannelResponse response = this.smartMeterConfigurationClient .retrieveGetMbusEncryptionKeyStatusByChannelResponse(asyncRequest); <START> assertNotNull(OPERATION + ": Result should not be null", response.getResult()); <END> assertEquals(OPERATION + ": Result should be OK", OsgpResultType.OK, response.getResult()); assertEquals(OPERATION + "Encryptionkeystatus should be ENCRYPTION_KEY_IN_USE ", EncryptionKeyStatus.ENCRYPTION_KEY_IN_USE, response.getEncryptionKeyStatus()); }</code><technical_language>null assertion removed. equals assertion next line report expected OK, actual null</technical_language>

Target:
public void theGetMBusEncryptionKeyStatusByChannelResponseIsReturned(final Map<String, String> settings) throws Throwable { final GetMbusEncryptionKeyStatusByChannelAsyncRequest asyncRequest = GetMbusEncryptionKeyStatusByChannelRequestFactory .fromScenarioContext(); final GetMbusEncryptionKeyStatusByChannelResponse response = this.smartMeterConfigurationClient .retrieveGetMbusEncryptionKeyStatusByChannelResponse(asyncRequest); assertEquals(OPERATION + ", Checking result:", OsgpResultType.OK, response.getResult()); assertEquals(OPERATION + ", Checking EncryptionKeyStatus:", EncryptionKeyStatus.ENCRYPTION_KEY_IN_USE, response.getEncryptionKeyStatus()); }
Source:
<code><START> public Collection<T> getIntersectingElements(long position) { <END> fLock.readLock().lock(); try { Iterable<T> matchStarts = Iterables.concat(fStartTimesIndex.asMap().headMap(position, true).values()); Iterable<T> matchEnds = Iterables.concat(fEndTimesIndex.asMap().tailMap(position, true).values()); final SetView<T> checkNotNull = checkNotNull(Sets.intersection(Sets.newHashSet(matchStarts), Sets.newHashSet(matchEnds))); return checkNotNull; } finally { fLock.readLock().unlock(); } }</code><technical_language>Iterable. potentially useful Collection is size(), Iterables.size() casts Collection if can. Praise Guava</technical_language>

Target:
public Collection<T> getIntersectingElements(long position) { fLock.readLock().lock(); try { Iterable<T> matchStarts = Iterables.concat(fStartTimesIndex.asMap().headMap(position, true).values()); Iterable<T> matchEnds = Iterables.concat(fEndTimesIndex.asMap().tailMap(position, true).values()); return checkNotNull(Sets.intersection(Sets.newHashSet(matchStarts), Sets.newHashSet(matchEnds))); } finally { fLock.readLock().unlock(); } }
Source:
<code>public int hashCode() { <START> return new HashCodeBuilder(3,17) <END> .append(fTreeChar) .append(fPos) .toHashCode(); }</code><technical_language>simply empty constructor</technical_language>

Target:
public int hashCode() { return new HashCodeBuilder() .append(fTreeChar) .append(fPos) .toHashCode(); }
Source:
<code>private int codepointAt(final int idx) { <START> if (idx < 0 || idx >= text.length) { <END> return 0; } return text[idx]; }</code><technical_language>this hide bugs? sense throw exception simply remove check? 0x0 is a valid code point this this return a bit ambiguous. in favor of accessing array JVM throw error if this is possible</technical_language>

Target:
private int codepointAt(final int idx) { if (idx < 0) { return -1; } return text[idx]; }
Source:
<code>public Bean<I, T> findBean(I id) { InfinispanEjbLogger.ROOT_LOGGER.tracef("Locating bean %s", id); BeanEntry<I> entry = this.beanFactory.findValue(id); Bean<I, T> bean = (entry != null) ? this.beanFactory.createBean(id, entry) : null; if (bean == null) { InfinispanEjbLogger.ROOT_LOGGER.debugf("Could not find bean %s", id); return null; } <START> return new SchedulableBean(bean); <END> }</code><technical_language>needs some action this point prevent concurrent expiration while invocation is in process, in particular, bean is schedule expired a member currently performing invocation</technical_language>

Target:
public Bean<I, T> findBean(I id) { InfinispanEjbLogger.ROOT_LOGGER.tracef("Locating bean %s", id); BeanEntry<I> entry = this.beanFactory.findValue(id); Bean<I, T> bean = (entry != null) ? this.beanFactory.createBean(id, entry) : null; if (bean == null) { InfinispanEjbLogger.ROOT_LOGGER.debugf("Could not find bean %s", id); return null; } this.prepareRescheduling(id); return new SchedulableBean(bean, entry); }
Source:
<code>public RepositoryFileAttributes getAttributes(String storageId, String repositoryId, String artifactPath) throws IOException, NoSuchAlgorithmException, ArtifactTransportException, ProviderImplementationException { logger.debug("******"); artifactOperationsValidator.validate(storageId, repositoryId, artifactPath); final Repository repository = getStorage(storageId).getRepository(repositoryId); LayoutProvider<?> layoutProvider = layoutProviderRegistry.getProvider(repository.getLayout()); RepositoryProvider repositoryProvider = repositoryProviderRegistry.getProvider(repository.getType()); logger.debug("REpository TYpe = "+repositoryProvider.getAlias()); RepositoryPath path = null; try { if(!repositoryProvider.getAlias().equals("group")) <START> path = layoutProvider.resolve(repository).resolve(artifactPath); <END> else path = ((GroupRepositoryProvider)repositoryProvider).getPath(storageId,repositoryId,artifactPath); } catch (Exception e) { e.printStackTrace(); } logger.debug("PATH == "+path.toString()); RepositoryFileAttributes fileAttributes = (RepositoryFileAttributes) Files.readAttributes(path, RepositoryFileAttributes.class); if (fileAttributes == null) { throw new ArtifactResolutionException("Artifact " + artifactPath + " not found."); } return fileAttributes; }</code><technical_language>Please curly braces. This misunderstandings in condition checking (as this *can* happen)</technical_language>

Target:
public RepositoryFileAttributes getAttributes(String storageId, String repositoryId, String artifactPath) throws IOException, NoSuchAlgorithmException, ArtifactTransportException, ProviderImplementationException { artifactOperationsValidator.validate(storageId, repositoryId, artifactPath); final Repository repository = getStorage(storageId).getRepository(repositoryId); RepositoryProvider repositoryProvider = repositoryProviderRegistry.getProvider(repository.getType()); logger.debug("Requested Repository Type = "+repositoryProvider.getAlias()); RepositoryPath path = null; path = (RepositoryPath)repositoryProvider.getPath(storageId, repositoryId, artifactPath); if(path == null) { logger.error("Failed to resolve path for requested artifact"); return null; } RepositoryFileAttributes fileAttributes = (RepositoryFileAttributes) Files.readAttributes(path, RepositoryFileAttributes.class); if (fileAttributes == null) { throw new ArtifactResolutionException("Artifact " + artifactPath + " not found."); } return fileAttributes; }
Source:
<code>protected void updateData(double[] x, @NonNull AnalysisBaseQueryFilter filters, IProgressMonitor monitor) { if (fXYDataProvider == null) { LOGGER.log(Level.WARNING, "Data provider for this viewer is not available"); return; } long <START> currentEnd = <END> 0; while (currentEnd < filters.getQueryInterval().getEndTime().toNanos()) { ICommonXAxisResponse response = fXYDataProvider.fetch(x, filters, monitor); ICommonXAxisModel model = response.getModel(); if (model != null) { updateDisplay(model); } ICommonXAxisResponse.Status status = response.getStatus(); if (status == ICommonXAxisResponse.Status.COMPLETED) { return; } else if (status == ICommonXAxisResponse.Status.FAILED || status == ICommonXAxisResponse.Status.CANCELLED) { LOGGER.log(Level.WARNING, response.getStatusMessage()); return; } else { try { finishedLatch.await(BUILD_UPDATE_TIMEOUT, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { LOGGER.log(Level.INFO, e.getMessage()); return; } } } }</code><technical_language>updated, this infinite loop while</technical_language>

Target:
protected void updateData(double[] x, @NonNull AnalysisBaseQueryFilter filters, IProgressMonitor monitor) { if (fXYDataProvider == null) { LOGGER.log(Level.WARNING, "Data provider for this viewer is not available"); return; } long currentEnd = 0; while (currentEnd < filters.getQueryInterval().getEndTime().toNanos()) { ICommonXAxisResponse response = fXYDataProvider.fetch(x, filters, monitor); ICommonXAxisModel model = response.getModel(); if (model != null) { updateDisplay(model); } ICommonXAxisResponse.Status status = response.getStatus(); currentEnd = response.getCurrentEnd(); if (status == ICommonXAxisResponse.Status.COMPLETED) { return; } else if (status == ICommonXAxisResponse.Status.FAILED || status == ICommonXAxisResponse.Status.CANCELLED) { LOGGER.log(Level.WARNING, response.getStatusMessage()); return; } else { try { finishedLatch.await(BUILD_UPDATE_TIMEOUT, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { LOGGER.log(Level.INFO, e.getMessage()); return; } } } }
Source:
<code>private ValidationResult() { <START> this(null); <END> }</code><technical_language>Please remember this ctor changed</technical_language>

Target:
public ValidationResult() { message = null; }
Source:
<code>private Collection<VDomainModelReference> getView(VView view, EObject newEntry) { final Set<VDomainModelReference> result = new LinkedHashSet<VDomainModelReference>(); final VViewModelProperties properties = ViewModelPropertiesHelper.getInhertitedPropertiesOrEmpty(view); final VView detailView = emfFormsViewService.getView(newEntry, properties); final TreeIterator<EObject> eAllContents = detailView.eAllContents(); while (eAllContents.hasNext()) { final EObject next = eAllContents.next(); if (next instanceof VDomainModelReference) { <START> result.add((VDomainModelReference) next); <END> } } return result; }</code><technical_language>This include DMRs part of a rule. check parent/containing-feature exclude those</technical_language>

Target:
private Collection<VDomainModelReference> getView(VView view, EObject newEntry) { final Set<VDomainModelReference> result = new LinkedHashSet<VDomainModelReference>(); final VViewModelProperties properties = ViewModelPropertiesHelper.getInhertitedPropertiesOrEmpty(view); final VView detailView = emfFormsViewService.getView(newEntry, properties); final TreeIterator<EObject> eAllContents = detailView.eAllContents(); while (eAllContents.hasNext()) { final EObject next = eAllContents.next(); if (next instanceof VDomainModelReference && next.eContainingFeature() == VViewPackage.eINSTANCE.getControl_DomainModelReference()) { result.add((VDomainModelReference) next); } } return result; }
Source:
<code><START> public void testComma() <END> { final CsvInputFormat format = new CsvInputFormat(Collections.singletonList("a"), ",", false, 0); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("column[a,] not in columns"); format.createReader( new TimestampSpec("timestamp", "auto", null), new DimensionsSpec(DimensionsSpec.getDefaultSchemas(Arrays.asList("a,", "b"))) ); }</code><technical_language>I test fails if of columns names defined in CsvInputFormat a comma (i.e., error message: Column[%s] a comma, cannot). Otherwise, testing behavior testColumnMissing()</technical_language>

Target:
public void testComma() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Column[a,] has a comma, it cannot"); new CsvInputFormat(Collections.singletonList("a,"), ",", false, 0); }
Source:
<code>public String getAsString(FacesContext context, UIComponent component, Object value) { <START> if (null != value && null != component && null != component.getAttributes()) { <END> Map<String, Object> attributes = component.getAttributes(); if (attributes.containsKey("pattern")) { pattern = (String) attributes.get("pattern"); } setPattern(pattern); if (attributes.containsKey("locale")) { locale = (Locale) attributes.get("locale"); } setLocale(locale); if (attributes.containsKey("timeZone")) { timeZone = (TimeZone) attributes.get("timeZone"); } setTimeZone(timeZone); if (attributes.containsKey("dateStyle")) { dateStyle = (String) attributes.get("dateStyle"); } setDateStyle(dateStyle); if (attributes.containsKey("timeStyle")) { timeStyle = (String) attributes.get("timeStyle"); } setTimeStyle(timeStyle); if (attributes.containsKey("type")) { type = (String) attributes.get("type"); } setType(type); XMLGregorianCalendar xmlGregCal = (XMLGregorianCalendar) value; Date date = xmlGregCal.toGregorianCalendar().getTime(); return super.getAsString(context, component, date); } return ""; }</code><technical_language>break this 2-if-statement if agreen if (null != component && null != component.getAttributes()) {</technical_language>

Target:
public String getAsString(FacesContext context, UIComponent component, Object value) { if (null != component && null != component.getAttributes()) { Map<String, Object> attributes = component.getAttributes(); if (attributes.containsKey("pattern")) { pattern = (String) attributes.get("pattern"); } setPattern(pattern); if (attributes.containsKey("locale")) { locale = (Locale) attributes.get("locale"); } setLocale(locale); if (attributes.containsKey("timeZone")) { timeZone = (TimeZone) attributes.get("timeZone"); } setTimeZone(timeZone); if (attributes.containsKey("dateStyle")) { dateStyle = (String) attributes.get("dateStyle"); } setDateStyle(dateStyle); if (attributes.containsKey("timeStyle")) { timeStyle = (String) attributes.get("timeStyle"); } setTimeStyle(timeStyle); if (attributes.containsKey("type")) { type = (String) attributes.get("type"); } setType(type); } if (null != value) { return super.getAsString(context, component, ((XMLGregorianCalendar) value).toGregorianCalendar(). getTime()); } return ""; }
Source:
<code>void reportHasValues() { <START> assertThat(eitherWithA.hasA()).isTrue(); <END> assertThat(eitherWithA.hasB()).isFalse(); assertThat(eitherWithB.hasB()).isTrue(); assertThat(eitherWithB.hasA()).isFalse(); }</code><technical_language>I in cases, assertTrue() assertFalse() work better. a long read :) Please consider</technical_language>

Target:
void reportHasValues() { assertTrue(eitherWithA.hasA()); assertFalse(eitherWithA.hasB()); assertTrue(eitherWithB.hasB()); assertFalse(eitherWithB.hasA()); }
Source:
<code>public Assignees assignees() { <START> return new MkAssignees(); <END> }</code><technical_language>throw UnsupportedOperationException instead. object returning is working anyway, inform user early</technical_language>

Target:
public Assignees assignees() { throw new UnsupportedOperationException(); }