auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public File tryFindHook(Repository repository, final Hook hook) { final File gitDir = repository.getDirectory(); final File[] hookDirCandidates = gitDir.listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.isDirectory() && pathname.getName().equals("hooks"); } }); if (hookDirCandidates.length < 1) return null; final File[] matchingHooks = hookDirCandidates[0] .listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.isFile() && pathname.getName().equals(hook.getName()); } }); if (matchingHooks.length < 1) return null; return matchingHooks[0]; }

Target:
public File tryFindHook(Repository repository, final Hook hook) { final File gitDir = repository.getDirectory(); final File[] hookDirCandidates = gitDir.listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.isDirectory() && pathname.getName().equals("hooks"); } }); if (hookDirCandidates == null || hookDirCandidates.length < 1) return null; final File[] matchingHooks = hookDirCandidates[0] .listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.isFile() && pathname.getName().equals(hook.getName()); } }); if (matchingHooks == null || matchingHooks.length < 1) return null; return matchingHooks[0]; }
Source:
public double getInflationRate(final Double firstTime, final Double secondTime) { ArgumentChecker.isTrue(firstTime < secondTime, "firstTime should be before secondTime"); return this.getPriceIndex(secondTime) / this.getPriceIndex(firstTime) - 1.0; }

Target:
public double getInflationRate(final Double firstTime, final Double secondTime) { ArgumentChecker.isTrue(firstTime < secondTime, "first time should be before second time {}", firstTime, secondTime); return this.getPriceIndex(secondTime) / this.getPriceIndex(firstTime) - 1.0; }
Source:
public GraphQLSchema build() { return build(null); }

Target:
public GraphQLSchema build() { return build(Collections.<GraphQLType>emptySet()); }
Source:
public RuntimeException translateException(Exception exception) { RuntimeException runtimeException = exception instanceof RuntimeException ? (RuntimeException) exception : new RuntimeException(exception.getMessage(), exception); RuntimeException potentiallyTranslatedException = exceptionTranslator .translateExceptionIfPossible(runtimeException); return potentiallyTranslatedException != null ? potentiallyTranslatedException : runtimeException; }

Target:
private RuntimeException translateException(Exception exception) { RuntimeException runtimeException = exception instanceof RuntimeException ? (RuntimeException) exception : new RuntimeException(exception.getMessage(), exception); RuntimeException potentiallyTranslatedException = exceptionTranslator .translateExceptionIfPossible(runtimeException); return potentiallyTranslatedException != null ? potentiallyTranslatedException : runtimeException; }
Source:
public void handleOutgoingSessionNegotiation( final OutgoingSessionNegotiation negotiation) { executor.execute(new Runnable() { @Override public void run() { SessionNegotiation.Status status = negotiation .start(new ConsoleProgressIndicator(System.out)); if (status == Status.OK) sessionManager.startSharingProjects(negotiation.getPeer()); else if (status == Status.ERROR || status == Status.REMOTE_ERROR) log.error(negotiation.getErrorMessage()); } }); }

Target:
public void handleOutgoingSessionNegotiation( final OutgoingSessionNegotiation negotiation) { sessionExecutor.execute(new Runnable() { @Override public void run() { SessionNegotiation.Status status; if (ServerConfig.isInteractive()) { status = negotiation .start(new ConsoleProgressIndicator(System.out)); } else { status = negotiation .start(new NullProgressMonitor()); } switch (status) { case OK: sessionManager.startSharingProjects(negotiation.getPeer()); break; case ERROR: log.error("ERROR running session negotiation: "+negotiation.getErrorMessage()); break; case REMOTE_ERROR: log.error("REMOTE_ERROR running session negotiation: "+ negotiation.getErrorMessage()+" at remote: "+negotiation.getPeer().toString()); break; case CANCEL: log.info("Session negotiation was cancelled locally"); break; case REMOTE_CANCEL: log.info("Session negotiation was cancelled by remote: "+ negotiation.getPeer().toString()); break; } } }); }
Source:
AsyncHttpMessageHandlerSpec(Expression uriExpression, AsyncRestTemplate asyncRestTemplate) { this.target = new AsyncHttpRequestExecutingMessageHandler(uriExpression, asyncRestTemplate); this.target.setUriVariableExpressions(this.uriVariableExpressions); this.target.setHeaderMapper(this.headerMapper); this.asyncRestTemplate = asyncRestTemplate; }

Target:
AsyncHttpMessageHandlerSpec(Expression uriExpression, AsyncRestTemplate asyncRestTemplate) { super(new AsyncHttpRequestExecutingMessageHandler(uriExpression, asyncRestTemplate)); this.asyncRestTemplate = asyncRestTemplate; }
Source:
public <R> CtMethod<R> getOverriddenMethod() { CtTypeReference<T> lambdaTypeRef = getType(); if (lambdaTypeRef == null) { return null; } CtMethod<?> lambdaExecutableMethod = null; if (!(lambdaTypeRef instanceof CtIntersectionTypeReference)) { return getOverriddenAux(lambdaTypeRef); } else { CtElement parent = lambdaTypeRef.getParent(); CtTypeReference<?> parentTypeReference = null; if (parent != null && parent instanceof CtLocalVariable) { parentTypeReference = ((CtLocalVariable) parent).getType(); } else if (parent != null && parent instanceof CtAssignment) { parentTypeReference = ((CtAssignment) parent).getAssigned().getType(); } for (CtTypeReference<?> ctTypeReference : ((CtIntersectionTypeReference<?>) lambdaTypeRef).getBounds()) { CtMethod<?> tmp = getOverriddenAux(ctTypeReference); if (tmp != null && (lambdaExecutableMethod == null || ctTypeReference.equals(parentTypeReference))) { lambdaExecutableMethod = tmp; } } } if (lambdaExecutableMethod == null) { throw new SpoonException("The lambda can be based on interface, which has one method. But " + lambdaTypeRef.getQualifiedName() + " has no one"); } return (CtMethod<R>) lambdaExecutableMethod; }

