auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testEOF() { StringReader reader = new StringReader("test"); CharacterStreamReadingMessageSource source = new CharacterStreamReadingMessageSource(reader, -1, true); ApplicationEventPublisher publisher = mock(ApplicationEventPublisher.class); source.setApplicationEventPublisher(publisher); Message<?> message1 = source.receive(); assertEquals("test", message1.getPayload()); Message<?> message2 = source.receive(); assertNull(message2); <START> verify(publisher).publishEvent(any(ApplicationEvent.class)); <END> }</code><technical_language>M-m-m. work for StreamClosedEvent type</technical_language>

Target:
public void testEOF() { StringReader reader = new StringReader("test"); CharacterStreamReadingMessageSource source = new CharacterStreamReadingMessageSource(reader, -1, true); ApplicationEventPublisher publisher = mock(ApplicationEventPublisher.class); source.setApplicationEventPublisher(publisher); Message<?> message1 = source.receive(); assertEquals("test", message1.getPayload()); Message<?> message2 = source.receive(); assertNull(message2); verify(publisher).publishEvent(any(StreamClosedEvent.class)); }
Source:
<code>static <T, R> R apply(Function<T, R> f, T t) { try { return f.apply(t); } catch (Throwable ex) { <START> throw ExceptionHelper.wrapOrThrow(ex); <END> } }</code><technical_language>Inline</technical_language>

Target:
static <T, R> R apply(Function<T, R> f, T t) { try { return f.apply(t); } catch (Throwable ex) { throw Exceptions.propagate(ex); } }
Source:
<code>public int getUserId(String userName) { resultSet = executor.executeQuery("SELECT User_ID FROM Users WHERE Name LIKE '" + userName + "';"); if(resultSet == null) return -1; else { try { while(resultSet.next()) { return resultSet.getInt("User_ID"); } } catch (SQLException e) { <START> new IllegalStateException("SQL Error: " + e); <END> } } return -1; }</code><technical_language>throw please</technical_language>

Target:
public int getUserId(String userName) { resultSet = executor.executeQuery("SELECT User_ID FROM Users WHERE Name LIKE '" + userName + "';"); if(resultSet == null) return -1; else { try { while(resultSet.next()) { return resultSet.getInt("User_ID"); } } catch (SQLException e) { throw new IllegalStateException("SQL Error: " + e); } } return -1; }
Source:
<code>public void doNormalTreeRefAnalysis(TreeReference treeRef) throws AnalysisInvalidException { <START> if (treeRef.getName(0).equals(mainInstanceRoot)) { <END> this.result = true; this.shortCircuit = true; } }</code><technical_language>idea is provide 'main' instances</technical_language>

Target:
public void doNormalTreeRefAnalysis(TreeReference treeRef) throws AnalysisInvalidException { if (referenceRefersToMainInstance(treeRef)) { this.result = true; this.shortCircuit = true; } }
Source:
<code>public static boolean validateResources(IResource[] resources, Shell shell, String title) { List<IResource> readOnlyFiles= getReadonlyFiles(resources); if (readOnlyFiles.size() == 0) return true; Map<IFile, Long> oldTimeStamps= createModificationStampMap(readOnlyFiles); IFile[] files= readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]); IStatus status= ResourcesPlugin.getWorkspace().validateEdit(files, shell); if (!status.isOK()) { String message= getString("ValidateEdit.error.unable_to_perform"); displayError(shell, title, status, message); return false; } IStatus modified= null; Map<IFile, Long> newTimeStamps= createModificationStampMap(readOnlyFiles); <START> for (Iterator<IFile> iter= oldTimeStamps.keySet().iterator(); iter.hasNext();) { <END> IFile file= iter.next(); if (file.isReadOnly()) { IStatus entry= new Status(IStatus.ERROR, CompareUIPlugin.getPluginId(), VALIDATE_EDIT_PROBLEM, getFormattedString("ValidateEdit.error.stillReadonly", file.getFullPath().toString()), null); modified= addStatus(modified, entry); } else if (! oldTimeStamps.get(file).equals(newTimeStamps.get(file))) { IStatus entry= new Status(IStatus.ERROR, CompareUIPlugin.getPluginId(), VALIDATE_EDIT_PROBLEM, getFormattedString("ValidateEdit.error.fileModified", file.getFullPath().toString()), null); modified= addStatus(modified, entry); } } if (modified != null) { String message= getString("ValidateEdit.error.unable_to_perform"); displayError(shell, title, modified, message); return false; } return true; }</code><technical_language>modern for loop</technical_language>

Target:
public static boolean validateResources(IResource[] resources, Shell shell, String title) { List<IResource> readOnlyFiles= getReadonlyFiles(resources); if (readOnlyFiles.size() == 0) return true; Map<IFile, Long> oldTimeStamps= createModificationStampMap(readOnlyFiles); IFile[] files= readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]); IStatus status= ResourcesPlugin.getWorkspace().validateEdit(files, shell); if (!status.isOK()) { String message= getString("ValidateEdit.error.unable_to_perform"); displayError(shell, title, status, message); return false; } IStatus modified= null; Map<IFile, Long> newTimeStamps= createModificationStampMap(readOnlyFiles); for (Map.Entry<IFile, Long> entry : newTimeStamps.entrySet()) { IFile file = entry.getKey(); Long newTimeStamp = entry.getValue(); if (file.isReadOnly()) { IStatus error = new Status(IStatus.ERROR, CompareUIPlugin.getPluginId(), VALIDATE_EDIT_PROBLEM, getFormattedString("ValidateEdit.error.stillReadonly", file.getFullPath().toString()), null); modified= addStatus(modified, error); } else if (!oldTimeStamps.get(file).equals(newTimeStamp)) { IStatus error = new Status(IStatus.ERROR, CompareUIPlugin.getPluginId(), VALIDATE_EDIT_PROBLEM, getFormattedString("ValidateEdit.error.fileModified", file.getFullPath().toString()), null); modified= addStatus(modified, error); } } if (modified != null) { String message= getString("ValidateEdit.error.unable_to_perform"); displayError(shell, title, modified, message); return false; } return true; }
Source:
<code>public void testZKOperationsAfterClientSaslAuthFailure() throws Exception { CountdownWatcher watcher = new CountdownWatcher(); ZooKeeper zk = new ZooKeeper(hostPort, CONNECTION_TIMEOUT, watcher); watcher.waitForConnected(CONNECTION_TIMEOUT); try { setSaslFailureFlag(zk); int totalTry = 10; int tryCount = 0; boolean success = false; while (!success && tryCount++ <= totalTry) { try { zk.create("/saslAuthFail", "data".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL); success = true; } catch (KeeperException.ConnectionLossException e) { Thread.sleep(1000); } } <START> assertTrue("ZNode creation is failing continusly after Sasl auth failure.", success); <END> } finally { zk.close(); } }</code><technical_language>typo: continuously</technical_language>

