auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public String getLabel(Object element, int columnIdx) { GerritDiffNode gerrritNode = (GerritDiffNode) element; FileInfo fileInfo = gerrritNode.getFileInfo(); switch (columnIdx) { case 0: return ""; case 1: { switch (gerrritNode.getKind()) { case GerritDifferences.NO_CHANGE: return ""; case GerritDifferences.ADDITION: return "A"; case GerritDifferences.DELETION: return "D"; case GerritDifferences.CHANGE: return "M"; case GerritDifferences.RENAMED: return "R"; case GerritDifferences.COPIED: return "C"; default: return "M"; } } case 2: return gerrritNode.getLabelName(nameFirst); case 3: String commentString = ""; int commentsCount = fileInfo.getCommentsCount(); int draftsCount = fileInfo.getDraftsCount(); if (draftsCount != 0) { commentString += DRAFTS + draftsCount; if (commentsCount != 0) { commentString += " "; } } else { commentString = " "; } if (commentsCount != 0) { commentString += COMMENTS + commentsCount; } return commentString; case 4: StringBuilder modifySize = new StringBuilder(); modifySize.append('+'); modifySize.append(Integer.toString(fileInfo.getLines_inserted())); modifySize.append('/'); modifySize.append('-'); modifySize.append(Integer.toString(fileInfo.getLines_deleted())); return modifySize.toString(); default: return ""; } }

Target:
public String getLabel(Object element, int columnIdx) { GerritDiffNode gerrritNode = (GerritDiffNode) element; FileInfo fileInfo = gerrritNode.getFileInfo(); switch (columnIdx) { case 0: return ""; case 1: { switch (gerrritNode.getKind()) { case GerritDifferences.NO_CHANGE: return ""; case GerritDifferences.ADDITION: return "A"; case GerritDifferences.DELETION: return "D"; case GerritDifferences.CHANGE: return "M"; case GerritDifferences.RENAMED: return "R"; case GerritDifferences.COPIED: return "C"; default: return "M"; } } case 2: return gerrritNode.getLabelName(nameFirst); case 3: String commentString = ""; int commentsCount = fileInfo.getCommentsCount(); int draftsCount = fileInfo.getDraftsCount(); if (draftsCount != 0) { commentString += DRAFTS + draftsCount; if (commentsCount != 0) { commentString += " "; } } else { commentString = " "; } if (commentsCount != 0) { commentString += COMMENTS + commentsCount; } return commentString; case 4: StringBuilder modifySize = new StringBuilder(); FileInfo file = gerrritNode.getDiffFileInfo() != null ? gerrritNode.getDiffFileInfo() : gerrritNode.getFileInfo(); modifySize.append('+'); modifySize.append(Integer.toString(file.getLines_inserted())); modifySize.append('/'); modifySize.append('-'); modifySize.append(Integer.toString(file.getLines_deleted())); return modifySize.toString(); default: return ""; } }
Source:
public int execute() throws InterruptedException { if (!executionCheck.apply(this)) { return 0; } List<String> lines = getLines(); if (log.isDebugEnabled()) { log.debug("executing: - {}", summary, lines); } int result; try { mutexAcquire.call(); result = runner.execute(lines, summary); } catch (UncheckedInterruptedException e) { throw e.getCause(); } catch (Exception e) { throw new IllegalStateException("execution failed, invocation error for ${summary}", e); } finally { mutexRelease.call(); } if (log.isDebugEnabled()) { log.debug("finished executing: - result code {}", summary, result); } if (!resultCodeCheck.apply(result)) throw new IllegalStateException("execution failed, invalid result ${result} for ${summary}"); return result; }

Target:
public int execute() { if (!executionCheck.apply(this)) { return 0; } List<String> lines = getLines(); if (log.isDebugEnabled()) { log.debug("executing: - {}", summary, lines); } int result; try { mutexAcquire.run(); result = runner.execute(lines, summary); } catch (RuntimeInterruptedException e) { throw e; } catch (Exception e) { throw new IllegalStateException(format("execution failed, invocation error for %s", summary), e); } finally { mutexRelease.run(); } if (log.isDebugEnabled()) { log.debug("finished executing: - result code {}", summary, result); } if (!resultCodeCheck.apply(result)) { throw new IllegalStateException(format("execution failed, invalid result %s for %s", result, summary)); } return result; }
Source:
private String getFullyQualifiedName(String name) { if (currentScopeRootTree().is(Kind.CLASSDEF)) { Name className = ((ClassDef) currentScopeRootTree()).name(); String enclosingClassQualifiedName = Optional.ofNullable(className.symbol()).map(Symbol::fullyQualifiedName).orElse(className.name()); return enclosingClassQualifiedName + "." + name; } return fullyQualifiedModuleName != null ? (fullyQualifiedModuleName + "." + name) : null; }

Target:
private String getFullyQualifiedName(String name) { String prefix = scopeQualifiedName(); return prefix != null ? (prefix + "." + name) : null; }
Source:
public static Object[][] testDataExample() { return new Object[][]{ new Object[]{ "admin@.com", "admin", "test problem name", "test problem type", "test problem description", "test problem propose", Arrays.asList("1 test image comment", "2 test image comment"), Arrays.asList(new File("resources" + File.separator + "images" + File.separator + "bomb.jpg").getAbsolutePath(), new File("resources" + File.separator + "images" + File.separator + "svalka.jpg").getAbsolutePath()), 50.2, 30.0 } }; }

Target:
public static Object[][] testDataExample() { return new Object[][]{ new Object[]{ "test problem type", "test problem description", "test problem propose", Arrays.asList("1 test image comment", "2 test image comment"), Arrays.asList(new File("resources" + File.separator + "images" + File.separator + "bomb.jpg").getAbsolutePath(), new File("resources" + File.separator + "images" + File.separator + "svalka.jpg").getAbsolutePath()), 47.3, 31.1 } }; }
Source:
protected int getNeededDiskSize(Guid storageDomainId) { int result = 0; for (DiskImage img : getParameters().getDiskInfoMap().values()) { if (ImagesHandler.getStorageDomainId(img).getValue().equals(storageDomainId)) { result = result + (int) Math.ceil(img.getActualSize()); } } return result; }

