auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public int queryReplicationStatus() { if (localClusterDescriptor.getRole() == ClusterRole.ACTIVE) { if (replicationManager != null) { return replicationManager.queryReplicationStatus(); } return 0; } else { log.warn("Illegal queryReplicationStatus when cluster{} with role {}", localClusterDescriptor.getClusterId(), localClusterDescriptor.getRole()); <START> return -1; <END> } }</code><technical_language>1 a final static variable INVALID_REPLICATION_STATUS</technical_language>

Target:
public int queryReplicationStatus() { if (localClusterDescriptor.getRole() == ClusterRole.ACTIVE) { if (!isLeader) { log.warn("Illegal queryReplicationStatus when node is not a leader " + "in an ACTIVE Cluster{} ", localClusterDescriptor.getClusterId()); return 0; } if (replicationManager == null) { log.warn("Illegal queryReplicationStatus when replication manager is null " + "in an ACTIVE Cluster{} ", localClusterDescriptor.getClusterId()); return 0; } return replicationManager.queryReplicationStatus(); } else { log.warn("Illegal queryReplicationStatus when cluster{} with role {}", localClusterDescriptor.getClusterId(), localClusterDescriptor.getRole()); return INVALID_REPLICATION_STATUS; } }
Source:
<code>public byte[] decrypt(InputStream from, byte[] AAD) { byte[] lengthBuffer = new byte[SIZE_LENGTH]; int gotBytes = 0; while (gotBytes < SIZE_LENGTH) { int n; try { n = from.read(lengthBuffer, gotBytes, SIZE_LENGTH - gotBytes); } catch (IOException e) { throw new ParquetCryptoRuntimeException(e); } if (n <= 0) { throw new ParquetCryptoRuntimeException("Tried to read int (4 bytes), but only got " + gotBytes + " bytes."); } gotBytes += n; } final int ciphertextLength = ((lengthBuffer[3] & 0xff) << 24) | ((lengthBuffer[2] & 0xff) << 16) | ((lengthBuffer[1] & 0xff) << 8) | ((lengthBuffer[0] & 0xff)); if (ciphertextLength < 1) { throw new ParquetCryptoRuntimeException("Wrong length of encrypted metadata: " + ciphertextLength); } byte[] ciphertextBuffer = new byte[ciphertextLength]; gotBytes = 0; while (gotBytes < ciphertextLength) { int n; try { n = from.read(ciphertextBuffer, gotBytes, ciphertextLength - gotBytes); <START> } catch (IOException e) { <END> throw new ParquetCryptoRuntimeException(e); } if (n <= 0) { throw new ParquetCryptoRuntimeException("Tried to read " + ciphertextLength + " bytes, but only got " + gotBytes + " bytes."); } gotBytes += n; } return decrypt(ciphertextBuffer, 0, ciphertextLength, AAD); }</code><technical_language>IOException thrown out</technical_language>

Target:
public byte[] decrypt(InputStream from, byte[] AAD) throws IOException { byte[] lengthBuffer = new byte[SIZE_LENGTH]; int gotBytes = 0; while (gotBytes < SIZE_LENGTH) { int n = from.read(lengthBuffer, gotBytes, SIZE_LENGTH - gotBytes); if (n <= 0) { throw new IOException("Tried to read int (4 bytes), but only got " + gotBytes + " bytes."); } gotBytes += n; } final int ciphertextLength = ((lengthBuffer[3] & 0xff) << 24) | ((lengthBuffer[2] & 0xff) << 16) | ((lengthBuffer[1] & 0xff) << 8) | ((lengthBuffer[0] & 0xff)); if (ciphertextLength < 1) { throw new IOException("Wrong length of encrypted metadata: " + ciphertextLength); } byte[] ciphertextBuffer = new byte[ciphertextLength]; gotBytes = 0; while (gotBytes < ciphertextLength) { int n = from.read(ciphertextBuffer, gotBytes, ciphertextLength - gotBytes); if (n <= 0) { throw new IOException("Tried to read " + ciphertextLength + " bytes, but only got " + gotBytes + " bytes."); } gotBytes += n; } return decrypt(ciphertextBuffer, 0, ciphertextLength, AAD); }
Source:
<code>private Map<String, VariantAnnotation> getStoredVariantAnnotations(Map<String, VariantAnnotation> variantAnnotations) { Map<String, VariantAnnotation> storedVariantAnnotations = new HashMap<>(); BasicDBObject query = generateQueryForAnnotationInVariant(variantAnnotations.keySet().toArray(new String[]{})); <START> Iterator<DBObject> iterator = mongoOperations.getCollection(collection).find(query).iterator(); <END> while (iterator.hasNext()) { final DBObject object = iterator.next(); final String id = (String) object.get(ID); final BasicDBList dbAnnotations = (BasicDBList) object.get(ANNOTATION_FIELD); if (dbAnnotations != null && !dbAnnotations.isEmpty()) { final DBObject dbAnnotation = (DBObject) dbAnnotations.get(0); storedVariantAnnotations.put(id, convertToVariantAnnotation(dbAnnotation)); } } return storedVariantAnnotations; }</code><technical_language>overload find(DBObject, DBObject) project field ANNOTATION_FIELD</technical_language>

Target:
private Map<String, VariantAnnotation> getStoredVariantAnnotations(Map<String, VariantAnnotation> variantAnnotations) { Map<String, VariantAnnotation> storedVariantAnnotations = new HashMap<>(); BasicDBObject query = generateQueryForAnnotationInVariant(variantAnnotations.keySet().toArray(new String[]{})); BasicDBObject projection = new BasicDBObject(ANNOTATION_FIELD, 1); Iterator<DBObject> iterator = mongoOperations.getCollection(collection).find(query, projection).iterator(); while (iterator.hasNext()) { final DBObject object = iterator.next(); final String variantId = (String) object.get(ID); final BasicDBList dbAnnotations = (BasicDBList) object.get(ANNOTATION_FIELD); if (dbAnnotations != null && !dbAnnotations.isEmpty()) { final DBObject dbAnnotation = (DBObject) dbAnnotations.get(0); storedVariantAnnotations.put(variantId, convertToVariantAnnotation(dbAnnotation)); } } return storedVariantAnnotations; }
Source:
<code>public boolean isFeatureEnabled(final Feature feature) { try { <START> return featuresCache.getCurrentData(PREFIX + "/" + feature.getId()) != null; <END> } catch (final Exception e) { LOG.warn("Error occurred when checking if feature '" + feature.getId() + "' is toggled", e); return false; } }</code><technical_language>I thought creating path beforehand, is limited amount of paths, other side optimised jvm</technical_language>

