Skip to content

Commit efa4434

Browse files
Merge branch 'main' into more_algos
2 parents 546b47c + 17f67d9 commit efa4434

17 files changed

Lines changed: 538 additions & 86 deletions

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ jobs:
202202
python builder.pyz build -p ${{ env.PACKAGE_NAME }} downstream
203203
204204
macos:
205-
runs-on: macos-14 #latest
205+
runs-on: macos-15 #latest
206206
steps:
207207
- uses: aws-actions/configure-aws-credentials@v4
208208
with:
@@ -220,7 +220,7 @@ jobs:
220220
python3 codebuild/macos_compatibility_check.py
221221
222222
macos-x64:
223-
runs-on: macos-14-large #latest
223+
runs-on: macos-15-large #latest
224224
steps:
225225
- uses: aws-actions/configure-aws-credentials@v4
226226
with:
@@ -287,7 +287,7 @@ jobs:
287287
288288
289289
localhost-test-macos:
290-
runs-on: macos-14 # latest
290+
runs-on: macos-15 # latest
291291
steps:
292292
- uses: aws-actions/configure-aws-credentials@v4
293293
with:

src/main/java/software/amazon/awssdk/crt/CRT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,16 +492,16 @@ private static native void awsCrtInit(int memoryTracingLevel, boolean debugWait,
492492
* Given an error code, get a boolean to check if an error is transient or not.
493493
*
494494
* Transient errors are defined as IO level errors where we are unable to read an HTTP response.
495-
* This can occur due to connect timeouts, read timeouts, or the server closing the connection without
495+
* This can occur due to connect timeouts, read timeouts, or the server closing the connection without
496496
* sending a response. This method helps identify CRT error codes that are not generic or widely adopted.
497497
*
498-
* This is not the complete logic to identify transient or retryable errors, this includes only IO level
498+
* This is not the complete logic to identify transient or retryable errors, this includes only IO level
499499
* errors that are transient.
500500
*
501501
* @param errorCode An error code returned from an exception or other native function call
502502
* @return A boolean for if the error is transient or not
503503
*/
504-
public static native Boolean awsIsTransientError(int errorCode);
504+
public static native boolean awsIsTransientError(int errorCode);
505505

506506
/**
507507
* @return The number of bytes allocated in native resources. If

src/main/java/software/amazon/awssdk/crt/http/Http2StreamManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ private Http2StreamManager(Http2StreamManagerOptions options) {
123123
maxConnections,
124124
idealConcurrentStreamsPerConnection,
125125
maxConcurrentStreamsPerConnection,
126+
options.getMaxConcurrentStreams(),
126127
options.hasPriorKnowledge(),
127128
options.shouldCloseConnectionOnServerError(),
128129
options.getConnectionPingPeriodMs(),
@@ -265,6 +266,7 @@ private static native long http2StreamManagerNew(Http2StreamManager thisObj,
265266
int maxConns,
266267
int ideal_concurrent_streams_per_connection,
267268
int max_concurrent_streams_per_connection,
269+
int max_concurrent_streams,
268270
boolean priorKnowledge,
269271
boolean closeConnectionOnServerError,
270272
int connectionPingPeriodMs,

src/main/java/software/amazon/awssdk/crt/http/Http2StreamManagerOptions.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
* instance
1010
*/
1111
public class Http2StreamManagerOptions {
12-
public static final int DEFAULT_MAX_WINDOW_SIZE = Integer.MAX_VALUE;
1312
public static final int DEFAULT_MAX = Integer.MAX_VALUE;
14-
public static final int DEFAULT_MAX_CONNECTIONS = 2;
1513
public static final int DEFAULT_CONNECTION_PING_TIMEOUT_MS = 3000;
1614
private static final String HTTPS = "https";
1715

@@ -20,6 +18,7 @@ public class Http2StreamManagerOptions {
2018
private int idealConcurrentStreamsPerConnection = 100;
2119
private boolean connectionManualWindowManagement = false;
2220
private int maxConcurrentStreamsPerConnection = DEFAULT_MAX;
21+
private int maxConcurrentStreams = 0;
2322

2423
private boolean priorKnowledge = false;
2524
private boolean closeConnectionOnServerError = false;
@@ -108,6 +107,28 @@ public int getMaxConcurrentStreamsPerConnection() {
108107
return maxConcurrentStreamsPerConnection;
109108
}
110109

110+
/**
111+
* The max number of concurrent streams that can be active across all connections
112+
* at the same time. 0 means no limit (default). When this limit is reached, the
113+
* stream manager will wait for existing streams to complete before creating new
114+
* ones, even if connections have available capacity.
115+
*
116+
* @param maxConcurrentStreams The max number of concurrent streams across all connections
117+
* @return this
118+
*/
119+
public Http2StreamManagerOptions withMaxConcurrentStreams(int maxConcurrentStreams) {
120+
this.maxConcurrentStreams = maxConcurrentStreams;
121+
return this;
122+
}
123+
124+
/**
125+
* @return The max number of concurrent streams across all connections.
126+
* 0 means no limit (default).
127+
*/
128+
public int getMaxConcurrentStreams() {
129+
return maxConcurrentStreams;
130+
}
131+
111132
/**
112133
* @return The connection level manual flow control enabled or not.
113134
*/

src/main/java/software/amazon/awssdk/crt/http/HttpStreamBase.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55

66
package software.amazon.awssdk.crt.http;
77

8-
import software.amazon.awssdk.crt.CRT;
98
import software.amazon.awssdk.crt.CrtResource;
10-
import software.amazon.awssdk.crt.CrtRuntimeException;
11-
12-
import java.util.concurrent.CompletableFuture;
139

1410
/**
1511
* An base class represents a single Http Request/Response for both HTTP/1.1 and
@@ -100,6 +96,22 @@ public int getResponseStatusCode() {
10096
throw new IllegalStateException("Can't get Status Code on Closed Stream");
10197
}
10298

99+
/**
100+
* Cancels the stream with the default error code (AWS_ERROR_HTTP_STREAM_CANCELLED).
101+
* <p>
102+
* For HTTP/1.1 streams, this is equivalent to closing the connection.
103+
* For HTTP/2 streams, this sends a RST_STREAM frame with AWS_HTTP2_ERR_CANCEL.
104+
* <p>
105+
* The stream will complete with AWS_ERROR_HTTP_STREAM_CANCELLED, unless the stream is
106+
* already completing for other reasons, or the stream is not activated,
107+
* in which case this call will have no effect.
108+
*/
109+
public void cancel() {
110+
if (!isNull()) {
111+
httpStreamBaseCancelDefaultError(getNativeHandle());
112+
}
113+
}
114+
103115
/*******************************************************************************
104116
* Native methods
105117
******************************************************************************/
@@ -111,4 +123,6 @@ public int getResponseStatusCode() {
111123
private static native void httpStreamBaseActivate(long http_stream, HttpStreamBase streamObj);
112124

113125
private static native int httpStreamBaseGetResponseStatusCode(long http_stream);
126+
127+
private static native void httpStreamBaseCancelDefaultError(long http_stream);
114128
}

src/main/java/software/amazon/awssdk/crt/io/TlsCipherPreference.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ public enum TlsCipherPreference {
7676
* This security policy was the system default before PQ was enabled by default, specifically
7777
* aws-c-io's AWS_IO_TLS_CIPHER_PREF_TLSV1_0_2023_06.
7878
*/
79-
TLS_CIPHER_PREF_TLSv1_0_2023(10);
79+
TLS_CIPHER_PREF_TLSv1_0_2023(10),
80+
81+
/**
82+
* The latest recommended non-Post-quantum enabled TLS Policy. This policy may change over time.
83+
*/
84+
TLS_CIPHER_NON_PQ_DEFAULT(11);
8085

8186
private int val;
8287

src/native/crt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ void JNICALL Java_software_amazon_awssdk_crt_CRT_awsCrtInit(
709709
}
710710

711711
JNIEXPORT
712-
bool JNICALL
712+
jboolean JNICALL
713713
Java_software_amazon_awssdk_crt_CRT_awsIsTransientError(JNIEnv *env, jclass jni_crt_class, jint error_code) {
714714
(void)env;
715715
(void)jni_crt_class;

src/native/http2_stream_manager.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ JNIEXPORT jlong JNICALL Java_software_amazon_awssdk_crt_http_Http2StreamManager_
113113
jint jni_max_conns,
114114
jint jni_ideal_concurrent_streams_per_connection,
115115
jint jni_max_concurrent_streams_per_connection,
116+
jint jni_max_concurrent_streams,
116117
jboolean jni_prior_knowledge,
117118
jboolean jni_close_connection_on_server_error,
118119
jint jni_connection_ping_period_ms,
@@ -207,6 +208,7 @@ JNIEXPORT jlong JNICALL Java_software_amazon_awssdk_crt_http_Http2StreamManager_
207208
.ideal_concurrent_streams_per_connection = (size_t)jni_ideal_concurrent_streams_per_connection,
208209
.max_concurrent_streams_per_connection = (size_t)jni_max_concurrent_streams_per_connection,
209210
.max_connections = (size_t)jni_max_conns,
211+
.max_concurrent_streams = (size_t)jni_max_concurrent_streams,
210212
};
211213

212214
struct aws_http_connection_monitoring_options monitoring_options;

src/native/http_request_response.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,26 @@ JNIEXPORT void JNICALL Java_software_amazon_awssdk_crt_http_HttpStreamBase_httpS
706706
aws_http_stream_update_window(stream, window_update);
707707
}
708708

709+
JNIEXPORT void JNICALL Java_software_amazon_awssdk_crt_http_HttpStreamBase_httpStreamBaseCancelDefaultError(
710+
JNIEnv *env,
711+
jclass jni_class,
712+
jlong jni_binding) {
713+
714+
(void)jni_class;
715+
aws_cache_jni_ids(env);
716+
717+
struct http_stream_binding *binding = (struct http_stream_binding *)jni_binding;
718+
struct aws_http_stream *stream = binding->native_stream;
719+
720+
if (stream == NULL) {
721+
aws_jni_throw_runtime_exception(env, "HttpStream is null.");
722+
return;
723+
}
724+
725+
AWS_LOGF_TRACE(AWS_LS_HTTP_STREAM, "Cancelling Stream with default error. stream: %p", (void *)stream);
726+
aws_http_stream_cancel_default_error(stream);
727+
}
728+
709729
JNIEXPORT void JNICALL Java_software_amazon_awssdk_crt_http_Http2Stream_http2StreamResetStream(
710730
JNIEnv *env,
711731
jclass jni_class,

src/native/mqtt5_packets.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ struct aws_mqtt5_packet_publish_view_java_jni *aws_mqtt5_packet_publish_view_cre
11361136
mqtt5_publish_packet_properties.publish_payload_field_id,
11371137
s_publish_packet_string,
11381138
"payload",
1139-
&java_packet->correlation_data_buf,
1139+
&java_packet->payload_buf,
11401140
&java_packet->payload_cursor,
11411141
true,
11421142
&was_value_set) == AWS_OP_ERR) {

0 commit comments

Comments
 (0)