auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private ByteBuffer parsePayLoad(ByteBuffer pcapPacketHeader, int blockLength) throws IOException, BadPcapFileException { ByteBuffer pcapPacketData; <START> <END> pcapPacketHeader.getInt(); pcapPacketHeader.getInt(); pcapPacketHeader.getInt(); int capturedLen = pcapPacketHeader.getInt(); pcapPacketHeader.getInt(); long includedPacketLength = ConversionHelper.unsignedIntToLong(capturedLen); SeekableByteChannel fFileChannel = getFileChannel(); if (fFileChannel.size() - fFileChannel.position() < includedPacketLength) { throw new BadPcapFileException(String.format("%04x", includedPacketLength) + " is causing buffer overrun."); } if (capturedLen > Integer.MAX_VALUE) { throw new BadPcapFileException(String.format("%04x", capturedLen) + " packet length is bigger than 2^31-1 bytes are not supported."); } pcapPacketData = ByteBuffer.allocate((int) includedPacketLength); pcapPacketData.clear(); ByteOrder byteOrder = getByteOrder(); pcapPacketHeader.order(byteOrder); int payLoad = fFileChannel.read(pcapPacketData); if (payLoad == 0) { throw new BadPcapFileException(String.format("%04x", payLoad) + " is a bad payload."); } pcapPacketData.flip(); fFileChannel.position(fFileChannel.position() + blockLength - capturedLen - PcapFileValues.PCAPNG_PACKET_HEADER_SIZE); return pcapPacketData; }</code><technical_language>This code assumes 8 bytes of pcapPacketHeader read... true in practice safe</technical_language>

Target:
private ByteBuffer parsePayLoad(ByteBuffer pcapPacketHeader, int blockLength) throws IOException, BadPcapFileException { ByteBuffer pcapPacketData; pcapPacketHeader.getInt(); pcapPacketHeader.getInt(); pcapPacketHeader.getInt(); int capturedLen = pcapPacketHeader.getInt(); pcapPacketHeader.getInt(); long includedPacketLength = ConversionHelper.unsignedIntToLong(capturedLen); SeekableByteChannel fileChannel = getFileChannel(); if (fileChannel.size() - fileChannel.position() < includedPacketLength) { throw new BadPcapFileException(String.format("%04x", includedPacketLength) + " is causing buffer overrun."); } if (capturedLen > Integer.MAX_VALUE) { throw new BadPcapFileException(String.format("%04x", capturedLen) + " packet length is bigger than 2^31-1 bytes are not supported."); } pcapPacketData = ByteBuffer.allocate((int) includedPacketLength); pcapPacketData.clear(); ByteOrder byteOrder = getByteOrder(); pcapPacketHeader.order(byteOrder); int payLoad = fileChannel.read(pcapPacketData); if (payLoad == 0) { throw new BadPcapFileException(String.format("%04x", payLoad) + " is a bad payload."); } pcapPacketData.flip(); fileChannel.position(fileChannel.position() + blockLength - capturedLen - PcapFileValues.PCAPNG_PACKET_HEADER_SIZE); return pcapPacketData; }
Source:
<code>void errorOutReadKey(final CompletionKey key, final int rc) { <START> LOG.info("Removing completion key: {}", key); <END> final ReadCompletion readCompletion = (ReadCompletion)completionObjects.remove(key); if (null == readCompletion) { return; } executor.submitOrdered(readCompletion.ledgerId, new SafeRunnable() { @Override public void safeRun() { String bAddress = "null"; Channel c = channel; if (c != null && c.getRemoteAddress() != null) { bAddress = c.getRemoteAddress().toString(); } LOG.debug("Could not write request for reading entry: ledger-id: bookie: rc: {}", new Object[]{ readCompletion.entryId, readCompletion.ledgerId, bAddress, rc }); readCompletion.cb.readEntryComplete(rc, readCompletion.ledgerId, readCompletion.entryId, null, readCompletion.ctx); } @Override public String toString() { return String.format("ErrorOutReadKey(%s)", key); } }); }</code><technical_language>@govind-menon remove change "debug" level</technical_language>

Target:
void errorOutReadKey(final CompletionKey key, final int rc) { LOG.debug("Removing completion key: {}", key); final ReadCompletion readCompletion = (ReadCompletion)completionObjects.remove(key); if (null == readCompletion) { return; } executor.submitOrdered(readCompletion.ledgerId, new SafeRunnable() { @Override public void safeRun() { String bAddress = "null"; Channel c = channel; if (c != null && c.getRemoteAddress() != null) { bAddress = c.getRemoteAddress().toString(); } LOG.debug("Could not write request for reading entry: ledger-id: bookie: rc: {}", new Object[]{ readCompletion.entryId, readCompletion.ledgerId, bAddress, rc }); readCompletion.cb.readEntryComplete(rc, readCompletion.ledgerId, readCompletion.entryId, null, readCompletion.ctx); } @Override public String toString() { return String.format("ErrorOutReadKey(%s)", key); } }); }
Source:
<code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Log.d(TAG, "Entering Appium settings"); registerLocaleSettingReceiver(); registerAnimationSettingReceiver(); registerDataConnectionSettingReceiver(); registerLocationInfoReceiver(); <START> if (Build.VERSION.SDK_INT >= 26) { <END> Log.d(TAG, "Initializing the foreground service"); Intent intent = new Intent(Settings.this, ForegroundService.class); intent.setAction(ForegroundService.ACTION_START); startService(intent); } Log.d(TAG, "Closing settings app"); Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { Settings.this.finish(); } }, 1000); }</code><technical_language>Build.VERSION_CODES.O instead of 26</technical_language>

Target:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Log.d(TAG, "Entering Appium settings"); registerLocaleSettingReceiver(); registerAnimationSettingReceiver(); registerDataConnectionSettingReceiver(); registerLocationInfoReceiver(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { Log.d(TAG, "Initializing the foreground service"); Intent intent = new Intent(Settings.this, ForegroundService.class); intent.setAction(ForegroundService.ACTION_START); startService(intent); } Log.d(TAG, "Closing settings app"); Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { Settings.this.finish(); } }, 1000); }
Source:
<code>private int[] getDimVals(final DimDim dimLookup, final List<String> dimValues) { if (dimValues.size() == 0) { dimLookup.add(""); return null; } if (dimValues.size() == 1) { return new int[]{dimLookup.add(dimValues.get(0))}; } String[] dimArray = dimValues.toArray(new String[dimValues.size()]); Arrays.sort(dimArray); final int[] retVal = new int[dimArray.length]; int count = 0; for (String dimValue : dimArray) { <START> retVal[count++] = dimLookup.add(dimValue); <END> } return retVal; }</code><technical_language>remove optimization here</technical_language>

