Skip to content

Commit 2cf580a

Browse files
dlsrb6342RobWin
authored andcommitted
Remove hibernate-validator dependency (ReactiveX#660)
1 parent 8cea8c5 commit 2cf580a

File tree

11 files changed

+283
-96
lines changed

11 files changed

+283
-96
lines changed

resilience4j-framework-common/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ dependencies {
55
compile project(':resilience4j-retry')
66
compile project(':resilience4j-bulkhead')
77

8-
compile libraries.validationApi
9-
compile libraries.hibernate_validator
108
}
119

1210
ext.moduleName='io.github.resilience4j.framework-common'

resilience4j-framework-common/src/main/java/io/github/resilience4j/common/bulkhead/configuration/BulkheadConfigurationProperties.java

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,40 @@
1515
*/
1616
package io.github.resilience4j.common.bulkhead.configuration;
1717

18+
import io.github.resilience4j.bulkhead.BulkheadConfig;
1819
import io.github.resilience4j.common.utils.ConfigUtils;
1920
import io.github.resilience4j.core.ConfigurationNotFoundException;
2021
import io.github.resilience4j.core.StringUtils;
2122
import io.github.resilience4j.core.lang.Nullable;
22-
import org.hibernate.validator.constraints.time.DurationMin;
2323

24-
import javax.validation.constraints.Min;
2524
import java.time.Duration;
2625
import java.util.HashMap;
2726
import java.util.Map;
27+
import java.util.Objects;
2828

2929
public class BulkheadConfigurationProperties {
3030

3131
private Map<String, InstanceProperties> instances = new HashMap<>();
3232
private Map<String, InstanceProperties> configs = new HashMap<>();
3333

34-
public io.github.resilience4j.bulkhead.BulkheadConfig createBulkheadConfig(InstanceProperties instanceProperties) {
34+
public BulkheadConfig createBulkheadConfig(InstanceProperties instanceProperties) {
3535
if (StringUtils.isNotEmpty(instanceProperties.getBaseConfig())) {
3636
InstanceProperties baseProperties = configs.get(instanceProperties.getBaseConfig());
3737
if (baseProperties == null) {
3838
throw new ConfigurationNotFoundException(instanceProperties.getBaseConfig());
3939
}
4040
return buildConfigFromBaseConfig(baseProperties, instanceProperties);
4141
}
42-
return buildBulkheadConfig(io.github.resilience4j.bulkhead.BulkheadConfig.custom(), instanceProperties);
42+
return buildBulkheadConfig(BulkheadConfig.custom(), instanceProperties);
4343
}
4444

45-
private io.github.resilience4j.bulkhead.BulkheadConfig buildConfigFromBaseConfig(InstanceProperties baseProperties, InstanceProperties instanceProperties) {
45+
private BulkheadConfig buildConfigFromBaseConfig(InstanceProperties baseProperties, InstanceProperties instanceProperties) {
4646
ConfigUtils.mergePropertiesIfAny(baseProperties, instanceProperties);
47-
io.github.resilience4j.bulkhead.BulkheadConfig baseConfig = buildBulkheadConfig(io.github.resilience4j.bulkhead.BulkheadConfig.custom(), baseProperties);
48-
return buildBulkheadConfig(io.github.resilience4j.bulkhead.BulkheadConfig.from(baseConfig), instanceProperties);
47+
BulkheadConfig baseConfig = buildBulkheadConfig(BulkheadConfig.custom(), baseProperties);
48+
return buildBulkheadConfig(BulkheadConfig.from(baseConfig), instanceProperties);
4949
}
5050

51-
private io.github.resilience4j.bulkhead.BulkheadConfig buildBulkheadConfig(io.github.resilience4j.bulkhead.BulkheadConfig.Builder builder, InstanceProperties instanceProperties) {
51+
private BulkheadConfig buildBulkheadConfig(BulkheadConfig.Builder builder, InstanceProperties instanceProperties) {
5252
if (instanceProperties.getMaxConcurrentCalls() != null) {
5353
builder.maxConcurrentCalls(instanceProperties.getMaxConcurrentCalls());
5454
}
@@ -84,23 +84,30 @@ public Map<String, InstanceProperties> getConfigs() {
8484
*/
8585
public static class InstanceProperties {
8686

87-
@Min(1)
8887
private Integer maxConcurrentCalls;
89-
@DurationMin(millis = 0)
90-
private Duration maxWaitDuration;
91-
@Nullable
92-
private String baseConfig;
93-
@Min(1)
94-
@Nullable
95-
private Integer eventConsumerBufferSize;
88+
private Duration maxWaitDuration;
89+
@Nullable
90+
private String baseConfig;
91+
@Nullable
92+
private Integer eventConsumerBufferSize;
9693

9794
public InstanceProperties setMaxConcurrentCalls(Integer maxConcurrentCalls) {
95+
Objects.requireNonNull(maxConcurrentCalls);
96+
if (maxConcurrentCalls < 1) {
97+
throw new IllegalArgumentException("maxConcurrentCalls must be greater than or equal to 1.");
98+
}
99+
98100
this.maxConcurrentCalls = maxConcurrentCalls;
99101
return this;
100102
}
101103

102104
public InstanceProperties setMaxWaitDuration(Duration maxWaitDuration) {
103-
this.maxWaitDuration = maxWaitDuration;
105+
Objects.requireNonNull(maxWaitDuration);
106+
if (maxWaitDuration.toMillis() < 0) {
107+
throw new IllegalArgumentException("maxWaitDuration must be greater than or equal to 0.");
108+
}
109+
110+
this.maxWaitDuration = maxWaitDuration;
104111
return this;
105112
}
106113

@@ -110,7 +117,12 @@ public InstanceProperties setBaseConfig(String baseConfig) {
110117
}
111118

112119
public InstanceProperties setEventConsumerBufferSize(Integer eventConsumerBufferSize) {
113-
this.eventConsumerBufferSize = eventConsumerBufferSize;
120+
Objects.requireNonNull(eventConsumerBufferSize);
121+
if (eventConsumerBufferSize < 1) {
122+
throw new IllegalArgumentException("eventConsumerBufferSize must be greater than or equal to 1.");
123+
}
124+
125+
this.eventConsumerBufferSize = eventConsumerBufferSize;
114126
return this;
115127
}
116128

@@ -122,10 +134,12 @@ public Duration getMaxWaitDuration() {
122134
return maxWaitDuration;
123135
}
124136

137+
@Nullable
125138
public String getBaseConfig() {
126139
return baseConfig;
127140
}
128141

142+
@Nullable
129143
public Integer getEventConsumerBufferSize() {
130144
return eventConsumerBufferSize;
131145
}

resilience4j-framework-common/src/main/java/io/github/resilience4j/common/bulkhead/configuration/ThreadPoolBulkheadConfigurationProperties.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
import io.github.resilience4j.core.StringUtils;
2222
import io.github.resilience4j.core.lang.Nullable;
2323

24-
import javax.validation.constraints.Min;
2524
import java.time.Duration;
2625
import java.util.HashMap;
2726
import java.util.Map;
27+
import java.util.Objects;
2828

2929
public class ThreadPoolBulkheadConfigurationProperties {
3030

@@ -102,7 +102,6 @@ public ThreadPoolBulkheadConfig buildThreadPoolBulkheadConfig(ThreadPoolBulkhead
102102
*/
103103
public static class InstanceProperties {
104104

105-
@Min(1)
106105
@Nullable
107106
private Integer eventConsumerBufferSize;
108107

@@ -159,6 +158,11 @@ public Integer getEventConsumerBufferSize() {
159158
}
160159

161160
public InstanceProperties setEventConsumerBufferSize(Integer eventConsumerBufferSize) {
161+
Objects.requireNonNull(eventConsumerBufferSize);
162+
if (eventConsumerBufferSize < 1) {
163+
throw new IllegalArgumentException("eventConsumerBufferSize must be greater than or equal to 1.");
164+
}
165+
162166
this.eventConsumerBufferSize = eventConsumerBufferSize;
163167
return this;
164168
}

0 commit comments

Comments
 (0)