Skip to content

Commit

Permalink
Issue ReactiveX#288: Improve Kotlin support via Nullability annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
checketts authored and RobWin committed Apr 4, 2019
1 parent 73e864d commit 4755232
Show file tree
Hide file tree
Showing 113 changed files with 1,893 additions and 62 deletions.
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ buildscript {
classpath "org.ajoberstar:gradle-git:1.3.2"
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.17"
classpath 'com.github.erizo.gradle:jcstress-gradle-plugin:0.8.0'
classpath "com.netflix.nebula:gradle-extra-configurations-plugin:4.0.1"
}
}

Expand Down Expand Up @@ -55,9 +56,14 @@ configure(project.coreProjects) {
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply from: "${rootDir}/publishing.gradle"
apply plugin: 'nebula.optional-base'

dependencies {
compile ( libraries.vavr)
compile ( libraries.slf4j)

// JSR-305 only used for non-required meta-annotations
compile "com.google.code.findbugs:jsr305:3.0.2", optional

testCompile ( libraries.junit)
testCompile ( libraries.assertj)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
*
* Copyright 2018: Clint Checketts
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
@NonNullApi
@NonNullFields
package io.github.resilience4j.decorators;

import io.github.resilience4j.core.lang.NonNullApi;
import io.github.resilience4j.core.lang.NonNullFields;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
*
* Copyright 2018: Clint Checketts
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
@NonNullApi
@NonNullFields
package io.github.resilience4j.bulkhead.event;

import io.github.resilience4j.core.lang.NonNullApi;
import io.github.resilience4j.core.lang.NonNullFields;
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.github.resilience4j.bulkhead.event.BulkheadOnCallRejectedEvent;
import io.github.resilience4j.core.EventConsumer;
import io.github.resilience4j.core.EventProcessor;
import io.github.resilience4j.core.lang.Nullable;

import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
Expand All @@ -50,7 +51,7 @@ public class SemaphoreBulkhead implements Bulkhead {
* @param name the name of this bulkhead
* @param bulkheadConfig custom bulkhead configuration
*/
public SemaphoreBulkhead(String name, BulkheadConfig bulkheadConfig) {
public SemaphoreBulkhead(String name, @Nullable BulkheadConfig bulkheadConfig) {
this.name = name;
this.config = bulkheadConfig != null ? bulkheadConfig
: BulkheadConfig.ofDefaults();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
*
* Copyright 2018: Clint Checketts
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
@NonNullApi
@NonNullFields
package io.github.resilience4j.bulkhead.internal;

import io.github.resilience4j.core.lang.NonNullApi;
import io.github.resilience4j.core.lang.NonNullFields;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
*
* Copyright 2018: Clint Checketts
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
@NonNullApi
@NonNullFields
package io.github.resilience4j.bulkhead;

import io.github.resilience4j.core.lang.NonNullApi;
import io.github.resilience4j.core.lang.NonNullFields;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
*
* Copyright 2018: Clint Checketts
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
@NonNullApi
@NonNullFields
package io.github.resilience4j.bulkhead.utils;

import io.github.resilience4j.core.lang.NonNullApi;
import io.github.resilience4j.core.lang.NonNullFields;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
*
* Copyright 2018: Clint Checketts
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
@NonNullApi
@NonNullFields
package io.github.resilience4j.cache.event;

import io.github.resilience4j.core.lang.NonNullApi;
import io.github.resilience4j.core.lang.NonNullFields;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
*
* Copyright 2018: Clint Checketts
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
@NonNullApi
@NonNullFields
package io.github.resilience4j.cache.internal;

import io.github.resilience4j.core.lang.NonNullApi;
import io.github.resilience4j.core.lang.NonNullFields;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
*
* Copyright 2018: Clint Checketts
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
@NonNullApi
@NonNullFields
package io.github.resilience4j.cache;

import io.github.resilience4j.core.lang.NonNullApi;
import io.github.resilience4j.core.lang.NonNullFields;
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package io.github.resilience4j.circuitbreaker;

import io.github.resilience4j.core.lang.Nullable;

import java.time.Duration;
import java.util.Arrays;
import java.util.Optional;
Expand Down Expand Up @@ -89,8 +91,8 @@ public static CircuitBreakerConfig ofDefaults(){
}

public static class Builder {
private Predicate<Throwable> recordFailurePredicate;
private Predicate<Throwable> errorRecordingPredicate;
@Nullable private Predicate<Throwable> recordFailurePredicate;
@Nullable private Predicate<Throwable> errorRecordingPredicate;
@SuppressWarnings("unchecked")
private Class<? extends Throwable>[] recordExceptions = new Class[0];
@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -248,7 +250,9 @@ public CircuitBreakerConfig build() {
config.failureRateThreshold = failureRateThreshold;
config.ringBufferSizeInClosedState = ringBufferSizeInClosedState;
config.ringBufferSizeInHalfOpenState = ringBufferSizeInHalfOpenState;
config.recordFailurePredicate = errorRecordingPredicate;
if(errorRecordingPredicate != null) {
config.recordFailurePredicate = errorRecordingPredicate;
}
config.automaticTransitionFromOpenToHalfOpenEnabled = automaticTransitionFromOpenToHalfOpenEnabled;
return config;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
*
* Copyright 2018: Clint Checketts
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
@NonNullApi
@NonNullFields
package io.github.resilience4j.circuitbreaker.event;

import io.github.resilience4j.core.lang.NonNullApi;
import io.github.resilience4j.core.lang.NonNullFields;
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@


import io.github.resilience4j.circuitbreaker.CircuitBreaker;
import io.github.resilience4j.core.lang.Nullable;

import java.util.concurrent.atomic.LongAdder;

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

CircuitBreakerMetrics(int ringBufferSize, RingBitSet sourceSet) {
CircuitBreakerMetrics(int ringBufferSize, @Nullable RingBitSet sourceSet) {
this.ringBufferSize = ringBufferSize;
if(sourceSet != null) {
this.ringBitSet = new RingBitSet(this.ringBufferSize, sourceSet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import io.github.resilience4j.circuitbreaker.CircuitBreaker;
import io.github.resilience4j.circuitbreaker.CircuitBreakerConfig;
import io.github.resilience4j.core.lang.Nullable;

final class ClosedState extends CircuitBreakerState {

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

ClosedState(CircuitBreakerStateMachine stateMachine, CircuitBreakerMetrics circuitBreakerMetrics) {
ClosedState(CircuitBreakerStateMachine stateMachine, @Nullable CircuitBreakerMetrics circuitBreakerMetrics) {
super(stateMachine);
CircuitBreakerConfig circuitBreakerConfig = stateMachine.getCircuitBreakerConfig();
if(circuitBreakerMetrics == null){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
*
* Copyright 2018: Clint Checketts
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
@NonNullApi
@NonNullFields
package io.github.resilience4j.circuitbreaker.internal;

import io.github.resilience4j.core.lang.NonNullApi;
import io.github.resilience4j.core.lang.NonNullFields;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
*
* Copyright 2018: Clint Checketts
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
@NonNullApi
@NonNullFields
package io.github.resilience4j.circuitbreaker;

import io.github.resilience4j.core.lang.NonNullApi;
import io.github.resilience4j.core.lang.NonNullFields;
Loading

0 comments on commit 4755232

Please sign in to comment.