Target:
private int[] getDimVals(final DimDim dimLookup, final List<String> dimValues) { if (dimValues.size() == 0) { dimLookup.add(null); return null; } if (dimValues.size() == 1) { return new int[]{dimLookup.add(dimValues.get(0))}; } String[] dimArray = dimValues.toArray(new String[dimValues.size()]); Arrays.sort(dimArray); final int[] retVal = new int[dimArray.length]; for (int i = 0; i < dimArray.length; i++) { retVal[i] = dimLookup.add(dimArray[i]); } return retVal; }
Source:
<code>protected String[] getCommandArgs() { return new String[]{ "--no-color", <START> "--except=lower-camel-case", <END> "--", inputFile.getPath() }; }</code><technical_language>I set this "--only=constant-naming,constant-k-prefix", syntax "--" line removed</technical_language>

Target:
protected String[] getCommandArgs() { return new String[]{ "--only=constant-naming,constant-k-prefix" }; }
Source:
<code>public void testBuilderFromProperties() throws FileNotFoundException, IOException { String prefix = "rya_"; String auth = "U"; String visibility = "U"; String user = "user"; String password = "password"; String instance = "instance"; String zookeeper = "zookeeper"; boolean useMock = false; boolean useComposite = true; boolean usePrefixHash = true; boolean useInference = true; boolean displayPlan = false; Properties props = new Properties(); props.load(new FileInputStream("src/test/resources/properties/rya.properties")); AccumuloRdfConfiguration conf = AccumuloRdfConfiguration.fromProperties(props); <START> org.junit.Assert.assertEquals(conf.getTablePrefix(), prefix); <END> org.junit.Assert.assertEquals(conf.getCv(), visibility); org.junit.Assert.assertEquals(conf.getAuthorizations(), new Authorizations(auth)); org.junit.Assert.assertEquals(conf.isInfer(), useInference); org.junit.Assert.assertEquals(conf.isUseCompositeCardinality(), useComposite); org.junit.Assert.assertEquals(conf.isDisplayQueryPlan(), displayPlan); org.junit.Assert.assertEquals(conf.getAccumuloInstance(), instance); org.junit.Assert.assertEquals(conf.getAccumuloPassword(), password); org.junit.Assert.assertEquals(conf.getAccumuloUser(), user); org.junit.Assert.assertEquals(conf.getAccumuloZookeepers(), zookeeper); org.junit.Assert.assertEquals(conf.getUseMockAccumulo(), useMock); org.junit.Assert.assertEquals(conf.isPrefixRowsWithHash(), usePrefixHash); }</code><technical_language>nit: statically import assertion methods</technical_language>

Target:
public void testBuilderFromProperties() throws FileNotFoundException, IOException { String prefix = "rya_"; String auth = "U"; String visibility = "U"; String user = "user"; String password = "password"; String instance = "instance"; String zookeeper = "zookeeper"; boolean useMock = false; boolean useComposite = true; boolean usePrefixHash = true; boolean useInference = true; boolean displayPlan = false; Properties props = new Properties(); props.load(new FileInputStream("src/test/resources/properties/rya.properties")); AccumuloRdfConfiguration conf = AccumuloRdfConfiguration.fromProperties(props); assertEquals(conf.getTablePrefix(), prefix); assertEquals(conf.getCv(), visibility); assertEquals(conf.getAuthorizations(), new Authorizations(auth)); assertEquals(conf.isInfer(), useInference); assertEquals(conf.isUseCompositeCardinality(), useComposite); assertEquals(conf.isDisplayQueryPlan(), displayPlan); assertEquals(conf.getAccumuloInstance(), instance); assertEquals(conf.getAccumuloPassword(), password); assertEquals(conf.getAccumuloUser(), user); assertEquals(conf.getAccumuloZookeepers(), zookeeper); assertEquals(conf.getUseMockAccumulo(), useMock); assertEquals(conf.isPrefixRowsWithHash(), usePrefixHash); }
Source:
<code>public void sequencerPerformanceTest() { long start = System.currentTimeMillis(); while (true) { if ((System.currentTimeMillis() - start) / milliToSecond > time) { break; } <START> tokenQuery(runtime, random.nextInt(randomBoundary)); tokenTx(runtime, random.nextInt(randomBoundary)); <END> } }</code><technical_language>tokenQuery tokenTx randomBoundary, means control ratio of requests. Refer 'readPercent' set a ratio for them</technical_language>

Target:
public void sequencerPerformanceTest() throws IOException, InterruptedException { setMetricsReportFlags("sequencer"); Process server = runServer(); runtime = initRuntime(); long start = System.currentTimeMillis(); while (true) { if ((System.currentTimeMillis() - start) / MILLI_TO_SECOND > time) { break; } tokenQuery(runtime, random.nextInt(randomBoundary)); tokenTx(runtime, random.nextInt(randomBoundary)); } killServer(server); }
Source:
<code>public Map<Requirement, Collection<Capability>> findProviders(Collection<? extends Requirement> requirements) { try { if (!init()) { return Collections.emptyMap(); } } catch (RuntimeException re) { <START> throw re; <END> } catch (Exception e) { throw Exceptions.duck(e); } return repoImpl.findProviders(requirements); }</code><technical_language>if duck, need do this extra Runtime check</technical_language>

Target:
public Map<Requirement, Collection<Capability>> findProviders(Collection<? extends Requirement> requirements) { if (!init()) { return Collections.emptyMap(); } return repoImpl.findProviders(requirements); }
Source:
<code><START> void setChecks(List<GitHubBranchCommitCheck> checks) { <END> this.checks = checks; }</code><technical_language>No) sense. this annotations is for arguments for returned value. sense here</technical_language>