Target:
public void testZKOperationsAfterClientSaslAuthFailure() throws Exception { CountdownWatcher watcher = new CountdownWatcher(); ZooKeeper zk = new ZooKeeper(hostPort, CONNECTION_TIMEOUT, watcher); watcher.waitForConnected(CONNECTION_TIMEOUT); try { setSaslFailureFlag(zk); int totalTry = 10; int tryCount = 0; boolean success = false; while (!success && tryCount++ <= totalTry) { try { zk.create("/saslAuthFail", "data".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL); success = true; } catch (KeeperException.ConnectionLossException e) { Thread.sleep(1000); } } assertTrue("ZNode creation is failing continuously after Sasl auth failure.", success); } finally { zk.close(); } }
Source:
<code>private void load() { <START> Toast.makeText(getApplicationContext(), R.string.loading, Toast.LENGTH_SHORT).show(); <END> new ReadFileTask(getContentResolver(), mFile, getExternalCacheDir(), (data) -> { switch (data.error) { case ReadFileTask.NORMAL: cacheFile = data.cachedFile; mOriginal = data.fileContents; try { mInput.setText(data.fileContents); if (data.fileContents.isEmpty()) { Toast.makeText(getApplicationContext(), R.string.file_empty, Toast.LENGTH_SHORT).show(); } else { mInput.setHint(null); } } catch (OutOfMemoryError e) { Toast.makeText(getApplicationContext(), R.string.error, Toast.LENGTH_SHORT).show(); finish(); } break; case ReadFileTask.EXCEPTION_STREAM_NOT_FOUND: Toast.makeText(getApplicationContext(), R.string.error_file_not_found, Toast.LENGTH_SHORT).show(); finish(); break; case ReadFileTask.EXCEPTION_IO: Toast.makeText(getApplicationContext(), R.string.error_io, Toast.LENGTH_SHORT).show(); finish(); break; } }).execute(); }</code><technical_language>I this a snackbar. For error snackbars activity is destroyed (and undissmissable dialogs undissmissable)</technical_language>

Target:
private void load() { Snackbar.make(scrollView, R.string.loading, Snackbar.LENGTH_SHORT).show(); new ReadFileTask(getContentResolver(), mFile, getExternalCacheDir(), (data) -> { switch (data.error) { case ReadFileTask.NORMAL: cacheFile = data.cachedFile; mOriginal = data.fileContents; try { mInput.setText(data.fileContents); if (data.fileContents.isEmpty()) { mInput.setHint(R.string.file_empty); } else { mInput.setHint(null); } } catch (OutOfMemoryError e) { Toast.makeText(getApplicationContext(), R.string.error, Toast.LENGTH_SHORT).show(); finish(); } break; case ReadFileTask.EXCEPTION_STREAM_NOT_FOUND: Toast.makeText(getApplicationContext(), R.string.error_file_not_found, Toast.LENGTH_SHORT).show(); finish(); break; case ReadFileTask.EXCEPTION_IO: Toast.makeText(getApplicationContext(), R.string.error_io, Toast.LENGTH_SHORT).show(); finish(); break; } }).execute(); }
Source:
<code>public void testACNVPlotting() { File tDir = IOUtils.tempDir("Test", "Plotting"); final String[] arguments = { <START> "-" + ExomeStandardArgumentDefinitions.ALLELIC_COUNTS_FILE_SHORT_NAME, SNP_COUNTS_FILE.getAbsolutePath(), <END> "-" + ExomeStandardArgumentDefinitions.TANGENT_NORMALIZED_COUNTS_FILE_SHORT_NAME, TANGENT_NORMALIZED_COVERAGE_FILE.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.SEGMENT_FILE_SHORT_NAME, SEGMENTS_FILE.getAbsolutePath(), "-" + StandardArgumentDefinitions.OUTPUT_SHORT_NAME, tDir.getAbsolutePath() }; runCommandLine(arguments); Assert.assertTrue(new File(tDir, sampleName + "_ACNV.png").exists()); Assert.assertTrue(new File(tDir, sampleName + "_ACNV.png").length() > 0); }</code><technical_language>is SNP_COUNTS_FILE in this context</technical_language>

Target:
public void testACNVPlotting() { File tDir = IOUtils.tempDir("Test", "Plotting"); final String[] arguments = { "-" + ExomeStandardArgumentDefinitions.ALLELIC_COUNTS_FILE_SHORT_NAME, TUMOR_ALLELIC_COUNTS_FILE.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.TANGENT_NORMALIZED_COUNTS_FILE_SHORT_NAME, TANGENT_NORMALIZED_COVERAGE_FILE.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.SEGMENT_FILE_SHORT_NAME, SEGMENTS_FILE.getAbsolutePath(), "-" + StandardArgumentDefinitions.OUTPUT_SHORT_NAME, tDir.getAbsolutePath() }; runCommandLine(arguments); Assert.assertTrue(new File(tDir, sampleName + "_ACNV.png").exists()); Assert.assertTrue(new File(tDir, sampleName + "_ACNV.png").length() > 0); }
Source:
<code>public boolean recordBackPressure(Integer taskId) { <START> return tasks.get(taskId).backpressure.getAndSet(true); <END> }</code><technical_language>return of this method switched. getAndSet is return previous value, is true if backpressure false if not. This is of * @return true if update recorded, false if taskId is BP This is control server sends messages client backpressure, happen frequently enough beginning frequently that</technical_language>

Target:
public boolean recordBackPressure(Integer taskId) { return tasks.get(taskId).backpressure.getAndSet(true) == false; }
Source:
<code><START> public HostValidator(VDS host) { <END> this.host = host; }</code><technical_language>private able initialize class? sense regular initialization do injecting members</technical_language>

