method2testcases
stringlengths
118
6.63k
### Question: CollectionUtils { public static <T> T firstIfPresent(List<T> list) { if (list == null || list.isEmpty()) { return null; } else { return list.get(0); } } private CollectionUtils(); static boolean isNullOrEmpty(Collection<?> collection); static boolean isNullOrEmpty(Map<?, ?> map); static List<T> mergeList...
### Question: AsyncChecksumValidationInterceptor implements ExecutionInterceptor { @Override public Optional<Publisher<ByteBuffer>> modifyAsyncHttpResponseContent(Context.ModifyHttpResponse context, ExecutionAttributes executionAttributes) { if (getObjectChecksumEnabledPerResponse(context.request(), context.httpRespons...
### Question: ToString { public static String create(String className) { return className + "()"; } private ToString(String className); static String create(String className); static ToString builder(String className); ToString add(String fieldName, Object field); String build(); }### Answer: @Test public void create...
### Question: ImmutableMap implements Map<K, V> { public V put(K key, V value) { throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); } private ImmutableMap(Map<K, V> map); static Builder<K, V> builder(); static ImmutableMap<K, V> of(K k0, V v0); static ImmutableMap<K, V> of(K k0, V v0, K k1, V v1); static I...
### Question: ThreadFactoryBuilder { public ThreadFactory build() { String threadNamePrefixWithPoolNumber = threadNamePrefix + "-" + POOL_NUMBER.getAndIncrement() % POOL_NUMBER_MAX; ThreadFactory result = new NamedThreadFactory(Executors.defaultThreadFactory(), threadNamePrefixWithPoolNumber); if (daemonThreads) { resu...
### Question: MetricCollectionAggregator { public List<PutMetricDataRequest> getRequests() { List<PutMetricDataRequest> requests = new ArrayList<>(); List<MetricDatum> requestMetricDatums = new ArrayList<>(); ValuesInRequestCounter valuesInRequestCounter = new ValuesInRequestCounter(); Map<Instant, Collection<MetricAgg...
### Question: UploadMetricsTasks implements Callable<CompletableFuture<?>> { @Override public CompletableFuture<?> call() { try { List<PutMetricDataRequest> allRequests = collectionAggregator.getRequests(); List<PutMetricDataRequest> requests = allRequests; if (requests.size() > maximumRequestsPerFlush) { METRIC_LOGGER...
### Question: MetricUploader { public CompletableFuture<Void> upload(List<PutMetricDataRequest> requests) { CompletableFuture<?>[] publishResults = startCalls(requests); return CompletableFuture.allOf(publishResults).whenComplete((r, t) -> { int numRequests = publishResults.length; if (t != null) { METRIC_LOGGER.warn((...
### Question: MetricUploader { public void close(boolean closeClient) { if (closeClient) { this.cloudWatchClient.close(); } } MetricUploader(CloudWatchAsyncClient cloudWatchClient); CompletableFuture<Void> upload(List<PutMetricDataRequest> requests); void close(boolean closeClient); }### Answer: @Test public void clos...
### Question: CloudWatchMetricPublisher implements MetricPublisher { @Override public void publish(MetricCollection metricCollection) { try { executor.submit(new AggregateMetricsTask(metricAggregator, metricCollection)); } catch (RejectedExecutionException e) { METRIC_LOGGER.warn(() -> "Some AWS SDK client-side metrics...
### Question: SystemPropertyTlsKeyManagersProvider extends AbstractFileStoreTlsKeyManagersProvider { @Override public KeyManager[] keyManagers() { return getKeyStore().map(p -> { Path path = Paths.get(p); String type = getKeyStoreType(); char[] password = getKeyStorePassword().map(String::toCharArray).orElse(null); try...
### Question: FileStoreTlsKeyManagersProvider extends AbstractFileStoreTlsKeyManagersProvider { public static FileStoreTlsKeyManagersProvider create(Path path, String type, String password) { char[] passwordChars = password != null ? password.toCharArray() : null; return new FileStoreTlsKeyManagersProvider(path, type, ...
### Question: IntermediateModel { public ShapeModel getShapeByNameAndC2jName(String shapeName, String shapeC2jName) { for (ShapeModel sm : getShapes().values()) { if (shapeName.equals(sm.getShapeName()) && shapeC2jName.equals(sm.getC2jName())) { return sm; } } throw new IllegalArgumentException("C2J shape " + shapeC2jN...
### Question: DefaultNamingStrategy implements NamingStrategy { @Override public String getJavaClassName(String shapeName) { return Arrays.stream(shapeName.split("[._-]|\\W")) .filter(s -> !StringUtils.isEmpty(s)) .map(Utils::capitalize) .collect(joining()); } DefaultNamingStrategy(ServiceModel serviceModel, ...
### Question: DefaultNamingStrategy implements NamingStrategy { @Override public String getAuthorizerClassName(String shapeName) { String converted = getJavaClassName(shapeName); if (converted.length() > 0 && !Character.isLetter(converted.charAt(0))) { return AUTHORIZER_NAME_PREFIX + converted; } return converted; } De...
### Question: AsyncChecksumValidationInterceptor implements ExecutionInterceptor { @Override public void afterUnmarshalling(Context.AfterUnmarshalling context, ExecutionAttributes executionAttributes) { boolean recordingChecksum = Boolean.TRUE.equals(executionAttributes.getAttribute(ASYNC_RECORDING_CHECKSUM)); boolean ...
### Question: DefaultNamingStrategy implements NamingStrategy { @Override public String getServiceName() { String baseName = Stream.of(serviceModel.getMetadata().getServiceId()) .filter(Objects::nonNull) .filter(s -> !s.trim().isEmpty()) .findFirst() .orElseThrow(() -> new IllegalStateException("ServiceId is missing in...
### Question: DefaultNamingStrategy implements NamingStrategy { @Override public String getSdkFieldFieldName(MemberModel memberModel) { return screamCase(memberModel.getName()) + "_FIELD"; } DefaultNamingStrategy(ServiceModel serviceModel, CustomizationConfig customizationConfig); @Over...
### Question: PutObjectInterceptor implements ExecutionInterceptor { @Override public SdkHttpRequest modifyHttpRequest(Context.ModifyHttpRequest context, ExecutionAttributes executionAttributes) { if (context.request() instanceof PutObjectRequest) { return context.httpRequest().toBuilder().putHeader("Expect", "100-cont...
### Question: DocumentationUtils { public static String stripHtmlTags(String documentation) { if (documentation == null) { return ""; } if (documentation.startsWith("<")) { int startTagIndex = documentation.indexOf(">"); int closingTagIndex = documentation.lastIndexOf("<"); if (closingTagIndex > startTagIndex) { docume...
### Question: Utils { public static String unCapitalize(String name) { if (name == null || name.trim().isEmpty()) { throw new IllegalArgumentException("Name cannot be null or empty"); } StringBuilder sb = new StringBuilder(name.length()); int i = 0; do { sb.append(Character.toLowerCase(name.charAt(i++))); } while ((i <...
### Question: UnusedImportRemover implements CodeTransformer { @Override public String apply(String content) { return findUnusedImports(content).stream().map(this::removeImportFunction).reduce(Function.identity(), Function::andThen).apply(content); } @Override String apply(String content); }### Answer: @Test public v...
### Question: ResponseMetadataSpec implements ClassSpec { @Override public ClassName className() { return poetExtensions.getResponseMetadataClass(); } ResponseMetadataSpec(IntermediateModel model); @Override TypeSpec poetSpec(); @Override ClassName className(); }### Answer: @Test public void responseMetadataGeneration...
### Question: AwsServiceBaseResponseSpec implements ClassSpec { @Override public ClassName className() { return poetExtensions.getModelClass(intermediateModel.getSdkResponseBaseClassName()); } AwsServiceBaseResponseSpec(IntermediateModel intermediateModel); @Override TypeSpec poetSpec(); @Override ClassName className()...
### Question: AwsServiceBaseRequestSpec implements ClassSpec { @Override public ClassName className() { return poetExtensions.getModelClass(intermediateModel.getSdkRequestBaseClassName()); } AwsServiceBaseRequestSpec(IntermediateModel intermediateModel); @Override TypeSpec poetSpec(); @Override ClassName className(); ...
### Question: PoetCollectors { public static Collector<CodeBlock, ?, CodeBlock> toCodeBlock() { return Collector.of(CodeBlock::builder, CodeBlock.Builder::add, PoetCollectors::parallelNotSupported, CodeBlock.Builder::build); } private PoetCollectors(); static Collector<CodeBlock, ?, CodeBlock> toCodeBlock(); static Co...
### Question: PoetCollectors { public static Collector<CodeBlock, ?, CodeBlock> toDelimitedCodeBlock(String delimiter) { return Collector.of(() -> new CodeBlockJoiner(delimiter), CodeBlockJoiner::add, PoetCollectors::parallelNotSupported, CodeBlockJoiner::join); } private PoetCollectors(); static Collector<CodeBlock, ...
### Question: EndpointDiscoveryCacheLoaderGenerator implements ClassSpec { private MethodSpec create() { return MethodSpec.methodBuilder("create") .addModifiers(STATIC, PUBLIC) .returns(className()) .addParameter(poetExtensions.getClientClass(model.getMetadata().getSyncInterface()), CLIENT_FIELD) .addStatement("return ...
### Question: Crc32Validation { public static SdkHttpFullResponse validate(boolean calculateCrc32FromCompressedData, SdkHttpFullResponse httpResponse) { if (!httpResponse.content().isPresent()) { return httpResponse; } return httpResponse.toBuilder().content( process(calculateCrc32FromCompressedData, httpResponse, http...
### Question: IdempotentUtils { @Deprecated @SdkProtectedApi public static String resolveString(String token) { return token != null ? token : generator.get(); } private IdempotentUtils(); @Deprecated @SdkProtectedApi static String resolveString(String token); @SdkProtectedApi static Supplier<String> getGenerator(); @...
### Question: GetBucketPolicyInterceptor implements ExecutionInterceptor { @Override public Optional<InputStream> modifyHttpResponseContent(Context.ModifyHttpResponse context, ExecutionAttributes executionAttributes) { if (INTERCEPTOR_CONTEXT_PREDICATE.test(context)) { String policy = context.responseBody() .map(r -> i...
### Question: DefaultSdkAutoConstructList implements SdkAutoConstructList<T> { @Override public boolean equals(Object o) { return impl.equals(o); } private DefaultSdkAutoConstructList(); @SuppressWarnings("unchecked") static DefaultSdkAutoConstructList<T> getInstance(); @Override int size(); @Override boolean isEmpty(...
### Question: DefaultSdkAutoConstructList implements SdkAutoConstructList<T> { @Override public int hashCode() { return impl.hashCode(); } private DefaultSdkAutoConstructList(); @SuppressWarnings("unchecked") static DefaultSdkAutoConstructList<T> getInstance(); @Override int size(); @Override boolean isEmpty(); @Overr...
### Question: DefaultSdkAutoConstructList implements SdkAutoConstructList<T> { @Override public String toString() { return impl.toString(); } private DefaultSdkAutoConstructList(); @SuppressWarnings("unchecked") static DefaultSdkAutoConstructList<T> getInstance(); @Override int size(); @Override boolean isEmpty(); @Ov...
### Question: DefaultSdkAutoConstructMap implements SdkAutoConstructMap<K, V> { @Override public boolean equals(Object o) { return impl.equals(o); } private DefaultSdkAutoConstructMap(); @SuppressWarnings("unchecked") static DefaultSdkAutoConstructMap<K, V> getInstance(); @Override int size(); @Override boolean isEmpt...
### Question: DefaultSdkAutoConstructMap implements SdkAutoConstructMap<K, V> { @Override public int hashCode() { return impl.hashCode(); } private DefaultSdkAutoConstructMap(); @SuppressWarnings("unchecked") static DefaultSdkAutoConstructMap<K, V> getInstance(); @Override int size(); @Override boolean isEmpty(); @Ove...
### Question: DefaultSdkAutoConstructMap implements SdkAutoConstructMap<K, V> { @Override public String toString() { return impl.toString(); } private DefaultSdkAutoConstructMap(); @SuppressWarnings("unchecked") static DefaultSdkAutoConstructMap<K, V> getInstance(); @Override int size(); @Override boolean isEmpty(); @...
### Question: PaginatorUtils { public static <T> boolean isOutputTokenAvailable(T outputToken) { if (outputToken == null) { return false; } if (outputToken instanceof String) { return !((String) outputToken).isEmpty(); } if (outputToken instanceof Map) { return !((Map) outputToken).isEmpty(); } if (outputToken instance...
### Question: RequestOverrideConfiguration { public Map<String, List<String>> headers() { return headers; } protected RequestOverrideConfiguration(Builder<?> builder); Map<String, List<String>> headers(); Map<String, List<String>> rawQueryParameters(); List<ApiName> apiNames(); Optional<Duration> apiCallTimeout(); Opt...
### Question: RequestOverrideConfiguration { public List<MetricPublisher> metricPublishers() { return metricPublishers; } protected RequestOverrideConfiguration(Builder<?> builder); Map<String, List<String>> headers(); Map<String, List<String>> rawQueryParameters(); List<ApiName> apiNames(); Optional<Duration> apiCall...
### Question: AsyncStreamingRequestMarshaller extends AbstractStreamingRequestMarshaller<T> { @Override public SdkHttpFullRequest marshall(T in) { SdkHttpFullRequest.Builder marshalled = delegateMarshaller.marshall(in).toBuilder(); addHeaders(marshalled, asyncRequestBody.contentLength(), requiresLength, transferEncodin...
### Question: RetryPolicyContext implements ToCopyableBuilder<RetryPolicyContext.Builder, RetryPolicyContext> { public int totalRequests() { return this.retriesAttempted + 1; } private RetryPolicyContext(Builder builder); static Builder builder(); SdkRequest originalRequest(); SdkHttpFullRequest request(); SdkExceptio...
### Question: RetryPolicyContext implements ToCopyableBuilder<RetryPolicyContext.Builder, RetryPolicyContext> { public Integer httpStatusCode() { return this.httpStatusCode; } private RetryPolicyContext(Builder builder); static Builder builder(); SdkRequest originalRequest(); SdkHttpFullRequest request(); SdkException...
### Question: RetryPolicyContext implements ToCopyableBuilder<RetryPolicyContext.Builder, RetryPolicyContext> { public SdkException exception() { return this.exception; } private RetryPolicyContext(Builder builder); static Builder builder(); SdkRequest originalRequest(); SdkHttpFullRequest request(); SdkException exce...
### Question: DefaultWaiterResponse implements WaiterResponse<T> { public static <T> Builder<T> builder() { return new Builder<>(); } private DefaultWaiterResponse(Builder<T> builder); static Builder<T> builder(); @Override ResponseOrException<T> matched(); @Override int attemptsExecuted(); @Override boolean equals(Ob...
### Question: S3ArnUtils { public static S3AccessPointResource parseS3AccessPointArn(Arn arn) { return S3AccessPointResource.builder() .partition(arn.partition()) .region(arn.region().orElse(null)) .accountId(arn.accountId().orElse(null)) .accessPointName(arn.resource().resource()) .build(); } private S3ArnUtils(); st...
### Question: MakeHttpRequestStage implements RequestPipeline<SdkHttpFullRequest, Pair<SdkHttpFullRequest, SdkHttpFullResponse>> { public Pair<SdkHttpFullRequest, SdkHttpFullResponse> execute(SdkHttpFullRequest request, RequestExecutionContext context) throws Exception { InterruptMonitor.checkInterrupted(); HttpExecute...
### Question: MakeAsyncHttpRequestStage implements RequestPipeline<CompletableFuture<SdkHttpFullRequest>, CompletableFuture<Response<OutputT>>> { @Override public CompletableFuture<Response<OutputT>> execute(CompletableFuture<SdkHttpFullRequest> requestFuture, RequestExecutionContext context) { CompletableFuture<Respon...
### Question: ApiCallAttemptTimeoutTrackingStage implements RequestToResponsePipeline<OutputT> { @Override public Response<OutputT> execute(SdkHttpFullRequest request, RequestExecutionContext context) throws Exception { try { long timeoutInMillis = resolveTimeoutInMillis(context.requestConfig()::apiCallAttemptTimeout, ...
### Question: AsyncApiCallTimeoutTrackingStage implements RequestPipeline<SdkHttpFullRequest, CompletableFuture<OutputT>> { @Override public CompletableFuture<OutputT> execute(SdkHttpFullRequest input, RequestExecutionContext context) throws Exception { CompletableFuture<OutputT> future = new CompletableFuture<>(); lon...
### Question: ApiCallTimeoutTrackingStage implements RequestToResponsePipeline<OutputT> { @Override public Response<OutputT> execute(SdkHttpFullRequest request, RequestExecutionContext context) throws Exception { try { return executeWithTimer(request, context); } catch (Exception e) { throw translatePipelineException(c...
### Question: SystemPropertyHttpServiceProvider implements SdkHttpServiceProvider<T> { @Override public Optional<T> loadService() { return implSetting .getStringValue() .map(this::createServiceFromProperty); } private SystemPropertyHttpServiceProvider(SystemSetting implSetting, Class<T> serviceClass); @Override Option...
### Question: SdkHttpServiceProviderChain implements SdkHttpServiceProvider<T> { @Override public Optional<T> loadService() { return httpProviders.stream() .map(SdkHttpServiceProvider::loadService) .filter(Optional::isPresent) .map(Optional::get) .findFirst(); } @SafeVarargs SdkHttpServiceProviderChain(SdkHttpServiceP...
### Question: CachingSdkHttpServiceProvider implements SdkHttpServiceProvider<T> { @Override public Optional<T> loadService() { if (factory == null) { synchronized (this) { if (factory == null) { this.factory = delegate.loadService(); } } } return factory; } CachingSdkHttpServiceProvider(SdkHttpServiceProvider<T> deleg...
### Question: ClasspathSdkHttpServiceProvider implements SdkHttpServiceProvider<T> { @Override public Optional<T> loadService() { Iterator<T> httpServices = serviceLoader.loadServices(serviceClass); if (!httpServices.hasNext()) { return Optional.empty(); } T httpService = httpServices.next(); if (httpServices.hasNext()...
### Question: MetricUtils { public static <T> Pair<T, Duration> measureDuration(Supplier<T> c) { long start = System.nanoTime(); T result = c.get(); Duration d = Duration.ofNanos(System.nanoTime() - start); return Pair.of(result, d); } private MetricUtils(); static Pair<T, Duration> measureDuration(Supplier<T> c); sta...
### Question: MetricUtils { public static <T> Pair<T, Duration> measureDurationUnsafe(Callable<T> c) throws Exception { long start = System.nanoTime(); T result = c.call(); Duration d = Duration.ofNanos(System.nanoTime() - start); return Pair.of(result, d); } private MetricUtils(); static Pair<T, Duration> measureDura...
### Question: MetricUtils { public static void collectHttpMetrics(MetricCollector metricCollector, SdkHttpFullResponse httpResponse) { if (metricCollector != null && httpResponse != null) { metricCollector.reportMetric(HttpMetric.HTTP_STATUS_CODE, httpResponse.statusCode()); SdkHttpUtils.allMatchingHeadersFromCollectio...
### Question: Mimetype { public String getMimetype(Path path) { Validate.notNull(path, "path"); Path file = path.getFileName(); if (file != null) { return getMimetype(file.toString()); } return MIMETYPE_OCTET_STREAM; } private Mimetype(); static Mimetype getInstance(); String getMimetype(Path path); String getMimetype...
### Question: UserAgentUtils { static String userAgent() { String ua = UA_STRING; ua = ua .replace("{platform}", "java") .replace("{version}", VersionInfo.SDK_VERSION) .replace("{os.name}", sanitizeInput(JavaSystemSetting.OS_NAME.getStringValue().orElse(null))) .replace("{os.version}", sanitizeInput(JavaSystemSetting.O...
### Question: ByteArrayAsyncRequestBody implements AsyncRequestBody { @Override public void subscribe(Subscriber<? super ByteBuffer> s) { if (s == null) { throw new NullPointerException("Subscription MUST NOT be null."); } try { s.onSubscribe( new Subscription() { private boolean done = false; @Override public void req...
### Question: ClockSkewAdjuster { public Integer getAdjustmentInSeconds(SdkHttpResponse response) { Instant now = Instant.now(); Instant serverTime = ClockSkew.getServerTime(response).orElse(null); Duration skew = ClockSkew.getClockSkew(now, serverTime); try { return Math.toIntExact(skew.getSeconds()); } catch (Arithme...
### Question: FileContentStreamProvider implements ContentStreamProvider { @Override public InputStream newStream() { closeCurrentStream(); currentStream = invokeSafely(() -> Files.newInputStream(filePath)); return currentStream; } FileContentStreamProvider(Path filePath); @Override InputStream newStream(); }### Answe...
### Question: AwsHostNameUtils { public static Optional<Region> parseSigningRegion(final String host, final String serviceHint) { if (host == null) { throw new IllegalArgumentException("hostname cannot be null"); } if (host.endsWith(".amazonaws.com")) { int index = host.length() - ".amazonaws.com".length(); return pars...
### Question: HelpfulUnknownHostExceptionInterceptor implements ExecutionInterceptor { @Override public Throwable modifyException(Context.FailedExecution context, ExecutionAttributes executionAttributes) { if (!hasCause(context.exception(), UnknownHostException.class)) { return context.exception(); } StringBuilder erro...
### Question: S3AccessPointResource implements S3Resource, ToCopyableBuilder<S3AccessPointResource.Builder, S3AccessPointResource> { @Override public Builder toBuilder() { return builder() .partition(partition) .region(region) .accountId(accountId) .accessPointName(accessPointName); } private S3AccessPointResource(Bui...
### Question: QueryParametersToBodyInterceptor implements ExecutionInterceptor { @Override public SdkHttpRequest modifyHttpRequest(Context.ModifyHttpRequest context, ExecutionAttributes executionAttributes) { SdkHttpRequest httpRequest = context.httpRequest(); if (!(httpRequest instanceof SdkHttpFullRequest)) { return ...
### Question: ProtocolUtils { public static SdkHttpFullRequest.Builder createSdkHttpRequest(OperationInfo operationInfo, URI endpoint) { SdkHttpFullRequest.Builder request = SdkHttpFullRequest .builder() .method(operationInfo.httpMethod()) .uri(endpoint); return request.encodedPath(SdkHttpUtils.appendUri(request.encode...
### Question: ProtocolUtils { @SdkTestInternalApi static String addStaticQueryParametersToRequest(SdkHttpFullRequest.Builder request, String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) ...
### Question: AwsCborProtocolFactory extends BaseAwsJsonProtocolFactory { @Override protected Map<MarshallLocation, TimestampFormatTrait.Format> getDefaultTimestampFormats() { if (!isCborEnabled()) { return super.getDefaultTimestampFormats(); } Map<MarshallLocation, TimestampFormatTrait.Format> formats = new EnumMap<>(...
### Question: AwsXmlUnmarshallingContext { public Builder toBuilder() { return builder().sdkHttpFullResponse(this.sdkHttpFullResponse) .parsedXml(this.parsedXml) .executionAttributes(this.executionAttributes) .isResponseSuccess(this.isResponseSuccess) .parsedErrorXml(this.parsedErrorXml); } private AwsXmlUnmarshalling...
### Question: AwsXmlUnmarshallingContext { @Override public int hashCode() { int result = sdkHttpFullResponse != null ? sdkHttpFullResponse.hashCode() : 0; result = 31 * result + (parsedXml != null ? parsedXml.hashCode() : 0); result = 31 * result + (executionAttributes != null ? executionAttributes.hashCode() : 0); re...
### Question: ProfileFileLocation { @SdkInternalApi static String userHomeDirectory() { boolean isWindows = JavaSystemSetting.OS_NAME.getStringValue() .map(s -> StringUtils.lowerCase(s).startsWith("windows")) .orElse(false); String home = System.getenv("HOME"); if (home != null) { return home; } if (isWindows) { String...
### Question: ProfileFile { public Map<String, Profile> profiles() { return profiles; } private ProfileFile(Map<String, Map<String, String>> rawProfiles); static Builder builder(); static Aggregator aggregator(); static ProfileFile defaultProfileFile(); Optional<Profile> profile(String profileName); Map<String, Profil...
### Question: ProfileFile { public static ProfileFile defaultProfileFile() { return ProfileFile.aggregator() .applyMutation(ProfileFile::addCredentialsFile) .applyMutation(ProfileFile::addConfigFile) .build(); } private ProfileFile(Map<String, Map<String, String>> rawProfiles); static Builder builder(); static Aggrega...
### Question: EnhancedS3ServiceMetadata implements ServiceMetadata { @Override public URI endpointFor(Region region) { if (Region.US_EAST_1.equals(region) && !useUsEast1RegionalEndpoint.getValue()) { return URI.create("s3.amazonaws.com"); } return s3ServiceMetadata.endpointFor(region); } EnhancedS3ServiceMetadata(); pr...
### Question: AwsRegionProviderChain implements AwsRegionProvider { @Override public Region getRegion() throws SdkClientException { List<String> exceptionMessages = null; for (AwsRegionProvider provider : providers) { try { Region region = provider.getRegion(); if (region != null) { return region; } } catch (Exception ...
### Question: LazyAwsRegionProvider implements AwsRegionProvider { @Override public Region getRegion() { return delegate.getValue().getRegion(); } LazyAwsRegionProvider(Supplier<AwsRegionProvider> delegateConstructor); @Override Region getRegion(); @Override String toString(); }### Answer: @Test public void getRegionI...
### Question: AwsProfileRegionProvider implements AwsRegionProvider { @Override public Region getRegion() { return profileFile.get() .profile(profileName) .map(p -> p.properties().get(ProfileProperty.REGION)) .map(Region::of) .orElseThrow(() -> SdkClientException.builder() .message("No region provided in profile: " + p...
### Question: EC2MetadataUtils { public static String getToken() { try { return HttpResourcesUtils.instance().readResource(TOKEN_ENDPOINT_PROVIDER, "PUT"); } catch (Exception e) { boolean is400ServiceException = e instanceof SdkServiceException && ((SdkServiceException) e).statusCode() == 400; if (is400ServiceException...
### Question: DefaultMetricCollection implements MetricCollection { @SuppressWarnings("unchecked") @Override public <T> List<T> metricValues(SdkMetric<T> metric) { if (metrics.containsKey(metric)) { List<MetricRecord<?>> metricRecords = metrics.get(metric); List<?> values = metricRecords.stream() .map(MetricRecord::val...
### Question: DefaultMetricCollection implements MetricCollection { @Override public List<MetricCollection> children() { return children; } DefaultMetricCollection(String name, Map<SdkMetric<?>, List<MetricRecord<?>>> metrics, List<MetricCollection> children); @Override String name(); @SuppressWarnings("uncheck...
### Question: DefaultSdkMetric extends AttributeMap.Key<T> implements SdkMetric<T> { public static <T> SdkMetric<T> create(String name, Class<T> clzz, MetricLevel level, MetricCategory c1, MetricCategory... cn) { Stream<MetricCategory> categoryStream = Stream.of(c1); if (cn != null) { categoryStream = Stream.concat(cat...
### Question: StaticCredentialsProvider implements AwsCredentialsProvider { public static StaticCredentialsProvider create(AwsCredentials credentials) { return new StaticCredentialsProvider(credentials); } private StaticCredentialsProvider(AwsCredentials credentials); static StaticCredentialsProvider create(AwsCredent...
### Question: ContainerCredentialsProvider extends HttpCredentialsProvider { public static Builder builder() { return new BuilderImpl(); } private ContainerCredentialsProvider(BuilderImpl builder); static Builder builder(); @Override String toString(); }### Answer: @Test(expected = SdkClientException.class) public vo...
### Question: HttpCredentialsProvider implements AwsCredentialsProvider, SdkAutoCloseable { @Override public AwsCredentials resolveCredentials() { if (isLocalCredentialLoadingDisabled()) { throw SdkClientException.builder() .message("Loading credentials from local endpoint is disabled. Unable to load " + "credentials f...
### Question: LazyAwsCredentialsProvider implements AwsCredentialsProvider, SdkAutoCloseable { public static LazyAwsCredentialsProvider create(Supplier<AwsCredentialsProvider> delegateConstructor) { return new LazyAwsCredentialsProvider(delegateConstructor); } private LazyAwsCredentialsProvider(Supplier<AwsCredentials...
### Question: ProfileCredentialsProvider implements AwsCredentialsProvider, SdkAutoCloseable { public static Builder builder() { return new BuilderImpl(); } private ProfileCredentialsProvider(BuilderImpl builder); static ProfileCredentialsProvider create(); static ProfileCredentialsProvider create(String profileName);...
### Question: EventStreamAws4Signer extends BaseEventStreamAsyncAws4Signer { public static EventStreamAws4Signer create() { return new EventStreamAws4Signer(); } private EventStreamAws4Signer(); static EventStreamAws4Signer create(); }### Answer: @Test public void openStreamEventSignaturesCanRollOverBetweenDays() { E...
### Question: BaseEventStreamAsyncAws4Signer extends BaseAsyncAws4Signer { static String toDebugString(Message m, boolean truncatePayload) { StringBuilder sb = new StringBuilder("Message = {headers={"); Map<String, HeaderValue> headers = m.getHeaders(); Iterator<Map.Entry<String, HeaderValue>> headersIter = headers.ent...
### Question: SignerKey { public boolean isValidForDate(Instant other) { return daysSinceEpoch == DateUtils.numberOfDaysSinceEpoch(other.toEpochMilli()); } SignerKey(Instant date, byte[] signingKey); boolean isValidForDate(Instant other); byte[] getSigningKey(); }### Answer: @Test public void isValidForDate_dayBefore_...
### Question: ArnResource implements ToCopyableBuilder<ArnResource.Builder, ArnResource> { @Override public Builder toBuilder() { return builder() .resource(resource) .resourceType(resourceType) .qualifier(qualifier); } private ArnResource(DefaultBuilder builder); Optional<String> resourceType(); String resource(); Op...
### Question: ArnResource implements ToCopyableBuilder<ArnResource.Builder, ArnResource> { public static Builder builder() { return new DefaultBuilder(); } private ArnResource(DefaultBuilder builder); Optional<String> resourceType(); String resource(); Optional<String> qualifier(); static Builder builder(); static Arn...
### Question: Arn implements ToCopyableBuilder<Arn.Builder, Arn> { @Override public Builder toBuilder() { return builder().accountId(accountId) .partition(partition) .region(region) .resource(resource) .service(service) ; } private Arn(DefaultBuilder builder); String partition(); String service(); Optional<String> reg...
### Question: Http2Configuration implements ToCopyableBuilder<Http2Configuration.Builder, Http2Configuration> { public static Builder builder() { return new DefaultBuilder(); } private Http2Configuration(DefaultBuilder builder); Long maxStreams(); Integer initialWindowSize(); Duration healthCheckPingPeriod(); @Overrid...
### Question: ProxyConfiguration implements ToCopyableBuilder<ProxyConfiguration.Builder, ProxyConfiguration> { @Override public Builder toBuilder() { return new BuilderImpl(this); } private ProxyConfiguration(BuilderImpl builder); String scheme(); String host(); int port(); Set<String> nonProxyHosts(); @Override bool...
### Question: FutureCancelHandler extends ChannelInboundHandlerAdapter { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) { if (cancelled(ctx, e)) { RequestContext requestContext = ctx.channel().attr(REQUEST_CONTEXT_KEY).get(); requestContext.handler().onError(e); ctx.fireExceptionCaught(ne...
### Question: Http1TunnelConnectionPool implements ChannelPool { @Override public Future<Void> release(Channel channel) { return release(channel, eventLoop.newPromise()); } Http1TunnelConnectionPool(EventLoop eventLoop, ChannelPool delegate, SslContext sslContext, URI proxyAddress, ...
### Question: Http1TunnelConnectionPool implements ChannelPool { @Override public void close() { delegate.close(); } Http1TunnelConnectionPool(EventLoop eventLoop, ChannelPool delegate, SslContext sslContext, URI proxyAddress, URI remoteAddress, ChannelPoolHandler handler); @SdkTest...
### Question: NettyRequestExecutor { @SuppressWarnings("unchecked") public CompletableFuture<Void> execute() { Promise<Channel> channelFuture = context.eventLoopGroup().next().newPromise(); executeFuture = createExecutionFuture(channelFuture); context.channelPool().acquire(channelFuture); channelFuture.addListener((Gen...