Target:
public void setChecks(List<GitHubBranchCommitCheck> checks) { this.checks = checks; }
Source:
<code>public PoolDTO populate(ModelTranslator modelTranslator, Pool source, PoolDTO dest) { if (source == null) { throw new IllegalArgumentException("source is null"); } if (dest == null) { throw new IllegalArgumentException("destination is null"); } dest.setId(source.getId()); dest.setQuantity(source.getQuantity()); dest.setStartDate(source.getStartDate()); dest.setEndDate(source.getEndDate()); dest.setAttributes(source.getAttributes()); dest.setRestrictedToUsername(source.getRestrictedToUsername()); dest.setConsumed(source.getConsumed()); dest.setProductId(source.getProductId()); dest.setProductAttributes(source.getProductAttributes()); dest.setDerivedProductId(source.getDerivedProductId()); if (modelTranslator != null) { Collection<Product> products = source.getProduct() == null ? null : <START> source.getProduct().getProvidedProducts(); <END> if (products != null && !products.isEmpty()) { for (Product prod : products) { if (prod != null) { dest.addProvidedProduct( new PoolDTO.ProvidedProductDTO(prod.getId(), prod.getName())); } } } else { dest.setProvidedProducts(Collections.<PoolDTO.ProvidedProductDTO>emptySet()); } Collection<Product> derivedProducts = source.getDerivedProduct() == null ? null : source.getDerivedProduct().getProvidedProducts(); if (derivedProducts != null && !derivedProducts.isEmpty()) { for (Product derivedProd : derivedProducts) { if (derivedProd != null) { dest.addDerivedProvidedProduct( new PoolDTO.ProvidedProductDTO(derivedProd.getId(), derivedProd.getName())); } } } else { dest.setDerivedProvidedProducts(Collections.<PoolDTO.ProvidedProductDTO>emptySet()); } } return dest; }</code><technical_language>need n-tier aware translations</technical_language>

Target:
public PoolDTO populate(ModelTranslator modelTranslator, Pool source, PoolDTO dest) { if (source == null) { throw new IllegalArgumentException("source is null"); } if (dest == null) { throw new IllegalArgumentException("destination is null"); } dest.setId(source.getId()); dest.setQuantity(source.getQuantity()); dest.setStartDate(source.getStartDate()); dest.setEndDate(source.getEndDate()); dest.setAttributes(source.getAttributes()); dest.setRestrictedToUsername(source.getRestrictedToUsername()); dest.setConsumed(source.getConsumed()); dest.setProductId(source.getProductId()); dest.setProductAttributes(source.getProductAttributes()); dest.setDerivedProductId(source.getDerivedProductId()); if (modelTranslator != null) { Collection<Product> products = source.getProduct() == null ? null : source.getProduct().getProvidedProducts(); Set<PoolDTO.ProvidedProductDTO> providedProductDTOs = new HashSet<>(); addProvidedProducts(products, providedProductDTOs); dest.setProvidedProducts(providedProductDTOs); Collection<Product> derivedProducts = source.getDerivedProduct() == null ? null : source.getDerivedProduct().getProvidedProducts(); Set<PoolDTO.ProvidedProductDTO> derivedProvidedProductDTOs = new HashSet<>(); addProvidedProducts(derivedProducts, derivedProvidedProductDTOs); dest.setDerivedProvidedProducts(derivedProvidedProductDTOs); } return dest; }
Source:
<code>public static AsyncTimeLockUnlocker create(TimelockService timelockService) { return new AsyncTimeLockUnlocker( Autobatchers.<Set<LockToken>, Void>independent(batch -> { Set<LockToken> allTokensToUnlock = batch.stream() .map(BatchElement::argument) .flatMap(Collection::stream) .collect(Collectors.toSet()); try { timelockService.tryUnlock(allTokensToUnlock); } catch (Throwable t) { log.info("Failed to unlock lock tokens from timelock. They will eventually expire on their " + "own, but if this message recurs frequently, it may be worth investigation.", SafeArg.of("numFailed", allTokensToUnlock.size()), <START> SafeArg.of("firstFailures", <END> Iterables.transform(Iterables.limit(allTokensToUnlock, 20), LockToken::getRequestId)), t); } batch.stream().map(BatchElement::result).forEach(f -> f.set(null)); }) .safeLoggablePurpose("async-timelock-unlocker") .build()); }</code><technical_language>of lock leasing, logging request id useful, a randomly client assigned id actual request id server, do this request id (for LockTokenShare class least) this is of sharing a lock for immutable timestamp for n transactions biasing *not* logging request ids, logging potentially non-actionable ones</technical_language>

Target:
public static AsyncTimeLockUnlocker create(TimelockService timelockService) { return new AsyncTimeLockUnlocker( Autobatchers.<Set<LockToken>, Void>independent(batch -> { Set<LockToken> allTokensToUnlock = batch.stream() .map(BatchElement::argument) .flatMap(Collection::stream) .collect(Collectors.toSet()); try { timelockService.tryUnlock(allTokensToUnlock); } catch (Throwable t) { log.info("Failed to unlock lock tokens from timelock. They will eventually expire on their " + "own, but if this message recurs frequently, it may be worth investigation.", SafeArg.of("numFailed", allTokensToUnlock.size()), t); } batch.stream().map(BatchElement::result).forEach(f -> f.set(null)); }) .safeLoggablePurpose("async-timelock-unlocker") .build()); }
Source:
<code>private List<RefContentProposal> createContentProposals( final Collection<Ref> refs, final Ref HEAD) { final TreeSet<Ref> set = new TreeSet<>(new Comparator<Ref>() { @Override public int compare(Ref o1, Ref o2) { return o1.getName().compareTo(o2.getName()); } }); set.addAll(refs); if (HEAD != null) set.add(HEAD); final List<RefContentProposal> result = new ArrayList<>( set.size()); <START> for (final Ref r : set) <END> result.add(new RefContentProposal(localDb, r, HEAD == null)); return result; }</code><technical_language>missing braces</technical_language>