Target:
public boolean isFeatureEnabled(final Feature feature) { try { return featuresCache.getCurrentData(getPath(feature)) != null; } catch (final Exception e) { LOG.warn("Error occurred when checking if feature '" + feature.getId() + "' is toggled", e); return false; } }
Source:
<code>public <T> Mono<CosmosAsyncItemResponse<T>> createItem(T item, CosmosItemRequestOptions options) { if (options == null) { options = new CosmosItemRequestOptions(); } @SuppressWarnings("unchecked") Class<T> itemType = (Class<T>) item.getClass(); RequestOptions requestOptions = ModelBridgeInternal.toRequestOptions(options); return database.getDocClientWrapper() .createDocument(getLink(), item, requestOptions, true) <START> .map(response -> ModelBridgeInternal.createCosmosAsyncItemResponse(response, itemType, getItemDeserializerWithoutDecryption())) <END> .single(); }</code><technical_language>decryption is excluded</technical_language>

Target:
public <T> Mono<CosmosItemResponse<T>> createItem(T item, CosmosItemRequestOptions options) { if (options == null) { options = new CosmosItemRequestOptions(); } @SuppressWarnings("unchecked") Class<T> itemType = (Class<T>) item.getClass(); RequestOptions requestOptions = ModelBridgeInternal.toRequestOptions(options); return database.getDocClientWrapper() .createDocument(getLink(), item, requestOptions, true) .map(response -> ModelBridgeInternal.createCosmosAsyncItemResponse(response, itemType, getItemDeserializer())) .single(); }
Source:
<code>public String processSubmit(@ModelAttribute("sample") Sample sample, ModelMap model, SessionStatus session) throws IOException, MalformedSampleException { if (sample instanceof DetailedSampleBuilder) { DetailedSampleBuilder builder = (DetailedSampleBuilder) sample; builder.setSampleClass(sampleClassService.get(builder.getSampleClass().getId())); if (builder.getTissueClass() != null) { builder.setTissueClass(sampleClassService.get(builder.getTissueClass().getId())); } sample = builder.build(new InferStockFromAliquot() { @Override public SampleClass infer(SampleClass sampleClass) { <START> return sampleClassService.inferStockFromAliquot(sampleClass); <END> } }); } try { if (sample.getId() == Sample.UNSAVED_ID) { sampleService.create(sample); } else { sampleService.update(sample); } session.setComplete(); model.clear(); return "redirect:/miso/sample/" + sample.getId(); } catch (IOException ex) { log.debug("Failed to save sample", ex); throw ex; } }</code><technical_language>If other reason this, SampleClassService a method returns inferencer, a new created for request. SampleClassService implement interface</technical_language>