Target:
public <R> CtMethod<R> getOverriddenMethod() { CtTypeReference<T> lambdaTypeRef = getType(); if (lambdaTypeRef == null) { return null; } if (!(lambdaTypeRef instanceof CtIntersectionTypeReference)) { return getOverriddenMethodForNormalType(lambdaTypeRef); } CtMethod<?> lambdaExecutableMethod = getOverriddenMethodForIntersectionType(lambdaTypeRef); if (lambdaExecutableMethod == null) { throw new SpoonException("The lambda can be based on interface, which has one method. But " + lambdaTypeRef.getQualifiedName() + " has no one"); } return (CtMethod<R>) lambdaExecutableMethod; }
Source:
public void shouldCreateWarehouse() throws Exception { onRequest() .havingMethodEqualTo("POST") .havingPathEqualTo(Warehouses.URI) .havingHeader(GoodData.GDC_HOST_HEADER) .respond() .withBody(readFromResource(TASK_POLL)) .withStatus(202); onRequest() .havingMethodEqualTo("GET") .havingPathEqualTo(pollingTask.getPollLink()) .havingHeader(GoodData.GDC_HOST_HEADER) .respond() .withStatus(202) .thenRespond() .withBody(readFromResource(TASK_DONE)) .withStatus(201); onRequest() .havingMethodEqualTo("GET") .havingPathEqualTo(finishedTask.getWarehouseLink()) .havingHeader(GoodData.GDC_HOST_HEADER) .respond() .withBody(readFromResource(WAREHOUSE)) .withStatus(200); final Warehouse created = gd.getWarehouseService().createWarehouse(new Warehouse(TITLE, "{Token}", "Storage")).get(); assertThat(created, notNullValue()); assertThat(created.getTitle(), is(TITLE)); assertThat(created.getConnectionUrl(), is(CONNECTION_URL)); }

Target:
public void shouldCreateWarehouse() throws Exception { onRequest() .havingMethodEqualTo("POST") .havingPathEqualTo(Warehouses.URI) .respond() .withBody(readFromResource(TASK_POLL)) .withStatus(202); onRequest() .havingMethodEqualTo("GET") .havingPathEqualTo(pollingTask.getPollLink()) .respond() .withStatus(202) .thenRespond() .withBody(readFromResource(TASK_DONE)) .withStatus(201); onRequest() .havingMethodEqualTo("GET") .havingPathEqualTo(finishedTask.getWarehouseLink()) .respond() .withBody(readFromResource(WAREHOUSE)) .withStatus(200); final Warehouse created = gd.getWarehouseService().createWarehouse(new Warehouse(TITLE, "{Token}", "Storage")).get(); assertThat(created, notNullValue()); assertThat(created.getTitle(), is(TITLE)); assertThat(created.getConnectionUrl(), is(CONNECTION_URL)); }
Source:
public boolean hasOperations(View view) { return getOperations(view) != null; }

Target:
public boolean hasOperations(View view) { return viewOperations.containsKey(view.getName()); }
Source:
public static @CheckForNull String getAccessIpAddress(@Nonnull Server server) throws IllegalArgumentException, NoSuchElementException { String fixedIPv4 = null; String fixedIPv6 = null; String floatingIPv6 = null; Collection<List<? extends Address>> addressMap = server.getAddresses().getAddresses().values(); for (List<? extends Address> addresses: addressMap) { for (Address addr: addresses) { String type = addr.getType(); int version = addr.getVersion(); String address = addr.getAddr(); if (version != 4 && version != 6) throw new IllegalArgumentException( "Unknown or unsupported IP protocol version: " + version ); if (Objects.equals(type, "floating")) { if (version == 4) { return address; } else { if (floatingIPv6 == null) { floatingIPv6 = address; } } } else if (Objects.equals(type, "fixed") || type == null) { if (version == 4) { if (fixedIPv4 == null) { fixedIPv4 = address; } } else { if (fixedIPv6 == null) { fixedIPv6 = address; } } } } } if (floatingIPv6 != null) return floatingIPv6; if (fixedIPv4 != null) return fixedIPv4; if (fixedIPv6 != null) return fixedIPv6; throw new NoSuchElementException("No access IP address found for " + server.getName() + ": " + addressMap); }

Target:
public static @CheckForNull String getAccessIpAddress(@Nonnull Server server) throws IllegalArgumentException, NoSuchElementException { String fixedIPv4 = null; String fixedIPv6 = null; String floatingIPv6 = null; Collection<List<? extends Address>> addressMap = server.getAddresses().getAddresses().values(); for (List<? extends Address> addresses: addressMap) { for (Address addr: addresses) { String type = addr.getType(); int version = addr.getVersion(); String address = addr.getAddr(); if (version != 4 && version != 6) throw new IllegalArgumentException( "Unknown or unsupported IP protocol version: " + version ); if (Objects.equals(type, "floating")) { if (version == 4) { return address; } else { if (floatingIPv6 == null) { floatingIPv6 = address; } } } else { if (version == 4) { if (fixedIPv4 == null) { fixedIPv4 = address; } } else { if (fixedIPv6 == null) { fixedIPv6 = address; } } } } } if (floatingIPv6 != null) return floatingIPv6; if (fixedIPv4 != null) return fixedIPv4; if (fixedIPv6 != null) return fixedIPv6; throw new NoSuchElementException("No access IP address found for " + server.getName() + ": " + addressMap); }
Source:
public void configurePipeline(PipelineConfigurer pipelineConfigurer) throws IllegalArgumentException { super.configurePipeline(pipelineConfigurer); parseConfiguration(config.compressor); try { Schema outputSchema = Schema.parseJson(config.schema); List<Field> outFields = outputSchema.getFields(); for (Field field : outFields) { outSchemaMap.put(field.getName(), field.getSchema().getType()); } pipelineConfigurer.getStageConfigurer().setOutputSchema(outputSchema); } catch (IOException e) { throw new IllegalArgumentException("Format of schema specified is invalid. Please check the format."); } Schema inputSchema = pipelineConfigurer.getStageConfigurer().getInputSchema(); if (inputSchema != null) { for (Schema.Field field : inputSchema.getFields()) { if (outSchemaMap.containsKey(field.getName()) && compMap.containsKey(field.getName()) && compMap.get(field.getName()) != CompressorType.NONE && !Schema.Type.BYTES.equals(field.getSchema().getType()) && !Schema.Type.STRING.equals(field.getSchema().getType())) { throw new IllegalArgumentException( String.format("Input field %s should be of type BYTES to compress. It is currently of type %s", field.getName(), field.getSchema().getType().toString())); } } } }