Target:
private List<RefContentProposal> createContentProposals( final Collection<Ref> refs, final Ref HEAD) { final TreeSet<Ref> set = new TreeSet<>(new Comparator<Ref>() { @Override public int compare(Ref o1, Ref o2) { return o1.getName().compareTo(o2.getName()); } }); set.addAll(refs); if (HEAD != null) { set.add(HEAD); } final List<RefContentProposal> result = new ArrayList<>( set.size()); for (final Ref r : set) { result.add(new RefContentProposal(localDb, r, HEAD == null)); } return result; }
Source:
<code>void avoidArtifactDuplicates( Set<Artifact> providerArtifacts ) { for ( Artifact artifact : artifacts ) { Iterator<Artifact> it = providerArtifacts.iterator(); while ( it.hasNext() ) { Artifact providerArtifact = it.next(); String classifier1 = providerArtifact.getClassifier(); String classifier2 = artifact.getClassifier(); if ( providerArtifact.getGroupId().equals( artifact.getGroupId() ) && providerArtifact.getArtifactId().equals( artifact.getArtifactId() ) && providerArtifact.getType().equals( artifact.getType() ) && ( classifier1 == null ? classifier2 == null : classifier1.equals( classifier2 ) ) ) { it.remove(); <START> if ( mojo != null && mojo.getLog().isDebugEnabled() ) <END> { mojo.getLog().debug( "Removed artifact " + providerArtifact + " from provider. " + "Already appears in test classpath." ); } } } } addMissingArtifacts( providerArtifacts ); adoptArtifactVersions( providerArtifacts ); }</code><technical_language>I problems this class: 1. AbstractSurefireMojo here. 2. provider is executed. add a boolean this method isPlatformPrvicer enum instead of null-checks in if ( junitJupiterApi != null && junitJupiterEngine == null ). 3. do align versions of junit-platform-launcher dependency of provider in classpath user's dependency version well</technical_language>

Target:
void avoidArtifactDuplicates( Set<Artifact> providerArtifacts ) { for ( Artifact artifact : artifacts ) { Iterator<Artifact> it = providerArtifacts.iterator(); while ( it.hasNext() ) { Artifact providerArtifact = it.next(); String classifier1 = providerArtifact.getClassifier(); String classifier2 = artifact.getClassifier(); if ( providerArtifact.getGroupId().equals( artifact.getGroupId() ) && providerArtifact.getArtifactId().equals( artifact.getArtifactId() ) && providerArtifact.getType().equals( artifact.getType() ) && ( classifier1 == null ? classifier2 == null : classifier1.equals( classifier2 ) ) ) { it.remove(); if ( logger.isDebugEnabled() ) { logger.debug( "Removed artifact " + providerArtifact + " from provider. " + "Already appears in test classpath." ); } } } } }
Source:
<code>private void publishFailureEvent(String message, String error, String configName, String formTitle, String body) { <START> Map<String, Object> params = new HashMap<>(); <END> params.put(EventParameters.CONFIGURATION_NAME, configName); params.put(EventParameters.FORM_TITLE, formTitle); params.put(EventParameters.MESSAGE, message); params.put(EventParameters.EXCEPTION, error); params.put(EventParameters.JSON_CONTENT, body); eventRelay.sendEventMessage(new MotechEvent(EventSubjects.FORM_FAIL, params)); }</code><technical_language>I more sense put this in event builder class, separate web layer</technical_language>

Target:
private void publishFailureEvent(String message, String error, String configName, String formTitle, String body) { FailureEventBuilder builder = new FailureEventBuilder(); builder.setMessage(message) .setError(error) .setConfigName(configName) .setFormTitle(formTitle) .setBody(body); MotechEvent event = builder.createFailureEvent(); eventRelay.sendEventMessage(event); }
Source:
<code>public static void setupXStreamSecurityPolicy(XStream xstream) { xstream.addPermission(NoTypePermission.NONE); for (TypePermission perm : Arrays.asList(NullPermission.NULL, ArrayTypePermission.ARRAYS, PrimitiveTypePermission.PRIMITIVES)) { xstream.addPermission(perm); } for (Class<?> allowHierarchy : Arrays.asList(java.util.Collection.class, org.apache.jmeter.testelement.TestElement.class, org.apache.jorphan.collections.HashTree.class, org.apache.jmeter.samplers.SampleSaveConfiguration.class)) { <START> xstream.allowTypeHierarchy(allowHierarchy); <END> } xstream.allowTypes(new String[] { "org.apache.jmeter.save.ScriptWrapper", "org.apache.jmeter.testelement.property.JMeterProperty" }); xstream.allowTypesByRegExp(new String[] { "^org\\.apache\\.jmeter\\.(testelement|protocol|gui\\.action\\.template)\\..*" }); String[] regexps = getPropDefault("jmeter.xstream.regex_whitelists", "").split("\\s*,\\s*"); if (regexps.length > 0) { xstream.allowTypesByRegExp(regexps); } String[] wildcards = getPropDefault("jmeter.xstream.wildcard_whitelists", "").split("\\s*,\\s*"); if (wildcards.length > 0) { xstream.allowTypesByWildcard(wildcards); } if (getPropDefault("jmeter.xstream.permissive", false)) { xstream.addPermission(AnyTypePermission.ANY); } }</code><technical_language>allow subclasses of SampleResult</technical_language>

Target:
public static void setupXStreamSecurityPolicy(XStream xstream) { xstream.addPermission(NoTypePermission.NONE); xstream.addPermission(new LoggingPermissiveTypePermission()); for (TypePermission perm : Arrays.asList(NullPermission.NULL, ArrayTypePermission.ARRAYS, PrimitiveTypePermission.PRIMITIVES)) { xstream.addPermission(perm); } for (Class<?> allowHierarchy : Arrays.asList(java.util.Collection.class, org.apache.jmeter.testelement.TestElement.class, org.apache.jorphan.collections.HashTree.class, org.apache.jmeter.samplers.SampleSaveConfiguration.class, org.apache.jmeter.samplers.SampleResult.class)) { xstream.allowTypeHierarchy(allowHierarchy); } xstream.allowTypes(new String[] { "org.apache.jmeter.save.ScriptWrapper", "org.apache.jmeter.testelement.property.JMeterProperty" }); xstream.allowTypesByRegExp(new String[] { "^org\\.apache\\.jmeter\\.(testelement|protocol|gui\\.action\\.template)\\..*" }); String[] regexps = getPropDefault("jmeter.xstream.regex_whitelists", "").split("\\s*,\\s*"); if (regexps.length > 0) { xstream.allowTypesByRegExp(regexps); } String[] wildcards = getPropDefault("jmeter.xstream.wildcard_whitelists", "").split("\\s*,\\s*"); if (wildcards.length > 0) { xstream.allowTypesByWildcard(wildcards); } if (getPropDefault("jmeter.xstream.permissive", false)) { xstream.addPermission(AnyTypePermission.ANY); } }
Source:
<code>public MesosCloud( String mesosMasterUrl, String frameworkName, String frameworkId, String role, String agentUser, String jenkinsURL, List<? extends MesosAgentSpecTemplate> mesosAgentSpecTemplates) throws InterruptedException, ExecutionException, IOException { super("MesosCloud", null); try { this.master = mesosMasterUrl; this.jenkinsURL = new URL(jenkinsURL); } catch (MalformedURLException e) { throw new RuntimeException( String.format("Mesos Cloud URL validation failed for Jenkins %s", jenkinsURL), e); } if (selfIsMesosTask()) { String mesosSandbox = System.getenv("MESOS_SANDBOX"); this.sslCert = Optional.ofNullable(loadDcosCert(mesosSandbox)); this.dcosAuthorization = Optional.ofNullable(loadDcosAuthorization()); } else { this.sslCert = Optional.empty(); this.dcosAuthorization = Optional.empty(); } this.agentUser = agentUser; this.role = role; <START> this.mesosAgentSpecTemplates = mesosAgentSpecTemplates != null ? mesosAgentSpecTemplates : Collections.emptyList(); <END> this.frameworkName = frameworkName; this.frameworkId = frameworkId; if (StringUtils.isEmpty(this.frameworkId)) { this.frameworkId = UUID.randomUUID().toString(); } logger.info( "Created Mesos cloud instance for framework and endpoint {}", this.frameworkId, this.master); }</code><technical_language>Hudson.util static method for fixing empty collections <LINK_0> suggestion this.mesosAgentSpecTemplates = Util.fixNull(mesosAgentSpecTemplates);</technical_language>