Target:
protected int getNeededDiskSize(Guid storageDomainId) { int result = 0; for (DiskImage img : getParameters().getDiskInfoList()) { if (ImagesHandler.getStorageDomainId(img).getValue().equals(storageDomainId)) { result = result + (int) Math.ceil(img.getActualSize()); } } return result; }
Source:
private CacheConfiguration defaultCacheConfiguration(String cacheName) { CacheConfiguration cfg = new CacheConfiguration(cacheName); cfg.setAtomicityMode(TRANSACTIONAL); cfg.setWriteSynchronizationMode(FULL_SYNC); return cfg; }

Target:
private CacheConfiguration defaultCacheConfiguration(String cacheName) { CacheConfiguration cfg = new CacheConfiguration(cacheName); cfg.setWriteSynchronizationMode(writeSynchronizationMode()); return cfg; }
Source:
public void testAddWithoutParameterUpdate() throws Exception { assertTrue(new File(db.getWorkTree(), "sub").mkdir()); File file = new File(db.getWorkTree(), "sub/a.txt"); FileUtils.createNewFile(file); PrintWriter writer = new PrintWriter(file); writer.print("content"); writer.close(); File file2 = new File(db.getWorkTree(), "sub/b.txt"); FileUtils.createNewFile(file2); writer = new PrintWriter(file2); writer.print("content b"); writer.close(); Git git = new Git(db); git.add().addFilepattern("sub").call(); assertEquals( "[sub/a.txt, mode:100644, content:content]" + "[sub/b.txt, mode:100644, content:content b]", indexState(CONTENT)); git.commit().setMessage("commit").call(); File file3 = new File(db.getWorkTree(), "sub/c.txt"); FileUtils.createNewFile(file3); writer = new PrintWriter(file3); writer.print("content c"); writer.close(); writer = new PrintWriter(file); writer.print("modified content"); writer.close(); FileUtils.delete(file2); git.add().addFilepattern("sub").call(); assertEquals( "[sub/a.txt, mode:100644, content:modified content]" + "[sub/b.txt, mode:100644, content:content b]" + "[sub/c.txt, mode:100644, content:content c]", indexState(CONTENT)); }

Target:
public void testAddWithoutParameterUpdate() throws Exception { FileUtils.mkdir(new File(db.getWorkTree(), "sub")); File file = new File(db.getWorkTree(), "sub/a.txt"); FileUtils.createNewFile(file); PrintWriter writer = new PrintWriter(file); writer.print("content"); writer.close(); File file2 = new File(db.getWorkTree(), "sub/b.txt"); FileUtils.createNewFile(file2); writer = new PrintWriter(file2); writer.print("content b"); writer.close(); Git git = new Git(db); git.add().addFilepattern("sub").call(); assertEquals( "[sub/a.txt, mode:100644, content:content]" + "[sub/b.txt, mode:100644, content:content b]", indexState(CONTENT)); git.commit().setMessage("commit").call(); File file3 = new File(db.getWorkTree(), "sub/c.txt"); FileUtils.createNewFile(file3); writer = new PrintWriter(file3); writer.print("content c"); writer.close(); writer = new PrintWriter(file); writer.print("modified content"); writer.close(); FileUtils.delete(file2); git.add().addFilepattern("sub").call(); assertEquals( "[sub/a.txt, mode:100644, content:modified content]" + "[sub/b.txt, mode:100644, content:content b]" + "[sub/c.txt, mode:100644, content:content c]", indexState(CONTENT)); }
Source:
BlobIdPreamble(DataInputStream stream) throws IOException { version = stream.readShort(); byte blobIdFlag; blobDataType = null; switch (version) { case BLOB_ID_V1: type = BlobIdType.NATIVE; datacenterId = UNKNOWN_DATACENTER_ID; accountId = UNKNOWN_ACCOUNT_ID; containerId = UNKNOWN_CONTAINER_ID; isEncrypted = false; break; case BLOB_ID_V2: stream.readByte(); type = BlobIdType.NATIVE; datacenterId = stream.readByte(); accountId = stream.readShort(); containerId = stream.readShort(); isEncrypted = false; break; case BLOB_ID_V3: blobIdFlag = stream.readByte(); type = BlobIdType.values()[blobIdFlag & BLOB_ID_TYPE_MASK]; datacenterId = stream.readByte(); accountId = stream.readShort(); containerId = stream.readShort(); isEncrypted = false; break; case BLOB_ID_V4: blobIdFlag = stream.readByte(); type = BlobIdType.values()[blobIdFlag & BLOB_ID_TYPE_MASK]; isEncrypted = (blobIdFlag & IS_ENCRYPTED_MASK) != 0; datacenterId = stream.readByte(); accountId = stream.readShort(); containerId = stream.readShort(); break; case BLOB_ID_V5: blobIdFlag = stream.readByte(); type = BlobIdType.values()[blobIdFlag & BLOB_ID_TYPE_MASK]; isEncrypted = (blobIdFlag & IS_ENCRYPTED_MASK) != 0; int dataTypeOrdinal = (blobIdFlag & BLOB_DATA_TYPE_MASK) >> BLOB_DATA_TYPE_SHIFT; blobDataType = dataTypeOrdinal < BlobDataType.values().length ? BlobDataType.values()[dataTypeOrdinal] : null; datacenterId = stream.readByte(); accountId = stream.readShort(); containerId = stream.readShort(); break; default: throw new IllegalArgumentException("blobId version " + version + " is not supported."); } }

