Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions schemaregistry/rest-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, CreateAxiosDef
import { OAuthClient } from './oauth/oauth-client';
import { RestError } from './rest-error';
import axiosRetry from "axios-retry";
import { fullJitter, isRetriable } from './retry-helper';
import { fullJitter, isRetriable, isSuccess } from './retry-helper';
/*
* Confluent-Schema-Registry-TypeScript - Node.js wrapper for Confluent Schema Registry
*
Expand Down Expand Up @@ -181,7 +181,7 @@ export class RestService {
})
return response;
} catch (error) {
if (axios.isAxiosError(error) && error.response && (error.response.status < 200 || error.response.status > 299)) {
if (axios.isAxiosError(error) && error.response && !isSuccess(error.response.status)) {
const data = error.response.data;
if (data.error_code && data.message) {
error = new RestError(data.message, error.response.status, data.error_code);
Expand Down
6 changes: 5 additions & 1 deletion schemaregistry/retry-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ function fullJitter(baseDelayMs: number, maxDelayMs: number, retriesAttempted: n
return Math.random() * Math.min(maxDelayMs, baseDelayMs * 2 ** retriesAttempted)
}

function isSuccess(statusCode: number): boolean {
return statusCode >= 200 && statusCode <= 299
}

function isRetriable(statusCode: number): boolean {
return statusCode == 408 || statusCode == 429
|| statusCode == 500 || statusCode == 502 || statusCode == 503 || statusCode == 504;
}

export { sleep, fullJitter, isRetriable };
export { sleep, fullJitter, isSuccess, isRetriable };
2 changes: 1 addition & 1 deletion schemaregistry/serde/serde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export abstract class Serde {
}
for (let i = 0; i < rules.length; i++ ) {
let rule = rules[i]
if (rule.disabled) {
if (this.isDisabled(rule)) {
continue
}
let mode = rule.mode
Expand Down
8 changes: 4 additions & 4 deletions schemaregistry/test/serde/avro.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,16 +664,16 @@ describe('AvroSerializer', () => {
registry.registerOverride({type: 'ENCRYPT', disabled: true})
deser = new AvroDeserializer(client, SerdeType.VALUE, deserConfig, registry)
obj2 = await deser.deserialize(topic, bytes)
expect(obj2.stringField).not.toEqual(obj.stringField);
expect(obj2.bytesField).not.toEqual(obj.bytesField);
expect(obj2.stringField).not.toEqual("hi");
expect(obj2.bytesField).not.toEqual(Buffer.from([1, 2]));

clearKmsClients()
registry = new RuleRegistry()
registry.registerExecutor(new FieldEncryptionExecutor())
deser = new AvroDeserializer(client, SerdeType.VALUE, {}, registry)
obj2 = await deser.deserialize(topic, bytes)
expect(obj2.stringField).not.toEqual(obj.stringField);
expect(obj2.bytesField).not.toEqual(obj.bytesField);
expect(obj2.stringField).not.toEqual("hi");
expect(obj2.bytesField).not.toEqual(Buffer.from([1, 2]));
})
it('basic encryption with logical type', async () => {
let conf: ClientConfig = {
Expand Down