Target:
public MesosCloud( String mesosMasterUrl, String frameworkName, String frameworkId, String role, String agentUser, String jenkinsURL, List<? extends MesosAgentSpecTemplate> mesosAgentSpecTemplates) throws InterruptedException, ExecutionException, IOException { super("MesosCloud", null); try { this.master = mesosMasterUrl; this.jenkinsURL = new URL(jenkinsURL); } catch (MalformedURLException e) { throw new RuntimeException( String.format("Mesos Cloud URL validation failed for Jenkins %s", jenkinsURL), e); } if (selfIsMesosTask()) { String mesosSandbox = System.getenv("MESOS_SANDBOX"); this.sslCert = Optional.ofNullable(loadDcosCert(mesosSandbox)); this.dcosAuthorization = Optional.ofNullable(loadDcosAuthorization()); } else { this.sslCert = Optional.empty(); this.dcosAuthorization = Optional.empty(); } this.agentUser = agentUser; this.role = role; this.mesosAgentSpecTemplates = Util.fixNull(mesosAgentSpecTemplates); this.frameworkName = frameworkName; this.frameworkId = frameworkId; if (StringUtils.isEmpty(this.frameworkId)) { this.frameworkId = UUID.randomUUID().toString(); } logger.info( "Created Mesos cloud instance for framework and endpoint {}", this.frameworkId, this.master); }
Source:
<code>public void manualAbortProcess() throws Exception { ProcessTree.enabled = true; FreeStyleProject project = j.createFreeStyleProject(); project.setScm(new ExtractResourceSCM(getClass().getResource( "ProcessTreeKiller-test-project.jar"))); project.getBuildersList().add(new Maven("install", "maven")); final QueueTaskFuture<FreeStyleBuild> f = project.scheduleBuild2(0); final FreeStyleBuild b = f.waitForStart(); boolean sleepTestStarted = false; while (b.isBuilding()) { final String log = readFully(b.getLogReader()); sleepTestStarted = log != null && log.contains("Running SleepingTest"); if (sleepTestStarted) { break; } <START> Thread.sleep(1000); <END> } assertTrue(sleepTestStarted); b.doStop(); j.assertBuildStatus(Result.ABORTED, f.get()); b.getWorkspace().deleteRecursive(); }</code><technical_language>Nit: easier read TimeUnit.SECONDS.sleep(1); instead</technical_language>

Target:
public void manualAbortProcess() throws Exception { ProcessTree.enabled = true; FreeStyleProject project = j.createFreeStyleProject(); project.setScm(new ExtractResourceSCM(getClass().getResource( "ProcessTreeKiller-test-project.jar"))); project.getBuildersList().add(new Maven("install", "maven")); final QueueTaskFuture<FreeStyleBuild> f = project.scheduleBuild2(0); final FreeStyleBuild b = f.waitForStart(); String buildLog = null; boolean sleepTestStarted = false; while (b.isBuilding()) { buildLog = readFully(b.getLogReader()); sleepTestStarted = buildLog != null && buildLog.contains("SleepingTest"); if (sleepTestStarted) { break; } TimeUnit.SECONDS.sleep(1); } assertTrue(buildLog, sleepTestStarted); b.doStop(); j.assertBuildStatus(Result.ABORTED, f.get()); b.getWorkspace().deleteRecursive(); }
Source:
<code>private static boolean unpacked(Any any) { <START> checkNotNull(any); <END> final BoolValue unpacked = unpack(any, BoolValue.class); return unpacked.getValue(); }</code><technical_language>do do for a private static method</technical_language>

Target:
private static boolean unpacked(Any any) { final BoolValue unpacked = unpack(any, BoolValue.class); return unpacked.getValue(); }
Source:
<code><START> public CatalogEntitySummary getEntity(String entityId) { <END> Maybe<VersionedName> versionedName = Osgis.parseOsgiIdentifier(entityId); String symbolicName; String version; if (versionedName.isPresent()) { symbolicName = versionedName.get().getSymbolicName(); version = (versionedName.get().getVersion() != null) ? versionedName.get().getVersion().toString() : BrooklynCatalog.DEFAULT_VERSION; } else { symbolicName = entityId; version = BrooklynCatalog.DEFAULT_VERSION; } @SuppressWarnings("unchecked") CatalogItem<? extends Entity,EntitySpec<?>> result = (CatalogItem<? extends Entity,EntitySpec<?>>) brooklyn().getCatalog().getCatalogItem(symbolicName, version); if (result==null) { throw WebResourceUtils.notFound("Entity with id '%s' not found", entityId); } return CatalogTransformer.catalogEntitySummary(brooklyn(), result); }</code><technical_language>CatalogUtils convenience replace this entire method</technical_language>

Target:
public CatalogEntitySummary getEntity(String entityId) { CatalogItem<? extends Entity,EntitySpec<?>> result = CatalogUtils.getCatalogItemOptionalVersion(mgmt(), Entity.class, entityId); if (result==null) { throw WebResourceUtils.notFound("Entity with id '%s' not found", entityId); } return CatalogTransformer.catalogEntitySummary(brooklyn(), result); }
Source:
<code>public <X> ExtendedQueryResult<T> orderAsc(SingularAttribute<T, X> attribute, boolean appendEntityName) { lastPaginatedQuery = null; <START> if (!context.getRepositoryMethod().isQuery()) { <END> context.addCriteriaBuilderPostProcessor(new OrderByCriteriaBuilderPostProcessor(attribute, OrderDirection.ASC)); } else { context.addQueryStringPostProcessor(new OrderByQueryStringPostProcessor(attribute, OrderDirection.ASC, appendEntityName)); } return this; }</code><technical_language>negative logic</technical_language>