Target:
BlobIdPreamble(DataInputStream stream) throws IOException { version = stream.readShort(); byte blobIdFlag; switch (version) { case BLOB_ID_V1: type = BlobIdType.NATIVE; datacenterId = UNKNOWN_DATACENTER_ID; accountId = UNKNOWN_ACCOUNT_ID; containerId = UNKNOWN_CONTAINER_ID; isEncrypted = false; blobDataType = null; break; case BLOB_ID_V2: stream.readByte(); type = BlobIdType.NATIVE; datacenterId = stream.readByte(); accountId = stream.readShort(); containerId = stream.readShort(); isEncrypted = false; blobDataType = null; break; case BLOB_ID_V3: blobIdFlag = stream.readByte(); type = BlobIdType.values()[blobIdFlag & BLOB_ID_TYPE_MASK]; datacenterId = stream.readByte(); accountId = stream.readShort(); containerId = stream.readShort(); isEncrypted = false; blobDataType = null; break; case BLOB_ID_V4: blobIdFlag = stream.readByte(); type = BlobIdType.values()[blobIdFlag & BLOB_ID_TYPE_MASK]; isEncrypted = (blobIdFlag & IS_ENCRYPTED_MASK) != 0; datacenterId = stream.readByte(); accountId = stream.readShort(); containerId = stream.readShort(); blobDataType = null; break; case BLOB_ID_V5: blobIdFlag = stream.readByte(); type = BlobIdType.values()[blobIdFlag & BLOB_ID_TYPE_MASK]; isEncrypted = (blobIdFlag & IS_ENCRYPTED_MASK) != 0; datacenterId = stream.readByte(); accountId = stream.readShort(); containerId = stream.readShort(); int dataTypeOrdinal = (blobIdFlag & BLOB_DATA_TYPE_MASK) >> BLOB_DATA_TYPE_SHIFT; blobDataType = BlobDataType.values()[dataTypeOrdinal]; break; default: throw new IllegalArgumentException("blobId version " + version + " is not supported."); } }
Source:
public List<String> validateResponseAttributes( List<FeedbackResponseAttributes> responses, int numRecipients) { List<String> errors = new ArrayList<String>(); for(FeedbackResponseAttributes response : responses){ boolean validAnswer = false; FeedbackContributionResponseDetails frd = (FeedbackContributionResponseDetails) response.getResponseDetails(); if(frd.getAnswer() <= 200 && frd.getAnswer() >= 0 && frd.getAnswer() % 10 == 0) { validAnswer = true; } if(frd.getAnswer() == Const.POINTS_NOT_SURE){ validAnswer = true; } if(validAnswer == false){ errors.add(ERROR_INVALID_OPTION); } } return errors; }

Target:
public List<String> validateResponseAttributes( List<FeedbackResponseAttributes> responses, int numRecipients) { List<String> errors = new ArrayList<String>(); for(FeedbackResponseAttributes response : responses){ boolean validAnswer = false; FeedbackContributionResponseDetails frd = (FeedbackContributionResponseDetails) response.getResponseDetails(); boolean isValidRange = frd.getAnswer() >= 0 && frd.getAnswer() <= 200; boolean isMultipleOf10 = frd.getAnswer() % 10 == 0; if(isValidRange && isMultipleOf10) { validAnswer = true; } if(frd.getAnswer() == Const.POINTS_NOT_SURE){ validAnswer = true; } if(validAnswer == false){ errors.add(ERROR_INVALID_OPTION); } } return errors; }
Source:
public static synchronized void stop() throws InterruptedException{ if (m_es != null) { try { m_es.submit(new Runnable() { @Override public void run() }).get(); } catch (Exception e) { Throwables.getRootCause(e).printStackTrace(); } m_es.shutdown(); try { m_es.awaitTermination(365, TimeUnit.DAYS); } catch (InterruptedException e) { throw new RuntimeException("Unable to shutdown ReverseDNSCache", e); } m_es = null; } }

Target:
public static synchronized void stop() throws InterruptedException{ if (m_es != null) { m_es.shutdown(); try { m_es.awaitTermination(365, TimeUnit.DAYS); } catch (InterruptedException e) { throw new RuntimeException("Unable to shutdown ReverseDNSCache", e); } m_es = null; } }
Source:
CassandraDependenciesJob(Builder builder) { this.keyspace = builder.keyspace; this.day = builder.day; SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); df.setTimeZone(TimeZone.getTimeZone("UTC")); this.dateStamp = df.format(new Date(builder.day)); this.conf = new SparkConf(true).setMaster(builder.sparkMaster).setAppName(getClass().getName()); conf.set("spark.cassandra.connection.host", parseHosts(builder.contactPoints)); conf.set("spark.cassandra.connection.port", parsePort(builder.contactPoints)); if (builder.localDc != null) conf.set("connection.local_dc", builder.localDc); if (builder.jars != null) conf.setJars(builder.jars); for (Map.Entry<String, String> entry : builder.sparkProperties.entrySet()) { conf.set(entry.getKey(), entry.getValue()); log.info("Spark conf properties: {}={}", entry.getKey(), entry.getValue()); } this.logInitializer = builder.logInitializer; }

Target:
CassandraDependenciesJob(Builder builder) { this.keyspace = builder.keyspace; this.day = builder.day; SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); df.setTimeZone(TimeZone.getTimeZone("UTC")); this.dateStamp = df.format(new Date(builder.day)); this.conf = new SparkConf(true).setMaster(builder.sparkMaster).setAppName(getClass().getName()); conf.set("spark.cassandra.connection.host", parseHosts(builder.contactPoints)); conf.set("spark.cassandra.connection.port", parsePort(builder.contactPoints)); if (builder.localDc != null) conf.set("connection.local_dc", builder.localDc); if (builder.jars != null) conf.setJars(builder.jars); for (Map.Entry<String, String> entry : builder.sparkProperties.entrySet()) { conf.set(entry.getKey(), entry.getValue()); log.debug("Spark conf properties: {}={}", entry.getKey(), entry.getValue()); } this.logInitializer = builder.logInitializer; }
Source:
private void visitRecordType(ObjectType type) { emit("{"); Iterator<String> it = getEmittablePropertyNames(type).iterator(); while (it.hasNext()) { String propName = it.next(); JSType propType = type.getPropertyType(propName); if (propType == type) { emitComment("Unsupported circular reference for prop name: " + propName); continue; } if (isValidJSProperty(propName)) { emit(propName); } else { emit("'" + propName + "'"); } UnionType unionType = propType.toMaybeUnionType(); if (unionType != null && unionType .getAlternatesWithoutStructuralTyping() .stream() .anyMatch(JSType::isVoidType)) { emit("?"); visitTypeDeclaration(propType, false, true); } else { visitTypeDeclaration(propType, false, false); } if (it.hasNext()) { emit(","); } } emit("}"); }

Target:
private void visitRecordType(ObjectType type) { visitedRecordTypes.add(type); emit("{"); Iterator<String> it = getEmittablePropertyNames(type).iterator(); while (it.hasNext()) { String propName = it.next(); JSType propType = type.getPropertyType(propName); if (visitedRecordTypes.contains(propType)) { emitComment("Unsupported circular reference for prop name: " + propName); continue; } if (isValidJSProperty(propName)) { emit(propName); } else { emit("'" + propName + "'"); } UnionType unionType = propType.toMaybeUnionType(); if (unionType != null && unionType .getAlternatesWithoutStructuralTyping() .stream() .anyMatch(JSType::isVoidType)) { emit("?"); visitTypeDeclaration(propType, false, true); } else { visitTypeDeclaration(propType, false, false); } if (it.hasNext()) { emit(","); } } emit("}"); visitedRecordTypes.remove(type); }
Source:
private Pair<String, Boolean> sanitize(String s) { if (s == null) { return new Pair<>(null, false); } StringBuilder sb = new StringBuilder(); boolean ruleApplied = false; for (int i = 0; i < s.length(); i++) { char cur = s.charAt(i); boolean isLegal = true; if (!(44 <= cur && cur <= 57) && !(65 <= cur && cur <= 90) && !(97 <= cur && cur <= 122) && cur != 95) { if (!((i == 0 && cur == 0x2206) || (i == 0 && cur == 0x0394) || (i == 0 && cur == 126))) { isLegal = false; ruleApplied = true; } } sb.append(isLegal ? cur : '-'); } return new Pair<>(sb.toString(), ruleApplied); }

