auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public EventHubConsumerOptions clone() { EventHubConsumerOptions clone; try { clone = (EventHubConsumerOptions) super.clone(); } catch (CloneNotSupportedException e) { clone = new EventHubConsumerOptions(); } if (retry != null) { try { clone.retry((Retry) retry.clone()); } catch (CloneNotSupportedException e) { <START> logger.asWarning().log("Unable to create clone of retry.", e); <END> clone.retry(retry); } } clone.scheduler(this.scheduler()); clone.identifier(this.identifier()); clone.prefetchCount(this.prefetchCount()); clone.ownerLevel(this.ownerLevel()); return clone; }</code><technical_language>warning error</technical_language>

Target:
public EventHubConsumerOptions clone() { EventHubConsumerOptions clone; try { clone = (EventHubConsumerOptions) super.clone(); } catch (CloneNotSupportedException e) { clone = new EventHubConsumerOptions(); } if (retry != null) { try { clone.retry((Retry) retry.clone()); } catch (CloneNotSupportedException e) { logger.error("Unable to create clone of retry.", e); clone.retry(retry); } } clone.scheduler(this.scheduler()); clone.identifier(this.identifier()); clone.prefetchCount(this.prefetchCount()); clone.ownerLevel(this.ownerLevel()); return clone; }
Source:
<code>public ToolNBT() { durability = 0; harvestLevel = 0; attack = 0; speed = 0; <START> attackSpeed = 0; <END> }</code><technical_language>Initialize 1 here, remove assignment of 1 in tool data building. long is other set else 1. rename attackSpeedMultiplier, confuse actual attackspeed stat of tool (which is product of + tools AS)</technical_language>

Target:
public ToolNBT() { durability = 0; harvestLevel = 0; attack = 0; speed = 0; attackSpeedMultiplier = 1; }
Source:
<code>List<String> genArgs() { return asList( "-d", "-p", <START> "crate.pid", <END> String.format("-Des.cluster.name=%s", clusterName), String.format("-Des.http.port=%d", configuration.httpPort), String.format("-Des.transport.tcp.port=%d", configuration.transportPort), String.format("-Des.node.name=%s", nodeNode), String.format("-Des.discovery.zen.ping.multicast.enabled=%s", "false"), String.format("-Des.discovery.zen.ping.unicast.hosts=%s", unicastHosts()) ); }</code><technical_language>clusterName.pid conflict instances other nodes</technical_language>

Target:
List<String> genArgs() { return asList( String.format("-Des.cluster.name=%s", clusterName), String.format("-Des.http.port=%d", configuration.httpPort), String.format("-Des.transport.tcp.port=%d", configuration.transportPort), String.format("-Des.node.name=%s", nodeNode), String.format("-Des.discovery.zen.ping.multicast.enabled=%s", "false"), String.format("-Des.discovery.zen.ping.unicast.hosts=%s", unicastHosts()) ); }
Source:
<code>public void testReadUncalledSegments() { <START> final File testDir = new File("src/test/resources/org/broadinstitute/hellbender/tools/exome/caller"); <END> final File testSegments = new File(testDir,"segments.tsv"); List<SimpleInterval> segments = SegmentUtils.readIntervalsFromSegmentFile(testSegments); Assert.assertEquals(segments.size(), 4); Assert.assertEquals(segments.get(0).getContig(), "chr"); Assert.assertEquals(segments.get(1).getStart(), 300); Assert.assertEquals(segments.get(2).getEnd(), 550); }</code><technical_language>give this class scope</technical_language>

Target:
public void testReadUncalledSegments() { final List<SimpleInterval> segments = SegmentUtils.readIntervalsFromSegmentFile(TEST_SEGMENTS); Assert.assertEquals(segments.size(), 4); Assert.assertEquals(segments.get(0).getContig(), "chr"); Assert.assertEquals(segments.get(1).getStart(), 300); Assert.assertEquals(segments.get(2).getEnd(), 550); }
Source:
<code>private void finalizeINodeFileUnderConstruction(String src, INodeFile pendingFile) throws IOException { boolean skipReplicationCheck = false; if (pendingFile.getStoragePolicyID() == HdfsConstants.DB_STORAGE_POLICY_ID){ skipReplicationCheck = true; <START> } <END> finalizeINodeFileUnderConstructionInternal(src, pendingFile, skipReplicationCheck); }</code><technical_language>remove this function if handle case of files in DB</technical_language>

Target:
private void finalizeINodeFileUnderConstruction(String src, INodeFile pendingFile) throws IOException { finalizeINodeFileUnderConstructionInternal(src, pendingFile, false); }
Source:
<code>public void performAlign(int offset, int width) { int total = fSashForm.getBounds().width; int timeAxisOffset = Math.min(offset, total); <START> int width1 = Math.max(0, timeAxisOffset - fSashForm.getSashWidth()); <END> int width2 = total - timeAxisOffset; if (width1 + width2 > 0) { fSashForm.setWeights(new int[] { width1, width2 }); } fSashForm.layout(); Composite composite = fTimeGraphViewer.getTimeAlignedComposite(); GridLayout layout = (GridLayout) composite.getLayout(); int timeBasedControlsWidth = composite.getSize().x; int marginSize = timeBasedControlsWidth - width; layout.marginRight = Math.max(0, marginSize); composite.layout(); }</code><technical_language>I able reproduce it. problem occurs, performAlign is called sash is painted once. fSashDragListener is null moment. of fSashForm.getBounds().width returns 0 total timeAxisOffset, width1 width2 0. I proposed fix is fine assuming width1 width2 positive numbers</technical_language>

Target:
public void performAlign(int offset, int width) { int total = fSashForm.getBounds().width; int timeAxisOffset = Math.min(offset, total); int width1 = Math.max(0, timeAxisOffset - fSashForm.getSashWidth()); int width2 = total - timeAxisOffset; if (width1 >= 0 && width2 > 0 || width1 > 0 && width2 >= 0) { fSashForm.setWeights(new int[] { width1, width2 }); fSashForm.layout(); } Composite composite = fTimeGraphViewer.getTimeAlignedComposite(); GridLayout layout = (GridLayout) composite.getLayout(); int timeBasedControlsWidth = composite.getSize().x; int marginSize = timeBasedControlsWidth - width; layout.marginRight = Math.max(0, marginSize); composite.layout(); }
Source:
<code>protected GenericRecord decodeMessage(byte[] value, String topic, SpecificDatumReader<GenericRecord> reader) throws IOException { <START> if (value.length > 1 && value[0] == 0) { <END> return schemaRegistryClient.decodeMessage(topic, value); } else { return deserializeAvroRecord(decoderFactory, reader, value); } }</code><technical_language>this convention coming (use byte differentiate)</technical_language>