Target:
protected HostValidator(VDS host) { this.host = host; }
Source:
<code>public ResourceGroupStateInfo( @JsonProperty("id") ResourceGroupId id, @JsonProperty("state") ResourceGroupState state, @JsonProperty("softMemoryLimit") DataSize softMemoryLimit, @JsonProperty("memoryUsage") DataSize memoryUsage, @JsonProperty("maxRunningQueries") int maxRunningQueries, @JsonProperty("maxQueuedQueries") int maxQueuedQueries, @JsonProperty("runningTimeLimit") Duration runningTimeLimit, @JsonProperty("queuedTimeLimit") Duration queuedTimeLimit, @JsonProperty("runningQueries") List<QueryStateInfo> runningQueries, @JsonProperty("numQueuedQueries") int numQueuedQueries) { this.id = requireNonNull(id, "id is null"); this.state = requireNonNull(state, "state is null"); this.softMemoryLimit = requireNonNull(softMemoryLimit, "softMemoryLimit is null"); this.memoryUsage = requireNonNull(memoryUsage, "memoryUsage is null"); this.maxRunningQueries = maxRunningQueries; this.maxQueuedQueries = maxQueuedQueries; <START> this.runningTimeLimit = runningTimeLimit; <END> this.queuedTimeLimit = queuedTimeLimit; this.runningQueries = ImmutableList.copyOf(requireNonNull(runningQueries, "runningQueries is null")); this.numQueuedQueries = numQueuedQueries; }</code><technical_language>supposed null if set? If not, requireNonNull</technical_language>

Target:
public ResourceGroupStateInfo( @JsonProperty("id") ResourceGroupId id, @JsonProperty("state") ResourceGroupState state, @JsonProperty("softMemoryLimit") DataSize softMemoryLimit, @JsonProperty("memoryUsage") DataSize memoryUsage, @JsonProperty("maxRunningQueries") int maxRunningQueries, @JsonProperty("maxQueuedQueries") int maxQueuedQueries, @JsonProperty("runningTimeLimit") Duration runningTimeLimit, @JsonProperty("queuedTimeLimit") Duration queuedTimeLimit, @JsonProperty("runningQueries") List<QueryStateInfo> runningQueries, @JsonProperty("numQueuedQueries") int numQueuedQueries) { this.id = requireNonNull(id, "id is null"); this.state = requireNonNull(state, "state is null"); this.softMemoryLimit = requireNonNull(softMemoryLimit, "softMemoryLimit is null"); this.memoryUsage = requireNonNull(memoryUsage, "memoryUsage is null"); this.maxRunningQueries = maxRunningQueries; this.maxQueuedQueries = maxQueuedQueries; this.runningTimeLimit = requireNonNull(runningTimeLimit, "runningTimeLimit is null"); this.queuedTimeLimit = requireNonNull(queuedTimeLimit, "queuedTimeLimit is null"); this.runningQueries = ImmutableList.copyOf(requireNonNull(runningQueries, "runningQueries is null")); this.numQueuedQueries = numQueuedQueries; }
Source:
<code>public static String getNextNodeName() { String testName = getSimpleName(getCurrentTestName()); int index = getTestResources(testName).addNode(); <START> return (testName != null ? testName + "-" : "") + "Node" + getNameForIndex(index); <END> }</code><technical_language>need check for testName != null. I null if is, getTestResources(testName) throw a NPE accessing map</technical_language>

Target:
public static String getNextNodeName() { String testName = getCurrentTestName(); TestResources resources = getTestResources(testName); String simpleName = resources.getSimpleName(); int nextNodeIndex = resources.addNode(); return simpleName + "-" + "Node" + getNameForIndex(nextNodeIndex); }
Source:
<code>void delete(final String rawPath, final MantaHttpHeaders requestHeaders, final Integer pruneDepth) throws IOException { Validate.notBlank(rawPath, "rawPath must not be blank"); String path = formatPath(rawPath); <START> if (pruneDepth == null) { <END> LOG.debug("DELETE {}", path); httpHelper.httpDelete(path, requestHeaders); } else { PruneEmpytParentDirectoryStrategy.pruneParentDirectories(this, requestHeaders, path, pruneDepth); } }</code><technical_language>good handle 0 case in PruneEmpytParentDirectoryStrategy easier next maintainer if this check pruneDepth == null || pruneDepth == 0 (since fact null means unboxing safe)</technical_language>