Target:
public void configurePipeline(PipelineConfigurer pipelineConfigurer) throws IllegalArgumentException { super.configurePipeline(pipelineConfigurer); parseConfiguration(config.compressor); try { Schema outputSchema = Schema.parseJson(config.schema); List<Field> outFields = outputSchema.getFields(); for (Field field : outFields) { outSchemaMap.put(field.getName(), field.getSchema().getType()); } pipelineConfigurer.getStageConfigurer().setOutputSchema(outputSchema); } catch (IOException e) { throw new IllegalArgumentException("Format of schema specified is invalid. Please check the format."); } Schema inputSchema = pipelineConfigurer.getStageConfigurer().getInputSchema(); if (inputSchema != null) { for (Schema.Field field : inputSchema.getFields()) { if (outSchemaMap.containsKey(field.getName()) && compMap.containsKey(field.getName()) && compMap.get(field.getName()) != CompressorType.NONE && !Schema.Type.BYTES.equals(field.getSchema().getType()) && !Schema.Type.STRING.equals(field.getSchema().getType())) { throw new IllegalArgumentException( String.format("Input field %s must be of type bytes or string. It is currently of type %s", field.getName(), field.getSchema().getType().toString())); } } } }
Source:
public void damage(double amount, Entity source, EntityDamageEvent.DamageCause cause) { if (noDamageTicks > 0 || health <= 0 || !canTakeDamage(cause)) { return; } else { noDamageTicks = maxNoDamageTicks; } if (cause != null && hasPotionEffect(PotionEffectType.FIRE_RESISTANCE)) { switch (cause) { case PROJECTILE: if (source == null || !(source instanceof Fireball)) { break; } case FIRE: case FIRE_TICK: case LAVA: return; } } EntityDamageEvent event; if (source == null) { event = new EntityDamageEvent(this, cause, amount); } else { event = new EntityDamageByEntityEvent(source, this, cause, amount); } EventFactory.callEvent(event); if (event.isCancelled()) { return; } if (source != null && source instanceof GlowPlayer) { ((GlowPlayer) source).addExhaustion(0.3f); } amount = event.getFinalDamage(); lastDamage = amount; setHealth(health - amount); playEffect(EntityEffect.HURT); if (health > 0.0) { Sound hurtSound = getHurtSound(); if (hurtSound != null) { world.playSound(location, hurtSound, 1.0f, 1.0f); } } }

Target:
public void damage(double amount, Entity source, EntityDamageEvent.DamageCause cause) { if (noDamageTicks > 0 || health <= 0 || !canTakeDamage(cause)) { return; } else { noDamageTicks = maxNoDamageTicks; } if (cause != null && hasPotionEffect(PotionEffectType.FIRE_RESISTANCE)) { switch (cause) { case PROJECTILE: if (source == null || !(source instanceof Fireball)) { break; } case FIRE: case FIRE_TICK: case LAVA: return; } } EntityDamageEvent event; if (source == null) { event = new EntityDamageEvent(this, cause, amount); } else { event = new EntityDamageByEntityEvent(source, this, cause, amount); } EventFactory.callEvent(event); if (event.isCancelled()) { return; } if (source != null && source instanceof GlowPlayer) { ((GlowPlayer) source).addExhaustion(0.3f); } amount = event.getFinalDamage(); lastDamage = amount; setHealth(health - amount); playEffect(EntityEffect.HURT); if (health > 0) { Sound hurtSound = getHurtSound(); if (hurtSound != null) { world.playSound(location, hurtSound, 1.0f, 1.0f); } } }
Source:
public void testAddAndRemoveUsageListener() throws Exception { final RecordingUsageListener listener = new RecordingUsageListener(); mgmt.getUsageManager().addUsageListener(listener); app = TestApplication.Factory.newManagedInstanceForTests(mgmt); app.setCatalogItemId("testCatalogItem"); app.start(ImmutableList.<Location>of()); Asserts.succeedsEventually(new Runnable() { @Override public void run() { List<List<?>> events = listener.getApplicationEvents(); assertEquals(events.size(), 2, "events="+events); String appId = (String) events.get(0).get(1); String appName = (String) events.get(0).get(2); String entityType = (String) events.get(0).get(3); String catalogItemId = (String) events.get(0).get(4); System.out.println(catalogItemId); Map<?,?> metadata = (Map<?, ?>) events.get(0).get(5); ApplicationEvent appEvent = (ApplicationEvent) events.get(0).get(6); assertEquals(appId, app.getId(), "events="+events); assertNotNull(appName, "events="+events); assertEquals(app.getCatalogItemId(), "testCatalogItem"); assertNotNull(entityType, "events="+events); assertNotNull(metadata, "events="+events); assertEquals(appEvent.getState(), Lifecycle.STARTING, "events="+events); }}); listener.clearEvents(); mgmt.getUsageManager().removeUsageListener(listener); app.start(ImmutableList.<Location>of()); Asserts.succeedsContinually(new Runnable() { @Override public void run() { List<List<?>> events = listener.getLocationEvents(); assertEquals(events.size(), 0, "events="+events); }}); }

Target:
public void testAddAndRemoveUsageListener() throws Exception { final RecordingUsageListener listener = new RecordingUsageListener(); mgmt.getUsageManager().addUsageListener(listener); app = TestApplication.Factory.newManagedInstanceForTests(mgmt); app.setCatalogItemId("testCatalogItem"); app.start(ImmutableList.<Location>of()); Asserts.succeedsEventually(new Runnable() { @Override public void run() { List<List<?>> events = listener.getApplicationEvents(); assertEquals(events.size(), 2, "events="+events); String appId = (String) events.get(0).get(1); String appName = (String) events.get(0).get(2); String entityType = (String) events.get(0).get(3); String catalogItemId = (String) events.get(0).get(4); Map<?,?> metadata = (Map<?, ?>) events.get(0).get(5); ApplicationEvent appEvent = (ApplicationEvent) events.get(0).get(6); assertEquals(appId, app.getId(), "events="+events); assertNotNull(appName, "events="+events); assertEquals(catalogItemId, app.getCatalogItemId(), "events="+events); assertNotNull(entityType, "events="+events); assertNotNull(metadata, "events="+events); assertEquals(appEvent.getState(), Lifecycle.STARTING, "events="+events); }}); listener.clearEvents(); mgmt.getUsageManager().removeUsageListener(listener); app.start(ImmutableList.<Location>of()); Asserts.succeedsContinually(new Runnable() { @Override public void run() { List<List<?>> events = listener.getLocationEvents(); assertEquals(events.size(), 0, "events="+events); }}); }
Source:
public String doctitle() { return getString("doctitle"); }

