Skip to content
Draft
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
45 changes: 0 additions & 45 deletions .github/workflows/nebula-ci.yml

This file was deleted.

51 changes: 0 additions & 51 deletions .github/workflows/nebula-publish.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/nebula-snapshot.yml

This file was deleted.

22 changes: 20 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,38 @@
plugins {

id "java"
id "com.netflix.nebula.netflixoss" version "11.3.1"
id "me.champeau.jmh" version "0.7.1"
id("org.openrewrite.rewrite") version("6.12.0")
}

group = "com.netflix"
version = '1.5.19-SNAPSHOT'

allprojects {
repositories {
mavenCentral()
}
}

dependencies {
rewrite("org.openrewrite.recipe:rewrite-migrate-java:2.12.0")
}
rewrite {
activeRecipe("org.openrewrite.java.migrate.UpgradeToJava21")
}
subprojects {

apply plugin: 'nebula.netflixoss'
apply plugin: 'java-library'
apply plugin: 'java'

test {
jvmArgs '--add-opens', 'java.base/java.lang=ALL-UNNAMED'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

group = "com.netflix.hystrix"

Expand Down
6 changes: 4 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#Mon Jun 19 21:27:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=9d926787066a081739e8200858338b4a69e837c3a821a33aca9db09dd4a41026
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
1 change: 1 addition & 0 deletions hystrix-contrib/hystrix-javanica/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,5 @@ dependencies {
testImplementation 'log4j:log4j:1.2.17'
testImplementation 'org.slf4j:slf4j-log4j12:1.7.7'
testImplementation 'com.tngtech.java:junit-dataprovider:1.10.2'
testImplementation 'javax.annotation:javax.annotation-api:1.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ public Object methodsAnnotatedWithHystrixCommand(final ProceedingJoinPoint joinP
Method method = getMethodFromTarget(joinPoint);
Validate.notNull(method, "failed to get method from joinPoint: %s", joinPoint);
if (method.isAnnotationPresent(HystrixCommand.class) && method.isAnnotationPresent(HystrixCollapser.class)) {
throw new IllegalStateException("method cannot be annotated with HystrixCommand and HystrixCollapser " +
"annotations at the same time");
throw new IllegalStateException("""
method cannot be annotated with HystrixCommand and HystrixCollapser \
annotations at the same time\
""");
}
MetaHolderFactory metaHolderFactory = META_HOLDER_FACTORY_MAP.get(HystrixPointcutType.of(method));
MetaHolder metaHolder = metaHolderFactory.create(joinPoint);
Expand Down Expand Up @@ -119,8 +121,7 @@ private Object executeObservable(HystrixInvokable invokable, ExecutionType execu
public Observable call(Throwable throwable) {
if (throwable instanceof HystrixBadRequestException) {
return Observable.error(throwable.getCause());
} else if (throwable instanceof HystrixRuntimeException) {
HystrixRuntimeException hystrixRuntimeException = (HystrixRuntimeException) throwable;
} else if (throwable instanceof HystrixRuntimeException hystrixRuntimeException) {
return Observable.error(hystrixRuntimeExceptionToThrowable(metaHolder, hystrixRuntimeException));
}
return Observable.error(throwable);
Expand Down Expand Up @@ -154,11 +155,10 @@ private Throwable getCause(HystrixRuntimeException e) {
// latest exception in flow should be propagated to end user
if (e.getFallbackException() instanceof FallbackInvocationException) {
cause = e.getFallbackException().getCause();
if (cause instanceof HystrixRuntimeException) {
cause = getCause((HystrixRuntimeException) cause);
if (cause instanceof HystrixRuntimeException exception) {
cause = getCause(exception);
}
} else if (cause instanceof CommandActionExecutionException) { // this situation is possible only if a callee throws an exception which type extends Throwable directly
CommandActionExecutionException commandActionExecutionException = (CommandActionExecutionException) cause;
} else if (cause instanceof CommandActionExecutionException commandActionExecutionException) {
cause = commandActionExecutionException.getCause();
}

Expand Down Expand Up @@ -310,12 +310,12 @@ private static Class<?> getFirstGenericParameter(final Type type, final int nest

for (int cDept = 0; cDept < nestedDepth; cDept++) {
if (!(tType instanceof ParameterizedType))
throw new IllegalStateException(String.format("Sub type at nesting level %d of %s is expected to be generic", cDepth, type));
throw new IllegalStateException("Sub type at nesting level %d of %s is expected to be generic".formatted(cDepth, type));
tType = ((ParameterizedType) tType).getActualTypeArguments()[cDept];
}

if (tType instanceof ParameterizedType)
return (Class<?>) ((ParameterizedType) tType).getRawType();
if (tType instanceof ParameterizedType parameterizedType)
return (Class<?>) parameterizedType.getRawType();
else if (tType instanceof Class)
return (Class<?>) tType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ public class CommandCollapser extends HystrixCollapser<List<Object>, Object, Obj

private MetaHolder metaHolder;

private static final String ERROR_MSG = "Failed to map all collapsed requests to response. " +
"The expected contract has not been respected. ";
private static final String ERROR_MSG = """
Failed to map all collapsed requests to response. \
The expected contract has not been respected. \
""";

private static final String ERROR_MSF_TEMPLATE = "Collapser key: '{}', requests size: '{}', response size: '{}'";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ Object process(Action action) throws Exception {
if (isIgnorable(cause)) {
throw new HystrixBadRequestException(cause.getMessage(), cause);
}
if (cause instanceof RuntimeException) {
throw (RuntimeException) cause;
} else if (cause instanceof Exception) {
throw (Exception) cause;
if (cause instanceof RuntimeException exception) {
throw exception;
} else if (cause instanceof Exception exception) {
throw exception;
} else {
// instance of Throwable
throw new CommandActionExecutionException(cause);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public Object executeWithArgs(ExecutionType executionType, Object[] args) throws
*/
@Override
public String getActionName() {
if (hystrixCommand != null && hystrixCommand instanceof HystrixInvokableInfo) {
HystrixInvokableInfo info = (HystrixInvokableInfo) hystrixCommand;
if (hystrixCommand != null && hystrixCommand instanceof HystrixInvokableInfo info) {
return info.getCommandKey().name();
}
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ public static Object execute(HystrixInvokable invokable, ExecutionType execution
}

private static HystrixExecutable castToExecutable(HystrixInvokable invokable, ExecutionType executionType) {
if (invokable instanceof HystrixExecutable) {
return (HystrixExecutable) invokable;
if (invokable instanceof HystrixExecutable executable) {
return executable;
}
throw new RuntimeException("Command should implement " + HystrixExecutable.class.getCanonicalName() + " interface to execute in: " + executionType + " mode");
}

private static HystrixObservable castToObservable(HystrixInvokable invokable) {
if (invokable instanceof HystrixObservable) {
return (HystrixObservable) invokable;
if (invokable instanceof HystrixObservable observable) {
return observable;
}
throw new RuntimeException("Command should implement " + HystrixObservable.class.getCanonicalName() + " interface to execute in observable mode");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ protected Observable resumeWithFallback() {
Object[] args = createArgsForFallback(metaHolder, cause);
try {
Object res = commandActions.getFallbackAction().executeWithArgs(executionType, args);
if (res instanceof Observable) {
return (Observable) res;
} else if (res instanceof Single) {
return ((Single) res).toObservable();
} else if (res instanceof Completable) {
return ((Completable) res).toObservable();
if (res instanceof Observable observable) {
return observable;
} else if (res instanceof Single single) {
return single.toObservable();
} else if (res instanceof Completable completable) {
return completable.toObservable();
} else {
return Observable.just(res);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ public void validateReturnType(Method commandMethod) throws FallbackDefinitionEx

private Type getFirstParametrizedType(Method m) {
Type gtype = m.getGenericReturnType();
if (gtype instanceof ParameterizedType) {
ParameterizedType pType = (ParameterizedType) gtype;
if (gtype instanceof ParameterizedType pType) {
return pType.getActualTypeArguments()[0];
}
return null;
Expand Down Expand Up @@ -173,7 +172,7 @@ private void validateReturnType(Method commandMethod, Method fallbackMethod) {
extraHint = "--> " + ((ParameterizedType) parentKind).getRawType().toString() + "<Ooops!>\n";
}
}
msg.add(String.format(error.reason + "\n" + extraHint + "Command type literal pos: %s; Fallback type literal pos: %s",
msg.add((error.reason + "\n" + extraHint + "Command type literal pos: %s; Fallback type literal pos: %s").formatted(
positionAsString(error.commandType, commandParametrizedTypes),
positionAsString(error.fallbackType, fallbackParametrizedTypes)));
}
Expand Down Expand Up @@ -286,7 +285,7 @@ private static Result regularEquals(final Type commandType, final Type fallbackT
public List<Error> get() {
return Collections.singletonList(new Error(
commandType,
String.format("Different types. Command type: '%s'; fallback type: '%s'", commandType, fallbackType),
"Different types. Command type: '%s'; fallback type: '%s'".formatted(commandType, fallbackType),
fallbackType));
}
});
Expand Down Expand Up @@ -314,7 +313,7 @@ private static int position(Type type, List<Type> types) {

private static Error boundsError(Type t1, Type[] b1, String boundType, Type t2, Type[] b2) {
return new Error(t1,
String.format("Different %s bounds. Command bounds: '%s'; Fallback bounds: '%s'",
"Different %s bounds. Command bounds: '%s'; Fallback bounds: '%s'".formatted(
boundType,
StringUtils.join(b1, ", "),
StringUtils.join(b2, ", ")),
Expand All @@ -326,7 +325,7 @@ private static Result equals(Type[] t1, Type[] t2) {
if (t1 == null) return Result.failure();
if (t2 == null) return Result.failure();
if (t1.length != t2.length)
return Result.failure(new Error(String.format("Different size of type literals. Command size = %d, fallback size = %d",
return Result.failure(new Error("Different size of type literals. Command size = %d, fallback size = %d".formatted(
t1.length, t2.length)));
Result result = SUCCESS;
for (int i = 0; i < t1.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ public boolean isDone() {
@Override
public Object get() throws InterruptedException, ExecutionException {
Object result = origin.get();
if (result instanceof Future) {
return ((Future) result).get();
if (result instanceof Future future) {
return future.get();
}
return result;
}

@Override
public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
Object result = origin.get(timeout, unit);
if (result instanceof Future) {
return ((Future) result).get();
if (result instanceof Future future) {
return future.get();
}
return result;
}
Expand Down
Loading