Target:
protected GenericRecord decodeMessage(byte[] value, String topic, SpecificDatumReader<GenericRecord> reader) throws IOException { if (value.length > 5 && value[0] == 0) { return schemaRegistryClient.decodeMessage(topic, value); } else { return deserializeAvroRecord(reader, value); } }
Source:
<code>public void testUpdateComment() throws Exception { FileService fileService = new FileService(); authenticateEndpoint(fileService.getEndpoint(), USERNAME, PASSWORD); FileList listOfFiles = fileService.getMyFiles(); String fileId = listOfFiles.get(0).getFileId(); Comment commentObject = fileService.createComment(fileId, "CommentCreated" + System.currentTimeMillis()); if(commentObject != null) { String commentId = commentObject.getCommentId(); <START> fileService.updateComment(fileId, commentId, commentObject.getComment()+"Vimal"); <END> } }</code><technical_language>Please avoid devloper names in code. replace this else</technical_language>

Target:
public void testUpdateComment() throws Exception { FileService fileService = new FileService(); authenticateEndpoint(fileService.getEndpoint(), USERNAME, PASSWORD); FileList listOfFiles = fileService.getMyFiles(); String fileId = listOfFiles.get(0).getFileId(); Comment commentObject = fileService.createComment(fileId, "CommentCreated" + System.currentTimeMillis()); if(commentObject != null) { String commentId = commentObject.getCommentId(); fileService.updateComment(fileId, commentId, commentObject.getComment()+ System.currentTimeMillis()); } }
Source:
<code>public void testUnboundActionRequest() throws Exception { final TestOlingo4ResponseHandler<HttpStatusCode> responseHandler = new TestOlingo4ResponseHandler<>(); olingoApp.action(edm, TEST_UNBOUND_ACTION_RESETDATASOURCE, null, null, responseHandler); <START> final HttpStatusCode statusCode = responseHandler.await(15, TimeUnit.MINUTES); <END> assertEquals(204, statusCode.getStatusCode()); }</code><technical_language>Is needed await for 15 minutes? I dont feel comfortable waiting 15 minutes for test fail</technical_language>

Target:
public void testUnboundActionRequest() throws Exception { final TestOlingo4ResponseHandler<HttpStatusCode> responseHandler = new TestOlingo4ResponseHandler<>(); olingoApp.action(edm, TEST_UNBOUND_ACTION_RESETDATASOURCE, null, null, responseHandler); final HttpStatusCode statusCode = responseHandler.await(); assertEquals(HttpStatusCode.NO_CONTENT, statusCode); }
Source:
<code>public void simple3Row() throws Exception { rowPriorityResolver.set( 1, <START> 0 ); <END> rowPriorityResolver.set( 2, 0 ); rowPriorityResolver.set( 3, 2 ); final RowPriorities priorities = rowPriorityResolver.getPriorityRelations(); assertEquals( 1, priorities.getSalience( new RowNumber( 1 ) ).getSalience() ); assertEquals( 0, priorities.getSalience( new RowNumber( 2 ) ).getSalience() ); assertEquals( 1, priorities.getSalience( new RowNumber( 3 ) ).getSalience() ); }</code><technical_language>@Rikkola , method DecisionTableHitPolicyEnhancer.java .getPriorityOver( index , row ), is this zero Row 1 priority other row? If is case salience values like: * Row 1 : salience 0 * Row 2 : salience 0 * Row 3 : salience 1 I right this, If Row A priority Row B, Row A salience is bigger Row B salience</technical_language>

Target:
public void simple3Row() throws Exception { rowPriorityResolver.set(1, 0); rowPriorityResolver.set(2, 0); rowPriorityResolver.set(3, 2); priorities = rowPriorityResolver.getPriorityRelations(); assertSalience(2, new RowNumber(1)); assertSalience(0, new RowNumber(2)); assertSalience(1, new RowNumber(3)); }
Source:
<code>private QueryEngineHTTP(String serviceURI, Query query, String queryString, HttpClient client) { this.query = query; this.queryString = queryString; this.service = serviceURI; <START> this.context = ARQ.getContext(); <END> applyServiceConfig(serviceURI, this); if (client != null) setClient(client); }</code><technical_language>Need a copy of context isolate changes global context later. be, current style: this.context = ARQ.getContext.copy() ;</technical_language>

Target:
private QueryEngineHTTP(String serviceURI, Query query, String queryString, HttpClient client) { this.query = query; this.queryString = queryString; this.service = serviceURI; this.context = ARQ.getContext().copy(); applyServiceConfig(serviceURI, this); if (client != null) setClient(client); }
Source:
<code>protected ActionResult execute() throws EntityDoesNotExistException { String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID); String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME); new GateKeeper().verifyAccessible( logic.getInstructorForGoogleId(courseId, account.googleId), logic.getFeedbackSession(feedbackSessionName, courseId), false, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION); String[] usersToRemind = getRequestParamValues("usersToRemind"); if (usersToRemind == null || usersToRemind.length == 0) { statusToUser.add(Const.StatusMessages.FEEDBACK_SESSION_REMINDERSEMPTYRECIPIENT); return createRedirectResult(Const.ActionURIs.INSTRUCTOR_FEEDBACKS_PAGE); } logic.sendReminderForFeedbackSessionParticularUsers(courseId, feedbackSessionName, usersToRemind); statusToUser.add(Const.StatusMessages.FEEDBACK_SESSION_REMINDERSSENT); statusToAdmin = "Email sent out to the selected student(s) in " + "Feedback Session <span class=\"bold\">(" + feedbackSessionName + ")</span> " + <START> "of Course <span class=\"bold\">[" + courseId + "]</span>"; <END> return createRedirectResult(Const.ActionURIs.INSTRUCTOR_FEEDBACKS_PAGE); }</code><technical_language>add emails of users log message</technical_language>