Target:
public String doctitle() { return getDoctitle(); }
Source:
void createBatchDefault() { ServiceBusMessageBatch batch = new ServiceBusMessageBatch(MAX_MESSAGE_LENGTH_BYTES, null, null, null); when(asyncSender.createBatch()).thenReturn(Mono.just(batch)); ServiceBusMessageBatch batchMessage = sender.createBatch(); Assertions.assertEquals(MAX_MESSAGE_LENGTH_BYTES, batchMessage.getMaxSizeInBytes()); Assertions.assertEquals(0, batchMessage.getCount()); verify(asyncSender, times(1)).createBatch(); }

Target:
void createBatchDefault() { ServiceBusMessageBatch batch = new ServiceBusMessageBatch(MAX_MESSAGE_LENGTH_BYTES, null, null, null); when(asyncSender.createBatch()).thenReturn(Mono.just(batch)); ServiceBusMessageBatch batchMessage = sender.createBatch(); Assertions.assertEquals(MAX_MESSAGE_LENGTH_BYTES, batchMessage.getMaxSizeInBytes()); Assertions.assertEquals(0, batchMessage.getCount()); verify(asyncSender).createBatch(); }
Source:
protected Void doInBackground(Void... arg0) { try { if (!Utils.isNetworkAvailable(context)) { exception = new WebconnectionException(WebconnectionException.ERROR_NETWORK, "Network not available!"); return null; } String zipFileString = Utils.buildPathForTemplatesZip(templateData.getName()); ServerCalls.getInstance().downloadProject(zipFileUrl, zipFileString, null, null, 0); } catch (WebconnectionException | IOException webconnectionException) { Log.e(TAG, Log.getStackTraceString(webconnectionException)); message = webconnectionException.getMessage(); } return null; }

Target:
protected Boolean doInBackground(Void... arg0) { if (!Utils.isNetworkAvailable(context)) { return false; } String zipFileString = Utils.buildPathForTemplatesZip(templateData.getName()); try { ServerCalls.getInstance().downloadProject(zipFileUrl, zipFileString, null, null, 0); } catch (WebconnectionException | IOException webconnectionException) { Log.e(TAG, Log.getStackTraceString(webconnectionException)); message = webconnectionException.getMessage(); } return true; }
Source:
private static void checkMapNativeMaxSizePolicy(MapConfig mapConfig) { MaxSizePolicy maxSizePolicy = mapConfig.getEvictionConfig().getMaxSizePolicy(); if (!MAP_SUPPORTED_NATIVE_MAX_SIZE_POLICIES.contains(maxSizePolicy)) { throw new IllegalArgumentException("Maximum size policy " + maxSizePolicy + " cannot be used with NATIVE in memory format backed Map." + " Supported maximum size policies are: " + MAP_SUPPORTED_NATIVE_MAX_SIZE_POLICIES); } }

Target:
private static void checkMapNativeMaxSizePolicy(MapConfig mapConfig) { MaxSizePolicy maxSizePolicy = mapConfig.getEvictionConfig().getMaxSizePolicy(); if (!MAP_SUPPORTED_NATIVE_MAX_SIZE_POLICIES.contains(maxSizePolicy)) { throw new InvalidConfigurationException("Maximum size policy " + maxSizePolicy + " cannot be used with NATIVE in memory format backed Map." + " Supported maximum size policies are: " + MAP_SUPPORTED_NATIVE_MAX_SIZE_POLICIES); } }
Source:
public Collection<MercurialTagAction> getActiveBranches(AbstractBuild<?, ?> build, Launcher launcher, TaskListener listener) throws IOException, InterruptedException { ArgumentListBuilder cmd = findHgExe(build, listener, false); cmd.add("branches", "--active"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); joinWithPossibleTimeout( launch(launcher).cmds(cmd) .stdout(new ForkOutputStream(baos, listener.getLogger())) .pwd(workspace2Repo(build.getWorkspace())), true, listener); Collection<MercurialTagAction> branches = new ArrayList<MercurialTagAction>(); BufferedReader in = new BufferedReader(new InputStreamReader( new ByteArrayInputStream(baos.toByteArray()))); String line; while ((line = in.readLine()) != null) { String sha = line.substring(line.indexOf(':')+1); String name = line.substring(0, line.indexOf(" ")); branches.add(new MercurialTagAction(sha, name)); } return branches; }

Target:
public Collection<MercurialTagAction> getActiveBranches(AbstractBuild<?, ?> build, Launcher launcher, TaskListener listener) throws IOException, InterruptedException { ArgumentListBuilder cmd = findHgExe(build, listener, false); cmd.add("branches", "--active", "--debug"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); joinWithPossibleTimeout( launch(launcher).cmds(cmd) .stdout(new ForkOutputStream(baos, listener.getLogger())) .pwd(workspace2Repo(build.getWorkspace())), true, listener); Collection<MercurialTagAction> branches = new ArrayList<MercurialTagAction>(); BufferedReader in = new BufferedReader(new InputStreamReader( new ByteArrayInputStream(baos.toByteArray()))); String line; while ((line = in.readLine()) != null) { String sha = line.substring(line.indexOf(':')+1); String name = line.substring(0, line.indexOf(" ")); branches.add(new MercurialTagAction(sha, name)); } return branches; }
Source:
public void testTextBuildWithPrivateUrl() { String content = builder.buildContentString(ics); System.out.println(content); assertTrue(content.matches(withPrivateUrlPattern)); assertTrue(content.matches(withoutDefaultUrlPattern)); }

Target:
public void testTextBuildWithPrivateUrl() { String content = builder.buildContentString(ics); assertTrue(content.matches(withPrivateUrlPattern)); assertTrue(content.matches(withoutDefaultUrlPattern)); }
Source:
public void testList() throws StripeException { SKUCollection skus = SKU.list(null); assertNotNull(skus); assertEquals(1, skus.getData().size()); verifyRequest( APIResource.RequestMethod.GET, "/v1/skus" ); }

