Skip to content

Commit ad007e9

Browse files
authored
Merge branch 'release_v2.4.0' into update-dependency-ydb-proto-api
2 parents 0e5abaa + 7b74739 commit ad007e9

File tree

204 files changed

+5316
-1522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

204 files changed

+5316
-1522
lines changed

.devcontainer/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM mcr.microsoft.com/devcontainers/java:1-21-bullseye
2+
3+
ENV MAVEN_CONFIG=/var/maven/.m2
4+
5+
# [Optional] Uncomment if you want to install more tools
6+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
7+
&& apt-get -y install --no-install-recommends maven \
8+
&& mkdir -p /var/maven/.m2 \
9+
&& chown -R vscode:vscode /var/maven/.m2
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -e
3+
4+
git config --local user.name "$(git config user.name)"
5+
git config --local user.email "$(git config user.email)"

.devcontainer/devcontainer.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/java
3+
{
4+
"name": "YDB Java SDK",
5+
"dockerFile": "Dockerfile",
6+
// Allows the container to use ptrace, which is useful for debugging.
7+
"capAdd": [
8+
"SYS_PTRACE"
9+
],
10+
// Disables seccomp, which can be necessary for some debugging tools to function correctly.
11+
"securityOpt": [
12+
"seccomp=unconfined"
13+
],
14+
"features": {
15+
"ghcr.io/devcontainers/features/github-cli:1": {},
16+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
17+
},
18+
// Use 'initializeCommand' to run commands before the container is created.
19+
"initializeCommand": "chmod +x .devcontainer/commands/initialize.sh && .devcontainer/commands/initialize.sh",
20+
// Use 'postCreateCommand' to run commands after the container is created.
21+
// Use 'postStartCommand' to run commands after the container is started.
22+
// Configure tool-specific properties.
23+
"customizations": {
24+
"vscode": {
25+
"extensions": [
26+
"redhat.java",
27+
"vscjava.vscode-java-pack"
28+
]
29+
}
30+
},
31+
// Maven cache volume configuration.
32+
"mounts": [
33+
"source=maven-cache,target=/var/maven/.m2,type=volume"
34+
]
35+
}

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,20 @@ ij_java_insert_override_annotation = true
1717
ij_java_lambda_brace_style = end_of_line
1818
ij_java_method_brace_style = end_of_line
1919
ij_java_names_count_to_use_import_on_demand = 9000
20+
ij_java_space_after_colon = true
21+
ij_java_space_before_colon = true
22+
ij_java_spaces_around_additive_operators = true
23+
ij_java_spaces_around_annotation_eq = true
24+
ij_java_spaces_around_assignment_operators = true
25+
ij_java_spaces_around_bitwise_operators = true
26+
ij_java_spaces_around_equality_operators = true
27+
ij_java_spaces_around_lambda_arrow = true
28+
ij_java_spaces_around_logical_operators = true
29+
ij_java_spaces_around_method_ref_dbl_colon = false
30+
ij_java_spaces_around_multiplicative_operators = true
31+
ij_java_spaces_around_relational_operators = true
32+
ij_java_spaces_around_shift_operators = true
33+
ij_java_spaces_around_type_bounds_in_type_parameters = true
34+
ij_java_spaces_around_unary_operator = false
2035
ij_java_use_single_class_imports = true
2136
ij_java_while_brace_force = always

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for more information:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://containers.dev/guide/dependabot
6+
7+
version: 2
8+
updates:
9+
- package-ecosystem: "devcontainers"
10+
directory: "/"
11+
schedule:
12+
interval: weekly

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
**/.idea/
1010
**/*.iml
1111
**/*.iws
12-
**/*.ipr
12+
**/*.ipr
13+
14+
# VS Code
15+
.vscode

CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
## 2.3.17 ##
2+
* Query: Fixed session status updating
3+
* Topic: Fixed maxActivePartitions on topic creation
4+
* Tests: Updated JUnit5 helper to avoid NPE
5+
* Added devcontainer configuration
6+
7+
## 2.3.16 ##
8+
* Core: Added option to control the grpc stream flow
9+
* Table: Added Serializable to all values and types
10+
* Topic: Fixed double compression of one message
11+
12+
## 2.3.15 ##
13+
14+
* Core: ResourceExhausted isn't pessimize the node
15+
* Table: Added flag about default value in TableColumn
16+
* Table: Added support of describeTableOptions
17+
* Query: Fixed QueryReader.setRowIndex() & added tests
18+
* Topic: Added max_active_partitions support to topic operations
19+
* Topic: Added configuration for GrpcStreamRetrier ID
20+
* Topic: Added equals & hashCode implementations for descriptions
21+
22+
## 2.3.14 ##
23+
24+
* Core: Removed mockito-inline from compile dependencies
25+
* Core: Improved catching of RuntimeException in BaseGrpcTransport
26+
* Table: Fixed support of extended date types in ProtoValue
27+
* Query: Added support of concurrent_result_sets option
28+
* Topic: Add equals() and hashCode() methods to topic description classes
29+
* Topic: Fixed ErrorHandler behaviour
30+
* Topic: Added support of readSessionId
31+
* Topic: SyncWriter.flush() now throw Exception when previous task was failed
32+
* Topic: Add functional interface support to ReadEventHandler
33+
* Topic: Added support of auto-partitioning options to CreateTopic/AlterTopic
34+
* Topic: Fix logger prefix for partition session log events and print correct consumer name
35+
36+
## 2.3.13 ##
37+
38+
* Topic: fixed reconnect after shutdown
39+
* OAuth2 provider: fixed NPE
40+
141
## 2.3.12 ##
242