Target:
void delete(final String rawPath, final MantaHttpHeaders requestHeaders, final Integer pruneDepth) throws IOException { Validate.notBlank(rawPath, "rawPath must not be blank"); String path = formatPath(rawPath); if (pruneDepth == null || pruneDepth == 0) { LOG.debug("DELETE {}", path); httpHelper.httpDelete(path, requestHeaders); } else { PruneEmpytParentDirectoryStrategy.pruneParentDirectories(this, requestHeaders, path, pruneDepth); } }
Source:
<code>public void accept(long blockNumber) { if (persistenceConfiguration.get().writePauseDurationMillis() == 0) { return; } if (shouldBackoffBeforeWritingBlockNumber(blockNumber)) { try { <START> long sweepPauseMillis = persistenceConfiguration.get().writePauseDurationMillis(); <END> log.info("Invoking backoff for ms, because we are writing block of a stream", SafeArg.of("blockNumber", blockNumber), SafeArg.of("sweepPauseMillis", sweepPauseMillis)); backoff.backoff(sweepPauseMillis); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }</code><technical_language>This sweepPauseMillis, this is sweep</technical_language>

Target:
public void accept(long blockNumber) { if (persistenceConfiguration.get().writePauseDurationMillis() == 0) { return; } if (shouldBackoffBeforeWritingBlockNumber(blockNumber)) { try { long writePauseDurationMillis = persistenceConfiguration.get().writePauseDurationMillis(); log.info("Invoking backoff for ms, because we are writing block of a stream", SafeArg.of("blockNumber", blockNumber), SafeArg.of("writePauseDurationMillis", writePauseDurationMillis)); backoff.backoff(writePauseDurationMillis); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }
Source:
<code>public <P> HeaderEnricherSpec expirationDateFunction(Function<Message<P>, Object> expirationDateFunction) { <START> return priorityFunction(expirationDateFunction, null); <END> }</code><technical_language>copy/paste</technical_language>

Target:
public <P> HeaderEnricherSpec expirationDateFunction(Function<Message<P>, Object> expirationDateFunction) { return expirationDateFunction(expirationDateFunction, null); }
Source:
<code>public String getHumanReadableString(Date date) { <START> return date == null ? ConvertedTime.NOT_AVAILABLE.toString() : new SimpleDateFormat("dd MMM, yyyy 'at' HH:mm:ss", Locale.ENGLISH) <END> .format(date); }</code><technical_language>Creating new instances of SimpleDateFormat is expensive. Formatting dates is expensive too. static thread safe either. Consider a static instance of org.joda.time.format.DateTimeFormatter instead</technical_language>

Target:
public String getHumanReadableString(Date date) { return date == null ? ConvertedTime.NOT_AVAILABLE.toString() : dateFormatter.print(new DateTime(date)); }
Source:
<code>public void run() { synchronized (managedStateImpl.commitLock) { long bytesSum = 0; for (Bucket bucket : managedStateImpl.buckets) { if (bucket != null) { bytesSum += bucket.getSizeInBytes(); } } if (bytesSum > managedStateImpl.getMaxMemorySize()) { Duration duration = managedStateImpl.getDurationPreventingFreeingSpace(); long durationMillis = 0; if (duration != null) { durationMillis = duration.getMillis(); } bucketAcessLock.writeLock().lock(); try { for (BucketIdTimeWrapper releaseItem : bucketHeapForRelease) { bucketHeapForAccess.add(releaseItem); } bucketHeapForRelease.clear(); TreeSet<BucketIdTimeWrapper> tmp = bucketHeapForAccess; bucketHeapForAccess = bucketHeapForRelease; bucketHeapForRelease = tmp; <START> } finally { <END> bucketAcessLock.writeLock().unlock(); } Iterator<BucketIdTimeWrapper> bucketIter = bucketHeapForRelease.iterator(); BucketIdTimeWrapper idTimeWrapper; while (bytesSum > managedStateImpl.getMaxMemorySize() && bucketIter.hasNext()) { idTimeWrapper = bucketIter.next(); if (System.currentTimeMillis() - idTimeWrapper.lastAccessedTime < durationMillis) { break; } long bucketId = idTimeWrapper.bucketId; Bucket bucket = managedStateImpl.getBucket(bucketId); if (bucket != null) { synchronized (bucket) { long sizeFreed; try { sizeFreed = bucket.freeMemory(managedStateImpl.getCheckpointManager().getLastTransferredWindow()); LOG.debug("bucket freed {}", bucketId, sizeFreed); } catch (IOException e) { managedStateImpl.throwable.set(e); throw new RuntimeException("freeing " + bucketId, e); } bytesSum -= sizeFreed; } if (bucket.getSizeInBytes() == 0) { bucketIter.remove(); } } } } } }</code><technical_language>this code is doing. Is putting items in bucketHeapForAccess bucketHeapForRelease</technical_language>

Target:
public void run() { synchronized (managedStateImpl.commitLock) { long bytesSum = 0; for (Bucket bucket : managedStateImpl.buckets) { if (bucket != null) { bytesSum += bucket.getSizeInBytes(); } } if (bytesSum > managedStateImpl.getMaxMemorySize()) { Duration duration = managedStateImpl.getDurationPreventingFreeingSpace(); long durationMillis = 0; if (duration != null) { durationMillis = duration.getMillis(); } synchronized (bucketLastAccess) { long now = System.currentTimeMillis(); for (Iterator<Map.Entry<Long, MutableLong>> iterator = bucketLastAccess.entrySet().iterator(); bytesSum > managedStateImpl.getMaxMemorySize() && iterator.hasNext(); ) { Map.Entry<Long, MutableLong> entry = iterator.next(); if (now - entry.getValue().longValue() < durationMillis) { break; } long bucketId = entry.getKey(); Bucket bucket = managedStateImpl.getBucket(bucketId); if (bucket != null) { synchronized (bucket) { long sizeFreed; try { sizeFreed = bucket.freeMemory(managedStateImpl.getCheckpointManager().getLastTransferredWindow()); LOG.debug("bucket freed {}", bucketId, sizeFreed); } catch (IOException e) { managedStateImpl.throwable.set(e); throw new RuntimeException("freeing " + bucketId, e); } bytesSum -= sizeFreed; } if (bucket.getSizeInBytes() == 0) { iterator.remove(); } } } } } } }
Source:
<code>private boolean isUpdateRequired(VM.VMStatus status){ <START> if (status == VM.VMStatus.Up || status == VM.VMStatus.PoweringDown || status == VM.VMStatus.Paused) { <END> return true; } return false; }</code><technical_language>switch/case</technical_language>

Target:
private boolean isUpdateRequired(VM.VMStatus status) { switch (status) { case Up: case PoweringDown: case Paused: return true; default: return false; } }
Source:
<code>public void testConversionTable() { for (int element = 0; element < DSTFileGenerator.CONVERSIONTABLE.length; element++) { int value = getValueForByte(DSTFileGenerator.CONVERSIONTABLE[element]); if (element > 121) { <START> assertEquals((element - 121) * (-1), value); <END> } else { assertEquals(element, value); } } }</code><technical_language>easier understand, easier whats wrong if breaks, if youd compile a expected actual list compare arrayEquals</technical_language>

Target:
public void testConversionTable() { int[] valueArray = new int[DSTFileGenerator.CONVERSION_TABLE.length]; for (int element = 0; element < DSTFileGenerator.CONVERSION_TABLE.length; element++) { if (element <= 121) { valueArray[element] = getByteForValue(element); } else { valueArray[element] = getByteForValue((element - 121) * (-1)); } } assertArrayEquals(DSTFileGenerator.CONVERSION_TABLE, valueArray); }
Source:
<code>public Object visitUnknownCommand(InvocationContext ctx, VisitableCommand command) throws Throwable { <START> return CompletableFutures.await(command.invokeAsync(componentRegistry)); <END> }</code><technical_language>suggestion throw new UnsupportedOperationException();</technical_language>

Target:
public Object visitUnknownCommand(InvocationContext ctx, VisitableCommand command) throws Throwable { return command.invoke(); }
Source:
<code>public String storeRunInfo(int configuration_id, String url, String author, String repo, String comment) { try { Connection conn = getConnection(); String sql = "INSERT INTO records (configuration_id, url, author, repo, comment) VALUES (?, ?, ?, ?, ?)"; PreparedStatement stmt = conn.prepareStatement(sql); stmt.setInt(1, configuration_id); stmt.setString(2, url); stmt.setString(3, author); stmt.setString(4, repo); stmt.setString(5, comment); stmt.executeUpdate(); sql = "SELECT MAX(record_id) FROM records;"; stmt = conn.prepareStatement(sql); <START> ResultSet recordIDRS = stmt.executeQuery(); <END> recordIDRS.first(); int record_id = recordIDRS.getInt(1); return Integer.toString(record_id); } catch (Exception e) { throw new RuntimeException(e); } }</code><technical_language>query update part of a sql transaction together? in other places function multiple sql statements</technical_language>

Target:
public String storeRunInfo(int configuration_id, String url, String author, String repo, String comment) { try { Connection conn = getConnection(); String sql = "INSERT INTO records (configuration_id, url, author, repo, comment) VALUES (?, ?, ?, ?, ?)"; PreparedStatement stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); stmt.setInt(1, configuration_id); stmt.setString(2, url); stmt.setString(3, author); stmt.setString(4, repo); stmt.setString(5, comment); stmt.executeUpdate(); ResultSet newID = stmt.getGeneratedKeys(); newID.first(); int record_id = newID.getInt(1); conn.close(); return Integer.toString(record_id); } catch (Exception e) { throw new RuntimeException(e); } }
Source:
<code>private Profile getBasicProfile() { try{ String basicProfilePath = "/basic_profile.ccpr"; InputStream is = this.getClass().getResourceAsStream(basicProfilePath); if(is == null) { throw new RuntimeException("Test resource missing: " + basicProfilePath); } ProfileParser parser = new ProfileParser(is, mAppPlatform.getInstance(), mFreshResourceTable, "profile", Resource.RESOURCE_VERSION_UNKNOWN, false); Profile p = parser.parse(); <START> return p; <END> } catch(Exception e) { throw PersistableSandbox.wrap("Error during profile test setup", e); } }</code><technical_language>return parser.parse();</technical_language>

Target:
private Profile getBasicProfile() { try{ String basicProfilePath = "/basic_profile.ccpr"; InputStream is = this.getClass().getResourceAsStream(basicProfilePath); if(is == null) { throw new RuntimeException("Test resource missing: " + basicProfilePath); } ProfileParser parser = new ProfileParser(is, mAppPlatform.getInstance(), mFreshResourceTable, "profile", Resource.RESOURCE_VERSION_UNKNOWN, false); return parser.parse(); } catch(Exception e) { throw PersistableSandbox.wrap("Error during profile test setup", e); } }
Source:
<code>public ArrayDefinition lookupArray(String name) { Definition def = lookupDefinition(name); <START> return (ArrayDefinition) ((def.getDeclaration() instanceof ArrayDeclaration) ? def : null); <END> }</code><technical_language>do (def instanceof ArrayDefinition)</technical_language>

Target:
public ArrayDefinition lookupArray(String name) { Definition def = lookupDefinition(name); return (ArrayDefinition) ((def instanceof ArrayDefinition) ? def : null); }
Source:
<code>public void shouldVoidDiagnosis() throws Exception { Diagnosis diagnosis = diagnosisService.getDiagnosisByUuid(getUuid()); Assert.assertFalse(diagnosis.isVoided()); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); req.addParameter("reason", "test"); handle(req); diagnosis = diagnosisService.getDiagnosisByUuid(getUuid()); Assert.assertTrue(diagnosis.isVoided()); Assert.assertEquals("test", diagnosis.getVoidReason()); <START> Assert.assertNotNull(diagnosis.getDateVoided()); <END> Assert.assertNotNull(diagnosis.getVoidedBy()); }</code><technical_language>Assert voided user is currently authenticated user</technical_language>

Target:
public void shouldVoidDiagnosis() throws Exception { Diagnosis diagnosis = diagnosisService.getDiagnosisByUuid(getUuid()); Assert.assertFalse(diagnosis.isVoided()); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); req.addParameter("reason", "test"); handle(req); diagnosis = diagnosisService.getDiagnosisByUuid(getUuid()); Assert.assertTrue(diagnosis.isVoided()); Assert.assertEquals("test", diagnosis.getVoidReason()); Assert.assertNotNull(diagnosis.getDateVoided()); Assert.assertNotNull(diagnosis.getVoidedBy()); Assert.assertEquals(Context.getAuthenticatedUser().getUuid(), diagnosis.getVoidedBy().getUuid()); }
Source:
<code>public SpellResult perform(CastContext context) { if (!(context.getTargetEntity() instanceof Player)) return null; Player p = ((Player) context.getTargetEntity()); if (randomizedMessages == null || randomizedMessages.isEmpty()) { if (message == null) return SpellResult.FAIL; <START> if (translateAltColorCodes) message = ChatColor.translateAlternateColorCodes(altColorCode, message); <END> p.chat(message); } else { if (translateAltColorCodes) { for (int i = 0; i < randomizedMessages.size(); i++) { randomizedMessages.set(i, ChatColor.translateAlternateColorCodes(altColorCode, randomizedMessages.get(i))); } } p.chat(randomizedMessages.get(ThreadLocalRandom.current().nextInt(randomizedMessages.size()))); } return SpellResult.CAST; }</code><technical_language>do this translation load time in #prepare(CastContext,ConfigurationSection)</technical_language>

Target:
public SpellResult perform(CastContext context) { if (!(context.getTargetEntity() instanceof Player)) return SpellResult.PLAYER_REQUIRED; Player p = ((Player) context.getTargetEntity()); p.chat(message); return SpellResult.CAST; }
Source:
<code>public List<DroolsFromUniConstraintStream<Solution_, Object>> getFromStreamList() { if (parent == null) { DroolsJoinBiConstraintStream<Solution_, A, B> joinStream = (DroolsJoinBiConstraintStream<Solution_, A, B>) this; List<DroolsFromUniConstraintStream<Solution_, Object>> leftParentFromStreamList = joinStream.getLeftParentStream().getFromStreamList(); List<DroolsFromUniConstraintStream<Solution_, Object>> rightParentFromStreamList = joinStream.getRightParentStream().getFromStreamList(); return Stream.concat(leftParentFromStreamList.stream(), rightParentFromStreamList.stream()) <START> .distinct() <END> .collect(Collectors.toList()); } else { return parent.getFromStreamList(); } }</code><technical_language>1) distinct happen here? I doubt it: expect caller of getFromStreamList() do distinct too, a perf loss do in too. 2) Is distinct worth anything? Do From's implement equals/hashcode? in doubt, leave out put in a "TODO distinct?"</technical_language>