Target:
public void testList() throws StripeException { final Map<String, Object> params = new HashMap<String, Object>(); params.put("limit", 1); final SKUCollection skus = SKU.list(params); assertNotNull(skus); assertEquals(1, skus.getData().size()); verifyRequest( APIResource.RequestMethod.GET, "/v1/skus", params ); }
Source:
public void cleanup() { executeStatement("delete old query status rows from " + escapeIdent(statusTableName) + " table", String.format(ENGLISH, "DELETE FROM %s WHERE query_id = ANY(" + "SELECT query_id FROM %s WHERE completed_at < now() - interval '24' hours" + ")", escapeIdent(statusTableName), escapeIdent(statusTableName)) ); }

Target:
public void cleanup() { executeStatement("delete old query status rows from " + escapeIdent(statusTableName) + " table", String.format(ENGLISH, "DELETE FROM %s WHERE query_id = ANY(" + "SELECT query_id FROM %s WHERE completed_at < now() - interval '%d seconds'" + ")", escapeIdent(statusTableName), escapeIdent(statusTableName), cleanupDuration.getSeconds()) ); }
Source:
BlobStoreCompactor(String dataDir, String storeId, StoreKeyFactory storeKeyFactory, StoreConfig config, StoreMetrics metrics, DiskIOScheduler diskIOScheduler, Log srcLog, MessageStoreRecovery recovery, Time time, UUID sessionId, UUID incarnationId) throws IOException, StoreException { this.dataDir = new File(dataDir); this.storeId = storeId; this.storeKeyFactory = storeKeyFactory; this.config = config; this.srcMetrics = metrics; tgtMetrics = new StoreMetrics(storeId + METRICS_SUFFIX, metrics.getRegistry()); this.srcLog = srcLog; this.diskIOScheduler = diskIOScheduler; this.recovery = recovery; this.time = time; this.sessionId = sessionId; this.incarnationId = incarnationId; fixStateIfRequired(); logger.trace("Constructed BlobStoreCompactor"); }

Target:
BlobStoreCompactor(String dataDir, String storeId, StoreKeyFactory storeKeyFactory, StoreConfig config, StoreMetrics metrics, DiskIOScheduler diskIOScheduler, Log srcLog, MessageStoreRecovery recovery, Time time, UUID sessionId, UUID incarnationId) throws IOException, StoreException { this.dataDir = new File(dataDir); this.storeId = storeId; this.storeKeyFactory = storeKeyFactory; this.config = config; this.srcMetrics = metrics; tgtMetrics = new StoreMetrics(storeId + METRICS_SUFFIX, metrics.getRegistry()); this.srcLog = srcLog; this.diskIOScheduler = diskIOScheduler; this.recovery = recovery; this.time = time; this.sessionId = sessionId; this.incarnationId = incarnationId; fixStateIfRequired(); logger.trace("Constructed BlobStoreCompactor for {}", dataDir); }
Source:
public static boolean hasPushPublishActionlet(final WorkflowAction action) { try { final List<WorkflowActionClass> actionlets = APILocator.getWorkflowAPI() .findActionClasses(action); for (WorkflowActionClass actionlet : actionlets) { if (actionlet.getActionlet() != null && actionlet.getActionlet().getClass() .getCanonicalName().equals(PushPublishActionlet.class.getCanonicalName())) { return true; } } } catch (DotDataException e) { Logger.error(ActionletUtil.class, String.format( "Can't determine weather or not action '%s' has PushPublishActionlet.", action.getName()), e); } return false; }

Target:
public static boolean hasPushPublishActionlet(final WorkflowAction action) { try { final List<WorkflowActionClass> actionlets = APILocator.getWorkflowAPI().findActionClasses(action); for (final WorkflowActionClass actionletClass : actionlets) { final Actionlet actionlet = AnnotationUtils. getBeanAnnotation(ReflectionUtils.getClassFor(actionletClass.getClazz()), Actionlet.class); if (null != actionlet && actionlet.pushPublish()) { return true; } } } catch (DotDataException e) { Logger.error(ActionletUtil.class, String.format( "Can't determine if action '%s' has PushPublishActionlet.", action.getName()), e); } return false; }
Source:
private void refetchTaskInformation(Task task) throws FacilityNotExistsException, InternalErrorException, PrivilegeException, ServiceNotExistsException { log.debug("Rereading facility and exec service for task {}", task.getId()); Facility dbFacility = perun.getFacilitiesManager().getFacilityById(perunSession, task.getFacilityId()); if(dbFacility == null) { throw new FacilityNotExistsException("No facility with id " + task.getFacilityId()); } Boolean taskModified = false; if(!dbFacility.equals(task.getFacility())) { task.setFacility(dbFacility); taskModified = true; } ExecService dbExecService = generalServiceManager.getExecService(perunSession, task.getExecServiceId()); if(dbExecService == null) { throw new ServiceNotExistsException("No exec service with id " + task.getExecServiceId()); } if(!dbExecService.equals(task.getExecService())) { task.setExecService(dbExecService); taskModified = true; } if(taskModified) { log.debug("Task components have changed, updating task {}", task.getId()); schedulingPool.setTaskStatus(task, task.getStatus()); } }

Target:
private void refetchTaskInformation(Task task) throws FacilityNotExistsException, InternalErrorException, PrivilegeException, ServiceNotExistsException { log.debug("Rereading facility and exec service for task {}", task.getId()); Facility dbFacility = perun.getFacilitiesManagerBl().getFacilityById(perunSession, task.getFacilityId()); if(dbFacility == null) { throw new FacilityNotExistsException("No facility with id " + task.getFacilityId()); } Boolean taskModified = false; if(!dbFacility.equals(task.getFacility())) { task.setFacility(dbFacility); taskModified = true; } ExecService dbExecService = generalServiceManager.getExecService(perunSession, task.getExecServiceId()); if(dbExecService == null) { throw new ServiceNotExistsException("No exec service with id " + task.getExecServiceId()); } if(!dbExecService.equals(task.getExecService())) { task.setExecService(dbExecService); taskModified = true; } if(taskModified) { log.debug("Task components have changed, updating task {}", task.getId()); schedulingPool.setTaskStatus(task, task.getStatus()); } }
Source:
public String getParentId() { if (parentId == UNDEFINED) { parentId = (String) state.get(KEY_PARENT_ID); } return parentId; }