Target:
private String sanitize(String s) { if (s == null) { return null; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); sb.append(characterIsValid(c) ? c : '-'); } return sb.toString(); }
Source:
public void correctHttpResponse() throws Exception { final PublicMetrics publicMetrics = () -> Collections.singleton(new Metric<Number>("mem.free", 1024)); final ResponseEntity<String> response = responseForMetrics(publicMetrics); assertThat(response.getStatusCode(), equalTo(HttpStatus.OK)); assertThat(response.getHeaders().getContentType().toString(), equalTo("text/plain;version=0.0.4;charset=utf-8")); }

Target:
public void correctHttpResponse() throws Exception { PublicMetrics publicMetrics = () -> Collections.singleton(new Metric<Number>("mem.free", 1024)); ResponseEntity<String> response = responseForMetrics(publicMetrics); assertThat(response.getStatusCode(), equalTo(HttpStatus.OK)); assertThat(response.getHeaders().getContentType().toString(), equalTo("text/plain;version=0.0.4;charset=utf-8")); }
Source:
public <T> Codec<T> getCodec(String codecName, Class<T> objectClass) { if (! codecs.containsKey(codecName)) { return null; } return codecs.get(codecName).getCodec(objectClass); }

Target:
public <T> Codec<T> getCodec(String codecName, Class<T> objectClass) { if (!codecFactories.containsKey(codecName)) { return null; } return codecFactories.get(codecName).newCodec(objectClass); }
Source:
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { try { fConfigDir = null; SubMonitor subMonitor = SubMonitor.convert(monitor, "", 4); try { preLaunchCheck(configuration, launch, subMonitor.newChild(2)); } catch (CoreException e) { if (e.getStatus().getSeverity() == IStatus.CANCEL) { monitor.setCanceled(true); return; } throw e; } VMRunnerConfiguration runnerConfig = new VMRunnerConfiguration(getMainClass(), getClasspath(configuration)); runnerConfig.setVMArguments(getVMArguments(configuration)); runnerConfig.setProgramArguments(getProgramArguments(configuration)); runnerConfig.setWorkingDirectory(getWorkingDirectory(configuration).getAbsolutePath()); runnerConfig.setEnvironment(getEnvironment(configuration)); runnerConfig.setVMSpecificAttributesMap(getVMSpecificAttributesMap(configuration)); monitor.worked(1); setDefaultSourceLocator(configuration); manageLaunch(launch); IVMRunner runner = getVMRunner(configuration, mode); if (runner != null) runner.run(runnerConfig, launch, monitor); else monitor.setCanceled(true); monitor.done(); } catch (final CoreException e) { monitor.setCanceled(true); throw e; } }

Target:
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { try { fConfigDir = null; SubMonitor subMonitor = SubMonitor.convert(monitor, 4); try { preLaunchCheck(configuration, launch, subMonitor.newChild(2)); } catch (CoreException e) { if (e.getStatus().getSeverity() == IStatus.CANCEL) { subMonitor.setCanceled(true); return; } throw e; } VMRunnerConfiguration runnerConfig = new VMRunnerConfiguration(getMainClass(), getClasspath(configuration)); runnerConfig.setVMArguments(getVMArguments(configuration)); runnerConfig.setProgramArguments(getProgramArguments(configuration)); runnerConfig.setWorkingDirectory(getWorkingDirectory(configuration).getAbsolutePath()); runnerConfig.setEnvironment(getEnvironment(configuration)); runnerConfig.setVMSpecificAttributesMap(getVMSpecificAttributesMap(configuration)); subMonitor.worked(1); setDefaultSourceLocator(configuration); manageLaunch(launch); IVMRunner runner = getVMRunner(configuration, mode); if (runner != null) runner.run(runnerConfig, launch, subMonitor); else subMonitor.setCanceled(true); } catch (final CoreException e) { throw e; } }
Source:
public <T> ResourceOperations<T> getResourceOperations(Class<T> type) { FileResourceTransactionImpl transaction = getTransaction(); if (transaction.isStarted()) { return (ResourceOperations<T>) transaction; } else { if (File.class.equals(type)) { return (ResourceOperations<T>) DefaultFileOperations.INSTANCE; } else if (Path.class.equals(type)) { return (ResourceOperations<T>) DefaultPathOperations.INSTANCE; } else { throw new IllegalArgumentException("Unsupport resource type [" + type.getName() + "]"); } } }

Target:
public <T> ResourceOperations<T> getResourceOperations(Class<T> type) { if (File.class.equals(type)) { FileResourceTransactionImpl transaction = getTransaction(); if (transaction.isStarted()) { return (ResourceOperations<T>) transaction; } else { return (ResourceOperations<T>) DefaultFileOperations.INSTANCE; } } else if (Path.class.equals(type)) { return (ResourceOperations<T>) DefaultPathOperations.INSTANCE; } else { throw new IllegalArgumentException("Unsupport resource type [" + type.getName() + "]"); } }
Source:
protected TextField<Integer> newHoursTextField(final String id, IModel<Integer> model, Class<Integer> type) { TextField<Integer> hoursTextField = new TextField<Integer>(id, model, type); hoursTextField.add(getMaximumHours() == 24 ? RangeValidator.range(0, 23) : RangeValidator .range(1, 12)); hoursTextField.setLabel(new Model<>(HOURS)); return hoursTextField; }