Target:
public List<DroolsFromUniConstraintStream<Solution_, Object>> getFromStreamList() { if (parent == null) { DroolsJoinBiConstraintStream<Solution_, A, B> joinStream = (DroolsJoinBiConstraintStream<Solution_, A, B>) this; List<DroolsFromUniConstraintStream<Solution_, Object>> leftParentFromStreamList = joinStream.getLeftParentStream().getFromStreamList(); List<DroolsFromUniConstraintStream<Solution_, Object>> rightParentFromStreamList = joinStream.getRightParentStream().getFromStreamList(); return Stream.concat(leftParentFromStreamList.stream(), rightParentFromStreamList.stream()) .collect(Collectors.toList()); } else { return parent.getFromStreamList(); } }
Source:
<code>public void registerModuleMusic(String moduleName, final GameOptions options) { if (currentlyRegisteredModule != null) { if (moduleName.equals(currentlyRegisteredModule)) { stopMusic(); playMusicTrack(this.musicMap.get(GAME_MUSIC_SET).get(2), options); return; } else { unregisterModuleMusic(); currentlyRegisteredModule = null; } } if (Assets.getAssetHelper().list(Json.class, moduleName + ":musicConfig").isEmpty()) { logger.warn("Music config not found for module " + moduleName + ":musicConfig"); return; } Json musicJson = Assets.getJson(moduleName + ":musicConfig"); MusicConfig musicConfig = MusicConfig.load(moduleName, musicJson.getJsonValue()); <START> Map<String, List<String>> musicMap = musicConfig.getMusicMap(); <END> for (String music : musicMap.get(GAME_MUSIC_SET)) { registerMusic(GAME_MUSIC_SET, music); logger.info("Registered " + music); } currentlyRegisteredModule = moduleName; stopMusic(); playMusicTrack(this.musicMap.get(GAME_MUSIC_SET).get(2), options); }</code><technical_language>This local musicMap variable _hides_ musicMap instance variable declared top of a class, a bad practice common of bugs. IDE highlighting this into. simply rename local variable watch out - is a bug? _Which_ musicMap needing interact in this method</technical_language>