Target:
public <X> ExtendedQueryResult<T> orderAsc(SingularAttribute<T, X> attribute, boolean appendEntityName) { lastPaginatedQuery = null; if (context.getRepositoryMethod().isQuery()) { context.addQueryStringPostProcessor(new OrderByQueryStringPostProcessor(attribute, OrderDirection.ASC, appendEntityName)); } else { context.addCriteriaBuilderPostProcessor(new OrderByCriteriaBuilderPostProcessor(attribute, OrderDirection.ASC)); } return this; }
Source:
<code>public MQTTDataGenerator connectToTopic(final String topic) { MQTTDataGenerator dataGenerator = dataGeneratorMap.get(topic); if (dataGenerator == null) { dataGenerator = new MQTTDataGenerator(this, topic); <START> dataGeneratorMap.put(topic, dataGenerator); <END> } return dataGenerator; }</code><technical_language>putIfAbsent synchronized block</technical_language>

Target:
public MQTTDataGenerator connectToTopic(final String topic) { MQTTDataGenerator dataGenerator = dataGeneratorMap.get(topic); if (dataGenerator == null) { dataGenerator = new MQTTDataGenerator(this, topic); dataGeneratorMap.putIfAbsent(topic, dataGenerator); dataGenerator = dataGeneratorMap.get(topic); } return dataGenerator; }
Source:
<code><START> public int getActionFilters() { <END> Integer actionFilterId; int i = 0; List<FilterSet> filterSetList = new ArrayList<>(taskContext.getTask().getTaskConfig().getFilters()); for (FilterSet filterSet : filterSetList) { actionFilterId = filterSet.getActionOrder(); if(actionFilterId != null) { return i; } i++; } return i; }</code><technical_language>this method complicated, try simplify it. is more readable return statement</technical_language>

Target:
public int getActionFilters() { int firstActionFilterIndex = 0; boolean actionFilterExist = false; List<FilterSet> filterSetList = new ArrayList<>(taskContext.getTask().getTaskConfig().getFilters()); for (int i = 0; i < filterSetList.size(); i++){ if(isActionFilter(filterSetList.get(i)) && !actionFilterExist) { firstActionFilterIndex = i; actionFilterExist = true; } else if (!isActionFilter(filterSetList.get(i))) { firstActionFilterIndex = filterSetList.size(); } } return firstActionFilterIndex; }
Source:
<code>public void onRequestTargetSet(RequestCycle cycle, Class<? extends IRequestablePage> requestTarget) { <START> WicketCallback.super.onRequestTargetSet(cycle, requestTarget); <END> LockType type = THREAD_LOCK.get(); Class<? extends IRequestablePage> requestedPage = THREAD_REQUESTED_PAGE.get(); if (type != null && requestedPage != null && requestedPage != requestTarget) { boolean lockTaken = locker.tryLock(type); if (!lockTaken && !GeoServerUnlockablePage.class.isAssignableFrom(requestTarget)) { cycle.setResponsePage(ServerBusyPage.class); } } }</code><technical_language>call other method, merge one, all, other method is get called anymore GeoServerApplication right</technical_language>

Target:
public void onRequestTargetSet(RequestCycle cycle, Class<? extends IRequestablePage> requestTarget) { if (!GeoServerUnlockablePage.class.isAssignableFrom(requestTarget)) { LockType type = THREAD_LOCK.get(); if (type != null || requestTarget == null) { return; } if (GeoServerSecuredPage.class.isAssignableFrom(requestTarget)) { type = LockType.WRITE; } if (type == null) { type = LockType.READ; } boolean lockTaken = locker.tryLock(type); if (lockTaken) { THREAD_LOCK.set(type); } } LockType type = THREAD_LOCK.get(); if (cycle != null && type != null) { boolean lockTaken = locker.tryLock(type); if (!lockTaken && !GeoServerUnlockablePage.class.isAssignableFrom(requestTarget)) { cycle.setResponsePage(ServerBusyPage.class); } } }
Source:
<code>private static void configureJaCoCoCoverageReport(final Test testTask, final boolean addForGroovy, Project project, final Map<String, Object> properties) { project.getTasks().withType(JacocoReport.class, jacocoReportTask -> { SingleFileReport xmlReport = jacocoReportTask.getReports().getXml(); <START> if (xmlReport.isEnabled() && xmlReport.getDestination().exists()) { <END> appendProp(properties, "sonar.coverage.jacoco.xmlReportPaths", xmlReport.getDestination()); } }); project.getPlugins().withType(JacocoPlugin.class, jacocoPlugin -> { JacocoTaskExtension jacocoTaskExtension = testTask.getExtensions().getByType(JacocoTaskExtension.class); File destinationFile = jacocoTaskExtension.getDestinationFile(); if (destinationFile.exists()) { properties.put("sonar.jacoco.reportPath", destinationFile); appendProp(properties, "sonar.jacoco.reportPaths", destinationFile); if (addForGroovy) { properties.put("sonar.groovy.jacoco.reportPath", destinationFile); } } }); }</code><technical_language>log a message xml report is enabled</technical_language>

Target:
private static void configureJaCoCoCoverageReport(final Test testTask, final boolean addForGroovy, Project project, final Map<String, Object> properties) { project.getTasks().withType(JacocoReport.class, jacocoReportTask -> { SingleFileReport xmlReport = jacocoReportTask.getReports().getXml(); if (xmlReport.isEnabled() && xmlReport.getDestination().exists()) { appendProp(properties, "sonar.coverage.jacoco.xmlReportPaths", xmlReport.getDestination()); } else { LOGGER.info("JaCoCo report task detected, but XML report is not enabled or it was not produced. " + "Coverage for this task will not be reported."); } }); project.getPlugins().withType(JacocoPlugin.class, jacocoPlugin -> { JacocoTaskExtension jacocoTaskExtension = testTask.getExtensions().getByType(JacocoTaskExtension.class); File destinationFile = jacocoTaskExtension.getDestinationFile(); if (destinationFile.exists()) { properties.put("sonar.jacoco.reportPath", destinationFile); appendProp(properties, "sonar.jacoco.reportPaths", destinationFile); if (addForGroovy) { properties.put("sonar.groovy.jacoco.reportPath", destinationFile); } } }); }
Source:
<code>public boolean isTopologyStateful() { Map<String, Object> config = topologyContext.getTopologyConfig(); <START> return String.valueOf(Config.TopologyReliabilityMode.EFFECTIVELY_ONCE).equals( <END> config.get(Config.TOPOLOGY_RELIABILITY_MODE)); }</code><technical_language>is good a method convert config.get(Config.TOPOLOGY_RELIABILITY_MODE) enum compare enum values. Comparing Strings is error prone</technical_language>