Target:
protected TextField<Integer> newHoursTextField(final String id, IModel<Integer> model, Class<Integer> type) { TextField<Integer> hoursTextField = new TextField<>(id, model, type); hoursTextField.add(getMaximumHours() == 24 ? RangeValidator.range(0, 23) : RangeValidator .range(1, 12)); hoursTextField.setLabel(new Model<>(HOURS)); return hoursTextField; }
Source:
private void onReceiveTimeout(ReceiveTimeout message, ActorRef self, ActorRef sender) throws Exception { if (logger.isInfoEnabled()) { logger.info("Conference Received Timeout, will stop conference now."); } onStopConference(new StopConference(SUPER_ADMIN_ACCOUNT_SID), self, sender); }

Target:
private void onReceiveTimeout(ReceiveTimeout message, ActorRef self, ActorRef sender) throws Exception { if (logger.isInfoEnabled()) { logger.info("Conference Received Timeout, will stop conference now."); } onStopConference(new StopConference(), self, sender); }
Source:
private static String readFile(File file) throws IOException { Reader in = new BufferedReader(new FileReader(file)); StringBuilder sb = new StringBuilder(); char[] chars = new char[1 << 16]; int length; while ((length = in.read(chars)) > 0) sb.append(chars, 0, length); in.close(); return sb.toString(); }

Target:
private static String readFile(File file) throws IOException { Reader in = new BufferedReader(new FileReader(file)); StringBuilder sb = new StringBuilder(); char[] chars = new char[1 << 16]; int length; try { while ((length = in.read(chars)) > 0) sb.append(chars, 0, length); } finally { in.close(); } return sb.toString(); }
Source:
protected boolean canDoAction() { return isImageExist() && checkOperationIsCorrect() && canFindVmOrTemplate() && isDiskUsedAsOvfStore() && isImageNotLocked() && isSourceAndDestTheSame() && validateSourceStorageDomain() && validateDestStorage() && checkTemplateInDestStorageDomain() && validateSpaceRequirements() && checkCanBeMoveInVm() && checkIfNeedToBeOverride() && setAndValidateDiskProfiles() && verifyShareableDisksMoving(); }

Target:
protected boolean canDoAction() { return isImageExist() && checkOperationIsCorrect() && canFindVmOrTemplate() && isDiskUsedAsOvfStore() && isImageNotLocked() && isSourceAndDestTheSame() && validateSourceStorageDomain() && validateDestStorage() && checkTemplateInDestStorageDomain() && validateSpaceRequirements() && checkCanBeMoveInVm() && checkIfNeedToBeOverride() && setAndValidateDiskProfiles(); }
Source:
public Response add(GlusterVolume volume) { validateParameters(volume, "name", "volumeType", "glusterBricks"); GlusterVolumeEntity volumeEntity = getMapper(GlusterVolume.class, GlusterVolumeEntity.class).map(volume, null); volumeEntity.setClusterId(Guid.createGuidFromString(clusterId)); return performCreation(VdcActionType.CreateGlusterVolume, new CreateGlusterVolumeParameters(volumeEntity), new QueryIdResolver(VdcQueryType.GetGlusterVolumeById, GetGlusterVolumeByIdQueryParameters.class), true); }

Target:
public Response add(GlusterVolume volume) { validateParameters(volume, "name", "volumeType", "glusterBricks"); GlusterVolumeEntity volumeEntity = getMapper(GlusterVolume.class, GlusterVolumeEntity.class).map(volume, null); volumeEntity.setClusterId(asGuid(clusterId)); return performCreation(VdcActionType.CreateGlusterVolume, new CreateGlusterVolumeParameters(volumeEntity), new QueryIdResolver(VdcQueryType.GetGlusterVolumeById, GetGlusterVolumeByIdQueryParameters.class), true); }
Source:
public void update(List<File> files) { containers.clear(); for(File file: files) { ConfigFile containerConfigFile = new CompatibleConfigFileFormat(new File(file, "playonlinux.cfg")); String containerType = containerConfigFile.readValue("containerType"); if(StringUtils.isBlank(containerType)) { containerType = "WinePrefix"; } containers.add(anyContainerFactory.createInstance(containerType, file)); } notifyObservers(this); }

Target:
public void update(List<File> files) { containers.clear(); for(File file: files) { final ConfigFile containerConfigFile = new CompatibleConfigFileFormat(new File(file, "playonlinux.cfg")); String containerType = containerConfigFile.readValue("containerType"); if(StringUtils.isBlank(containerType)) { containerType = "WinePrefix"; } containers.add(anyContainerFactory.createInstance(containerType, file)); } notifyObservers(this); }
Source:
private Stringer getStringerForName(Table t, Index indy, String name, int createMediaMask) { if ((name == null) || (name.length() == 0)) return null; Stringer rv; try { t.acquireReadLock(); rv = getStringerForNameWhileLocked(t, indy, name); if (rv != null) return rv; } finally { t.releaseReadLock(); } try { t.acquireWriteLock(); rv = getStringerForNameWhileLocked(t, indy, name); if (rv != null) return rv; rv = new Stringer(getNextWizID()); rv.name = new String(name); rv.ignoreCaseHash = rv.name.toLowerCase().hashCode(); rv.setMediaMask(createMediaMask); t.add(rv, !loading); return rv; } finally { t.releaseWriteLock(); } }

Target:
private Stringer getStringerForName(Table t, Index indy, String name, int createMediaMask) { if ((name == null) || (name.length() == 0)) return null; Stringer rv; try { t.acquireReadLock(); rv = getStringerForNameWhileLocked(t, indy, name); if (rv != null) return rv; } finally { t.releaseReadLock(); } try { t.acquireWriteLock(); rv = getStringerForNameWhileLocked(t, indy, name); if (rv != null) return rv; rv = new Stringer(getNextWizID()); rv.name = new String(name); rv.ignoreCaseHash = name.toLowerCase().hashCode(); rv.setMediaMask(createMediaMask); t.add(rv, !loading); return rv; } finally { t.releaseWriteLock(); } }
Source:
public Result getRpcResult() { Result result; try { if (resultFuture.isDone()) { result = resultFuture.get(); } else { result = new RpcResult(); } } catch (Exception e) { logger.error("Got exception when trying to fetch the underlying result of AsyncRpcResult.", e); result = new RpcResult(); } return result; }