Target:
protected ActionResult execute() throws EntityDoesNotExistException { String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID); String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME); new GateKeeper().verifyAccessible( logic.getInstructorForGoogleId(courseId, account.googleId), logic.getFeedbackSession(feedbackSessionName, courseId), false, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION); String[] usersToRemind = getRequestParamValues("usersToRemind"); if (usersToRemind == null || usersToRemind.length == 0) { statusToUser.add(Const.StatusMessages.FEEDBACK_SESSION_REMINDERSEMPTYRECIPIENT); return createRedirectResult(Const.ActionURIs.INSTRUCTOR_FEEDBACKS_PAGE); } logic.sendReminderForFeedbackSessionParticularUsers(courseId, feedbackSessionName, usersToRemind); statusToUser.add(Const.StatusMessages.FEEDBACK_SESSION_REMINDERSSENT); statusToAdmin = "Email sent out to the selected user(s): "; for(String user : usersToRemind){ statusToAdmin += "<br>" + user; } statusToAdmin += "<br>in Feedback Session <span class=\"bold\">(" + feedbackSessionName + ")</span> " + "of Course <span class=\"bold\">[" + courseId + "]</span>"; return createRedirectResult(Const.ActionURIs.INSTRUCTOR_FEEDBACKS_PAGE); }
Source:
<code>public Flux<PartitionOwnership> listOwnership(String fullyQualifiedNamespace, String eventHubName, String consumerGroup) { String prefix = getBlobPrefix(fullyQualifiedNamespace, eventHubName, consumerGroup, OWNERSHIP_PATH); BlobListDetails details = new BlobListDetails().setRetrieveMetadata(true); ListBlobsOptions options = new ListBlobsOptions().setPrefix(prefix).setDetails(details); return blobContainerAsyncClient.listBlobs(options) <START> .filter(blobItem -> blobItem.getName().split(BLOB_PATH_SEPARATOR).length == 5) <END> .map(this::convertToPartitionOwnership); }</code><technical_language>helpful a verbose log message if match? In case improperly configured checkpoints users figure out found</technical_language>

Target:
public Flux<PartitionOwnership> listOwnership(String fullyQualifiedNamespace, String eventHubName, String consumerGroup) { String prefix = getBlobPrefix(fullyQualifiedNamespace, eventHubName, consumerGroup, OWNERSHIP_PATH); return listBlobs(prefix, this::convertToPartitionOwnership); }
Source:
<code>public URI convert(URI inputFileUri, SchemaFormat baseFormat, SchemaFormat resultFormat) { if (resultFormat == SchemaFormat.DMS) { <START> return null; <END> } else if (resultFormat == SchemaFormat.DMSRUSDML) { return null; } else { return null; } }</code><technical_language>this other formats implemented yet, throw exception instead of returning null value</technical_language>

Target:
public URI convert(URI inputFileUri, SchemaFormat baseFormat, SchemaFormat resultFormat) { if (resultFormat == SchemaFormat.DMS) { throw new RuntimeException("Not implemented yet!"); } else if (resultFormat == SchemaFormat.DMSRUSDML) { throw new RuntimeException("Not implemented yet!"); } else { throw new RuntimeException("Not implemented yet!"); } }
Source:
<code>public List<Dac> findDacsByUser(AuthUser authUser) { if (isAuthUserAdmin(authUser)) { List<Dac> allDacs = dacDAO.findAll(); return allDacs; } <START> List<Dac> dacs = dacDAO.findDacsForEmail(authUser.getGoogleUser().getEmail()); <END> return dacs; }</code><technical_language>auth user's name is email address, this works: suggestion List<Dac> dacs = dacDAO.findDacsForEmail(authUser.getName());</technical_language>

Target:
public List<Dac> findDacsByUser(AuthUser authUser) { if (isAuthUserAdmin(authUser)) { List<Dac> allDacs = dacDAO.findAll(); return allDacs; } List<Dac> dacs = dacDAO.findDacsForEmail(authUser.getName()); return dacs; }
Source:
<code>public void testVFE9() { T_filled_new_array_range_11 t = new T_filled_new_array_range_11(); try { t.run(); <START> fail("expected NoClassDefFoundError exception"); <END> } catch (NoClassDefFoundError e) { } }</code><technical_language>@title suggests this is inaccessible class a nonexistent class</technical_language>

Target:
public void testVFE9() { T_filled_new_array_range_11 t = new T_filled_new_array_range_11(); try { t.run(); fail("expected IllegalAccessError exception"); } catch (IllegalAccessError e) { } }
Source:
<code>private static List<String> loadFileContent(String path, SourceType sourceType) throws IOException { checkPathAndMode(path, sourceType); log.debug("loading with sourceType {}", path, sourceType); BufferedReader reader = null; try { reader = ShifuFileUtils.getReader(path, sourceType); <START> List<String> content = new ArrayList<String>(); <END> String line = null; while((line = reader.readLine()) != null) { content.add(line); } return content; } finally { IOUtils.closeQuietly(reader); } }</code><technical_language>contents a name</technical_language>

Target:
private static List<String> loadFileContent(String path, SourceType sourceType) throws IOException { checkPathAndMode(path, sourceType); log.debug("loading with sourceType {}", path, sourceType); BufferedReader reader = null; try { reader = ShifuFileUtils.getReader(path, sourceType); List<String> contents = new ArrayList<String>(); String line = null; while((line = reader.readLine()) != null) { contents.add(line); } return contents; } finally { IOUtils.closeQuietly(reader); } }
Source:
<code>public boolean isNewborn() { if (getCreated() == null) { return false; } <START> Date now = new Date(); <END> Date oneDayFromRegistration = new Date(getCreated().getTime() + 24L * 60L * 60L * 1000L); return now.before(oneDayFromRegistration); }</code><technical_language>java.time avoid manual calculation of time period. Instant dayAgo = Instant.now().minus(Duration.ofDays(1)); return getCreated().toInstant() .isAfter(dayAgo);</technical_language>