Target:
public void registerModuleMusic(String moduleName, final GameOptions options) { if (currentlyRegisteredModule != null) { if (moduleName.equals(currentlyRegisteredModule)) { stopMusic(); playMusicTrack(this.musicMap.get(GAME_MUSIC_SET).get(2), options); return; } else { unregisterModuleMusic(); currentlyRegisteredModule = null; } } if (Assets.getAssetHelper().list(Json.class, moduleName + ":musicConfig").isEmpty()) { return; } else { logger.info("Music Config found for module " + moduleName); } Json musicJson = Assets.getJson(moduleName + ":musicConfig"); MusicConfig musicConfig = MusicConfig.load(moduleName, musicJson.getJsonValue()); Map<String, List<String>> musicSets = musicConfig.getMusicMap(); for (String music : musicSets.get(GAME_MUSIC_SET)) { registerMusic(GAME_MUSIC_SET, music); logger.info("Registered " + music); } currentlyRegisteredModule = moduleName; stopMusic(); playMusicTrack(this.musicMap.get(GAME_MUSIC_SET).get(2), options); }
Source:
<code>public void bind(Moshi moshi, JsonAdapter.Factory factory) { if (jsonAdapters.length > 0) { Type[] parameterTypes = method.getGenericParameterTypes(); Annotation[][] parameterAnnotations = method.getParameterAnnotations(); for (int i = adaptersOffset, size = parameterTypes.length; i < size; i++) { Type type = ((ParameterizedType) parameterTypes[i]).getActualTypeArguments()[0]; Set<? extends Annotation> jsonAnnotations = jsonAnnotations(parameterAnnotations[i]); <START> if (this.type == type && annotations.equals(jsonAnnotations)) { <END> jsonAdapters[i - adaptersOffset] = moshi.nextAdapter(factory, type, jsonAnnotations); } else { jsonAdapters[i - adaptersOffset] = moshi.adapter(type, jsonAnnotations); } } } }</code><technical_language>this Types.equal(). In general == .equals() works java.lang.reflect.Type. (for example, String[].class equal parameter of List<String[]>.class)</technical_language>

Target:
public void bind(Moshi moshi, JsonAdapter.Factory factory) { if (jsonAdapters.length > 0) { Type[] parameterTypes = method.getGenericParameterTypes(); Annotation[][] parameterAnnotations = method.getParameterAnnotations(); for (int i = adaptersOffset, size = parameterTypes.length; i < size; i++) { Type type = ((ParameterizedType) parameterTypes[i]).getActualTypeArguments()[0]; Set<? extends Annotation> jsonAnnotations = jsonAnnotations(parameterAnnotations[i]); jsonAdapters[i - adaptersOffset] = Types.equals(this.type, type) && annotations.equals(jsonAnnotations) ? moshi.nextAdapter(factory, type, jsonAnnotations) : moshi.adapter(type, jsonAnnotations); } } }
Source:
<code>public Observable<LoginResponse> login(Account account) { String url = userManager.getSiteUrl(account); String username = userManager.getUsername(account); String password = userManager.getPassword(account); Observable<LoginResponse> result = null; try { result = login(url, username, password); } catch (ExecutionException e) { <START> e.printStackTrace(); <END> } catch (InterruptedException e) { e.printStackTrace(); } return result; }</code><technical_language>wanna <LINK_0></technical_language>

Target:
public Observable<LoginResponse> login(Account account) { String url = userManager.getSiteUrl(account); String username = userManager.getUsername(account); String password = userManager.getPassword(account); Observable<LoginResponse> result = null; result = login(url, username, password); return result; }
Source:
<code>protected void pulsePhysics() { <START> if (boundingBox == null) { <END> Vector size = boundingBox.getSize(); for (Entity entity : world.getNearbyEntities( location, size.getX(), size.getY(), size.getZ())) { if (entity instanceof LivingEntity && entity != this && !(entity.equals(shooter))) { collide((LivingEntity) entity); break; } } } super.pulsePhysics(); }</code><technical_language>boundingBox != null ;)</technical_language>

Target:
protected void pulsePhysics() { if (boundingBox != null) { Vector size = boundingBox.getSize(); for (Entity entity : world.getNearbyEntities( location, size.getX(), size.getY(), size.getZ())) { if (entity instanceof LivingEntity && entity != this && !(entity.equals(shooter))) { collide((LivingEntity) entity); break; } } } super.pulsePhysics(); }
Source:
<code>public IToHex getInstance(DiscreteElement<?> elementType){ if(elementType instanceof EnumeratedElement){ iToHex = new EnumToHex(); return iToHex; } else if (elementType instanceof <START> RealElement || elementType instanceof FixedPointElement || elementType instanceof Float32Element || elementType instanceof Float64Element <END> || elementType instanceof Dec32Element){ iToHex = new RealToHex(); return iToHex; } else if (elementType instanceof IntegerElement){ iToHex = new IntToHex(); return iToHex; } else{ iToHex = new CharToHex(); } return iToHex; }</code><technical_language>extra checks necessary extend RealElement</technical_language>

