Skip to content

Commit

Permalink
Expose missing QUIC errors (java-native-access#549)
Browse files Browse the repository at this point in the history
Motivation:

We didnt expose all QUIC errors which lead to some
IllegalArgumentException

Modifications:

Expose all errors

Result:

No more unexpected errors
  • Loading branch information
normanmaurer authored Jul 1, 2023
1 parent 9dfaba6 commit b86395a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ public enum QuicError {
FINAL_SIZE(Quiche.QUICHE_ERR_FINAL_SIZE, "QUICHE_ERR_FINAL_SIZE"),
CONGESTION_CONTROL(Quiche.QUICHE_ERR_CONGESTION_CONTROL, "QUICHE_ERR_CONGESTION_CONTROL"),
STREAM_RESET(Quiche.QUICHE_ERR_STREAM_RESET, "STREAM_RESET"),
STREAM_STOPPED(Quiche.QUICHE_ERR_STREAM_STOPPED, "STREAM_STOPPED");
STREAM_STOPPED(Quiche.QUICHE_ERR_STREAM_STOPPED, "STREAM_STOPPED"),
ID_LIMIT(Quiche.QUICHE_ERR_ID_LIMIT, "ID_LIMIT"),
QUT_OF_IDENTIFIERS(Quiche.QUICHE_ERR_OUT_OF_IDENTIFIERS, "OUT_OF_IDENTIFIERS"),
KEY_UPDATE(Quiche.QUICHE_ERR_KEY_UPDATE, "KEY_UPDATE");

private static final IntObjectMap<QuicError> ERROR_MAP = new IntObjectHashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,19 @@ private static void loadNativeLibrary() {
static final int QUICHE_ERR_STREAM_STOPPED =
QuicheNativeStaticallyReferencedJniMethods.quiche_err_stream_stopped();


// Too many identifiers were provided.
static final int QUICHE_ERR_ID_LIMIT =
QuicheNativeStaticallyReferencedJniMethods.quiche_err_id_limit();

// Not enough available identifiers.
static final int QUICHE_ERR_OUT_OF_IDENTIFIERS =
QuicheNativeStaticallyReferencedJniMethods.quiche_err_out_of_identifiers();

// Error in key update.
static final int QUICHE_ERR_KEY_UPDATE =
QuicheNativeStaticallyReferencedJniMethods.quiche_err_key_update();

/**
* See <a href="https://github.com/cloudflare/quiche/blob/0.6.0/include/quiche.h#L176">
* QUICHE_CC_RENO</a>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ final class QuicheNativeStaticallyReferencedJniMethods {
static native int quiche_err_stream_stopped();
static native int quiche_err_stream_reset();
static native int quiche_err_congestion_control();
static native int quiche_err_id_limit();
static native int quiche_err_out_of_identifiers();
static native int quiche_err_key_update();

static native int quiche_cc_reno();
static native int quiche_cc_cubic();
Expand Down
15 changes: 15 additions & 0 deletions codec-native-quic/src/main/c/netty_quic_quiche.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,18 @@ static jint netty_quiche_err_congestion_control(JNIEnv* env, jclass clazz) {
return QUICHE_ERR_CONGESTION_CONTROL;
}

static jint netty_quiche_err_id_limit(JNIEnv* env, jclass clazz) {
return QUICHE_ERR_ID_LIMIT;
}

static jint netty_quiche_err_out_of_identifiers(JNIEnv* env, jclass clazz) {
return QUICHE_ERR_OUT_OF_IDENTIFIERS;
}

static jint netty_quiche_err_key_update(JNIEnv* env, jclass clazz) {
return QUICHE_ERR_KEY_UPDATE;
}

static jint netty_quiche_cc_reno(JNIEnv* env, jclass clazz) {
return QUICHE_CC_RENO;
}
Expand Down Expand Up @@ -801,6 +813,9 @@ static const JNINativeMethod statically_referenced_fixed_method_table[] = {
{ "quiche_err_stream_stopped", "()I", (void *) netty_quiche_err_stream_stopped },
{ "quiche_err_stream_reset", "()I", (void *) netty_quiche_err_stream_reset },
{ "quiche_err_congestion_control", "()I", (void *) netty_quiche_err_congestion_control },
{ "quiche_err_id_limit", "()I", (void *) netty_quiche_err_id_limit },
{ "quiche_err_out_of_identifiers", "()I", (void *) netty_quiche_err_out_of_identifiers },
{ "quiche_err_key_update", "()I", (void *) netty_quiche_err_key_update },
{ "quiche_cc_reno", "()I", (void *) netty_quiche_cc_reno },
{ "quiche_cc_cubic", "()I", (void *) netty_quiche_cc_cubic },
{ "quiche_cc_bbr", "()I", (void *) netty_quiche_cc_bbr }
Expand Down

0 comments on commit b86395a

Please sign in to comment.