Target:
public String getParentId() { if (parentId == UNDEFINED_PARENT_ID) { parentId = (String) state.get(KEY_PARENT_ID); } return parentId; }
Source:
protected void checkAuthorization(HttpServletRequest request) { final String authorization = request.getHeader("Authorization"); if (authorization != null && authorization.toLowerCase().startsWith("basic")) { String base64Credentials = authorization.substring("Basic".length()).trim(); byte[] decodedCredentials = java.util.Base64.getDecoder().decode(base64Credentials); String credentials = new String(decodedCredentials, java.nio.charset.StandardCharsets.UTF_8); final String[] values = credentials.split(":"); if (values.length == 2) { clientId = values[0]; clientSecret = values[1]; } } }

Target:
protected void checkAuthorization(HttpServletRequest request) { final String authorization = request.getHeader("Authorization"); if (authorization != null && authorization.toLowerCase().startsWith(BASIC_AUTHENTICATION_HEADER_PREFIX)) { String base64Credentials = authorization.substring(BASIC_AUTHENTICATION_HEADER_PREFIX.length()).trim(); byte[] decodedCredentials = java.util.Base64.getDecoder().decode(base64Credentials); String credentials = new String(decodedCredentials, java.nio.charset.StandardCharsets.UTF_8); String[] values = credentials.split(":", 2); if (values.length == 2) { clientId = values[0]; clientSecret = values[1]; } } }
Source:
private Parser loadParser(Header header) { ParserInfo parserInfo = client.getParserInfo(header.getDeviceId(), header.getVersion()); InputStream parserJar = client.getParserJar(parserInfo.getParserId()); String jarPath = String.format("%s%s%s-%s.jar", localParserJarPath, File.pathSeparator, header.getDeviceId(), header.getVersion()); try { IOUtils.copy(parserJar, new FileOutputStream(new File(jarPath))); } catch (IOException e) { throw new RuntimeException(e); } try { if (!ReflectionHelper.isJarInClassPath(jarPath) && !ReflectionHelper.isClassLoaded(parserInfo.getClassName())) { ReflectionHelper.loadJarAndAllItsClasses(jarPath); } return ReflectionHelper.newInstance(parserInfo.getClassName()); } catch (IOException e) { throw new RuntimeException(e); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InstantiationException e) { throw new RuntimeException(e); } }

Target:
private Parser loadParser(Header header) { ParserInfo parserInfo = client.getParserInfo(header.getDeviceId(), header.getVersion()); InputStream parserJar = client.getParserJar(parserInfo.getParserId()); String jarPath = String.format("%s%s%s-%s.jar", localParserJarPath, File.pathSeparator, header.getDeviceId(), header.getVersion()); try { IOUtils.copy(parserJar, new FileOutputStream(new File(jarPath))); if (!ReflectionHelper.isJarInClassPath(jarPath) && !ReflectionHelper.isClassLoaded(parserInfo.getClassName())) { ReflectionHelper.loadJarAndAllItsClasses(jarPath); } return ReflectionHelper.newInstance(parserInfo.getClassName()); } catch (Exception e) { throw new RuntimeException(e); } }
Source:
protected boolean isConnWithSameDetailsExists(StorageServerConnections connection) { List<StorageServerConnections> connections = null; if (connection.getstorage_type().isFileDomain()) { String connectionField = connection.getconnection(); connections = getStorageConnDao().getAllForStorage(connectionField); } else { connections = getStorageConnDao().getAllForConnection(connection); } if (connections.size() > 1 || (connections.size() == 1 && !connections.get(0).getid().equalsIgnoreCase(connection.getid()))) { return true; } else { return false; } }

Target:
protected boolean isConnWithSameDetailsExists(StorageServerConnections connection) { List<StorageServerConnections> connections = null; if (connection.getstorage_type().isFileDomain()) { String connectionField = connection.getconnection(); connections = getStorageConnDao().getAllForStorage(connectionField); } else { connections = getStorageConnDao().getAllForConnection(connection); } boolean isDuplicateConnExists = (connections.size() > 1 || (connections.size() == 1 && !connections.get(0).getid().equalsIgnoreCase(connection.getid()))); return isDuplicateConnExists; }
Source:
public void open() throws InvalidInterfaceException, InterfaceInUseException, OperationNotSupportedException, InvalidConfigurationException { try { portIdentifier = CommPortIdentifier.getPortIdentifier(port); } catch (NoSuchPortException e) { throw new InvalidInterfaceException("No such port: " + port); } try { serialPort = (RXTXPort)portIdentifier.open(PORT_ALIAS + " " + port, receiveTimeout); connectionOpen = true; if (parameters == null) parameters = new SerialPortParameters(baudRate, DEFAULT_DATA_BITS, DEFAULT_STOP_BITS, DEFAULT_PARITY, DEFAULT_FLOW_CONTROL); serialPort.setSerialPortParams(baudRate, parameters.dataBits, parameters.stopBits, parameters.parity); serialPort.setFlowControlMode(parameters.flowControl); serialPort.enableReceiveTimeout(receiveTimeout); portIdentifier.addPortOwnershipListener(this); inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); serialPort.notifyOnDataAvailable(true); serialPort.addEventListener(this); } catch (PortInUseException e) { throw new InterfaceInUseException("Port in use: " + port); } catch (UnsupportedCommOperationException e) { throw new OperationNotSupportedException(e.getMessage()); } catch (TooManyListenersException e) { throw new InvalidConfigurationException(e.getMessage()); } }

Target:
public void open() throws InterfaceInUseException, InvalidConfigurationException, InvalidInterfaceException { try { portIdentifier = CommPortIdentifier.getPortIdentifier(port); } catch (NoSuchPortException e) { throw new InvalidInterfaceException("No such port: " + port, e); } try { serialPort = (RXTXPort)portIdentifier.open(PORT_ALIAS + " " + port, receiveTimeout); connectionOpen = true; if (parameters == null) parameters = new SerialPortParameters(baudRate, DEFAULT_DATA_BITS, DEFAULT_STOP_BITS, DEFAULT_PARITY, DEFAULT_FLOW_CONTROL); serialPort.setSerialPortParams(baudRate, parameters.dataBits, parameters.stopBits, parameters.parity); serialPort.setFlowControlMode(parameters.flowControl); serialPort.enableReceiveTimeout(receiveTimeout); portIdentifier.addPortOwnershipListener(this); inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); serialPort.notifyOnDataAvailable(true); serialPort.addEventListener(this); } catch (PortInUseException e) { throw new InterfaceInUseException("Port " + port + " is already in use by other application(s)", e); } catch (UnsupportedCommOperationException e) { throw new InvalidConfigurationException(e.getMessage(), e); } catch (TooManyListenersException e) { throw new InvalidConfigurationException(e.getMessage(), e); } }
Source:
LobbyGameTableModel(final Map<GUID, GameDescription> gameList, final boolean isAdmin) { this.isAdmin = isAdmin; gameListModel = new GameListModel(); for (final Map.Entry<GUID, GameDescription> entry : gameList.entrySet()) { updateGame(entry.getKey(), entry.getValue()); } }