Target:
public boolean isTopologyStateful() { Map<String, Object> config = topologyContext.getTopologyConfig(); Config.TopologyReliabilityMode mode = Config.TopologyReliabilityMode.valueOf( String.valueOf(config.get(Config.TOPOLOGY_RELIABILITY_MODE))); return Config.TopologyReliabilityMode.EFFECTIVELY_ONCE.equals(mode); }
Source:
<code>public void getScoreTotal() { TestdataEntity e1 = new TestdataEntity("e1"); TestdataEntity e2 = new TestdataEntity("e2"); TestdataEntity e3 = new TestdataEntity("e3"); ConstraintMatchTotal constraintMatchTotal = new ConstraintMatchTotal("package1", "constraint1", SimpleScore.ZERO); <START> assertThat(constraintMatchTotal.getScore()).isEqualTo((org.optaplanner.core.api.score.Score) SimpleScore.ZERO); <END> ConstraintMatch match1 = constraintMatchTotal.addConstraintMatch(asList(e1, e2), SimpleScore.of(-1)); assertThat(constraintMatchTotal.getScore()).isEqualTo((org.optaplanner.core.api.score.Score) SimpleScore.of(-1)); ConstraintMatch match2 = constraintMatchTotal.addConstraintMatch(asList(e1, e3), SimpleScore.of(-20)); assertThat(constraintMatchTotal.getScore()).isEqualTo((org.optaplanner.core.api.score.Score) SimpleScore.of(-21)); ConstraintMatch match3 = constraintMatchTotal.addConstraintMatch(asList(e2, e1), SimpleScore.of(-300)); assertThat(constraintMatchTotal.getScore()).isEqualTo((org.optaplanner.core.api.score.Score) SimpleScore.of(-321)); constraintMatchTotal.removeConstraintMatch(match2); assertThat(constraintMatchTotal.getScore()).isEqualTo((org.optaplanner.core.api.score.Score) SimpleScore.of(-301)); constraintMatchTotal.removeConstraintMatch(match1); assertThat(constraintMatchTotal.getScore()).isEqualTo((org.optaplanner.core.api.score.Score) SimpleScore.of(-300)); constraintMatchTotal.removeConstraintMatch(match3); assertThat(constraintMatchTotal.getScore()).isEqualTo((org.optaplanner.core.api.score.Score) SimpleScore.ZERO); }</code><technical_language>This cast sense. Casting "actual" argument SimpleScore sense</technical_language>

Target:
public void getScoreTotal() { TestdataEntity e1 = new TestdataEntity("e1"); TestdataEntity e2 = new TestdataEntity("e2"); TestdataEntity e3 = new TestdataEntity("e3"); ConstraintMatchTotal constraintMatchTotal = new ConstraintMatchTotal("package1", "constraint1", SimpleScore.ZERO); assertThat(constraintMatchTotal.getScore()).isEqualTo(SimpleScore.ZERO); ConstraintMatch match1 = constraintMatchTotal.addConstraintMatch(asList(e1, e2), SimpleScore.of(-1)); assertThat(constraintMatchTotal.getScore()).isEqualTo(SimpleScore.of(-1)); ConstraintMatch match2 = constraintMatchTotal.addConstraintMatch(asList(e1, e3), SimpleScore.of(-20)); assertThat(constraintMatchTotal.getScore()).isEqualTo(SimpleScore.of(-21)); ConstraintMatch match3 = constraintMatchTotal.addConstraintMatch(asList(e2, e1), SimpleScore.of(-300)); assertThat(constraintMatchTotal.getScore()).isEqualTo(SimpleScore.of(-321)); constraintMatchTotal.removeConstraintMatch(match2); assertThat(constraintMatchTotal.getScore()).isEqualTo(SimpleScore.of(-301)); constraintMatchTotal.removeConstraintMatch(match1); assertThat(constraintMatchTotal.getScore()).isEqualTo(SimpleScore.of(-300)); constraintMatchTotal.removeConstraintMatch(match3); assertThat(constraintMatchTotal.getScore()).isEqualTo(SimpleScore.ZERO); }
Source:
<code>public void testOpenshiftConnection(OpenShift3Connection connection) { log.info("Performing test of OS 3 connection: " + connection.getTreeItem().getText()); connection.refresh(); try { new WaitUntil(new ShellIsAvailable("Problem occurred"), TimePeriod.getCustom(30)); CDKUtils.captureScreenshot("CDKServerAdapterAbstractTest#testOpenshiftConnection"); <START> new DefaultShell("Problem occurred").close(); END> fail("Problem dialog occured when refreshing OpenShift connection"); } catch (WaitTimeoutExpiredException ex) { log.info("Expected WaitTimeoutExpiredException occured"); } }</code><technical_language>@odockal this moved CDKLabel class(or similar)</technical_language>

Target:
public void testOpenshiftConnection(OpenShift3Connection connection) { log.info("Performing test of OS 3 connection: " + connection.getTreeItem().getText()); connection.refresh(); try { new WaitUntil(new ShellIsAvailable(CDKLabel.Shell.PROBLEM_DIALOG), TimePeriod.getCustom(30)); CDKUtils.captureScreenshot("CDKServerAdapterAbstractTest#testOpenshiftConnection"); new DefaultShell(CDKLabel.Shell.PROBLEM_DIALOG).close(); fail("Problem dialog occured when refreshing OpenShift connection"); } catch (WaitTimeoutExpiredException ex) { log.info("Expected WaitTimeoutExpiredException occured"); } }
Source:
<code>public void testGetAllFromDisksIncludingSnapshotsByDiskId() { List<Disk> result = dao.getAllFromDisksIncludingSnapshotsByDiskId(FixturesTool.IMAGE_GROUP_ID, null, false); <START> List<Disk> sameImageIdDisks = result.stream().filter(disk -> disk.getId().equals(FixturesTool.IMAGE_GROUP_ID)).collect( Collectors.toList()); assertEquals("wrong number of returned disks", 4, sameImageIdDisks.size()); <END> }</code><technical_language>do need filtering here</technical_language>