Target:
public boolean isNewborn() { if (getCreated() == null) { return false; } Instant oneDayFromRegistration = getCreated().toInstant().plus(Duration.ofDays(1)); return Instant.now().isBefore(oneDayFromRegistration); }
Source:
<code>private void startInvocation( IInvocationContext context, ExecutableCommand cmd, IScheduledInvocationListener... listeners) { initInvocation(); throwIfDeviceInInvocationThread(context.getDevices()); CLog.d("starting invocation for command id %d", cmd.getCommandTracker().getId()); final String invocationName = String.format("Invocation-%s", context.getSerials().get(0)); InvocationThread invocationThread = new InvocationThread(invocationName, context, cmd, listeners); <START> cmd.getCommandTracker().getContexts().add(context); <END> logInvocationStartedEvent(cmd.getCommandTracker(), context); invocationThread.start(); addInvocationThread(invocationThread); }</code><technical_language>I more sense</technical_language>

Target:
private void startInvocation( IInvocationContext context, ExecutableCommand cmd, IScheduledInvocationListener... listeners) { initInvocation(); throwIfDeviceInInvocationThread(context.getDevices()); int invocationId = cmd.getCommandTracker().getId(); CLog.d("starting invocation for command id %d", invocationId); final String invocationName = String.format("Invocation-%s", context.getSerials().get(0)); InvocationThread invocationThread = new InvocationThread(invocationName, context, cmd, listeners); if (context instanceof InvocationContext) { ((InvocationContext) context).setInvocationId(invocationId); } logInvocationStartedEvent(cmd.getCommandTracker(), context); invocationThread.start(); addInvocationThread(invocationThread); }
Source:
<code><START> public TxEntryCacheSet(VisitableCommand rCommand, CacheSet<CacheEntry<K, V>> set, InvocationContext rCtx, <END> boolean isRemoteIteration) { super(Caches.getCacheWithFlags(TxInterceptor.this.cache, (FlagAffectedCommand) rCommand), set); this.rCtx = rCtx; this.isRemoteIteration = isRemoteIteration; }</code><technical_language>need for public, package local is good</technical_language>

Target:
TxEntryCacheSet(VisitableCommand rCommand, CacheSet<CacheEntry<K, V>> set, InvocationContext rCtx, boolean isRemoteIteration) { super(Caches.getCacheWithFlags(TxInterceptor.this.cache, (FlagAffectedCommand) rCommand), set); this.rCtx = rCtx; this.isRemoteIteration = isRemoteIteration; }
Source:
<code>public void shouldNotReturnNullFileCacheEntries() throws IOException { File file = FileUtils.getResourceFileFromContext("test-data/hello.doc"); <START> assertNotNull(file); assertTrue(file.length() > 0); <END> Blob blob = Blobs.createBlob(file, "application/msword", null, "hello.doc"); BlobHolder bh = new SimpleCachableBlobHolder(blob); String cacheKey = CacheKeyGenerator.computeKey("identity", bh, null); ConversionCacheHolder.addToCache(cacheKey, bh); assertEquals(1, ConversionCacheHolder.getNbCacheEntries()); BlobHolder blobHolder = ConversionCacheHolder.getFromCache(cacheKey); Files.delete(Paths.get(blobHolder.getBlob().getFile().getPath())); assertEquals(1, ConversionCacheHolder.getNbCacheEntries()); assertTrue(ConversionCacheHolder.getCacheKeys().contains(cacheKey)); assertNull(ConversionCacheHolder.getFromCache(cacheKey)); assertEquals(0, ConversionCacheHolder.getNbCacheEntries()); }</code><technical_language>I 2 lines in existing test, I asserting a static test resource repository</technical_language>

Target:
public void shouldNotReturnNullFileCacheEntries() throws IOException { File file = FileUtils.getResourceFileFromContext("test-data/hello.doc"); Blob blob = Blobs.createBlob(file); BlobHolder bh = new SimpleCachableBlobHolder(blob); String cacheKey = CacheKeyGenerator.computeKey("identity", bh, null); ConversionCacheHolder.addToCache(cacheKey, bh); assertEquals(1, ConversionCacheHolder.getNbCacheEntries()); BlobHolder blobHolder = ConversionCacheHolder.getFromCache(cacheKey); Files.delete(Paths.get(blobHolder.getBlob().getFile().getPath())); assertEquals(1, ConversionCacheHolder.getNbCacheEntries()); assertTrue(ConversionCacheHolder.getCacheKeys().contains(cacheKey)); assertNull(ConversionCacheHolder.getFromCache(cacheKey)); assertEquals(0, ConversionCacheHolder.getNbCacheEntries()); }
Source:
<code>protected void marshallAndAssertArrayEquality(Object[] writeObj) throws Exception { byte[] bytes = marshaller.objectToByteBuffer(writeObj); <START> System.out.println(bytes.length); <END> Object[] readObj = (Object[]) marshaller.objectFromByteBuffer(bytes); assertArrayEquals("Writen[" + Arrays.toString(writeObj)+ "] and read[" + Arrays.toString(readObj)+ "] objects should be the same", readObj, writeObj); }</code><technical_language>Replace System.out log.debug (or trace)</technical_language>

Target:
protected void marshallAndAssertArrayEquality(Object[] writeObj) throws Exception { byte[] bytes = marshaller.objectToByteBuffer(writeObj); log.debugf("Payload size for object=%s : %s", Arrays.toString(writeObj), bytes.length); Object[] readObj = (Object[]) marshaller.objectFromByteBuffer(bytes); assertArrayEquals("Writen[" + Arrays.toString(writeObj) + "] and read[" + Arrays.toString(readObj) + "] objects should be the same", readObj, writeObj); }
Source:
<code>private String getType(String filename) { String type = filename.substring(filename.lastIndexOf('.') + 1); <START> boolean hash = false; <END> String hashAlgorithm = null; if (filename.endsWith(".sha1")) { type = filename.substring(0, filename.length() - 5); type = type.substring(type.lastIndexOf('.') + 1) + ".sha1"; } if (filename.endsWith(".md5")) { type = filename.substring(0, filename.length() - 4); type = type.substring(type.lastIndexOf('.') + 1) + ".md5"; } return type; }</code><technical_language>Un-used variable</technical_language>