Target:
LobbyGameTableModel(final Map<GUID, GameDescription> gameList, final boolean isAdmin) { this.isAdmin = isAdmin; gameListModel = new GameListModel(); for (final Map.Entry<GUID, GameDescription> entry : gameList.entrySet()) { gameUpdated(entry.getKey(), entry.getValue()); } }
Source:
protected Map<String, String> createPortAllocationRuntimeProperties(Port port) { Map<String, String> runtimeProperties = new HashMap<>(); runtimeProperties.put("vnic_id", port.getId()); String providerType = getProvider().getType().name(); runtimeProperties.put("provider_type", providerType); if (port.getSecurityGroups() != null && !port.getSecurityGroups().isEmpty()) { runtimeProperties.put("security_groups", StringUtils.join(port.getSecurityGroups(), ',')); } String pluginType = getProvider().getAdditionalProperties().getPluginType(); if (pluginType==null) { pluginType = ""; } runtimeProperties.put("plugin_type", pluginType); return runtimeProperties; }

Target:
protected Map<String, String> createPortAllocationRuntimeProperties(Port port) { Map<String, String> runtimeProperties = new HashMap<>(); runtimeProperties.put("vnic_id", port.getId()); String providerType = getProvider().getType().name(); runtimeProperties.put("provider_type", providerType); if (port.getSecurityGroups() != null && !port.getSecurityGroups().isEmpty()) { runtimeProperties.put("security_groups", StringUtils.join(port.getSecurityGroups(), ',')); } runtimeProperties.put("plugin_type", StringUtils.defaultString( getProvider().getAdditionalProperties().getPluginType())); return runtimeProperties; }
Source:
private synchronized void postPushUnregister(BroadcastReceiver pushReceiver, final ClientManager clientMgr, final boolean showLoginPage, final String refreshToken, final String clientId, final String loginServer, final Account account, Activity frontActivity) { if (!loggedOut) { try { context.unregisterReceiver(pushReceiver); } catch (Exception e) { logger.log(SalesforceLogger.Level.ERROR, TAG, "Exception occurred while unregistering", e); } removeAccount(clientMgr, showLoginPage, refreshToken, clientId, loginServer, account, frontActivity); } }

Target:
private synchronized void postPushUnregister(BroadcastReceiver pushReceiver, final ClientManager clientMgr, final boolean showLoginPage, final String refreshToken, final String clientId, final String loginServer, final Account account, Activity frontActivity) { if (!loggedOut) { try { context.unregisterReceiver(pushReceiver); } catch (Exception e) { SalesforceSDKLogger.e(TAG, "Exception occurred while unregistering", e); } removeAccount(clientMgr, showLoginPage, refreshToken, clientId, loginServer, account, frontActivity); } }
Source:
public ConsumerDTO setCapabilities(Set<CapabilityDTO> capabilities) { this.capabilities = capabilities; return this; }

Target:
public ConsumerDTO setCapabilities(Set<CapabilityDTO> capabilities) { if (capabilities != null) { if (this.capabilities == null) { this.capabilities = new HashSet<CapabilityDTO>(); } else { this.capabilities.clear(); } for (CapabilityDTO dto : capabilities) { if (dto == null || StringUtils.isEmpty(dto.getName())) { throw new IllegalArgumentException("null or imcomplete consumer capability"); } this.capabilities.add(new CapabilityDTO(dto)); } } else { this.capabilities = null; } return this; }
Source:
public <T> T generateValue() { return (T) this.getNext(); }

Target:
public <T> T generateValue() { if(this.nextValueIndex >= this.dataset.length) { this.nextValueIndex = 0; } Object nextValue = this.dataset[this.nextValueIndex]; this.nextValueIndex ++; return (T)nextValue; }
Source:
public static Map<String, Long> getAllCycles(final ZephyrRestClient restClient, final long projectId, final long versionId) { final Map<String, Long> cycles = new HashMap<String, Long>(); final String url = String.format(URL_GET_CYCLES, restClient.getUrl(), projectId,versionId); final HttpResponse response = restClient.get(url); final int statusCode = response.getStatusLine().getStatusCode(); if (statusCode >= 200 && statusCode < 300) { final HttpEntity entity = response.getEntity(); String string = null; try { string = EntityUtils.toString(entity); } catch (ParseException | IOException e) { ZephyrPlugin.log(e); } final JsonObject projObj = new JsonParser().parse(string).getAsJsonObject(); for (int i = 0; i < projObj.size(); i++) { final Set<String> keys = projObj.keySet(); for (final String key : keys) { if (!key.trim().equals("recordsCount")) { final JsonObject cycleObject = projObj.get(key).getAsJsonObject(); final String cycleName = cycleObject.get("name").getAsString(); final long id = Long.parseLong(key); cycles.put(cycleName, id); } } } } else { ZephyrPlugin.log("Unexpected response status: " + statusCode); } return cycles; }

