Sam Pengilly
07/13/2023, 10:39 PMarrow.fx.coroutines.Schedule
to arrow.resilience.Schedule
might be causing issues with kapt. After the change I'm getting a "Bad class file: <filepath>, undeclared type variable: Input" error, despite all the code looking correct and the only changes being import statements. Anyone else experienced this?simon.vergauwen
07/14/2023, 6:46 AMsimon.vergauwen
07/14/2023, 6:46 AMSam Pengilly
07/14/2023, 6:54 AMimport arrow.core.Either
import arrow.resilience.Schedule
import com.apollographql.apollo3.api.Error
import com.apollographql.apollo3.api.Query
import kotlin.time.Duration.Companion.milliseconds
interface MyClient {
suspend fun <D : Query.Data, T> executeQuery(
query: Query<D>,
networkRetryPolicy: Schedule<Throwable, *> = DefaultNetworkRetryPolicy,
parse: (data: D?, errors: List<Error>?) -> Either<Throwable, T>
): Either<Throwable, T>
companion object {
val DefaultNetworkRetryPolicy = Schedule
.exponential<Throwable>(10.milliseconds)
.andThen(Schedule.recurs(3))
}
}
Provided using Dagger:
@Module
@InstallIn(SingletonComponent::class)
class ApiModule {
@Provides
fun provideMyClient(config: MyConfig): MyClient =
MyClientImplementation(buildApolloClient(config))
}
internal class MyClientImplementation(private val apolloClient: ApolloClient) : MyClient {
override suspend fun <D : Query.Data, T> executeQuery(
query: Query<D>,
networkRetryPolicy: Schedule<Throwable, *>,
parse: (data: D?, errors: List<Error>?) -> Either<Throwable, T>
): Either<Throwable, T> = either {
val apolloResponse = Either.catch {
networkRetryPolicy.retry { apolloClient.query(query).execute() }
}.bind()
parse(apolloResponse.data, apolloResponse.errors).bind()
}
}
Sam Pengilly
07/14/2023, 6:54 AMSam Pengilly
07/14/2023, 6:59 AM/my/repository/folder/build/tmp/kapt3/stubs/my/package/ClassThatInjectsMyClientWithDagger.java:17: error: cannot access MyClient
public my.package.MyClient client;
^
bad class file: /my/repository/folder/build/libs/my-module.jar(/my/package/MyClient.class)
undeclared type variable: Input
Please remove or make sure it appears in the correct subdirectory of the classpath.
Tried to keep the names consistent but stripped down and not tied to the concepts of my systemAlejandro Serrano Mena
07/14/2023, 7:17 AMAlejandro Serrano Mena
07/14/2023, 7:26 AMDefaultNetworkRetryPolicy
? I use JD GUI to get it; that way we can inspect where the non-bound variable comes fromAlejandro Serrano Mena
07/14/2023, 7:26 AMSam Pengilly
07/14/2023, 8:48 AM@NotNull
public final Function2<Input, Continuation<? super Schedule.Decision<? super Input, ? extends Output>>, Object> getDefaultNetworkRetryPolicy-k5utPk0() {
return DefaultNetworkRetryPolicy;
}
@NotNull
private static final Function2<Input, Continuation<? super Schedule.Decision<? super Input, ? extends Output>>, Object> DefaultNetworkRetryPolicy = Schedule.andThen-GI_V1oY(Schedule.Companion.exponential-la_RjoE$default(Schedule.Companion, DurationKt.toDuration(10, DurationUnit.MILLISECONDS), 0.0D, 2, null), Schedule.Companion.recurs-ZhmCDx4(3L));
Sam Pengilly
07/14/2023, 8:52 AM// KAPT seems to not honour the JVM target specified in Kotlin options sometimes
// <https://youtrack.jetbrains.com/issue/KT-55947/Unable-to-set-kapt-jvm-target-version>
tasks.withType(KaptGenerateStubsTask::class.java).configureEach {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
}
Alejandro Serrano Mena
07/14/2023, 11:25 AMInput
seems to be introduced without declaring it before…Alejandro Serrano Mena
07/14/2023, 11:26 AMSam Pengilly
07/14/2023, 11:26 AMSam Pengilly
07/14/2023, 11:27 AMSam Pengilly
07/14/2023, 11:27 AMAlejandro Serrano Mena
07/14/2023, 11:34 AMDefaultNetworkRetryPolicy
Sam Pengilly
07/16/2023, 10:04 PMval DefaultNetworkRetryPolicy: Schedule<Throwable, Either<Duration, Long>> = Schedule
.exponential<Throwable>(10.milliseconds)
.andThen(Schedule.recurs(3))
Sam Pengilly
07/16/2023, 10:06 PMSam Pengilly
07/16/2023, 10:08 PMsuspend fun <D : Query.Data, T> executeQuery(
query: Query<D>,
networkRetryPolicy: Schedule<Throwable, Either<Duration, Long>> = DefaultNetworkRetryPolicy,
parse: (data: D?, errors: List<Error>?) -> Either<Throwable, T>
): Either<Throwable, T>