Target:
private String getType(String filename) { if (filename.contains(".")) { String type = filename.substring(filename.lastIndexOf('.') + 1); if (filename.endsWith(".sha1")) { type = filename.substring(0, filename.length() - 5); type = type.substring(type.lastIndexOf('.') + 1) + ".sha1"; } if (filename.endsWith(".md5")) { type = filename.substring(0, filename.length() - 4); type = type.substring(type.lastIndexOf('.') + 1) + ".md5"; } return type; } else { return null; } }
Source:
<code>public void testOverrideIndicatorText() { testCountOverrideIndicators(); for (Annotation <START> fOverrideAnnotation : <END> fOverrideAnnotations) { String text= fOverrideAnnotation.getText(); assertTrue(text != null && (text.equals("overrides java.lang.Object.toString") || text.equals("implements junit.framework.Test.run") || text.equals("implements junit.framework.Test.countTestCases") )); } }</code><technical_language>rename overrideAnnotation</technical_language>

Target:
public void testOverrideIndicatorText() { testCountOverrideIndicators(); for (Annotation overrideAnnotation : fOverrideAnnotations) { String text= overrideAnnotation.getText(); assertTrue(text != null && (text.equals("overrides java.lang.Object.toString") || text.equals("implements junit.framework.Test.run") || text.equals("implements junit.framework.Test.countTestCases") )); } }
Source:
<code>public boolean handleNetworkException(VDSNetworkException ex, VDS vds) { if (vds.getStatus() != VDSStatus.Down) { long timeoutToFence = calcTimeoutToFence(vds.getVmCount(), vds.getSpmStatus()); if (mUnrespondedAttempts.get() < Config.<Integer> GetValue(ConfigValues.VDSAttemptsToResetCount) || (lastUpdate + timeoutToFence) > System.currentTimeMillis()) { boolean result = false; if (vds.getStatus() != VDSStatus.Connecting && vds.getStatus() != VDSStatus.PreparingForMaintenance && vds.getStatus() != VDSStatus.NonResponsive) { setStatus(VDSStatus.Connecting, vds); result = true; } mUnrespondedAttempts.incrementAndGet(); return result; } if (vds.getStatus() == VDSStatus.NonResponsive || vds.getStatus() == VDSStatus.Maintenance) { setStatus(VDSStatus.NonResponsive, vds); return true; } setStatus(VDSStatus.NonResponsive, vds); log.infoFormat( "Server failed to respond, vds_id = {0}, vds_name = {1}, vm_count = {2}, " + <START> "spm_status = {3}, non-responsive_seconds = {4}, error = {5}", <END> vds.getId(), vds.getName(), vds.getVmCount(), vds.getSpmStatus(), TimeUnit.MILLISECONDS.toSeconds(timeoutToFence), ex.getMessage()); AuditLogableBase logable = new AuditLogableBase(vds.getId()); AuditLogDirector.log(logable, AuditLogType.VDS_FAILURE); ResourceManager.getInstance().getEventListener().vdsNotResponding(vds); } return true; }</code><technical_language>i suggest non-responsive_timeout (seconds)</technical_language>

Target:
public boolean handleNetworkException(VDSNetworkException ex, VDS vds) { if (vds.getStatus() != VDSStatus.Down) { long timeoutToFence = calcTimeoutToFence(vds.getVmCount(), vds.getSpmStatus()); if (mUnrespondedAttempts.get() < Config.<Integer> GetValue(ConfigValues.VDSAttemptsToResetCount) || (lastUpdate + timeoutToFence) > System.currentTimeMillis()) { boolean result = false; if (vds.getStatus() != VDSStatus.Connecting && vds.getStatus() != VDSStatus.PreparingForMaintenance && vds.getStatus() != VDSStatus.NonResponsive) { setStatus(VDSStatus.Connecting, vds); result = true; } mUnrespondedAttempts.incrementAndGet(); return result; } if (vds.getStatus() == VDSStatus.NonResponsive || vds.getStatus() == VDSStatus.Maintenance) { setStatus(VDSStatus.NonResponsive, vds); return true; } setStatus(VDSStatus.NonResponsive, vds); log.infoFormat( "Server failed to respond, vds_id = {0}, vds_name = {1}, vm_count = {2}, " + "spm_status = {3}, non-responsive_timeout (seconds) = {4}, error = {5}", vds.getId(), vds.getName(), vds.getVmCount(), vds.getSpmStatus(), TimeUnit.MILLISECONDS.toSeconds(timeoutToFence), ex.getMessage()); AuditLogableBase logable = new AuditLogableBase(vds.getId()); AuditLogDirector.log(logable, AuditLogType.VDS_FAILURE); ResourceManager.getInstance().getEventListener().vdsNotResponding(vds); } return true; }
Source:
<code>public ArchaiusConfigurationProvider(Map<String, String> variableValues) { <START> super(new ObjectMapper()); <END> this.variableValues = Maps.newHashMap(variableValues); this.configurationManager = ConfigurationManager.getConfigInstance(); this.propertyFactory = DynamicPropertyFactory.getInstance(); this.ownershipPolicy = new ConfigurationOwnershipPolicy() { @Override public boolean has(ConfigurationKey key, Map<String, String> variables) { return configurationManager.containsKey(key.getKey(variables)); } }; }</code><technical_language>set 'null' create a default in AbstractObjectConfigurationProvider</technical_language>