Target:
public static Map<String, Long> getAllCycles(final ZephyrRestClient restClient, final long projectId, final long versionId) { final Map<String, Long> cycles = new HashMap<String, Long>(); final String url = String.format(URL_GET_CYCLES, restClient.getUrl(), projectId, versionId); try (final CloseableHttpResponse response = restClient.get(url)) { final int statusCode = response.getStatusLine().getStatusCode(); if (statusCode >= 200 && statusCode < 300) { final HttpEntity entity = response.getEntity(); String string = null; try { string = EntityUtils.toString(entity); } catch (ParseException | IOException e) { throw new IllegalArgumentException( String.format("Bad response entity upon receipt of cycles <%s>", url), e); } final JsonObject projObj = new JsonParser().parse(string).getAsJsonObject(); for (int i = 0; i < projObj.size(); i++) { final Set<String> keys = projObj.keySet(); for (final String key : keys) { if (!key.trim().equals("recordsCount")) { final JsonObject cycleObject = projObj.get(key).getAsJsonObject(); final String cycleName = cycleObject.get("name").getAsString(); final long id = Long.parseLong(key); cycles.put(cycleName, id); } } } } else { throw new IllegalArgumentException( String.format("Unexpected response status <%s> upon receipt of cycles <%s>", statusCode, url)); } } catch (IOException e) { throw new IllegalArgumentException(e); } return cycles; }
Source:
public void testSTXY() throws Exception { assertQuery("select ST_X(ST_GeometryFromText('Point (1 2)'))", "select 1.0"); assertQuery("select ST_Y(ST_GeometryFromText('Point (1 2)'))", "select 2.0"); assertQueryFails("select ST_Y(ST_GeometryFromText('Polygon ((2 0, 2 1, 3 1))'))", "ST_Y only applies to Point. Input type is: Polygon"); assertQueryFails("select ST_Y(ST_GeometryFromText('POINT EMPTY'))", "This operation should not be performed on an empty geometry."); }

Target:
public void testSTXY() throws Exception { assertFunction("ST_Y(ST_GeometryFromText('POINT EMPTY'))", DOUBLE, null); assertFunction("ST_X(ST_GeometryFromText('POINT (1 2)'))", DOUBLE, 1.0); assertFunction("ST_Y(ST_GeometryFromText('POINT (1 2)'))", DOUBLE, 2.0); assertInvalidFunction("ST_Y(ST_GeometryFromText('POLYGON ((2 0, 2 1, 3 1))'))", "ST_Y only applies to POINT. Input type is: POLYGON"); }
Source:
BundleContext getContext() { final Bundle cxfBundle = FrameworkUtil.getBundle(SecurityJavaSubjectFilter.class); if (cxfBundle != null) { return cxfBundle.getBundleContext(); } return null; }

Target:
protected BundleContext getContext() { final Bundle cxfBundle = FrameworkUtil.getBundle(SecurityJavaSubjectFilter.class); if (cxfBundle != null) { return cxfBundle.getBundleContext(); } return null; }
Source:
public void setUp() throws Exception { logged = false; appContext = E4Application.createDefaultContext(); appContext.set(IWorkbench.PRESENTATION_URI_ARG, PartRenderingEngine.engineURI); final Display d = Display.getDefault(); appContext.set(Realm.class, DisplayRealm.getRealm(d)); appContext.set(UISynchronize.class, new UISynchronize() { @Override public void syncExec(Runnable runnable) { d.syncExec(runnable); } @Override public void asyncExec(Runnable runnable) { d.asyncExec(runnable); } }); LogReaderService logReaderService = appContext.get(LogReaderService.class); logReaderService.addLogListener(listener); ems = appContext.get(EModelService.class); }

Target:
public void setUp() { logged = false; appContext = E4Application.createDefaultContext(); appContext.set(IWorkbench.PRESENTATION_URI_ARG, PartRenderingEngine.engineURI); final Display d = Display.getDefault(); appContext.set(Realm.class, DisplayRealm.getRealm(d)); appContext.set(UISynchronize.class, new UISynchronize() { @Override public void syncExec(Runnable runnable) { d.syncExec(runnable); } @Override public void asyncExec(Runnable runnable) { d.asyncExec(runnable); } }); LogReaderService logReaderService = appContext.get(LogReaderService.class); logReaderService.addLogListener(listener); ems = appContext.get(EModelService.class); }
Source:
public void prepareRun(StageSubmitterContext context) throws Exception { super.prepareRun(context); context.record( TransformLineageRecorderUtils.oneToOneIn(TransformLineageRecorderUtils.getFields(context.getInputSchema()), "decode", "Decode the input fields based on expected decoder.")); }

Target:
public void prepareRun(StageSubmitterContext context) throws Exception { super.prepareRun(context); parseConfiguration(config.decode, context.getFailureCollector()); List<String> inFields = TransformLineageRecorderUtils.getFields(context.getInputSchema()); List<String> outFields = TransformLineageRecorderUtils.getFields(context.getOutputSchema()); List<String> identityFields = outFields.stream() .filter(field -> !decodeMap.containsKey(field) || decodeMap.get(field) == DecoderType.NONE) .collect(Collectors.toList()); List<String> processedFields = new ArrayList<>(outFields); processedFields.removeAll(identityFields); List<String> droppedFields = new ArrayList<>(inFields); droppedFields.removeAll(outFields); List<FieldOperation> output = new ArrayList<>(); output.addAll(TransformLineageRecorderUtils.generateOneToOnes(processedFields, "decode", "Decoded the input fields based on expected decoder.")); output.addAll(TransformLineageRecorderUtils.generateDrops(droppedFields)); output.addAll(TransformLineageRecorderUtils.generateOneToOnes(identityFields, "identity", TransformLineageRecorderUtils.IDENTITY_TRANSFORM_DESCRIPTION)); context.record(output); }
Source:
private int newCapacity(int minCapacity) { int oldCapacity = elementData.length; int newCapacity = oldCapacity + (oldCapacity >> 1); if (newCapacity - minCapacity <= 0) { if (elementData == DEFAULTCAPACITY_EMPTY_ELEMENTDATA) { return Math.max(DEFAULT_CAPACITY, minCapacity); } if (minCapacity < 0) { throw new OutOfMemoryError(); } return minCapacity; } return (newCapacity - MAX_ARRAY_SIZE <= 0) ? newCapacity : hugeCapacity(minCapacity); }

Target:
private int newCapacity(int minCapacity) { int oldCapacity = elementData.length; int newCapacity = oldCapacity + (oldCapacity >> 1); if (newCapacity - minCapacity <= 0) { if (elementData == DEFAULTCAPACITY_EMPTY_ELEMENTDATA) { return Math.max(DEFAULT_CAPACITY, minCapacity); } if (minCapacity < 0) { throw new RuntimeException("capacity overflow!"); } return minCapacity; } return (newCapacity - MAX_ARRAY_SIZE <= 0) ? newCapacity : hugeCapacity(minCapacity); }