343
* Table: added validation of entry type in describeTable method

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Firstly you can import YDB Java BOM to specify correct versions of SDK modules.
3030
<dependency>
3131
<groupId>tech.ydb</groupId>
3232
<artifactId>ydb-sdk-bom</artifactId>
33-
<version>2.3.12</version>
33+
<version>2.3.17</version>
3434
<type>pom</type>
3535
<scope>import</scope>
3636
</dependency>

auth-providers/oauth2-provider/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>tech.ydb</groupId>
77
<artifactId>ydb-sdk-parent</artifactId>
8-
<version>2.3.12</version>
8+
<version>2.3.18-SNAPSHOT</version>
99
<relativePath>../../pom.xml</relativePath>
1010
</parent>
1111

@@ -100,6 +100,7 @@
100100
<groupId>org.mockito</groupId>
101101
<artifactId>mockito-inline</artifactId>
102102
<version>${mockito.version}</version>
103+
<scope>test</scope>
103104
</dependency>
104105
</dependencies>
105106
</profile>

auth-providers/oauth2-provider/src/main/java/tech/ydb/auth/OAuth2TokenExchangeProvider.java

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import java.util.ArrayList;
1515
import java.util.Arrays;
1616
import java.util.HashSet;
17-
import java.util.Iterator;
1817
import java.util.List;
1918
import java.util.Set;
2019
import java.util.concurrent.CompletableFuture;
@@ -54,12 +53,12 @@ public class OAuth2TokenExchangeProvider implements AuthRpcProvider<GrpcAuthRpc>
5453

5554
private static final Logger logger = LoggerFactory.getLogger(OAuth2TokenExchangeProvider.class);
5655
private static final Gson GSON = new Gson();
57-
private static final Set<String> SUPPORTED_JWT_ALGS = new HashSet<String>(Arrays.asList(new String[]{
58-
"HS256", "HS384", "HS512",
59-
"RS256", "RS384", "RS512",
60-
"PS256", "PS384", "PS512",
61-
"ES256", "ES384", "ES512",
62-
}));
56+
private static final Set<String> SUPPORTED_JWT_ALGS = new HashSet<>(Arrays.asList(
57+
"HS256", "HS384", "HS512",
58+
"RS256", "RS384", "RS512",
59+
"PS256", "PS384", "PS512",
60+
"ES256", "ES384", "ES512"
61+
));
6362