Target:
public ArchaiusConfigurationProvider(Map<String, String> variableValues) { this.variableValues = Maps.newHashMap(variableValues); this.configurationManager = ConfigurationManager.getConfigInstance(); this.propertyFactory = DynamicPropertyFactory.getInstance(); this.ownershipPolicy = new ConfigurationOwnershipPolicy() { @Override public boolean has(ConfigurationKey key, Map<String, String> variables) { return configurationManager.containsKey(key.getKey(variables)); } }; }
Source:
<code>private void setupImageSizeSeekBar() { mImageSizeKeyArray = getResources().getStringArray(R.array.image_size_key_array); mImageSizeLabelArray = getResources().getStringArray(R.array.image_size_label_array); if (mImageSizeKeyArray.length != mImageSizeLabelArray.length) { throw new RuntimeException("Length of Image Size Key and Label arrays is not same"); } int imageSizeKey = Arrays.asList(mImageSizeKeyArray).indexOf(mEditorImageMetaData.getSize()); if (imageSizeKey == -1) { <START> imageSizeKey = mImageSizeLabelArray.length - 1; <END> } mImageSizeSeekBarView.setMax(mImageSizeLabelArray.length - 1); mImageSizeSeekBarView.setProgress(imageSizeKey); mImageSizeView.setText(mImageSizeLabelArray[imageSizeKey]); mImageSizeSeekBarView.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mImageSizeView.setText(mImageSizeLabelArray[progress]); } }); }</code><technical_language>I unrecognized be. do adding some logging for here? Thanks</technical_language>

Target:
private void setupImageSizeSeekBar() { mImageSizeKeyArray = getResources().getStringArray(R.array.image_size_key_array); mImageSizeLabelArray = getResources().getStringArray(R.array.image_size_label_array); if (mImageSizeKeyArray.length != mImageSizeLabelArray.length) { throw new RuntimeException("Length of Image Size Key and Label arrays is not same"); } int imageSizeKey = Arrays.asList(mImageSizeKeyArray).indexOf(mEditorImageMetaData.getSize()); if (imageSizeKey == -1) { imageSizeKey = mImageSizeLabelArray.length - 1; AppLog.w(AppLog.T.MEDIA, "Unrecognized image size class passed to MediaSettings from editor: " + mEditorImageMetaData.getSize()); } mImageSizeSeekBarView.setMax(mImageSizeLabelArray.length - 1); mImageSizeSeekBarView.setProgress(imageSizeKey); mImageSizeView.setText(mImageSizeLabelArray[imageSizeKey]); mImageSizeSeekBarView.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mImageSizeView.setText(mImageSizeLabelArray[progress]); } }); }
Source:
<code>public static Set<PersistentResource> loadRecords(Class<?> loadClass, RequestScope requestScope, Optional<FilterExpression> filterExpression) { DataStoreTransaction tx = requestScope.getTransaction(); if (shouldSkipCollection(loadClass, ReadPermission.class, requestScope)) { return Collections.emptySet(); } Iterable list; Optional<FilterExpression> filter = filterExpression; if(filterExpression.isPresent()) { <START> if(requestScope.getLoadFilterExpression(loadClass).isPresent()) { <END> filter = Optional.of(new AndFilterExpression(filterExpression.get(), requestScope.getLoadFilterExpression(loadClass).get())); } } else { filter = requestScope.getLoadFilterExpression(loadClass); } list = tx.loadObjects(loadClass, filter, Optional.empty(), Optional.empty(), requestScope); Set<PersistentResource> resources = new PersistentResourceSet(list, requestScope); resources = filter(ReadPermission.class, resources, false); return resources; }</code><technical_language>getLoadFilterExpression is a free operation. do result in if/else checks</technical_language>

Target:
public static Set<PersistentResource> loadRecords(Class<?> loadClass, RequestScope requestScope, Optional<FilterExpression> filterExpression) { DataStoreTransaction tx = requestScope.getTransaction(); if (shouldSkipCollection(loadClass, ReadPermission.class, requestScope)) { return Collections.emptySet(); } Iterable list; Optional<FilterExpression> filter = filterExpression; Optional<FilterExpression> loadFilterExpression = requestScope.getLoadFilterExpression(loadClass); if(filterExpression.isPresent()) { if(loadFilterExpression.isPresent()) { filter = Optional.of(new AndFilterExpression(filterExpression.get(), loadFilterExpression.get())); } } else { filter = loadFilterExpression; } list = tx.loadObjects(loadClass, filter, Optional.empty(), Optional.empty(), requestScope); Set<PersistentResource> resources = new PersistentResourceSet(list, requestScope); resources = filter(ReadPermission.class, resources, false); return resources; }
Source:
<code>public void store(Item item, String alias) { logger.debug("Storing item: " + item.getName()); if (item.getState() instanceof UnDefType) { <START> return; <END> } if(!JpaConfiguration.isInitialized) { logger.warn("Trying to create EntityManagerFactory but we don't have configuration yet!"); return; } String name = (alias != null) ? alias : item.getName(); JpaPersistentItem pItem = new JpaPersistentItem(); try { pItem.setValue(StateHelper.toString(item.getState())); } catch (Exception e1) { logger.error("Error on converting state value to string!"); logger.error(e1.getMessage(), e1); return; } pItem.setName(name); pItem.setRealName(item.getName()); pItem.setTimestamp(new Date()); EntityManager em = getEntityManagerFactory().createEntityManager(); try { logger.debug("Persisting item..."); em.getTransaction().begin(); em.persist(pItem); em.getTransaction().commit(); logger.debug("Persisting item...done"); } catch (Exception e) { logger.error("Error on persisting item! Rolling back!"); logger.error(e.getMessage(), e); em.getTransaction().rollback(); } finally { em.close(); } logger.debug("Storing item...done"); }</code><technical_language>add a debug/trace statement give developers a notion this method returns fast</technical_language>