Target:
public String processSubmit(@ModelAttribute("sample") Sample sample, ModelMap model, SessionStatus session) throws IOException, MalformedSampleException { if (sample instanceof DetailedSampleBuilder) { DetailedSampleBuilder builder = (DetailedSampleBuilder) sample; builder.setSampleClass(sampleClassService.get(builder.getSampleClass().getId())); if (builder.getTissueClass() != null) { builder.setTissueClass(sampleClassService.get(builder.getTissueClass().getId())); } if (builder.getParent() == null && builder.getSampleClass().getSampleCategory().equals(SampleAliquot.CATEGORY_NAME)) { builder.setStockClass(sampleClassService.inferStockFromAliquot(builder.getSampleClass())); } sample = builder.build(); } try { if (sample.getId() == Sample.UNSAVED_ID) { sampleService.create(sample); } else { sampleService.update(sample); } session.setComplete(); model.clear(); return "redirect:/miso/sample/" + sample.getId(); } catch (IOException ex) { log.debug("Failed to save sample", ex); throw ex; } }
Source:
<code>private List<MenuItem> findMenusInternal(final Menu menu, final Matcher<MenuItem> matcher, final boolean recursive) { LinkedHashSet<MenuItem> result = new LinkedHashSet<MenuItem>(); if (menu != null) { MenuItem[] items = menu.getItems(); for (MenuItem menuItem : items) { if (menuItem.isDisposed() || isSeparator(menuItem)) { continue; } boolean matches = matcher.matches(menuItem); if (matches) { menuItem.notifyListeners(SWT.Arm, createEvent(menuItem)); Menu subMenu = menuItem.getMenu(); if (subMenu != null) { subMenu.notifyListeners(SWT.Show, createEvent(subMenu)); } result.add(menuItem); } if (recursive) { Menu subMenu = menuItem.getMenu(); if (subMenu != null) { if (!matches) { menuItem.notifyListeners(SWT.Arm, createEvent(menuItem)); subMenu.notifyListeners(SWT.Show, createEvent(subMenu)); } List<MenuItem> menuItems = findMenusInternal(subMenu, matcher, recursive); if (!menuItems.isEmpty()) { result.addAll(menuItems); <START> } else { <END> subMenu.notifyListeners(SWT.Hide, createEvent(subMenu)); } } } } } return new ArrayList<MenuItem>(result); }</code><technical_language>While here, this I realize consistent, hiding sub-menu if menu item matches is returned method. I this be: } else if (!matches) {</technical_language>

Target:
private List<MenuItem> findMenusInternal(final Menu menu, final Matcher<MenuItem> matcher, final boolean recursive) { LinkedHashSet<MenuItem> result = new LinkedHashSet<MenuItem>(); if (menu != null) { MenuItem[] items = menu.getItems(); for (MenuItem menuItem : items) { if (menuItem.isDisposed() || isSeparator(menuItem)) { continue; } boolean matches = matcher.matches(menuItem); if (matches) { menuItem.notifyListeners(SWT.Arm, createEvent(menuItem)); Menu subMenu = menuItem.getMenu(); if (subMenu != null) { subMenu.notifyListeners(SWT.Show, createEvent(subMenu)); } result.add(menuItem); } if (recursive) { Menu subMenu = menuItem.getMenu(); if (subMenu != null) { if (!matches) { menuItem.notifyListeners(SWT.Arm, createEvent(menuItem)); subMenu.notifyListeners(SWT.Show, createEvent(subMenu)); } List<MenuItem> menuItems = findMenusInternal(subMenu, matcher, recursive); if (!menuItems.isEmpty()) { result.addAll(menuItems); } else if (!matches) { subMenu.notifyListeners(SWT.Hide, createEvent(subMenu)); } } } } } return new ArrayList<MenuItem>(result); }
Source:
<code>private void acceptTOSAndPrivacyPolicy(User user) { if (user.getTOSVersion() != CURRENT_TOS_VERSION) { user.setTOSVersion(CURRENT_TOS_VERSION); <START> user.setTOSVersionAcceptanceDate(new Date()); <END> } if (user.getPrivacyPolicyVersion() != CURRENT_PRIVACY_POLICY_VERSION) { user.setPrivacyPolicyVersion(CURRENT_PRIVACY_POLICY_VERSION); user.setPrivacyPolicyVersionAcceptanceDate(new Date()); } }</code><technical_language>Create date twice. acceptance time for both</technical_language>

Target:
private void acceptTOSAndPrivacyPolicy(User user) { Date date = new Date(); if (user.getTOSVersion() != CURRENT_TOS_VERSION) { user.setTOSVersion(CURRENT_TOS_VERSION); user.setTOSVersionAcceptanceDate((date)); } if (user.getPrivacyPolicyVersion() != CURRENT_PRIVACY_POLICY_VERSION) { user.setPrivacyPolicyVersion(CURRENT_PRIVACY_POLICY_VERSION); user.setPrivacyPolicyVersionAcceptanceDate(date); } }
Source:
<code>public void runTask() { JobConfig jobConfig = new JobConfig(this.config); String taskName = new TaskConfig(config).getTaskClass().get(); if (taskName == null) { throw new SamzaException("Neither APP nor task.class are defined defined"); } <START> LOG.info("LocalApplicationRunner will run " + taskName); <END> try { LOG.info("Starting job with config {}", jobConfig.getName(), jobConfig); JobRunner runner = new JobRunner(jobConfig); runner.run(true); } catch (Throwable t) { throw new SamzaException("Failed to runTask() application", t); } }</code><technical_language>np: s/LocalApplicationRunner/RemoteApplicationRunner</technical_language>

Target:
public void runTask() { throw new UnsupportedOperationException("Running StreamTask is not implemented for RemoteReplicationRunner"); }
Source:
<code>protected Boolean doInBackground(Void... nada) { if (mIsPage) { tmpPosts = mPostStore.getPagesForSite(mSite); } else { tmpPosts = mPostStore.getPostsForSite(mSite); } for (PostModel hiddenPost : mHiddenPosts) { tmpPosts.remove(hiddenPost); } if (mLoadMode == LoadMode.IF_CHANGED && PostUtils.postListsAreEqual(mPosts, tmpPosts)) { boolean postsAreUploading = false; for (PostModel post : tmpPosts) { if (PostUploadService.isPostUploading(post)) { postsAreUploading = true; break; } } if (!postsAreUploading) { return false; } } mFeaturedImageUrls.clear(); for (PostModel post : tmpPosts) { String imageUrl = null; if (post.getFeaturedImageId() != 0) { MediaModel media = mMediaStore.getSiteMediaWithId(mSite, post.getFeaturedImageId()); if (media != null) { imageUrl = media.getUrl(); } else { mediaIdsToUpdate.add(post.getFeaturedImageId()); } } else { <START> imageUrl = new ReaderImageScanner(post.getContent(), mSite.isPrivate()).getLargestImage(); <END> } if (!TextUtils.isEmpty(imageUrl)) { mFeaturedImageUrls.put(post.getId(), imageUrl); } } return true; }</code><technical_language>Sorry, I missed this in pass. SiteUtils.isPhotonCapable(mSite) here</technical_language>

Target:
protected Boolean doInBackground(Void... nada) { if (mIsPage) { tmpPosts = mPostStore.getPagesForSite(mSite); } else { tmpPosts = mPostStore.getPostsForSite(mSite); } for (PostModel hiddenPost : mHiddenPosts) { tmpPosts.remove(hiddenPost); } if (mLoadMode == LoadMode.IF_CHANGED && PostUtils.postListsAreEqual(mPosts, tmpPosts)) { boolean postsAreUploading = false; for (PostModel post : tmpPosts) { if (PostUploadService.isPostUploading(post)) { postsAreUploading = true; break; } } if (!postsAreUploading) { return false; } } mFeaturedImageUrls.clear(); boolean isPrivate = !SiteUtils.isPhotonCapable(mSite); for (PostModel post : tmpPosts) { String imageUrl = null; if (post.getFeaturedImageId() != 0) { MediaModel media = mMediaStore.getSiteMediaWithId(mSite, post.getFeaturedImageId()); if (media != null) { imageUrl = media.getUrl(); } else { mediaIdsToUpdate.add(post.getFeaturedImageId()); } } else { imageUrl = new ReaderImageScanner(post.getContent(), isPrivate).getLargestImage(); } if (!TextUtils.isEmpty(imageUrl)) { mFeaturedImageUrls.put(post.getId(), imageUrl); } } return true; }
Source:
<code>public Repository openRepository(Project.NameKey name) throws RepositoryNotFoundException { if (isUnreasonableName(name)) { throw new RepositoryNotFoundException("Invalid name: " + name); } if (!names.contains(name)) { File dir = FileKey.resolve(gitDirOf(name), FS.DETECTED); if (dir != null) { <START> if (dir.getName().equals(name.get() + Constants.DOT_GIT_EXT)) { <END> onCreateProject(name); } else { throw new RepositoryNotFoundException(gitDirOf(name)); } } else { throw new RepositoryNotFoundException(gitDirOf(name)); } } final FileKey loc = FileKey.lenient(gitDirOf(name), FS.DETECTED); try { return RepositoryCache.open(loc); } catch (IOException e1) { final RepositoryNotFoundException e2; e2 = new RepositoryNotFoundException("Cannot open repository " + name); e2.initCause(e1); throw e2; } }</code><technical_language>This case is uncommon. I reported developers do mistakes in weird ways. this type of mistake confusion. If push plain git repo get error. Gerrit do same. Throw error. please give :)</technical_language>