Target:
public IToHex getInstance(DiscreteElement<?> elementType){ if(elementType instanceof EnumeratedElement){ iToHex = new EnumToHex(); return iToHex; } else if (elementType instanceof RealElement){ iToHex = new RealToHex(); return iToHex; } else if (elementType instanceof IntegerElement){ iToHex = new IntToHex(); return iToHex; }else if (elementType instanceof EmptyEnum_Element){ return new EmptyEnumToHex(); }else if (elementType instanceof LongIntegerElement){ return new LongToHex(); }else if (elementType instanceof StringElement){ return new StringToHex(); }else if (elementType instanceof SignedInteger16Element){ return new SignedIntToHex(); } else{ iToHex = new CharToHex(); } return iToHex; }
Source:
<code>public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { <START> addPreferencesFromResource(R.xml.preferences_notification); <END> setUpScreen(); }</code><technical_language>Please rename xml file preferences_notifications (plural). I reads a bit better. Java class name is fine as-is</technical_language>

Target:
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { addPreferencesFromResource(R.xml.preferences_notifications); setUpScreen(); }
Source:
<code>public static VDSGroup map(SchedulingPolicy model, VDSGroup template) { VDSGroup entity = template != null ? template : new VDSGroup(); if (model.isSetId()) { entity.setClusterPolicyId(GuidUtils.asGuid(model.getId())); } if (model.isSetPolicy()) { SchedulingPolicyType policyType = SchedulingPolicyType.fromValue(model.getPolicy()); if (policyType != null) { ClusterPolicy clusterPolicy = new ClusterPolicy(); <START> clusterPolicy.setName(policyType.name().toLowerCase()); <END> clusterPolicy.setId(null); entity.setClusterPolicy(clusterPolicy); } } if (model.isSetThresholds()) { SchedulingPolicyThresholds thresholds = model.getThresholds(); if (entity.getClusterPolicyProperties() == null) { entity.setClusterPolicyProperties(new LinkedHashMap<String, String>()); } if (thresholds.getLow() != null) { entity.getClusterPolicyProperties().put(LOW_UTILIZATION, thresholds.getLow().toString()); } if (thresholds.getHigh() != null) { entity.getClusterPolicyProperties().put(HIGH_UTILIZATION, thresholds.getHigh().toString()); } if (thresholds.getDuration() != null) { int round = Math.round(thresholds.getDuration() / 60.0f); entity.getClusterPolicyProperties().put(CPU_OVER_COMMIT_DURATION_MINUTES, Integer.toString(round)); } } return entity; }</code><technical_language>is this needed? rebase issue</technical_language>

Target:
public static VDSGroup map(SchedulingPolicy model, VDSGroup template) { VDSGroup entity = template != null ? template : new VDSGroup(); if (model.isSetId()) { entity.setClusterPolicyId(GuidUtils.asGuid(model.getId())); } if (model.isSetPolicy() || model.isSetName()) { String policyName = model.isSetName() ? model.getName() : model.getPolicy(); ClusterPolicy clusterPolicy = new ClusterPolicy(); clusterPolicy.setName(policyName.toLowerCase()); clusterPolicy.setId(null); entity.setClusterPolicy(clusterPolicy); } if (model.isSetThresholds()) { SchedulingPolicyThresholds thresholds = model.getThresholds(); if (entity.getClusterPolicyProperties() == null) { entity.setClusterPolicyProperties(new LinkedHashMap<String, String>()); } if (thresholds.getLow() != null) { entity.getClusterPolicyProperties().put(LOW_UTILIZATION, thresholds.getLow().toString()); } if (thresholds.getHigh() != null) { entity.getClusterPolicyProperties().put(HIGH_UTILIZATION, thresholds.getHigh().toString()); } if (thresholds.getDuration() != null) { int round = Math.round(thresholds.getDuration() / 60.0f); entity.getClusterPolicyProperties().put(CPU_OVER_COMMIT_DURATION_MINUTES, Integer.toString(round)); } } return entity; }
Source:
<code>public void addTask(TaskType t, long delay, Object o){ try { if (AppConfig.getInstance().isJsonEvents()){ <START> JsonRpcNotification jsonRpcNotification = new JsonRpcNotification(); <END> jsonRpcNotification.fireEvents(t, delay, o); }else{ TaskProcessor.getInstance().addTask(new TaskRequest(t, delay, o)); } }catch (Exception e){ log.error("wrapping task error {}", e.toString()); } }</code><technical_language>create JsonRpcNotification time want fire event? Please instance variable for this class</technical_language>

Target:
public static void addTask(TaskType t, long delay, Object o){ try { if (AppConfig.getInstance().isJsonEvents()){ JsonRpcNotification jsonRpcNotification = new JsonRpcNotification(); jsonRpcNotification.fireEvents(t, delay, o); }else{ TaskProcessor.getInstance().addTask(new TaskRequest(t, delay, o)); } }catch (Exception e){ log.error("wrapping task error {}", e.toString()); } }
Source:
<code>public void setUp() throws SQLException { super.setUp(); if (testType.equals(MATCHER_EXECUTION)) { im = new MockMatcherIndexManager(ds); } else if (testType.equals(STANDARD_EXECUTION)) { im = new IndexManager(ds); } assertThat(im, is(notNullValue())); db = TestUtils.getDatabaseConnectionToExistingDb(im.getDatabase()); assertThat(db, is(notNullValue())); assertThat(im.getQueue(), is(notNullValue())); String[] metadataTableList = new String[] { IndexManager.INDEX_METADATA_TABLE_NAME }; <START> SQLDatabaseTestUtils.assertTablesExist(TestUtils.getDatabaseConnectionToExistingDb(db), <END> metadataTableList); }</code><technical_language>here, pass db method call</technical_language>