Target:
public void store(Item item, String alias) { logger.debug("Storing item: " + item.getName()); if (item.getState() instanceof UnDefType) { logger.debug("This item is of undefined type. Cannot perist it!"); return; } if(!JpaConfiguration.isInitialized) { logger.warn("Trying to create EntityManagerFactory but we don't have configuration yet!"); return; } String name = (alias != null) ? alias : item.getName(); JpaPersistentItem pItem = new JpaPersistentItem(); try { pItem.setValue(StateHelper.toString(item.getState())); } catch (Exception e1) { logger.error("Error on converting state value to string: {}", e1.getMessage()); return; } pItem.setName(name); pItem.setRealName(item.getName()); pItem.setTimestamp(new Date()); EntityManager em = getEntityManagerFactory().createEntityManager(); try { logger.debug("Persisting item..."); em.getTransaction().begin(); em.persist(pItem); em.getTransaction().commit(); logger.debug("Persisting item...done"); } catch (Exception e) { logger.error("Error on persisting item! Rolling back!"); logger.error(e.getMessage(), e); em.getTransaction().rollback(); } finally { em.close(); } logger.debug("Storing item...done"); }
Source:
<code>void onPullRequestHook(PullRequest pr) throws IOException { GHPullRequest ghpr = pr.getPullRequest(); int number = pr.getNumber(); String action = pr.getAction(); boolean doSave = false; if ("closed".equals(action)) { pullRequests.remove(number); doSave = true; } else if (!trigger.isActive()) { LOGGER.log(Level.FINE, "Not processing Pull request since the build is disabled"); <START> } else if ("edited".equals(action) || "labeled".equals(action) || "opened".equals(action) <END> || "reopened".equals(action) || "synchronize".equals(action) || "unlabeled".equals(action)) { GhprbPullRequest pull = getPullRequest(ghpr, number); pull.check(ghpr, true); doSave = true; } else { LOGGER.log(Level.WARNING, "Unknown Pull Request hook action: {0}", action); } if (doSave) { try { this.save(); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Unable to save repository!", e); } } }</code><technical_language>move list of allowed labels a static defined lists check if label is list? This improve readability :) Also, do need alter kind of tests</technical_language>

Target:
void onPullRequestHook(PullRequest pr) throws IOException { GHPullRequest ghpr = pr.getPullRequest(); int number = pr.getNumber(); String action = pr.getAction(); boolean doSave = false; if ("closed".equals(action)) { pullRequests.remove(number); doSave = true; } else if (!trigger.isActive()) { LOGGER.log(Level.FINE, "Not processing Pull request since the build is disabled"); } else if (ALLOWED_ACTIONS.contains(action)) { GhprbPullRequest pull = getPullRequest(ghpr, number); pull.check(ghpr, true); doSave = true; } else { LOGGER.log(Level.WARNING, "Unknown Pull Request hook action: {0}", action); } if (doSave) { try { this.save(); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Unable to save repository!", e); } } }
Source:
<code>private void checkSensorValue(String sensorName, String expectedValue) { solo.clickOnText(sensorName); solo.clickOnView(solo.getView(R.id.formula_editor_keyboard_compute)); solo.waitForView(solo.getView(R.id.formula_editor_compute_dialog_textview)); TextView computeTextView = (TextView) solo.getView(R.id.formula_editor_compute_dialog_textview); String sensorValue = computeTextView.getText().toString(); boolean sensorContainsExpectedValue = sensorValue.equals(expectedValue); <START> assertTrue("Sensor value is:" + sensorValue + " but should be:" + expectedValue, sensorContainsExpectedValue); <END> solo.goBack(); solo.waitForView(solo.getView(R.id.formula_editor_edit_field)); solo.goBack(); }</code><technical_language>assertEquals(...)</technical_language>

Target:
private void checkSensorValue(String sensorName, String expectedValue) { solo.clickOnText(sensorName); solo.clickOnView(solo.getView(R.id.formula_editor_keyboard_compute)); solo.waitForView(solo.getView(R.id.formula_editor_compute_dialog_textview)); TextView computeTextView = (TextView) solo.getView(R.id.formula_editor_compute_dialog_textview); String sensorValue = computeTextView.getText().toString(); assertEquals(sensorValue, expectedValue); solo.goBack(); solo.waitForView(solo.getView(R.id.formula_editor_edit_field)); solo.goBack(); }
Source:
<code>public void shouldThrowExceptionIfNoTypeMappingWasFoundWithoutAffectingContentProviderBlocking() { final StorIOContentResolver storIOContentResolver = mock(StorIOContentResolver.class); final StorIOContentResolver.Internal internal = mock(StorIOContentResolver.Internal.class); when(storIOContentResolver.internal()).thenReturn(internal); when(storIOContentResolver.delete()).thenReturn(new PreparedDelete.Builder(storIOContentResolver)); final List<TestItem> items = asList(TestItem.newInstance(), TestItem.newInstance()); final PreparedDelete<DeleteResults<TestItem>> preparedDelete = storIOContentResolver .delete() .objects(items) .prepare(); try { preparedDelete.executeAsBlocking(); fail(); <START> } catch (StorIOException expected) { <END> } verify(storIOContentResolver).delete(); verify(storIOContentResolver).internal(); verify(internal).typeMapping(TestItem.class); verify(internal, never()).delete(any(DeleteQuery.class)); verifyNoMoreInteractions(storIOContentResolver, internal); }</code><technical_language>Please add assertion for exception type message, expected exception</technical_language>

Target:
public void shouldThrowExceptionIfNoTypeMappingWasFoundWithoutAffectingContentProviderBlocking() { final StorIOContentResolver storIOContentResolver = mock(StorIOContentResolver.class); final StorIOContentResolver.Internal internal = mock(StorIOContentResolver.Internal.class); when(storIOContentResolver.internal()).thenReturn(internal); when(storIOContentResolver.delete()).thenReturn(new PreparedDelete.Builder(storIOContentResolver)); final List<TestItem> items = asList(TestItem.newInstance(), TestItem.newInstance()); final PreparedDelete<DeleteResults<TestItem>> preparedDelete = storIOContentResolver .delete() .objects(items) .prepare(); try { preparedDelete.executeAsBlocking(); fail(); } catch (StorIOException expected) { TestUtils.checkException(expected, IllegalStateException.class); } verify(storIOContentResolver).delete(); verify(storIOContentResolver).internal(); verify(internal).typeMapping(TestItem.class); verify(internal, never()).delete(any(DeleteQuery.class)); verifyNoMoreInteractions(storIOContentResolver, internal); }
Source:
<code>protected AbstractId(final String canonical) { if (canonical == null || canonical.trim().isEmpty()) <START> throw new IllegalArgumentException("Id string provided can't be empty or null."); <END> this.canonical = canonical; }</code><technical_language>parameter name is "canonical", good word referencing parameter. suggestion throw new IllegalArgumentException("canonical id provided empty null.");</technical_language>

Target:
protected AbstractId(final String canonical) { this.canonical = Objects.requireNonNull(canonical, "canonical cannot be null"); }
Source:
<code>public boolean isDirectory() { boolean isDirectory; switch (mode) { case SFTP: return isDirectory(AppConfig.getInstance()); case SMB: SmbFile smbFile = getSmbFile(); try { isDirectory = smbFile != null && smbFile.isDirectory(); } catch (SmbException e) { isDirectory = false; } <START> break; <END> case FILE: isDirectory = getFile().isDirectory(); break; case ROOT: try { isDirectory = RootHelper.isDirectory(path, 5); } catch (ShellNotRunningException e) { e.printStackTrace(); isDirectory = false; } break; case OTG: isDirectory = false; break; default: isDirectory = getFile().isDirectory(); break; } return isDirectory; }</code><technical_language>printing stack trace for exception</technical_language>

Target:
public boolean isDirectory() { boolean isDirectory; switch (mode) { case SFTP: return isDirectory(AppConfig.getInstance()); case SMB: SmbFile smbFile = getSmbFile(); try { isDirectory = smbFile != null && smbFile.isDirectory(); } catch (SmbException e) { e.printStackTrace(); isDirectory = false; } break; case FILE: isDirectory = getFile().isDirectory(); break; case ROOT: try { isDirectory = RootHelper.isDirectory(path, 5); } catch (ShellNotRunningException e) { e.printStackTrace(); isDirectory = false; } break; case OTG: isDirectory = false; break; default: isDirectory = getFile().isDirectory(); break; } return isDirectory; }
Source:
<code>private static Optional<Method> getRemoveInputFunction(Class<?> clazz, Class<?> stateClass, Method inputFunction) { List<Method> removeInputFunctions = FunctionsParserHelper.findPublicStaticMethodsWithAnnotation(clazz, RemoveInputFunction.class).stream() .filter(method -> Arrays.equals(method.getParameterTypes(), inputFunction.getParameterTypes()) && Arrays.deepEquals(method.getParameterAnnotations(), inputFunction.getParameterAnnotations())) .collect(toImmutableList()); <START> checkArgument(removeInputFunctions.size() <= 1, "Ambiguous aggregation removeInput functions"); <END> if (removeInputFunctions.isEmpty()) { return Optional.empty(); } return Optional.of(removeInputFunctions.get(0)); }</code><technical_language>I checkState, checkArgument happen of wrong content of class passed wrong argument method, I understand transitivity of "wrong method wrong class passed argument"..</technical_language>

Target:
private static Optional<Method> getRemoveInputFunction(Class<?> clazz, Class<?> stateClass, Method inputFunction) { List<Method> removeInputFunctions = FunctionsParserHelper.findPublicStaticMethodsWithAnnotation(clazz, RemoveInputFunction.class).stream() .filter(method -> Arrays.equals(method.getParameterTypes(), inputFunction.getParameterTypes()) && Arrays.deepEquals(method.getParameterAnnotations(), inputFunction.getParameterAnnotations())) .collect(toImmutableList()); checkState(removeInputFunctions.size() <= 1, "Ambiguous aggregation removeInput functions"); if (removeInputFunctions.isEmpty()) { return Optional.empty(); } return Optional.of(removeInputFunctions.get(0)); }
Source:
<code>QueryResult<U> executeJoinQuery( @Nonnull final Table<K1, V1, M1> table1, @Nonnull final Table<K2, V2, M2> table2, @Nonnull final Predicate<CorfuStoreEntry<K1, V1, M1>> query1, @Nonnull final Predicate<CorfuStoreEntry<K2, V2, M2>> query2, @Nonnull final QueryOptions<K1, V1, M1, R> queryOptions1, @Nonnull final QueryOptions<K2, V2, M2, S> queryOptions2, @Nonnull final BiPredicate<R, S> joinPredicate, @Nonnull final BiFunction<R, S, T> joinFunction, final Function<T, U> joinProjection) { <START> applyWritesForReadOnTable(table1); table1.getMetrics().incNumScans(); applyWritesForReadOnTable(table1); table1.getMetrics().incNumScans(); <END> return Query.executeJoinQuery(table1, table2, query1, query2, queryOptions1, queryOptions2, joinPredicate, joinFunction, joinProjection); }</code><technical_language>is this done table1</technical_language>

Target:
QueryResult<U> executeJoinQuery( @Nonnull final Table<K1, V1, M1> table1, @Nonnull final Table<K2, V2, M2> table2, @Nonnull final Predicate<CorfuStoreEntry<K1, V1, M1>> query1, @Nonnull final Predicate<CorfuStoreEntry<K2, V2, M2>> query2, @Nonnull final QueryOptions<K1, V1, M1, R> queryOptions1, @Nonnull final QueryOptions<K2, V2, M2, S> queryOptions2, @Nonnull final BiPredicate<R, S> joinPredicate, @Nonnull final BiFunction<R, S, T> joinFunction, final Function<T, U> joinProjection) { applyWritesForReadOnTable(table1); table1.getMetrics().incNumJoins(); applyWritesForReadOnTable(table1); table2.getMetrics().incNumJoins(); return Query.executeJoinQuery(table1, table2, query1, query2, queryOptions1, queryOptions2, joinPredicate, joinFunction, joinProjection); }
Source:
<code><START> private void sendJsPlugin(File srcFile, ResourceKey key, <END> HttpServletRequest req, HttpServletResponse res) throws IOException { if (srcFile.exists()) { res.setHeader("Content-Length", Long.toString(srcFile.length())); res.setContentType("application/javascript"); writeToResponse(res, new FileInputStream(srcFile)); } else { resourceCache.put(key, Resource.NOT_FOUND); Resource.NOT_FOUND.send(req, res); } }</code><technical_language>This method sends JS for URL /plugins/{name}/static/. If plugin requests /static/logo.gif JS 404. is... confusing for JS developer. I return JS for name /static/ 404 for other</technical_language>

Target:
private void sendJsPlugin(File srcFile, ResourceKey key, HttpServletRequest req, HttpServletResponse res) throws IOException { if (srcFile.exists()) { res.setHeader("Content-Length", Long.toString(srcFile.length())); if (srcFile.getName().endsWith(".js")) { res.setContentType("application/javascript"); } writeToResponse(res, new FileInputStream(srcFile)); } else { resourceCache.put(key, Resource.NOT_FOUND); Resource.NOT_FOUND.send(req, res); } }