Target:
public Repository openRepository(Project.NameKey name) throws RepositoryNotFoundException { if (isUnreasonableName(name)) { throw new RepositoryNotFoundException("Invalid name: " + name); } if (!names.contains(name)) { list(); if (names.contains(name)) { onCreateProject(name); } else { throw new RepositoryNotFoundException(gitDirOf(name)); } } final FileKey loc = FileKey.lenient(gitDirOf(name), FS.DETECTED); try { return RepositoryCache.open(loc); } catch (IOException e1) { final RepositoryNotFoundException e2; e2 = new RepositoryNotFoundException("Cannot open repository " + name); e2.initCause(e1); throw e2; } }
Source:
<code>@Override public Response<T> execute() throws IOException { synchronized (this) { if (executed) throw new IllegalStateException("Already executed"); executed = true; } if (canceled) { throw new InterruptedIOException("canceled"); } <START> Future<Response<T>> task = backgroundExecutor.submit(new Callable<Response<T>>() { <END> @Override public Response<T> call() throws Exception { try { if (behavior.calculateIsFailure()) { throw behavior.failureException(); } Response<T> response = delegate.execute(); Thread.sleep(behavior.calculateDelay(MILLISECONDS)); return response; } catch (IOException | RuntimeException e) { Thread.sleep(behavior.calculateDelay(MILLISECONDS)); throw e; } } }); this.task = task; try { return task.get(); } catch (CancellationException | InterruptedException e) { throw new InterruptedIOException("canceled"); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } if (cause instanceof IOException) { throw (IOException) cause; } throw new IllegalStateException(cause); } }</code><technical_language>split declaration assignment</technical_language>

Target:
@Override public Response<T> execute() throws IOException { final AtomicReference<Response<T>> responseRef = new AtomicReference<>(); final AtomicReference<Throwable> failureRef = new AtomicReference<>(); final CountDownLatch latch = new CountDownLatch(1); enqueue(new Callback<T>() { @Override public void onResponse(Response<T> response) { responseRef.set(response); latch.countDown(); } @Override public void onFailure(Throwable t) { failureRef.set(t); latch.countDown(); } }); try { latch.await(); } catch (InterruptedException e) { throw new InterruptedIOException("canceled"); } Response<T> response = responseRef.get(); if (response != null) return response; Throwable failure = failureRef.get(); if (failure instanceof RuntimeException) throw (RuntimeException) failure; if (failure instanceof IOException) throw (IOException) failure; throw new RuntimeException(failure); }
Source:
<code>private void placeIdentityDisks(List<Coordinate> startingCoordinates, Map<Coordinate, Coordinate> teleporters, int maxX, int maxY) { <START> int numberOfToPlaceIdentityDisks = (int) Math.ceil(builder.getNumberOfSquares() <END> * PERCENTAGE_OF_IDENTITY_DISKS); Set<Coordinate> placedIdentityDisksCoordinates = new HashSet<Coordinate>(); Random rand = new Random(); for (Coordinate startCoord : startingCoordinates) { Coordinate position = null; do { int x = startCoord.getX() - 4 + rand.nextInt(9); int y = startCoord.getY() - 4 + rand.nextInt(9); position = new Coordinate(x, y); } while (!builder.canPlaceItem(position) || placedIdentityDisksCoordinates.contains(position) || startingCoordinates.contains(position)); builder.placeUnchargedIdentityDisc(position); placedIdentityDisksCoordinates.add(position); } while (placedIdentityDisksCoordinates.size() < numberOfToPlaceIdentityDisks) { Coordinate position = Coordinate.random(maxX + 1, maxY + 1); if (builder.canPlaceItem(position) && !placedIdentityDisksCoordinates.contains(position)) { builder.placeUnchargedIdentityDisc(position); placedIdentityDisksCoordinates.add(position); } } placedCharchedIDdisks(startingCoordinates, teleporters); }</code><technical_language>I wrote this initially, bad English :) numberOfIdentityDisksToPlace()</technical_language>

Target:
private void placeIdentityDisks(List<Coordinate> startingCoordinates, Map<Coordinate, Coordinate> teleporters, int maxX, int maxY) { int numberOfIdentityDisksToPlace = (int) Math.ceil(builder.getNumberOfSquares() * PERCENTAGE_OF_IDENTITY_DISKS); Set<Coordinate> placedIdentityDisksCoordinates = new HashSet<Coordinate>(); Random rand = new Random(); for (Coordinate startCoord : startingCoordinates) { Coordinate position = null; do { int x = startCoord.getX() - 4 + rand.nextInt(9); int y = startCoord.getY() - 4 + rand.nextInt(9); position = new Coordinate(x, y); } while (!builder.canPlaceItem(position) || placedIdentityDisksCoordinates.contains(position) || startingCoordinates.contains(position)); builder.placeUnchargedIdentityDisc(position); placedIdentityDisksCoordinates.add(position); } while (placedIdentityDisksCoordinates.size() < numberOfIdentityDisksToPlace) { Coordinate position = Coordinate.random(maxX + 1, maxY + 1); if (builder.canPlaceItem(position) && !placedIdentityDisksCoordinates.contains(position)) { builder.placeUnchargedIdentityDisc(position); placedIdentityDisksCoordinates.add(position); } } placedCharchedIDdisks(startingCoordinates, teleporters); }
Source:
<code>public ScannerRunner(List<JavaFileScanner> executableScanners) { checks = new EnumMap<>(Tree.Kind.class); subscriptionVisitors = executableScanners.stream() .filter(s -> s instanceof IssuableSubscriptionVisitor) <START> .map(s -> (SubscriptionVisitor) s).collect(Collectors.toList()); <END> subscriptionVisitors.forEach(s -> s.nodesToVisit().forEach(k -> { if (!checks.containsKey(k)) { checks.put(k, new ArrayList<>()); } checks.get(k).add(s); }) ); }</code><technical_language>collect new line</technical_language>