Target:
public Result getRpcResult() { try { if (resultFuture.isDone()) { return resultFuture.get(); } } catch (Exception e) { logger.error("Got exception when trying to fetch the underlying result from AsyncRpcResult.", e); } return new RpcResult(); }
Source:
protected AbstractBeanDefinition doParse(Element element, ParserContext parserContext, String channelName) { BeanDefinitionBuilder listeningMessageProducer = BeanDefinitionBuilder.genericBeanDefinition(CacheListeningMessageProducer.class); IntegrationNamespaceUtils.setValueIfAttributeDefined(listeningMessageProducer, element, EXPRESSION_ATTRIBUTE,PAYLOAD_EXPRESSION_PROPERTY); IntegrationNamespaceUtils.setValueIfAttributeDefined(listeningMessageProducer, element, CACHE_EVENTS_ATTRIBUTE, SUPPORTED_EVENT_TYPES_PROPERTY); if (!element.hasAttribute(REGION_ATTRIBUTE)){ parserContext.getReaderContext().error("'region' attribute is required.",element); } listeningMessageProducer.addConstructorArgReference(element.getAttribute(REGION_ATTRIBUTE)); listeningMessageProducer.addPropertyReference(OUTPUT_CHANNEL_PROPERTY, channelName); IntegrationNamespaceUtils.setReferenceIfAttributeDefined(listeningMessageProducer, element, ERROR_CHANNEL_ATTRIBUTE); if (element.hasAttribute(AUTO_STARTUP)){ IntegrationNamespaceUtils.setValueIfAttributeDefined(listeningMessageProducer, element, AUTO_STARTUP); } return listeningMessageProducer.getBeanDefinition(); }

Target:
protected AbstractBeanDefinition doParse(Element element, ParserContext parserContext, String channelName) { BeanDefinitionBuilder listeningMessageProducer = BeanDefinitionBuilder.genericBeanDefinition(CacheListeningMessageProducer.class); IntegrationNamespaceUtils.setValueIfAttributeDefined(listeningMessageProducer, element, EXPRESSION_ATTRIBUTE,PAYLOAD_EXPRESSION_PROPERTY); IntegrationNamespaceUtils.setValueIfAttributeDefined(listeningMessageProducer, element, CACHE_EVENTS_ATTRIBUTE, SUPPORTED_EVENT_TYPES_PROPERTY); if (!element.hasAttribute(REGION_ATTRIBUTE)){ parserContext.getReaderContext().error("'region' attribute is required.",element); } listeningMessageProducer.addConstructorArgReference(element.getAttribute(REGION_ATTRIBUTE)); listeningMessageProducer.addPropertyReference(OUTPUT_CHANNEL_PROPERTY, channelName); IntegrationNamespaceUtils.setReferenceIfAttributeDefined(listeningMessageProducer, element, ERROR_CHANNEL_ATTRIBUTE); return listeningMessageProducer.getBeanDefinition(); }
Source:
public ArrayList loadTests(Context context) { SharedPreferences settings; List tests; settings = context.getSharedPreferences(PREFS_NAME,Context.MODE_PRIVATE); if (settings.contains(TESTS)) { String jsonTests = settings.getString(TESTS, null); Gson gson = new Gson(); NetworkMeasurement[] favoriteItems = gson.fromJson(jsonTests,NetworkMeasurement[].class); tests = Arrays.asList(favoriteItems); tests = new ArrayList(tests); } else return new ArrayList(); return (ArrayList) tests; }

Target:
public ArrayList loadTests(Context context) { SharedPreferences settings; List tests; settings = context.getSharedPreferences(PREFS_NAME,Context.MODE_PRIVATE); if (!settings.contains(TESTS)) { return new ArrayList(); } String jsonTests = settings.getString(TESTS, null); Gson gson = new Gson(); NetworkMeasurement[] favoriteItems = gson.fromJson(jsonTests,NetworkMeasurement[].class); tests = Arrays.asList(favoriteItems); tests = new ArrayList(tests); return (ArrayList) tests; }
Source:
private void startSimpleZKServer(CountDownLatch startupDelayLatch) throws IOException { zks = new SimpleZooKeeperServer(tmpDir, tmpDir, 3000, startupDelayLatch); SyncRequestProcessor.setSnapCount(100); final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]); servcnxnf = ServerCnxnFactory.createFactory(PORT, -1); Thread startupThread = new Thread() { public void run() { try { servcnxnf.startup(zks); } catch (IOException | InterruptedException e) { LOG.error("Unexcepted exception during server startup", e); } }; }; LOG.info("Starting zk server {}", HOSTPORT); startupThread.start(); }

Target:
private void startSimpleZKServer(CountDownLatch startupDelayLatch) throws IOException { zks = new SimpleZooKeeperServer(tmpDir, tmpDir, 3000, startupDelayLatch); SyncRequestProcessor.setSnapCount(100); final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]); servcnxnf = ServerCnxnFactory.createFactory(PORT, -1); Thread startupThread = new Thread() { public void run() { try { servcnxnf.startup(zks); } catch (IOException e) { LOG.error("Unexcepted exception during server startup", e); } catch (InterruptedException e) { LOG.error("Unexcepted exception during server startup", e); } }; }; LOG.info("Starting zk server {}", HOSTPORT); startupThread.start(); }
Source:
public int getPartitionsCount() { if (m_wrapper != null) { return m_wrapper.getConfigsCount(); } else { return 0; } }

Target:
public int getPartitionsCount() { int count = 0; for (BundleWrapper wapper : m_bundles.values()) { if (wapper != null) { count += wapper.getConfigsCount(); } } return count; }
Source:
public static Collection<Descriptor> getSortedDescriptorsForGlobalConfig(Predicate<GlobalConfigurationCategory> predicate) { ExtensionList<Descriptor> exts = ExtensionList.lookup(Descriptor.class); List<Tag> r = new ArrayList<>(exts.size()); for (ExtensionComponent<Descriptor> c : exts.getComponents()) { Descriptor d = c.getInstance(); if (d.getGlobalConfigPage()==null) continue; if (predicate.apply(d.getCategory())) { r.add(new Tag(c.ordinal(), d)); } } Collections.sort(r); List<Descriptor> answer = new ArrayList<>(r.size()); for (Tag d : r) answer.add(d.d); return GlobalConfiguration.GlobalConfigHiddenByPermissionFilter.apply(Jenkins.get(),answer); }

Target:
public static Collection<Descriptor> getSortedDescriptorsForGlobalConfig(Predicate<GlobalConfigurationCategory> predicate) { ExtensionList<Descriptor> exts = ExtensionList.lookup(Descriptor.class); List<Tag> r = new ArrayList<>(exts.size()); for (ExtensionComponent<Descriptor> c : exts.getComponents()) { Descriptor d = c.getInstance(); if (d.getGlobalConfigPage()==null) continue; if (predicate.apply(d.getCategory())) { r.add(new Tag(c.ordinal(), d)); } } Collections.sort(r); List<Descriptor> answer = new ArrayList<>(r.size()); for (Tag d : r) answer.add(d.d); return DescriptorVisibilityFilter.apply(Jenkins.get(),answer); }
Source:
public String toString() { String response = this.getResult() != null ? "result " + this.getResult().toString() : "error " + this.getError().toString(); return "Response with " + this.getId() + " id containing " + response; }