Target:
public void testGetAllFromDisksIncludingSnapshotsByDiskId() { List<Disk> result = dao.getAllFromDisksIncludingSnapshotsByDiskId(FixturesTool.IMAGE_GROUP_ID, null, false); assertEquals("wrong number of returned disks", 4, result.size()); }
Source:
<code>public String getName() { <START> return "Byte_array"; <END> }</code><technical_language>Is uppercase "Byte" expected? If so, wondering if other types consistent this naming scheme. ByteMappedType for instance. add _as_string suffix consistent PrimitiveByteArrayStringType</technical_language>

Target:
public String getName() { return "byte_array_as_string"; }
Source:
<code>public String[] getAdapterNames() { if (element.isValid()) { String[] adapters = Arrays.stream(element.getChildren()) .filter(child -> "adapter".equals(child.getName())) .map(child -> child.getAttribute("type")) <START> .filter(Objects::nonNull).toArray(String[]::new); <END> if (adapters.length == 0) { logError(); } return adapters; } String msg = NLS.bind(RegistryMessages.adapters_cantInstansiate, "<unknown>", "<unknown>"); RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, msg, null)); return new String[0]; }</code><technical_language>moving toArray() a line of rest</technical_language>

Target:
public String[] getAdapterNames() { return adapterNames; }
Source:
<code>public static void showPushNotification(Context context, Intent messageIntent) { final MPConfig config = MPConfig.getInstance(context); String resourcePackage = config.getResourcePackageName(); if (null == resourcePackage) { resourcePackage = context.getPackageName(); } final ResourceIds drawableIds = new ResourceReader.Drawables(resourcePackage, context); final Context applicationContext = context.getApplicationContext(); <START> MixpanelPushNotification mixpanelPushNotification = new MixpanelPushNotification(applicationContext, drawableIds); <END> Notification notification = mixpanelPushNotification.createNotification(messageIntent); if (null != notification) { final NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notification); } }</code><technical_language>implementation developers override notification is built if want add new features modify settings (that's makeNotificationIf... methods protected if devs overriding MixpanelFCMMessagingService). need a developers override notification posted notificationmanager</technical_language>

Target:
public static void showPushNotification(Context context, Intent messageIntent) { MixpanelPushNotification mixpanelPushNotification = new MixpanelPushNotification(context.getApplicationContext()); showPushNotification(context, messageIntent, mixpanelPushNotification); }
Source:
<code>public void setUp() throws IOException { bout = new ByteArrayOutputStream(); out = new PrintStream(bout); System.setOut(out); <START> JobSearchCreateTenant.createTenant(PROJECT_ID, TENANT_EXT_ID); <END> String got = bout.toString(); assertThat(got).contains("Created Tenant"); tenantId = JobSearchListGetCompanyTest.extractLastId(got.split("\n")[1]); bout = new ByteArrayOutputStream(); out = new PrintStream(bout); System.setOut(out); JobSearchCreateCompany.createCompany( PROJECT_ID, tenantId, COMPANY_DISPLAY_NAME, COMPANY_EXT_ID); got = bout.toString(); assertThat(got).contains("Created Company"); companyId = JobSearchListGetCompanyTest.extractLastId(got.split("\n")[1]); bout = new ByteArrayOutputStream(); out = new PrintStream(bout); System.setOut(out); JobSearchCreateJob.createJob( PROJECT_ID, tenantId, companyId, POST_UNIQUE_ID, "Developer Programs Engineer", "Developer Programs Engineers are the Engineering wing of Developer Relations.", "<LINK_0>", "Moantain View, CA", "94035", "en-US"); got = bout.toString(); assertThat(got).contains("Created job:"); jobId = JobSearchListGetCompanyTest.extractLastId(got.split("\n")[0].trim()); bout = new ByteArrayOutputStream(); out = new PrintStream(bout); System.setOut(out); }</code><technical_language>this a long time run? Is worth pre-creating a lot of setup steps in a DO_NOT_DELETE company / tenant id tests access</technical_language>

Target:
public void setUp() throws IOException { bout = new ByteArrayOutputStream(); out = new PrintStream(bout); System.setOut(out); }
Source:
<code>public Iterable<String> getAllContainerNames() { ArrayList<String> containers = new ArrayList<String>(containerToBlobs.keySet()); Collections.sort(containers); <START> return containers; <END> }</code><technical_language>I checked Atmos, Azure, CloudFiles, AWS-S3 sort well. sort in FilesystemStorageStrategyImpl.getAllContainerNames for consistency</technical_language>

Target:
public Collection<String> getAllContainerNames() { return containerToBlobs.keySet(); }
Source:
<code>public JobStatus waitForCompletion(final String jobId, final long blockTimeout, final long pollTime) throws GenieClientException, InterruptedException, IOException { if (StringUtils.isEmpty(jobId)) { throw new IllegalArgumentException("Missing required parameter: jobId."); } final long startTime = System.currentTimeMillis(); while (true) { final JobStatus status = this.getJobStatus(jobId); if (status == JobStatus.FAILED || status == JobStatus.KILLED || status == JobStatus.SUCCEEDED) { return status; } if (System.currentTimeMillis() - startTime < blockTimeout) { Thread.sleep(pollTime); } else { <START> throw new GenieClientException("Timed out waiting for job to finish"); <END> } } }</code><technical_language>discussed, GenieTimeoutException better</technical_language>

Target:
public JobStatus waitForCompletion(final String jobId, final long blockTimeout, final long pollTime) throws GenieClientException, InterruptedException, IOException, GenieTimeoutException { if (StringUtils.isEmpty(jobId)) { throw new IllegalArgumentException("Missing required parameter: jobId."); } final long startTime = System.currentTimeMillis(); while (true) { final JobStatus status = this.getJobStatus(jobId); if (status == JobStatus.FAILED || status == JobStatus.KILLED || status == JobStatus.SUCCEEDED) { return status; } if (System.currentTimeMillis() - startTime < blockTimeout) { Thread.sleep(pollTime); } else { throw new GenieTimeoutException("Timed out waiting for job to finish"); } } }