Target:
ScannerRunner(List<JavaFileScanner> executableScanners) { checks = new EnumMap<>(Tree.Kind.class); subscriptionVisitors = executableScanners.stream() .filter(isIssuableSubscriptionVisitor) .map(s -> (SubscriptionVisitor) s) .collect(Collectors.toList()); subscriptionVisitors.forEach(s -> s.nodesToVisit().forEach(k -> checks.computeIfAbsent(k, key -> new ArrayList<>()).add(s)) ); }
Source:
<code>public List<File> filterFiles(File[] files) { List<File> list = new ArrayList<>(); for (File file : files) { <START> if (file.lastModified() / ONE_SECOND + this.age <= System.currentTimeMillis() / ONE_SECOND) { <END> list.add(file); } else if (this.discardCallback != null) { this.discardCallback.accept(file); } } return list; }</code><technical_language>Well, if decide this way, reuse accept(File) instead of logic duplication</technical_language>

Target:
public List<File> filterFiles(File[] files) { List<File> list = new ArrayList<>(); long now = System.currentTimeMillis() / ONE_SECOND; for (File file : files) { if (fileIsAged(file, now)) { list.add(file); } else if (this.discardCallback != null) { this.discardCallback.accept(file); } } return list; }
Source:
<code>public void updated(Dictionary config) throws ConfigurationException { if (config != null) { Slack.authToken = (String) config.get("authToken"); if (StringUtils.isBlank(Slack.authToken)) { throw new ConfigurationException("slack", <START> "Parameter authToken is mandatory and must be configured. Please check your slack.cfg!"); <END> } isProperlyConfigured = true; } }</code><technical_language>reference specific files here, vary platform</technical_language>

Target:
public void updated(Dictionary config) throws ConfigurationException { if (config != null) { Slack.authToken = (String) config.get("authToken"); if (StringUtils.isBlank(Slack.authToken)) { throw new ConfigurationException("slack", "Parameter authToken is mandatory and must be configured. Please check your configuration!"); } isProperlyConfigured = true; } }
Source:
<code>public PyClassDefTree classDefStatement(AstNode astNode) { PyNameTree name = name(astNode.getFirstChild(PythonGrammar.CLASSNAME).getFirstChild(PythonGrammar.NAME)); PyArgListTree args = null; AstNode argList = astNode.getFirstChild(PythonGrammar.ARGLIST); <START> if(argList!=null) { <END> List<PyArgumentTree> arguments = argList(argList); args = new PyArgListTreeImpl(argList, arguments); } PyStatementListTree body = getStatementListFromSuite(astNode.getFirstChild(PythonGrammar.SUITE)); return new PyClassDefTreeImpl(astNode, name, args, body, DocstringExtractor.extractDocstring(astNode)); }</code><technical_language>formatting is incorrect (missing space if)</technical_language>

Target:
public PyClassDefTree classDefStatement(AstNode astNode) { PyNameTree name = name(astNode.getFirstChild(PythonGrammar.CLASSNAME).getFirstChild(PythonGrammar.NAME)); PyArgListTree args = null; AstNode leftPar = astNode.getFirstChild(PythonPunctuator.LPARENTHESIS); if (leftPar != null) { AstNode argList = astNode.getFirstChild(PythonGrammar.ARGLIST); List<PyArgumentTree> arguments = argList(argList); args = new PyArgListTreeImpl(argList, arguments); } PyStatementListTree body = getStatementListFromSuite(astNode.getFirstChild(PythonGrammar.SUITE)); return new PyClassDefTreeImpl(astNode, name, args, body, DocstringExtractor.extractDocstring(astNode)); }
Source:
<code>private String readString(ByteBuffer input) { <START> int nicknameLength = (int)input.get(); <END> if (nicknameLength > 0) { char[] nickname = new char[nicknameLength]; for (int i = 0; i < nickname.length; ++i) { nickname[i] = (char)(input.get()); } return new String(nickname); } else { return new String(); } }</code><technical_language>if this is multiple places. variable name is longer legit</technical_language>

Target:
private String readString(ByteBuffer input) { int stringLength = (int)input.get(); if (stringLength > 0) { char[] string = new char[stringLength]; for (int i = 0; i < string.length; ++i) { string[i] = (char)(input.get()); } return new String(string); } else { return new String(); } }
Source:
<code>public void onStateUpdateFromItem(State state) { <START> callback.handleUpdate(state); <END> }</code><technical_language>I agree @pfink, follow profile state updates item item commands. Please revert</technical_language>

Target:
public void onStateUpdateFromItem(State state) { if (!(state instanceof Command)) { logger.debug("The given state could not be transformed to a command", state); return; } Command command = (Command) state; callback.handleCommand(command); }
Source:
<code>public ScalebarDrawer(final Graphics2D graphics2d, final ScaleBarRenderSettings settings) { this.graphics2d = graphics2d; <START> this.transform = graphics2d.getTransform(); <END> this.settings = settings; this.params = settings.getParams(); }</code><technical_language>this.transform = new AffineTransform(graphics2d.getTransform());</technical_language>

Target:
public ScalebarDrawer(final Graphics2D graphics2d, final ScaleBarRenderSettings settings) { this.graphics2d = graphics2d; this.transform = new AffineTransform(graphics2d.getTransform()); this.settings = settings; this.params = settings.getParams(); }
Source:
<code>public void setVisible(boolean isVisible) { super.setVisible(isVisible); if (isVisible) { <START> sendOnResizeLocal_.schedule(5); <END> } }</code><technical_language>A couple of try: 1. Add some debug logging actual size of element is (i.e. offsetHeight/offsetWidth). common of this sort of behavior is elements compute size visible attached DOM. 2. In cases need wait for browser finish a layout pass picking layout properties, idiomatic do is Scheduler.get().scheduleDeferred(), schedules work happen next event loop (something a timer 0ms)</technical_language>