Target:
public String toString() { String response = this.getResult() != null ? "result " + this.getResult().toString() : "error " + this.getError().toString(); return "Response with " + this.getId() + " ID containing " + response; }
Source:
protected boolean canDoAction() { if (getParameters().getParametersList().isEmpty()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NO_DISKS_SPECIFIED); } else { return verifyShareableDisksMoving(); } }

Target:
protected boolean canDoAction() { if (getParameters().getParametersList().isEmpty()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NO_DISKS_SPECIFIED); } return verifyShareableDisksMoving(); }
Source:
@Test public void testJsonReplace() { checkExp("json_replace('{ \"a\": 1, \"b\": [2]}', '$.a', 10, '$.c', '[true]')"); checkExpType("json_replace('{ \"a\": 1, \"b\": [2]}', '$.a', 10, '$.c', '[true]')", "VARCHAR(2000)"); checkFails("select ^json_replace('{\"foo\":\"bar\"}')^", "(?s).*Invalid number of arguments.*"); }

Target:
@Test public void testJsonReplace() { expr("json_replace('{ \"a\": 1, \"b\": [2]}', '$.a', 10, '$.c', '[true]')").ok(); expr("json_replace('{ \"a\": 1, \"b\": [2]}', '$.a', 10, '$.c', '[true]')") .columnType("VARCHAR(2000)"); expr("select ^json_replace('{\"foo\":\"bar\"}')^") .fails("(?s).*Invalid number of arguments.*"); }
Source:
public void validate() { if (Strings.isNullOrEmpty(uf.server)) { throw new RuntimeConfigurationException("Server address required"); } try { new URL(uf.server); } catch (MalformedURLException e) { throw new RuntimeConfigurationException("Provided server address is not a valid URL", e); } if (!Strings.isNullOrEmpty(uf.solrServer)) { try { new URL(uf.solrServer); } catch (MalformedURLException e) { throw new RuntimeConfigurationException("Provided solr server address is not a valid URL", e); } } if (!Strings.isNullOrEmpty(uf.memcachedHost) && uf.memcachedPort == null) { throw new RuntimeConfigurationException("No memcachedPort specified"); } if (!Strings.isNullOrEmpty(uf.memcachedHost) && Strings.isNullOrEmpty(uf.cacheAppPrefix)) { throw new RuntimeConfigurationException("If memcachedHost is specified, cacheAppPrefix must be as well"); } if ((uf.devModeAssets == null || !uf.devModeAssets) && Strings.isNullOrEmpty(uf.compiledAssetDir)) { throw new RuntimeConfigurationException("If devModeAssets is false, compiledAssetDir must be specified"); } if (!Strings.isNullOrEmpty(uf.casLogoutUrl) && !Strings.isNullOrEmpty(uf.casLogoutServiceUrl)) { try { this.casLogoutUrl = uf.casLogoutUrl + "?service=" + URLEncoder.encode(uf.casLogoutServiceUrl, "UTF-8"); } catch (UnsupportedEncodingException e) { this.casLogoutUrl = uf.casLogoutUrl + "?service=" + URLEncoder.encode(uf.casLogoutServiceUrl); } } }

