Skip to content

Commit 4755232

Browse files
checkettsRobWin
authored andcommitted
Issue ReactiveX#288: Improve Kotlin support via Nullability annotations
1 parent 73e864d commit 4755232

File tree

113 files changed

+1893
-62
lines changed

Some content is hidden

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

113 files changed

+1893
-62
lines changed

build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ buildscript {
1515
classpath "org.ajoberstar:gradle-git:1.3.2"
1616
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.17"
1717
classpath 'com.github.erizo.gradle:jcstress-gradle-plugin:0.8.0'
18+
classpath "com.netflix.nebula:gradle-extra-configurations-plugin:4.0.1"
1819
}
1920
}
2021

@@ -55,9 +56,14 @@ configure(project.coreProjects) {
5556
apply plugin: 'maven-publish'
5657
apply plugin: 'com.jfrog.bintray'
5758
apply from: "${rootDir}/publishing.gradle"
59+
apply plugin: 'nebula.optional-base'
60+
5861
dependencies {
5962
compile ( libraries.vavr)
6063
compile ( libraries.slf4j)
64+
65+
// JSR-305 only used for non-required meta-annotations
66+
compile "com.google.code.findbugs:jsr305:3.0.2", optional
6167

6268
testCompile ( libraries.junit)
6369
testCompile ( libraries.assertj)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
*
3+
* Copyright 2018: Clint Checketts
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*
18+
*/
19+
@NonNullApi
20+
@NonNullFields
21+
package io.github.resilience4j.decorators;
22+
23+
import io.github.resilience4j.core.lang.NonNullApi;
24+
import io.github.resilience4j.core.lang.NonNullFields;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
*
3+
* Copyright 2018: Clint Checketts
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*
18+
*/
19+
@NonNullApi
20+
@NonNullFields
21+
package io.github.resilience4j.bulkhead.event;
22+
23+
import io.github.resilience4j.core.lang.NonNullApi;
24+
import io.github.resilience4j.core.lang.NonNullFields;

resilience4j-bulkhead/src/main/java/io/github/resilience4j/bulkhead/internal/SemaphoreBulkhead.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import io.github.resilience4j.bulkhead.event.BulkheadOnCallRejectedEvent;
2828
import io.github.resilience4j.core.EventConsumer;
2929
import io.github.resilience4j.core.EventProcessor;
30+
import io.github.resilience4j.core.lang.Nullable;
3031

3132
import java.util.concurrent.Semaphore;
3233
import java.util.concurrent.TimeUnit;
@@ -50,7 +51,7 @@ public class SemaphoreBulkhead implements Bulkhead {
5051
* @param name the name of this bulkhead
5152
* @param bulkheadConfig custom bulkhead configuration
5253
*/
53-
public SemaphoreBulkhead(String name, BulkheadConfig bulkheadConfig) {
54+
public SemaphoreBulkhead(String name, @Nullable BulkheadConfig bulkheadConfig) {
5455
this.name = name;
5556
this.config = bulkheadConfig != null ? bulkheadConfig
5657
: BulkheadConfig.ofDefaults();
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
*
3+
* Copyright 2018: Clint Checketts
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*
18+
*/
19+
@NonNullApi
20+
@NonNullFields
21+
package io.github.resilience4j.bulkhead.internal;
22+
23+
import io.github.resilience4j.core.lang.NonNullApi;
24+
import io.github.resilience4j.core.lang.NonNullFields;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
*
3+
* Copyright 2018: Clint Checketts
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*
18+
*/
19+
@NonNullApi
20+
@NonNullFields
21+
package io.github.resilience4j.bulkhead;
22+
23+
import io.github.resilience4j.core.lang.NonNullApi;
24+
import io.github.resilience4j.core.lang.NonNullFields;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
*
3+
* Copyright 2018: Clint Checketts
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*
18+
*/
19+
@NonNullApi
20+
@NonNullFields
21+
package io.github.resilience4j.bulkhead.utils;
22+
23+
import io.github.resilience4j.core.lang.NonNullApi;
24+
import io.github.resilience4j.core.lang.NonNullFields;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
*
3+
* Copyright 2018: Clint Checketts
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*
18+
*/
19+
@NonNullApi
20+
@NonNullFields
21+
package io.github.resilience4j.cache.event;
22+
23+
import io.github.resilience4j.core.lang.NonNullApi;
24+
import io.github.resilience4j.core.lang.NonNullFields;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
*
3+
* Copyright 2018: Clint Checketts
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*
18+
*/
19+
@NonNullApi
20+
@NonNullFields
21+
package io.github.resilience4j.cache.internal;
22+
23+
import io.github.resilience4j.core.lang.NonNullApi;
24+
import io.github.resilience4j.core.lang.NonNullFields;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
*
3+
* Copyright 2018: Clint Checketts
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*
18+
*/
19+
@NonNullApi
20+
@NonNullFields
21+
package io.github.resilience4j.cache;
22+
23+
import io.github.resilience4j.core.lang.NonNullApi;
24+
import io.github.resilience4j.core.lang.NonNullFields;

resilience4j-circuitbreaker/src/main/java/io/github/resilience4j/circuitbreaker/CircuitBreakerConfig.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package io.github.resilience4j.circuitbreaker;
2020

21+
import io.github.resilience4j.core.lang.Nullable;
22+
2123
import java.time.Duration;
2224
import java.util.Arrays;
2325
import java.util.Optional;
@@ -89,8 +91,8 @@ public static CircuitBreakerConfig ofDefaults(){
8991
}
9092

9193
public static class Builder {
92-
private Predicate<Throwable> recordFailurePredicate;
93-
private Predicate<Throwable> errorRecordingPredicate;
94+
@Nullable private Predicate<Throwable> recordFailurePredicate;
95+
@Nullable private Predicate<Throwable> errorRecordingPredicate;
9496
@SuppressWarnings("unchecked")
9597
private Class<? extends Throwable>[] recordExceptions = new Class[0];
9698
@SuppressWarnings("unchecked")
@@ -248,7 +250,9 @@ public CircuitBreakerConfig build() {
248250
config.failureRateThreshold = failureRateThreshold;
249251
config.ringBufferSizeInClosedState = ringBufferSizeInClosedState;
250252
config.ringBufferSizeInHalfOpenState = ringBufferSizeInHalfOpenState;
251-
config.recordFailurePredicate = errorRecordingPredicate;
253+
if(errorRecordingPredicate != null) {
254+
config.recordFailurePredicate = errorRecordingPredicate;
255+
}
252256
config.automaticTransitionFromOpenToHalfOpenEnabled = automaticTransitionFromOpenToHalfOpenEnabled;
253257
return config;
254258
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
*
3+
* Copyright 2018: Clint Checketts
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*
18+
*/
19+
@NonNullApi
20+
@NonNullFields
21+
package io.github.resilience4j.circuitbreaker.event;
22+
23+
import io.github.resilience4j.core.lang.NonNullApi;
24+
import io.github.resilience4j.core.lang.NonNullFields;

resilience4j-circuitbreaker/src/main/java/io/github/resilience4j/circuitbreaker/internal/CircuitBreakerMetrics.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121

2222
import io.github.resilience4j.circuitbreaker.CircuitBreaker;
23+
import io.github.resilience4j.core.lang.Nullable;
2324

2425
import java.util.concurrent.atomic.LongAdder;
2526

@@ -33,7 +34,7 @@ class CircuitBreakerMetrics implements CircuitBreaker.Metrics {
3334
this(ringBufferSize, null);
3435
}
3536

36-
CircuitBreakerMetrics(int ringBufferSize, RingBitSet sourceSet) {
37+
CircuitBreakerMetrics(int ringBufferSize, @Nullable RingBitSet sourceSet) {
3738
this.ringBufferSize = ringBufferSize;
3839
if(sourceSet != null) {
3940
this.ringBitSet = new RingBitSet(this.ringBufferSize, sourceSet);

resilience4j-circuitbreaker/src/main/java/io/github/resilience4j/circuitbreaker/internal/ClosedState.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import io.github.resilience4j.circuitbreaker.CircuitBreaker;
2222
import io.github.resilience4j.circuitbreaker.CircuitBreakerConfig;
23+
import io.github.resilience4j.core.lang.Nullable;
2324

2425
final class ClosedState extends CircuitBreakerState {
2526

@@ -30,7 +31,7 @@ final class ClosedState extends CircuitBreakerState {
3031
this(stateMachine, null);
3132
}
3233

33-
ClosedState(CircuitBreakerStateMachine stateMachine, CircuitBreakerMetrics circuitBreakerMetrics) {
34+
ClosedState(CircuitBreakerStateMachine stateMachine, @Nullable CircuitBreakerMetrics circuitBreakerMetrics) {
3435
super(stateMachine);
3536
CircuitBreakerConfig circuitBreakerConfig = stateMachine.getCircuitBreakerConfig();
3637
if(circuitBreakerMetrics == null){
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
*
3+
* Copyright 2018: Clint Checketts
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*
18+
*/
19+
@NonNullApi
20+
@NonNullFields
21+
package io.github.resilience4j.circuitbreaker.internal;
22+
23+
import io.github.resilience4j.core.lang.NonNullApi;
24+
import io.github.resilience4j.core.lang.NonNullFields;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
*
3+
* Copyright 2018: Clint Checketts
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*
18+
*/
19+
@NonNullApi
20+
@NonNullFields
21+
package io.github.resilience4j.circuitbreaker;
22+
23+
import io.github.resilience4j.core.lang.NonNullApi;
24+
import io.github.resilience4j.core.lang.NonNullFields;

0 commit comments

Comments
 (0)