Target:
public void setVisible(boolean isVisible) { super.setVisible(isVisible); if (isVisible) { Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { onResize(); } }); } }
Source:
<code>public <Intermediate, Final> ListenableFuture<Final> go( Request request, HttpResponseHandler<Intermediate, Final> httpResponseHandler, Duration duration ) { if (requestNum++ == 0) { throw new RuntimeException("simulating couldn't send request to server for some reason."); } <START> if (requestNum++ == 1) { <END> HttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.INTERNAL_SERVER_ERROR); httpResponse.setContent(ChannelBuffers.buffer(0)); httpResponseHandler.handleResponse(httpResponse); return Futures.immediateFailedFuture(new RuntimeException("server error")); } HttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK); httpResponse.setContent(ChannelBuffers.buffer(0)); httpResponseHandler.handleResponse(httpResponse); try { return results.take(); } catch (InterruptedException ex) { throw new RE(ex, "Interrupted."); } }</code><technical_language>This requestNum == 1</technical_language>

Target:
public <Intermediate, Final> ListenableFuture<Final> go( Request request, HttpResponseHandler<Intermediate, Final> httpResponseHandler, Duration duration ) { if (requestNum.getAndIncrement() == 0) { throw new RuntimeException("simulating couldn't send request to server for some reason."); } if (requestNum.get() == 2) { HttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.INTERNAL_SERVER_ERROR); httpResponse.setContent(ChannelBuffers.buffer(0)); httpResponseHandler.handleResponse(httpResponse); return Futures.immediateFailedFuture(new RuntimeException("server error")); } HttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK); httpResponse.setContent(ChannelBuffers.buffer(0)); httpResponseHandler.handleResponse(httpResponse); try { return results.take(); } catch (InterruptedException ex) { throw new RE(ex, "Interrupted."); } }
Source:
<code>public PinotColumnMetadata(String name, Type type, boolean inNullable, String comment) { <START> super(requireNonNull(name, "name is null"), requireNonNull(type, "type is null"), inNullable, comment, null, false, emptyMap()); <END> this.name = name; }</code><technical_language>ImmutableMap.of()</technical_language>

Target:
public PinotColumnMetadata(String name, Type type, boolean inNullable, String comment) { super(requireNonNull(name, "name is null"), requireNonNull(type, "type is null"), inNullable, comment, null, false, ImmutableMap.of()); this.name = name; }
Source:
<code><START> public List<DeviceData> batchInsertReturnsRemaining(final List<DeviceData> deviceDataList) { <END> final Map<String, List<WriteRequest>> requestItems = toWriteRequestItems(deviceDataList); final BatchWriteItemRequest batchWriteItemRequest = new BatchWriteItemRequest().withRequestItems(requestItems); final BatchWriteItemResult result = this.dynamoDBClient.batchWriteItem(batchWriteItemRequest); final Map<String, List<WriteRequest>> remainingItems = result.getUnprocessedItems(); final List<DeviceData> remainingData = Lists.newArrayList(); for (final List<WriteRequest> requests : remainingItems.values()) { for (final WriteRequest request: requests) { final Map<String, AttributeValue> item = request.getPutRequest().getItem(); if (item != null && !item.isEmpty()) { remainingData.add(dynamoItemToDeviceData(item)); } } } return remainingData; }</code><technical_language>Map<String, List<WriteRequest>> batchInsert(final Map<String, List<WriteRequest>> requestItems) method reduce duplication</technical_language>

Target:
public List<DeviceData> batchInsertReturnsRemaining(final List<DeviceData> deviceDataList) { final List<Map<String, AttributeValue>> remainingItems = batchInsertNoRetryReturnsRemaining(deviceDataList); final List<DeviceData> remainingDeviceData = Lists.newArrayListWithCapacity(remainingItems.size()); for (final Map<String, AttributeValue> item : remainingItems) { remainingDeviceData.add(dynamoItemToRawDeviceData(item)); } return remainingDeviceData; }
Source:
<code>public void testAdd() { Entity e = Mockito.mock(Entity.class); field.add(e); assertSame(e, field.getEntities().get(1)); <START> assertSame(e, field.getDrawables().getFirst()); <END> assertEquals(2, field.getDrawables().size()); }</code><technical_language>contains, is guarantee element is first. <logic</technical_language>

Target:
public void testAdd() { Entity e = Mockito.mock(Entity.class); field.add(e); assertTrue(field.getEntities().contains(e)); assertSame(e, field.getDrawables().getFirst()); assertEquals(2, field.getDrawables().size()); }
Source:
<code>public boolean belongsTo(Object family) { <START> return (this.family == null || family == null) ? false : this.family.equals(family); <END> }</code><technical_language>java.util.Objects.equals()</technical_language>

Target:
public boolean belongsTo(Object family) { return Objects.equals(this.family, family); }
Source:
<code>protected String getManagementRealm(String url) throws IOException { CloseableHttpClient defaultHttpClient = HttpClients.custom() .setConnectionManager(new PoolingHttpClientConnectionManager(registry)) .setRetryHandler(new StandardHttpRequestRetryHandler(5, true)) .setDefaultRequestConfig(requestConfig) .build(); HttpPost post = new HttpPost(url); post.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType()); CloseableHttpResponse response = null; try { response = defaultHttpClient.execute(post); } finally { defaultHttpClient.close(); } if (response.getStatusLine().getStatusCode() != HttpStatus.SC_UNAUTHORIZED) { throw new IllegalStateException(String.format("Server responded with %d instead of %d after first request.", response.getStatusLine().getStatusCode(), HttpStatus.SC_UNAUTHORIZED)); } if (!response.containsHeader(HttpHeaders.WWW_AUTHENTICATE)) { throw new IllegalStateException("Missing WWW-Authenticate header in server response after first request."); } for (HeaderElement el : response.getHeaders(HttpHeaders.WWW_AUTHENTICATE)[0].getElements()) { if (el.getName().equals("Digest realm")) { return el.getValue(); } } <START> throw new IllegalStateException("Digest realm not found in in WWW-Authenticate header."); <END> }</code><technical_language>in in</technical_language>