Target:
public void validate() { if (Strings.isNullOrEmpty(uf.server)) { throw new RuntimeConfigurationException("Server address required"); } try { new URL(uf.server); } catch (MalformedURLException e) { throw new RuntimeConfigurationException("Provided server address is not a valid URL", e); } if (!Strings.isNullOrEmpty(uf.solrServer)) { try { new URL(uf.solrServer); } catch (MalformedURLException e) { throw new RuntimeConfigurationException("Provided solr server address is not a valid URL", e); } } if (!Strings.isNullOrEmpty(uf.memcachedHost) && uf.memcachedPort == null) { throw new RuntimeConfigurationException("No memcachedPort specified"); } if (!Strings.isNullOrEmpty(uf.memcachedHost) && Strings.isNullOrEmpty(uf.cacheAppPrefix)) { throw new RuntimeConfigurationException("If memcachedHost is specified, cacheAppPrefix must be as well"); } if ((uf.devModeAssets == null || !uf.devModeAssets) && Strings.isNullOrEmpty(uf.compiledAssetDir)) { throw new RuntimeConfigurationException("If devModeAssets is false, compiledAssetDir must be specified"); } if (!Strings.isNullOrEmpty(uf.casLogoutUrl) && !Strings.isNullOrEmpty(uf.casLogoutServiceUrl)) { try { this.casLogoutUrl = uf.casLogoutUrl + "?service=" + URLEncoder.encode(uf.casLogoutServiceUrl, Charsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } }
Source:
protected void setActionMessageParameters() { super.setActionMessageParameters(); addValidationMessages(EngineMessage.VAR__ACTION__TRANSFER, EngineMessage.VAR__TYPE__IMAGE); }

Target:
protected void setActionMessageParameters() { addValidationMessages(EngineMessage.VAR__ACTION__TRANSFER, EngineMessage.VAR__TYPE__DISK); }
Source:
private Checkpoint getActivationCheckpoint(PTOperator oper) { if ((oper.recoveryCheckpoint == null || oper.recoveryCheckpoint == Checkpoint.INITIAL_CHECKPOINT) && oper.checkpoints.isEmpty()) { Checkpoint activationCheckpoint = Checkpoint.INITIAL_CHECKPOINT; for (PTInput input : oper.inputs) { PTOperator sourceOper = input.source.source; if (sourceOper.checkpoints.isEmpty()) { return getActivationCheckpoint(sourceOper); } activationCheckpoint = Checkpoint.max(activationCheckpoint, sourceOper.recoveryCheckpoint); } return activationCheckpoint; } return oper.recoveryCheckpoint; }

Target:
private Checkpoint getActivationCheckpoint(PTOperator oper) { if (oper.recoveryCheckpoint == null && oper.checkpoints.isEmpty()) { Checkpoint activationCheckpoint = Checkpoint.INITIAL_CHECKPOINT; for (PTInput input : oper.inputs) { PTOperator sourceOper = input.source.source; Checkpoint checkpoint = sourceOper.recoveryCheckpoint; if (sourceOper.checkpoints.isEmpty()) { checkpoint = getActivationCheckpoint(sourceOper); } activationCheckpoint = Checkpoint.max(activationCheckpoint, checkpoint); } return activationCheckpoint; } return oper.recoveryCheckpoint; }
Source:
public String convertStatementRankToJson(StatementRank rank) { return rank.toString().toLowerCase(); }

Target:
String convertStatementRankToJson(StatementRank rank) { switch (rank) { case PREFERRED: return NAME_RANK_PREFERRED; case NORMAL: return NAME_RANK_NORMAL; case DEPRECATED: return NAME_RANK_DEPRECATED; default: throw new IllegalArgumentException("Unknown rank " + rank.toString()); } }
Source:
public void replaceWithNameableCollection() { VM vm = new VM(); vm.setVmName(PROPERTY_VALUE); List<Nameable> items = Collections.<Nameable> singletonList(vm); String[] messageItems = ReplacementUtils.replaceWithNameableCollection(PROPERTY_NAME, items); validateMessageItems(messageItems, items); }

Target:
public void replaceWithNameableCollection() { Nameable item = new Nameable() { @Override public String getName() { return PROPERTY_VALUE; } }; List<Nameable> items = Collections.<Nameable> singletonList(item); String[] messageItems = ReplacementUtils.replaceWithNameable(PROPERTY_NAME, items); validateMessageItems(messageItems, items); }
Source:
public void testGetCell() throws Exception { final String factType = "org.kiegroup.Car"; final String factField = "color"; final String dataType = DataType.DataTypes.NUMERIC.name(); doReturn(factType).when(column).getFactType(); doReturn(factField).when(column).getFactField(); doReturn(dataType).when(column).getDataType(); testedFactory.getCell(column); verify(testedFactory, never()).makeSingleSelectionEnumCell(factType, factField, dataType); }

Target:
public void testGetCell() throws Exception { final String factType = "org.kiegroup.Car"; final String factField = "color"; final String dataType = DataType.DataTypes.STRING.name(); doReturn(factType).when(column).getFactType(); doReturn(factField).when(column).getFactField(); doReturn(dataType).when(column).getDataType(); testedFactory.getCell(column); verify(testedFactory, never()).makeSingleSelectionEnumCell(factType, factField, dataType); }
Source:
private void processSingleChargeEvent(long currentId, ChargeStatus fromChargeState, ChargeEventEntity chargeEventEntity) { PaymentGatewayStateTransitions.getInstance() .getEventForTransition(fromChargeState, chargeEventEntity.getStatus()) .ifPresent(eventType -> { Event event = getPaymentEvent(chargeEventEntity, eventType); final boolean emittedBefore = emittedEventDao.hasBeenEmittedBefore(event); if (emittedBefore) { logger.info("[{}/{}] - found - emitted before", currentId, maxId); } else { logger.info("[{}/{}] - found - emitting ", currentId, maxId, event); persistAndEmit(event); } }); }

Target:
private void processSingleChargeEvent(long currentId, ChargeStatus fromChargeState, ChargeEventEntity chargeEventEntity) { PaymentGatewayStateTransitions.getInstance() .getEventForTransition(fromChargeState, chargeEventEntity.getStatus()) .ifPresent(eventType -> { PaymentStateTransition transition = new PaymentStateTransition(chargeEventEntity.getId(), eventType); offerPaymentStateTransitionEvents(currentId, chargeEventEntity, transition); }); }
Source:
Set<String> byPath(String wsPath) { Set<String> ids = new HashSet<>(); for (Entry<String, Set<Pattern>> entry : patterns.getAll().entrySet()) { String id = entry.getKey(); Set<Pattern> patterns = entry.getValue(); for (Pattern pattern : patterns) { if (pattern.matcher(wsPath).lookingAt()) { ids.add(id); } } } return ImmutableSet.copyOf(ids); }

Target:
Set<String> byPath(String wsPath) { Set<String> ids = new HashSet<>(); for (Entry<String, Set<Pattern>> entry : patterns.getAll().entrySet()) { String id = entry.getKey(); Set<Pattern> patterns = entry.getValue(); for (Pattern pattern : patterns) { if (pattern.matcher(wsPath).matches()) { ids.add(id); } } } return ImmutableSet.copyOf(ids); }
Source:
public void onFinish(List<SpanExtents> result) { if (isCancelled()) { return; } long time = System.currentTimeMillis(); Object[] prevSpans = textBox.getText().getSpans(0, text.length(), SpanExtents.class); for (Object sp : prevSpans) { textBox.getText().removeSpan(sp); } for (int i = 0; i < result.size(); i++) { textBox.getText().setSpan(result.get(i), result.get(i).getStart(), result.get(i).getEnd(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); } time = System.currentTimeMillis() - time; Log.d(TAG, "That took " + time + "ms"); }

Target:
public void onFinish(List<SpanExtents> result) { if (isCancelled()) { return; } long time = System.currentTimeMillis(); Object[] prevSpans = textBox.getText().getSpans(0, text.length(), SpanExtents.class); for (Object sp : prevSpans) { textBox.getText().removeSpan(sp); } for (SpanExtents spanEx : result) { textBox.getText().setSpan(spanEx, spanEx.getStart(), spanEx.getEnd(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); } time = System.currentTimeMillis() - time; Log.d(TAG, "That took " + time + "ms"); }
Source:
public Track(String abPath) { try { song = new Mp3File(abPath); } catch (UnsupportedTagException e) { System.out.println("There was a Unsupported tag exception with file:" + abPath); e.printStackTrace(); } catch (InvalidDataException e) { System.out.println("There was a Invalid data exception with file:" + abPath); e.printStackTrace(); } catch (IOException e) { System.out.println("There was a IO exception with file:" + abPath); e.printStackTrace(); } absolutepath = abPath; getInformation(); }

Target:
public Track(String abPath) { try { song = new Mp3File(abPath); } catch (UnsupportedTagException e) { System.out.println("There was a Unsupported tag exception with file:" + abPath); e.printStackTrace(); } catch (InvalidDataException e) { System.out.println("There was a Invalid data exception with file:" + abPath); e.printStackTrace(); } catch (IOException e) { System.out.println("There was a IO exception with file:" + abPath); e.printStackTrace(); } absolutePath = abPath; getMetadata(); }