Target:
public void setUp() throws SQLException { super.setUp(); if (testType.equals(MATCHER_EXECUTION)) { im = new MockMatcherIndexManager(ds); } else if (testType.equals(STANDARD_EXECUTION)) { im = new IndexManager(ds); } assertThat(im, is(notNullValue())); db = TestUtils.getDatabaseConnectionToExistingDb(im.getDatabase()); assertThat(db, is(notNullValue())); assertThat(im.getQueue(), is(notNullValue())); String[] metadataTableList = new String[] { IndexManager.INDEX_METADATA_TABLE_NAME }; SQLDatabaseTestUtils.assertTablesExist(db, metadataTableList); }
Source:
<code>protected void destroyUnattachedVBD(Connection conn, VM vm) { try { for (VBD vbd : vm.getVBDs(conn)) { if (Types.VbdType.DISK.equals(vbd.getType(conn)) && !vbd.getCurrentlyAttached(conn)) { vbd.destroy(conn); } } } catch (final Exception e) { <START> s_logger.debug("destroyUnattachedVBD failed due to " + e.toString()); <END> } }</code><technical_language>add exception or/and catch more specific exceptions</technical_language>

Target:
protected void destroyUnattachedVBD(Connection conn, VM vm) { try { for (VBD vbd : vm.getVBDs(conn)) { if (Types.VbdType.DISK.equals(vbd.getType(conn)) && !vbd.getCurrentlyAttached(conn)) { vbd.destroy(conn); } } } catch (final Exception e) { s_logger.debug("Failed to destroy unattached VBD due to ", e); } }
Source:
<code>public Set<String> preSelect(Set<String> onlineSegments) { Set<String> segmentsToProcess = new HashSet<>(onlineSegments); SegmentLineage segmentLineage = SegmentLineageAccessHelper.getSegmentLineage(_propertyStore, _tableNameWithType); Set<String> segmentsToRemove = new HashSet<>(); <START> if (segmentLineage != null) { <END> for (String lineageEntryId : segmentLineage.getLineageEntryIds()) { LineageEntry lineageEntry = segmentLineage.getLineageEntry(lineageEntryId); if (lineageEntry.getState() == LineageEntryState.COMPLETED && onlineSegments .containsAll(lineageEntry.getSegmentsTo())) { segmentsToRemove.addAll(lineageEntry.getSegmentsFrom()); } else { segmentsToRemove.addAll(lineageEntry.getSegmentsTo()); } } } segmentsToProcess.removeAll(segmentsToRemove); return segmentsToProcess; }</code><technical_language>Check lineage creating segmentsToProcess segmentsToRemove. If lineage exist, return onlineSegments prevent unnecessary overhead. (Optional) Consider modifying onlineSegments in-place</technical_language>

Target:
public Set<String> preSelect(Set<String> onlineSegments) { SegmentLineage segmentLineage = SegmentLineageAccessHelper.getSegmentLineage(_propertyStore, _tableNameWithType); if (segmentLineage != null) { for (String lineageEntryId : segmentLineage.getLineageEntryIds()) { LineageEntry lineageEntry = segmentLineage.getLineageEntry(lineageEntryId); if (lineageEntry.getState() == LineageEntryState.COMPLETED) { onlineSegments.removeAll(lineageEntry.getSegmentsFrom()); } else { onlineSegments.removeAll(lineageEntry.getSegmentsTo()); } } } return onlineSegments; }
Source:
<code>public void findMissingEnumNames() { boolean missingKey = false; for (ConfigurationValues configValue : ConfigurationValues.values()) { if (!configValuesEnumNames.contains(configValue.toString())) { log.error("Found missing key: " + configValue.toString()); missingKey = true; break; } } <START> assertFalse(missingKey); <END> }</code><technical_language>Please add a message here</technical_language>

Target:
public void findMissingEnumNames() { boolean missingKey = false; for (ConfigurationValues configValue : ConfigurationValues.values()) { if (!configValuesEnumNames.contains(configValue.toString())) { log.error("Found missing key: " + configValue.toString()); missingKey = true; break; } } assertFalse("Found missing key: ", missingKey); }
Source:
<code>public Void visit(GenContext state, Match ast) { <START> return null; <END> }</code><technical_language>Need match (to cases)</technical_language>

Target:
public Void visit(GenContext state, Match ast) { ast.getMatchingOver().acceptVisitor(this, state); ast.getDefaultCase().getAST().acceptVisitor(this, state); for (Case cse : ast.getCases()) { cse.getAST().acceptVisitor(this, state); } return null; }
Source:
<code>private void _showImage(FileEntity fileEntity) { try { _imgCon.add(new ImageComponent(new Image(ImageResource.getResource(fileEntity, 80, 90)))); } catch (CmsValidationException e) { _logger.error("SetImage throw cmsValidation error", e); } catch (NullPointerException e) { <START> _logger.error("SetImage throw null pointer error", e); <END> } catch (IOException e) { _logger.error("SetImage throw Io exception", e); } }</code><technical_language>Checking a non-checked (RuntimeException) requires a special reason. is special reason for checking NPE</technical_language>

Target:
private void _showImage(FileEntity fileEntity) { try { _imgCon.add(new ImageComponent(new Image(ImageResource.getResource(fileEntity, 80, 90)))); } catch (IOException e) { _logger.error("SetImage throw Io exception", e); } catch (NullPointerException e) { _logger.error("Image is null,please upload first", e); } }
Source:
<code>public IRegion processFix(IDocument document, IMarker marker) throws CoreException { int line = (int) marker.getAttribute(IMarker.LINE_NUMBER); try { String indent = getIndent(document, line); int endOfCurrLine = document.getLineInformation(line - 1).getOffset() + document.getLineInformation(line - 1).getLength(); String replacementText = indent + "type: object"; document.replace(endOfCurrLine, 0, TextUtilities.getDefaultLineDelimiter(document) + replacementText); <START> return new Region(endOfCurrLine + 1, replacementText.length()); <END> } catch (BadLocationException e) { throw new CoreException(createStatus(e, "Cannot process the IMarker")); } }</code><technical_language>@tfesenko "1" hear assume line delimiter LF? test a CRLF scenario in QA</technical_language>

Target:
public IRegion processFix(IDocument document, IMarker marker) throws CoreException { int line = (int) marker.getAttribute(IMarker.LINE_NUMBER); try { String indent = getIndent(document, line); int endOfCurrLine = document.getLineInformation(line - 1).getOffset() + document.getLineInformation(line - 1).getLength(); String replacementText = indent + "type: object"; String delim = TextUtilities.getDefaultLineDelimiter(document); document.replace(endOfCurrLine, 0, delim + replacementText); return new Region(endOfCurrLine + delim.length(), replacementText.length()); } catch (BadLocationException e) { throw new CoreException(createStatus(e, "Cannot process the IMarker")); } }