Target:
private String getManagementRealm(String url) throws IOException { CloseableHttpClient defaultHttpClient = HttpClients.custom() .setDefaultRequestConfig(requestConfig) .build(); HttpPost post = new HttpPost(url); post.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType()); CloseableHttpResponse response = null; try { response = defaultHttpClient.execute(post); response.close(); } finally { defaultHttpClient.close(); } if (response.getStatusLine().getStatusCode() != HttpStatus.SC_UNAUTHORIZED) { throw new IllegalStateException(String.format("Server responded with %d instead of %d after first request.", response.getStatusLine().getStatusCode(), HttpStatus.SC_UNAUTHORIZED)); } if (!response.containsHeader(HttpHeaders.WWW_AUTHENTICATE)) { throw new IllegalStateException("Missing WWW-Authenticate header in server response after first request."); } for (HeaderElement el : response.getHeaders(HttpHeaders.WWW_AUTHENTICATE)[0].getElements()) { if (el.getName().equals("Digest realm")) { return el.getValue(); } } throw new IllegalStateException("Digest realm not found in WWW-Authenticate header."); }
Source:
<code>public Map<String, Ref> getRemoteRefs() throws IOException { Map<String, Ref> matches = new HashMap<String, Ref>(); RefDatabase rdb = repository.getRefDatabase(); for (RefSpec spec : getSubscribeSpecs()) { String remoteRef; boolean isTag = spec.getSource().startsWith(Constants.R_TAGS); if (isTag) remoteRef = spec.getSource(); else remoteRef = getRemoteRefFromLocal(remote, spec.getSource()); Collection<Ref> c; if (spec.isWildcard()) { remoteRef = remoteRef.substring(0, remoteRef.length() - 1); c = rdb.getRefs(remoteRef).values(); } else { Ref r = rdb.getRef(remoteRef); if (r == null) continue; <START> c = Collections.nCopies(1, r); <END> } for (Ref r : c) { if (isTag) matches.put(r.getName(), r); else matches.put(getLocalRefFromRemote(getRemote(), r.getName()), r); } } return matches; }</code><technical_language>Collections.singleton</technical_language>

Target:
public Map<String, Ref> getRemoteRefs() throws IOException { Map<String, Ref> matches = new HashMap<String, Ref>(); RefDatabase rdb = repository.getRefDatabase(); for (RefSpec spec : getSubscribeSpecs()) { String remoteRef; boolean isTag = spec.getSource().startsWith(Constants.R_TAGS); if (isTag) remoteRef = spec.getSource(); else remoteRef = getRemoteRefFromLocal(remote, spec.getSource()); Collection<Ref> c; if (spec.isWildcard()) { remoteRef = remoteRef.substring(0, remoteRef.length() - 1); c = rdb.getRefs(remoteRef).values(); } else { Ref r = rdb.getRef(remoteRef); if (r == null) continue; c = Collections.singleton(r); } for (Ref r : c) { if (isTag) matches.put(r.getName(), r); else matches.put(getLocalRefFromRemote(getRemote(), r.getName()), r); } } return matches; }
Source:
<code>public void onStreamDestroy(IMediaStream stream) { <START> } <END></code><technical_language>calling stream.addLivePacketListener onStreamCreate removing onStremDestroy</technical_language>

Target:
public void onStreamDestroy(IMediaStream stream) { PacketListener listener = null; String streamName = stream.getName(); WMSProperties props = stream.getProperties(); synchronized (props) { listener = (PacketListener) props.get(STREAM_ACTION_LISTENER_PROPERTY); } if (listener != null) { stream.removeLivePacketListener(listener); String entryId = Utils.getEntryIdFromStreamName(streamName); this.removeGlobalPTSSyncData(entryId); logger.info("remove PacketListener: " + stream.getSrc()); } }
Source:
<code>protected Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException { Object state = args.getState(); try { return this.possiblePlayer.parseValue(source, args); } catch (ArgumentParseException ex) { args.setState(state); try { return super.parseValue(source, args); } catch (ArgumentParseException ex2) { <START> if (returnSource && source instanceof User) <END> return source; else throw ex2; } } }</code><technical_language>require brackets if statements</technical_language>

Target:
protected Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException { Object state = args.getState(); try { return this.possiblePlayer.parseValue(source, args); } catch (ArgumentParseException ex) { args.setState(state); try { return super.parseValue(source, args); } catch (ArgumentParseException ex2) { if (this.returnSource && source instanceof User) { return source; } else { throw ex2; } } } }
Source:
<code>private static void setMaxAttributeSizeProperty(XMLInputFactory factory) { String maxAttributeSizeProperty = getProperty(MULE_MAX_ATTRIBUTE_SIZE); if(maxAttributeSizeProperty != null) { Integer maxAttributeSize = parseInt(maxAttributeSizeProperty); if(maxAttributeSize > 0) { factory.setProperty(P_MAX_ATTRIBUTE_SIZE, maxAttributeSizeProperty); return; } else if (LOGGER.isDebugEnabled()) { <START> LOGGER.debug("Invalid " + P_MAX_ATTRIBUTE_SIZE + " property value"); <END> } } factory.setProperty(P_MAX_ATTRIBUTE_SIZE, MAX_VALUE); }</code><technical_language>this a WARN</technical_language>

Target:
private static void setMaxAttributeSizeProperty(XMLInputFactory factory) { String maxAttributeSizeProperty = getProperty(MULE_MAX_ATTRIBUTE_SIZE); if(maxAttributeSizeProperty != null) { Integer maxAttributeSize = parseInt(maxAttributeSizeProperty); if(maxAttributeSize > 0) { factory.setProperty(P_MAX_ATTRIBUTE_SIZE, maxAttributeSizeProperty); return; } else { LOGGER.warn("Invalid " + P_MAX_ATTRIBUTE_SIZE + " property value"); } } factory.setProperty(P_MAX_ATTRIBUTE_SIZE, MAX_VALUE); }
Source:
<code>public TestSetRunListener( ConsoleReporter consoleReporter, FileReporter fileReporter, StatelessXmlReporter simpleXMLReporter, TestcycleConsoleOutputReceiver consoleOutputReceiver, StatisticsReporter statisticsReporter, boolean trimStackTrace, boolean isPlainFormat, boolean briefOrPlainFormat ) { <START> this.consoleReporter = consoleReporter != null ? consoleReporter : new NullConsoleReporter(); <END> this.fileReporter = fileReporter; this.statisticsReporter = statisticsReporter; this.simpleXMLReporter = simpleXMLReporter; this.consoleOutputReceiver = consoleOutputReceiver; this.briefOrPlainFormat = briefOrPlainFormat; detailsForThis = new TestSetStats( trimStackTrace, isPlainFormat ); testMethodStats = new ArrayList<TestMethodStats>(); }</code><technical_language>of classes in surefire-common project. nice create a new object new NullConsoleReporter() instead static final constant in abstract Factory in surefire-common. This null-check embedded in factory, e.g. factory methods createConsoleReporter(). I caller pass non-null consistent object this class TestSetRunListener constructor called class guess (means if == null => guess hide error). means checking consistency of object, is suitable, I treat object => I I call making a guess results a clean code me. If accepted paradigm occurrences in this PR change it</technical_language>