6463
private final Clock clock;
6564
private final String endpoint;
@@ -83,41 +82,40 @@ private OAuth2TokenExchangeProvider(Clock clock, String endpoint, String scope,
8382
public static String[] getSupportedJwtAlgorithms() {
8483
String[] result = new String[SUPPORTED_JWT_ALGS.size()];
8584
int i = 0;
86-
Iterator<String> it = SUPPORTED_JWT_ALGS.iterator();
87-
while (it.hasNext()) {
88-
result[i++] = it.next();
85+
for (String supportedJwtAlg : SUPPORTED_JWT_ALGS) {
86+
result[i++] = supportedJwtAlg;
8987
}
9088
Arrays.sort(result);
9189
return result;
9290
}
9391

9492
private static OAuth2TokenSource buildFixedTokenSourceFromConfig(TokenSourceJsonConfig cfg) {
95-
if (cfg.getToken() == null || cfg.getToken().length() == 0
96-
|| cfg.getTokenType() == null || cfg.getTokenType().length() == 0) {
93+
if (cfg.getToken() == null || cfg.getToken().isEmpty()
94+
|| cfg.getTokenType() == null || cfg.getTokenType().isEmpty()) {
9795
throw new RuntimeException("Both token and token-type are required");
9896
}
9997
return OAuth2TokenSource.fromValue(cfg.getToken(), cfg.getTokenType());
10098
}
10199

102100
private static OAuth2TokenSource buildJwtTokenSourceFromConfig(TokenSourceJsonConfig cfg) {
103-
if (cfg.getAlg() == null || cfg.getAlg().length() == 0) {
101+
if (cfg.getAlg() == null || cfg.getAlg().isEmpty()) {
104102
throw new RuntimeException("Algorithm is required");
105103
}
106-
if (cfg.getPrivateKey() == null || cfg.getPrivateKey().length() == 0) {
104+
if (cfg.getPrivateKey() == null || cfg.getPrivateKey().isEmpty()) {
107105
throw new RuntimeException("Key is required");
108106
}
109107

110108
String alg = cfg.getAlg().toUpperCase();
111109
if (!SUPPORTED_JWT_ALGS.contains(alg)) {
112110
String[] supportedAlgs = getSupportedJwtAlgorithms();
113-
String lstMsg = "";
111+
StringBuilder lstMsg = new StringBuilder();
114112
for (int i = 0; i < supportedAlgs.length; i++) {
115113
if (lstMsg.length() > 0) {
116-
lstMsg += ", ";
114+
lstMsg.append(", ");
117115
}
118-
lstMsg += "\"";
119-
lstMsg += supportedAlgs[i];
120-
lstMsg += "\"";
116+
lstMsg.append("\"");
117+
lstMsg.append(supportedAlgs[i]);
118+
lstMsg.append("\"");
121119
}
122120
throw new RuntimeException(
123121
String.format("Algorithm \"%s\" is not supported. Supported algorithms: %s",
@@ -129,7 +127,7 @@ private static OAuth2TokenSource buildJwtTokenSourceFromConfig(TokenSourceJsonCo
129127
boolean isHmac = "HS256".equals(alg)
130128
|| "HS384".equals(alg)
131129
|| "HS512".equals(alg);
132-
OAuth2TokenSource.JWTTokenBuilder builder = null;
130+
OAuth2TokenSource.JWTTokenBuilder builder;
133131
if (isHmac) {
134132
builder = OAuth2TokenSource.withHmacPrivateKeyBase64(cfg.getPrivateKey(), alg);
135133
} else {
@@ -184,6 +182,9 @@ public static Builder fromFile(File configFile) {
184182
configFile = expandUserHomeDir(configFile);
185183
try (BufferedReader br = new BufferedReader(new FileReader(configFile))) {
186184
JsonConfig cfg = GSON.fromJson(br, JsonConfig.class);
185+
if (cfg == null) {
186+
throw new RuntimeException("Empty config");
187+
}
187188

188189
if (cfg.getTokenEndpoint() != null) {
189190
builder.withTokenEndpoint(cfg.getTokenEndpoint());
@@ -193,13 +194,13 @@ public static Builder fromFile(File configFile) {
193194
builder.withCustomGrantType(cfg.getGrantType());
194195
}
195196

196-
if (cfg.getResource() != null && cfg.getResource().length != 0) {
197+
if (cfg.getResource() != null) {
197198
for (String res: cfg.getResource()) {
198199
builder.withResource(res);
199200
}
200201
}
201202

202-
if (cfg.getAudience() != null && cfg.getAudience().length != 0) {
203+
if (cfg.getAudience() != null) {
203204
for (String audience: cfg.getAudience()) {
204205
builder.withAudience(audience);
205206
}
@@ -312,6 +313,9 @@ private Token updateToken() throws IOException {
312313

313314
try (Reader reader = new InputStreamReader(response.getEntity().getContent())) {
314315
OAuth2Response json = GSON.fromJson(reader, OAuth2Response.class);
316+
if (json == null) {
317+
throw new UnexpectedResultException("Empty OAuth2 response", Status.of(StatusCode.INTERNAL_ERROR));
318+
}
315319

316320
if (!"Bearer".equalsIgnoreCase(json.getTokenType())) {
317321
throw new UnexpectedResultException(
@@ -529,13 +533,13 @@ private static class SingleStringOrArrayOfStringsJsonConfigDeserializer implemen
529533
public String[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
530534
if (json.isJsonArray()) {
531535
JsonArray arr = json.getAsJsonArray();
532-
if (arr.size() == 0) {
536+
if (arr.isEmpty()) {
533537
return null;
534538
}
535539
String[] result = new String[arr.size()];
536540
for (int i = 0; i < arr.size(); i++) {
537541
result[i] = arr.get(i).getAsJsonPrimitive().getAsString();
538-
if (result[i].length() == 0) {
542+
if (result[i].isEmpty()) {
539543
throw new RuntimeException("Cannot parse config from json: empty string");
540544
}
541545
}
@@ -544,7 +548,7 @@ public String[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationC
544548
if (json.isJsonPrimitive()) {
545549
String[] result = new String[1];
546550
result[0] = json.getAsJsonPrimitive().getAsString();
547-
if (result[0].length() == 0) {
551+
if (result[0].isEmpty()) {
548552
throw new RuntimeException("Cannot parse config from json: empty string");
549553
}
550554
return result;
@@ -709,14 +713,14 @@ public String[] getScope() {
709713
}
710714

711715
public String buildScope() {
712-
String result = new String();
716+
StringBuilder result = new StringBuilder();
713717
for (String s: this.scope) {
714718
if (result.length() != 0) {
715-
result += " ";
719+
result.append(" ");
716720
}
717-
result += s;
721+
result.append(s);
718722
}
719-
return result;
723+
return result.toString();
720724
}
721725

722726
public String getRequestedTokenType() {

0 commit comments

Comments
 (0)