Target:
public TestSetRunListener( ConsoleReporter consoleReporter, FileReporter fileReporter, StatelessXmlReporter simpleXMLReporter, TestcycleConsoleOutputReceiver consoleOutputReceiver, StatisticsReporter statisticsReporter, boolean trimStackTrace, boolean isPlainFormat, boolean briefOrPlainFormat ) { this.consoleReporter = consoleReporter; this.fileReporter = fileReporter; this.statisticsReporter = statisticsReporter; this.simpleXMLReporter = simpleXMLReporter; this.consoleOutputReceiver = consoleOutputReceiver; this.briefOrPlainFormat = briefOrPlainFormat; detailsForThis = new TestSetStats( trimStackTrace, isPlainFormat ); testMethodStats = new ArrayList<TestMethodStats>(); }
Source:
<code>private void makeFiltersModifiable() { <START> if ( !filtersCanBeModified) { <END> this.filtersCanBeModified = true; if (filters == null) { this.filters = new HashSet<>(); } else { this.filters = new HashSet<>(filters); } } }</code><technical_language>whitespace suggestion if (!filtersCanBeModified) {</technical_language>

Target:
private void makeFiltersModifiable() { if (!filtersCanBeModified) { this.filtersCanBeModified = true; final Set<String> tempFilters = filters; this.filters = new HashSet<>(); if (tempFilters != null) { this.filters.addAll(tempFilters); } } }
Source:
<code>public Object execute() throws Exception { System.out.printf("%s=%s%n", "Protocol", SystemBaseUrl.EXTERNAL.getProtocol()); <START> System.out.printf("%s=%s%n", "Host", SystemBaseUrl.EXTERNAL.getHost()); <END> System.out.printf("%s=%s%n", "Port", SystemBaseUrl.EXTERNAL.getPort()); System.out.printf("%s=%s%n", "Root Context", SystemBaseUrl.EXTERNAL.getRootContext()); System.out.printf("%s=%s%n", "External Http Port", SystemBaseUrl.EXTERNAL.getHttpPort()); System.out.printf("%s=%s%n", "External Https Port", SystemBaseUrl.EXTERNAL.getHttpsPort()); System.out.printf( "%s=%s%n", "Internal Http Port", System.getProperty(SystemBaseUrl.INTERNAL.getHttpPort())); System.out.printf( "%s=%s%n", "Internal Https Port", System.getProperty(SystemBaseUrl.INTERNAL.getHttpsPort())); System.out.printf("%s=%s%n", "Site Name", SystemInfo.getSiteName()); System.out.printf("%s=%s%n", "Organization", SystemInfo.getOrganization()); System.out.printf("%s=%s%n", "Contact", SystemInfo.getSiteContatct()); System.out.printf("%s=%s%n", "Version", SystemInfo.getVersion()); return null; }</code><technical_language>![MAJOR](<LINK_1> 'Severity: MAJOR') Replace this of System.out System.err a logger. [![rule](<LINK_2>](<LINK_0></technical_language>

Target:
public Object execute() throws Exception { System.out.printf("%s=%s%n", "Protocol", SystemBaseUrl.EXTERNAL.getProtocol()); System.out.printf("%s=%s%n", "Host", SystemBaseUrl.EXTERNAL.getHost()); System.out.printf("%s=%s%n", "Port", SystemBaseUrl.EXTERNAL.getPort()); System.out.printf("%s=%s%n", "Root Context", SystemBaseUrl.EXTERNAL.getRootContext()); System.out.printf("%s=%s%n", "External Http Port", SystemBaseUrl.EXTERNAL.getHttpPort()); System.out.printf("%s=%s%n", "External Https Port", SystemBaseUrl.EXTERNAL.getHttpsPort()); System.out.printf( "%s=%s%n", "Internal Http Port", System.getProperty(SystemBaseUrl.INTERNAL.getHttpPort())); System.out.printf( "%s=%s%n", "Internal Https Port", System.getProperty(SystemBaseUrl.INTERNAL.getHttpsPort())); System.out.printf("%s=%s%n", "Internal Protocol", SystemBaseUrl.INTERNAL.getProtocol()); System.out.printf("%s=%s%n", "Internal Host", SystemBaseUrl.INTERNAL.getHost()); System.out.printf("%s=%s%n", "Internal Port", SystemBaseUrl.INTERNAL.getPort()); System.out.printf("%s=%s%n", "Site Name", SystemInfo.getSiteName()); System.out.printf("%s=%s%n", "Organization", SystemInfo.getOrganization()); System.out.printf("%s=%s%n", "Contact", SystemInfo.getSiteContatct()); System.out.printf("%s=%s%n", "Version", SystemInfo.getVersion()); return null; }
Source:
<code>public static <E> void setView(Configuration conf, View<E> view) { if (view instanceof AbstractRefinableView) { conf.set(KITE_CONSTRAINTS, serialize((AbstractRefinableView) view)); <START> } <END> }</code><technical_language>I of View finding a good delegate a View. rely a view's underlying implementation work, in this case throw exception if assumption work (which should). fine this long is temporary, I delegating more implementations relying follow standard pattern</technical_language>

Target:
public static <E> void setView(Configuration conf, View<E> view) { if (view instanceof AbstractRefinableView) { conf.set(KITE_CONSTRAINTS, serialize(((AbstractRefinableView) view).getConstraints())); } else { throw new UnsupportedOperationException("Implementation " + "does not provide InputFormat support. View: " + view); } }