问:
Spring API-gateway | Resilience4j randomly invoking fallback method even if the service is returning proper response
To provide some background, I am trying to implement below architecture.
It is from a course provided by "DailyCodeBuffer" on microservices, there are 3 services, order, product and payment. Clients can call the order service and order-service internally accesses payment and product services. Everything is registered on Eureka service registry and there is an API-Gateway via which everything should be routed.
Architecture Schema

So, first I created everything without the Okta Auth implementation and things were working perfectly fine. Upon calling the order-service via the gateway, I was able to get the order details by id let's say for example.

Then I added the Okta auth and now every time I try to access an order details by id, for first 2-3 times I always get the fallback method response from the gateway. And if I keep requesting back to back, it gives me result after 2-3 times. If I try to hit the order-service directly without going via the gateway, things are working fine. Similarly, if I remove the circuit-breaker configuration for order-service from the Yaml given below, things are working fine again. Kindly suggest the possible reasons and the solution/direction in which I should look.
Please let me know if you want any other code/implementation from the repo. At this point, I honestly don’t know where to look for the issue.

Here is my API-gateway yaml:

```<code>server:
  port: 9090

logging:
  level:
    web: debug

spring:
  application:
    name: API-GATEWAY
  config:
    import: configserver:http://localhost:9296
  cloud:
    gateway:
      routes:
        - id: ORDER-SERVICE
          uri: lb://ORDER-SERVICE
          predicates:
            - Path=/order/**
          filters:
            - name: CircuitBreaker
              args:
                name: ORDER-SERVICE
                fallbackuri: forward:/orderServiceFallBack
            - name: RequestRateLimiter
              args:
                redis-rate-limiter.replenishRate: 1
                redis-rate-limiter.burstCapacity: 1
        - id: PAYMENT-SERVICE
          uri: lb://PAYMENT-SERVICE
          predicates:
            - Path=/payment/**
          filters:
            - name: CircuitBreaker
              args:
                name: PAYMENT-SERVICE
                fallbackuri: forward:/paymentServiceFallBack
            - name: RequestRateLimiter
              args:
                redis-rate-limiter.replenishRate: 1
                redis-rate-limiter.burstCapacity: 1
        - id: PRODUCT-SERVICE
          uri: lb://PRODUCT-SERVICE
          predicates:
            - Path=/product/**
          filters:
            - name: CircuitBreaker
              args:
                name: PRODUCT-SERVICE
                fallbackuri: forward:/productServiceFallBack
            - name: RequestRateLimiter
              args:
                redis-rate-limiter.replenishRate: 1
                redis-rate-limiter.burstCapacity: 1

okta:
  oauth2:
    issuer: <<not mentioning here for security reasons>>
    audience: api://default
    client-id: <<not mentioning here for security reasons>>
    client-secret: <<not mentioning here for security reasons>>
    scopes: openid, profile, email, offline_access
</code>```

Here is my controller layer for order-service(The SOUT is printing everything correctly every time, so I am skipping service layer code here, please ask if you still want it):

```<code>@PreAuthorize("hasAuthority('Admin') || hasAuthority('Customer')")
@GetMapping("/{orderId}")
public ResponseEntity<OrderResponse> getOrderDetails(@PathVariable("orderId") long orderId) {
    OrderResponse orderResponse = orderService.getOrderDetails(orderId);
    System.out.println("orderResponse = " + orderResponse);
    return new ResponseEntity<>(orderResponse, HttpStatus.OK);
}
</code>```

Here is my Cloud-Gateway application class where I have setup the circuit breaker with default configs:

```<code>@SpringBootApplication
public class CloudGatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(CloudGatewayApplication.class, args);
    }

    @Bean
    KeyResolver userKeySolver() {
        return exchange -> Mono.just("userKey");
    }

    @Bean
    public Customizer<Resilience4JCircuitBreakerFactory> defaultCustomizer() {
        return factory -> factory.configureDefault(
                id -> new Resilience4JConfigBuilder(id)
                        .circuitBreakerConfig(
                                CircuitBreakerConfig.ofDefaults()
                        ).build()
        );
    }

}
</code>```

FallBack controller in API-gateway:

```<code>import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class FallbackController {

    @GetMapping("/orderServiceFallBack")
    public String orderServiceFallback() {
        return "Order service is down!";
    }

    @GetMapping("/paymentServiceFallBack")
    public String paymentServiceFallback() {
        return "Payment service is down!";
    }

    @GetMapping("/productServiceFallBack")
    public String productServiceFallback() {
        return "Product service is down!";
    }
}
</code>```

Order-service logs (Same logs every time):

```<code>2023-01-05 10:56:22.465 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : HTTP GET https://dev-89319517.okta.com/oauth2/default/v1/keys
2023-01-05 10:56:22.466 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Accept=[text/plain, */*]
2023-01-05 10:56:23.799 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Response 200 OK
2023-01-05 10:56:23.799 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Reading to [java.lang.String] as "application/json"
2023-01-05 10:56:23.860 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.servlet.DispatcherServlet        : GET "/order/4", parameters={}
2023-01-05 10:56:23.872 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to com.dailycodebuffer.orderservice.controller.OrderController#getOrderDetails(long)
2023-01-05 10:56:23.915  INFO [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] c.d.o.service.OrderServiceImpl           : Get order details for order id: 4
2023-01-05 10:56:24.016  INFO [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] c.d.o.service.OrderServiceImpl           : Invoking product service to fetch the product for id: 2
2023-01-05 10:56:24.018 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : HTTP GET http://PRODUCT-SERVICE/product/2
2023-01-05 10:56:24.019 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Accept=[application/json, application/*+json]
2023-01-05 10:56:24.028 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,1bc48b17dcb26435] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : HTTP POST https://dev-89319517.okta.com/oauth2/default/v1/token
2023-01-05 10:56:24.028 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,1bc48b17dcb26435] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Accept=[application/json, application/*+json]
2023-01-05 10:56:24.029 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,1bc48b17dcb26435] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Writing [{grant_type=[client_credentials], scope=[internal]}] as "application/x-www-form-urlencoded;charset=UTF-8"
2023-01-05 10:56:24.672 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,1bc48b17dcb26435] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Response 200 OK
2023-01-05 10:56:24.672 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,1bc48b17dcb26435] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Reading to [org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse] as "application/json;charset=UTF-8"
2023-01-05 10:56:26.132 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Response 200 OK
2023-01-05 10:56:26.132 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Reading to [com.dailycodebuffer.orderservice.external.response.ProductResponse]
2023-01-05 10:56:26.134  INFO [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] c.d.o.service.OrderServiceImpl           : Getting payment information from payment service
2023-01-05 10:56:26.134 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : HTTP GET http://PAYMENT-SERVICE/payment/order/4
2023-01-05 10:56:26.134 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Accept=[application/json, application/*+json]
2023-01-05 10:56:26.134 DEBUG [ORDER-SERVICE,,] 14072 --- [/api/v2/spans}}] org.springframework.web.HttpLogging      : HTTP POST http://localhost:9411/api/v2/spans
2023-01-05 10:56:26.134 DEBUG [ORDER-SERVICE,,] 14072 --- [/api/v2/spans}}] org.springframework.web.HttpLogging      : Accept=[text/plain, application/json, application/*+json, */*]
2023-01-05 10:56:26.135 DEBUG [ORDER-SERVICE,,] 14072 --- [/api/v2/spans}}] org.springframework.web.HttpLogging      : Writing [[B@397bd980] as "application/json"
2023-01-05 10:56:26.165 DEBUG [ORDER-SERVICE,,] 14072 --- [/api/v2/spans}}] org.springframework.web.HttpLogging      : Response 202 ACCEPTED
2023-01-05 10:56:27.744 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Response 200 OK
2023-01-05 10:56:27.744 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Reading to [com.dailycodebuffer.orderservice.external.response.PaymentResponse]
orderResponse = OrderResponse(orderId=4, orderDate=2023-01-02T12:21:48.312429Z, orderStatus=PLACED, amount=2000, productDetails=OrderResponse.ProductDetails(productName=MacBook, productId=2, quantity=1, price=2000), paymentDetails=OrderResponse.PaymentDetails(paymentId=1, paymentMode=CASH, paymentStatus=SUCCESS, paymentDate=2023-01-02T12:21:48.794794Z))
2023-01-05 10:56:27.760 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Using 'application/json', given [*/*] and supported [application/json, application/*+json, application/json, application/*+json]
2023-01-05 10:56:27.763 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Writing [OrderResponse(orderId=4, orderDate=2023-01-02T12:21:48.312429Z, orderStatus=PLACED, amount=2000, pro (truncated)...]
2023-01-05 10:56:27.773 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.servlet.DispatcherServlet        : Completed 200 OK
2023-01-05 10:56:28.168 DEBUG [ORDER-SERVICE,,] 14072 --- [/api/v2/spans}}] org.springframework.web.HttpLogging      : HTTP POST http://localhost:9411/api/v2/spans
2023-01-05 10:56:28.169 DEBUG [ORDER-SERVICE,,] 14072 --- [/api/v2/spans}}] org.springframework.web.HttpLogging      : Accept=[text/plain, application/json, application/*+json, */*]
2023-01-05 10:56:28.169 DEBUG [ORDER-SERVICE,,] 14072 --- [/api/v2/spans}}] org.springframework.web.HttpLogging      : Writing [[B@3460194e] as "application/json"
2023-01-05 10:56:28.176 DEBUG [ORDER-SERVICE,,] 14072 --- [/api/v2/spans}}] org.springframework.web.HttpLogging      : Response 202 ACCEPTED
</code>```

API-Gateway logs when it fails:

```<code>2023-01-05 10:58:24.485 DEBUG [API-GATEWAY,,] 23068 --- [ctor-http-nio-1] o.s.w.s.adapter.HttpWebHandlerAdapter    : [f9b266b7-10] HTTP GET "/order/4"
2023-01-05 10:58:24.496 DEBUG [API-GATEWAY,e7049b94195ecf37,6cf05802f3dca2dc] 23068 --- [     parallel-1] o.s.w.s.s.DefaultWebSessionManager       : Created new WebSession.
2023-01-05 10:58:25.163 DEBUG [API-GATEWAY,,] 23068 --- [/api/v2/spans}}] o.s.w.r.f.client.ExchangeFunctions       : [34ca7d36] HTTP POST http://localhost:9411/api/v2/spans
2023-01-05 10:58:25.168 DEBUG [API-GATEWAY,60dd40f12b9da81d,070b6d8bba49f22f] 23068 --- [ctor-http-nio-4] o.s.core.codec.ByteArrayEncoder          : [34ca7d36] Writing 439 bytes
2023-01-05 10:58:25.181 DEBUG [API-GATEWAY,60dd40f12b9da81d,070b6d8bba49f22f] 23068 --- [ctor-http-nio-4] o.s.w.r.f.client.ExchangeFunctions       : [34ca7d36] [862de7b5-1, L:/127.0.0.1:59384 - R:localhost/127.0.0.1:9411] Response 202 ACCEPTED
2023-01-05 10:58:25.511 DEBUG [API-GATEWAY,b4f5aea2726ff3fb,08f2382b1d8686aa] 23068 --- [     parallel-2] s.w.r.r.m.a.RequestMappingHandlerMapping : [f9b266b7-10] Mapped to com.dailycodebuffer.cloudgateway.controller.FallbackController#orderServiceFallback()
2023-01-05 10:58:25.514 DEBUG [API-GATEWAY,b4f5aea2726ff3fb,08f2382b1d8686aa] 23068 --- [     parallel-2] o.s.w.r.r.m.a.ResponseBodyResultHandler  : [f9b266b7-10] Using 'text/plain;charset=UTF-8' given [*/*] and supported [text/plain;charset=UTF-8, text/event-stream, text/plain;charset=UTF-8, */*]
2023-01-05 10:58:25.514 DEBUG [API-GATEWAY,b4f5aea2726ff3fb,08f2382b1d8686aa] 23068 --- [     parallel-2] o.s.w.r.r.m.a.ResponseBodyResultHandler  : [f9b266b7-10] 0..1 [java.lang.String]
2023-01-05 10:58:25.514 DEBUG [API-GATEWAY,b4f5aea2726ff3fb,08f2382b1d8686aa] 23068 --- [     parallel-2] o.s.core.codec.CharSequenceEncoder       : [f9b266b7-10] Writing "Order service is down!"
2023-01-05 10:58:25.516 DEBUG [API-GATEWAY,,] 23068 --- [ctor-http-nio-1] o.s.w.s.adapter.HttpWebHandlerAdapter    : [f9b266b7-10] Completed 200 OK
2023-01-05 10:58:26.188 DEBUG [API-GATEWAY,,] 23068 --- [/api/v2/spans}}] o.s.w.r.f.client.ExchangeFunctions       : [1c1092e2] HTTP POST http://localhost:9411/api/v2/spans
2023-01-05 10:58:26.190 DEBUG [API-GATEWAY,60dd40f12b9da81d,070b6d8bba49f22f] 23068 --- [ctor-http-nio-4] o.s.core.codec.ByteArrayEncoder          : [1c1092e2] Writing 1268 bytes
2023-01-05 10:58:26.198 DEBUG [API-GATEWAY,60dd40f12b9da81d,070b6d8bba49f22f] 23068 --- [ctor-http-nio-4] o.s.w.r.f.client.ExchangeFunctions       : [1c1092e2] [862de7b5-2, L:/127.0.0.1:59384 - R:localhost/127.0.0.1:9411] Response 202 ACCEPTED
</code>```

API-Gateway logs when it returns proper results:

```<code>2023-01-05 10:59:44.857 DEBUG [API-GATEWAY,b4f5aea2726ff3fb,08f2382b1d8686aa] 23068 --- [ctor-http-nio-1] o.s.w.s.adapter.HttpWebHandlerAdapter    : [f9b266b7-12] HTTP GET "/order/4"
2023-01-05 10:59:44.865 DEBUG [API-GATEWAY,6e2c73066610bdd2,04c9da4375862aa5] 23068 --- [     parallel-3] o.s.w.s.s.DefaultWebSessionManager       : Created new WebSession.
2023-01-05 10:59:44.946 DEBUG [API-GATEWAY,,] 23068 --- [/api/v2/spans}}] o.s.w.r.f.client.ExchangeFunctions       : [c2145ca] HTTP POST http://localhost:9411/api/v2/spans
2023-01-05 10:59:44.947 DEBUG [API-GATEWAY,,] 23068 --- [ctor-http-nio-2] o.s.core.codec.ByteArrayEncoder          : [c2145ca] Writing 439 bytes
2023-01-05 10:59:44.960 DEBUG [API-GATEWAY,,] 23068 --- [ctor-http-nio-2] o.s.w.r.f.client.ExchangeFunctions       : [c2145ca] [fcfb2f85-3, L:/127.0.0.1:59436 - R:localhost/127.0.0.1:9411] Response 202 ACCEPTED
2023-01-05 10:59:45.484 DEBUG [API-GATEWAY,,] 23068 --- [ctor-http-nio-1] o.s.w.s.adapter.HttpWebHandlerAdapter    : [f9b266b7-12] Completed 200 OK
2023-01-05 10:59:45.964 DEBUG [API-GATEWAY,,] 23068 --- [/api/v2/spans}}] o.s.w.r.f.client.ExchangeFunctions       : [143e412e] HTTP POST http://localhost:9411/api/v2/spans
2023-01-05 10:59:45.965 DEBUG [API-GATEWAY,,] 23068 --- [ctor-http-nio-2] o.s.core.codec.ByteArrayEncoder          : [143e412e] Writing 853 bytes
2023-01-05 10:59:45.993 DEBUG [API-GATEWAY,,] 23068 --- [ctor-http-nio-2] o.s.w.r.f.client.ExchangeFunctions       : [143e412e] [fcfb2f85-4, L:/127.0.0.1:59436 - R:localhost/127.0.0.1:9411] Response 202 ACCEPTED
</code>```

Update: I added Exception in the fallback method argument list and below in the stacktrace:

```<code>@GetMapping("/orderServiceFallBack")
    public String orderServiceFallback(Exception e) {
        System.out.println("e.getMessage() = " + e.getMessage()); // This is printing null.
        System.out.println("e.getStackTrace() = " + Arrays.toString(e.getStackTrace()));
        return "Order service is down!";
    }
</code>```

Below is the stacktrace printed:

```<code>[java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211)
    org.springframework.web.reactive.result.method.annotation.ModelAttributeMethodArgumentResolver.constructAttribute(ModelAttributeMethodArgumentResolver.java:225)
    org.springframework.web.reactive.result.method.annotation.ModelAttributeMethodArgumentResolver.createAttribute(ModelAttributeMethodArgumentResolver.java:217)
    org.springframework.web.reactive.result.method.annotation.ModelAttributeMethodArgumentResolver.prepareAttributeMono(ModelAttributeMethodArgumentResolver.java:177)
    org.springframework.web.reactive.result.method.annotation.ModelAttributeMethodArgumentResolver.resolveArgument(ModelAttributeMethodArgumentResolver.java:111)
    org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:119)
    org.springframework.web.reactive.result.method.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:205)
    org.springframework.web.reactive.result.method.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:136)
    org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter.lambda$handle$1(RequestMappingHandlerAdapter.java:200)
    reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:44)
    reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:240)
    reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onComplete(MonoIgnoreThen.java:203)
    reactor.core.publisher.MonoFlatMap$FlatMapMain.onComplete(MonoFlatMap.java:181)
    reactor.core.publisher.Operators.complete(Operators.java:137)
    reactor.core.publisher.MonoZip.subscribe(MonoZip.java:121)
    reactor.core.publisher.Mono.subscribe(Mono.java:4490)
    reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:263)
    reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:51)
    reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:157)
    reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:74)
    reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82)
    reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.innerNext(FluxConcatMap.java:282)
    reactor.core.publisher.FluxConcatMap$ConcatMapInner.onNext(FluxConcatMap.java:863)
    reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)
    reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:180)
    reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2400)
    reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.request(MonoPeekTerminal.java:139)
    reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)
    reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2196)
    reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:2070)
    reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)
    reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onSubscribe(MonoPeekTerminal.java:152)
    reactor.core.publisher.MonoJust.subscribe(MonoJust.java:55)
    reactor.core.publisher.Mono.subscribe(Mono.java:4490)
    reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:451)
    reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onSubscribe(FluxConcatMap.java:219)
    reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:201)
    reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:83)
    reactor.core.publisher.Mono.subscribe(Mono.java:4490)
    reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:103)
    reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onError(MonoPeekTerminal.java:258)
    reactor.core.publisher.SerializedSubscriber.onError(SerializedSubscriber.java:124)
    reactor.core.publisher.SerializedSubscriber.onError(SerializedSubscriber.java:124)
    reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.handleTimeout(FluxTimeout.java:295)
    reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.doTimeout(FluxTimeout.java:280)
    reactor.core.publisher.FluxTimeout$TimeoutTimeoutSubscriber.onNext(FluxTimeout.java:419)
    reactor.core.publisher.FluxOnErrorReturn$ReturnSubscriber.onNext(FluxOnErrorReturn.java:162)
    reactor.core.publisher.MonoDelay$MonoDelayRunnable.propagateDelay(MonoDelay.java:271)
    reactor.core.publisher.MonoDelay$MonoDelayRunnable.run(MonoDelay.java:286)
    reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
    reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
    java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
    java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    java.base/java.lang.Thread.run(Thread.java:833)]
</code>```

Update2: I enabled the circuitbreakers' status in the actuator and checked before and after hitting the API. the failedCalls numbers are going up. But why? Because in my controller, the SOUT is printing everything perfectly fine.

This is what I am getting in the /actuator/health endpoint:

```<code>{
"status": "UP",
"components": {
    "circuitBreakers": {
        "status": "UP",
        "details": {
            "PAYMENT-SERVICE": {
                "status": "UP",
                "details": {
                    "failureRate": "-1.0%",
                    "failureRateThreshold": "50.0%",
                    "slowCallRate": "-1.0%",
                    "slowCallRateThreshold": "100.0%",
                    "bufferedCalls": 0,
                    "slowCalls": 0,
                    "slowFailedCalls": 0,
                    "failedCalls": 0,
                    "notPermittedCalls": 0,
                    "state": "CLOSED"
                }
            },
            "ORDER-SERVICE": {
                "status": "UP",
                "details": {
                    "failureRate": "-1.0%",
                    "failureRateThreshold": "50.0%",
                    "slowCallRate": "-1.0%",
                    "slowCallRateThreshold": "100.0%",
                    "bufferedCalls": 1,
                    "slowCalls": 0,
                    "slowFailedCalls": 0,
                    "failedCalls": 1,
                    "notPermittedCalls": 0,
                    "state": "CLOSED"
                }
            },
            "PRODUCT-SERVICE": {
                "status": "UP",
                "details": {
                    "failureRate": "-1.0%",
                    "failureRateThreshold": "50.0%",
                    "slowCallRate": "-1.0%",
                    "slowCallRateThreshold": "100.0%",
                    "bufferedCalls": 0,
                    "slowCalls": 0,
                    "slowFailedCalls": 0,
                    "failedCalls": 0,
                    "notPermittedCalls": 0,
                    "state": "CLOSED"
                }
            }
        }
    }
}
</code>```

Body:
To provide some background, I am trying to implement below architecture.
It is from a course provided by "DailyCodeBuffer" on microservices, there are 3 services, order, product and payment. Clients can call the order service and order-service internally accesses payment and product services. Everything is registered on Eureka service registry and there is an API-Gateway via which everything should be routed.
Architecture Schema

So, first I created everything without the Okta Auth implementation and things were working perfectly fine. Upon calling the order-service via the gateway, I was able to get the order details by id let's say for example.

Then I added the Okta auth and now every time I try to access an order details by id, for first 2-3 times I always get the fallback method response from the gateway. And if I keep requesting back to back, it gives me result after 2-3 times. If I try to hit the order-service directly without going via the gateway, things are working fine. Similarly, if I remove the circuit-breaker configuration for order-service from the Yaml given below, things are working fine again. Kindly suggest the possible reasons and the solution/direction in which I should look.
Please let me know if you want any other code/implementation from the repo. At this point, I honestly don’t know where to look for the issue.

Here is my API-gateway yaml:

server:
  port: 9090

logging:
  level:
    web: debug

spring:
  application:
    name: API-GATEWAY
  config:
    import: configserver:http://localhost:9296
  cloud:
    gateway:
      routes:
        - id: ORDER-SERVICE
          uri: lb://ORDER-SERVICE
          predicates:
            - Path=/order/**
          filters:
            - name: CircuitBreaker
              args:
                name: ORDER-SERVICE
                fallbackuri: forward:/orderServiceFallBack
            - name: RequestRateLimiter
              args:
                redis-rate-limiter.replenishRate: 1
                redis-rate-limiter.burstCapacity: 1
        - id: PAYMENT-SERVICE
          uri: lb://PAYMENT-SERVICE
          predicates:
            - Path=/payment/**
          filters:
            - name: CircuitBreaker
              args:
                name: PAYMENT-SERVICE
                fallbackuri: forward:/paymentServiceFallBack
            - name: RequestRateLimiter
              args:
                redis-rate-limiter.replenishRate: 1
                redis-rate-limiter.burstCapacity: 1
        - id: PRODUCT-SERVICE
          uri: lb://PRODUCT-SERVICE
          predicates:
            - Path=/product/**
          filters:
            - name: CircuitBreaker
              args:
                name: PRODUCT-SERVICE
                fallbackuri: forward:/productServiceFallBack
            - name: RequestRateLimiter
              args:
                redis-rate-limiter.replenishRate: 1
                redis-rate-limiter.burstCapacity: 1

okta:
  oauth2:
    issuer: <<not mentioning here for security reasons>>
    audience: api://default
    client-id: <<not mentioning here for security reasons>>
    client-secret: <<not mentioning here for security reasons>>
    scopes: openid, profile, email, offline_access

Here is my controller layer for order-service(The SOUT is printing everything correctly every time, so I am skipping service layer code here, please ask if you still want it):

@PreAuthorize("hasAuthority('Admin') || hasAuthority('Customer')")
@GetMapping("/{orderId}")
public ResponseEntity<OrderResponse> getOrderDetails(@PathVariable("orderId") long orderId) {
    OrderResponse orderResponse = orderService.getOrderDetails(orderId);
    System.out.println("orderResponse = " + orderResponse);
    return new ResponseEntity<>(orderResponse, HttpStatus.OK);
}

Here is my Cloud-Gateway application class where I have setup the circuit breaker with default configs:

@SpringBootApplication
public class CloudGatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(CloudGatewayApplication.class, args);
    }

    @Bean
    KeyResolver userKeySolver() {
        return exchange -> Mono.just("userKey");
    }

    @Bean
    public Customizer<Resilience4JCircuitBreakerFactory> defaultCustomizer() {
        return factory -> factory.configureDefault(
                id -> new Resilience4JConfigBuilder(id)
                        .circuitBreakerConfig(
                                CircuitBreakerConfig.ofDefaults()
                        ).build()
        );
    }

}

FallBack controller in API-gateway:

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class FallbackController {

    @GetMapping("/orderServiceFallBack")
    public String orderServiceFallback() {
        return "Order service is down!";
    }

    @GetMapping("/paymentServiceFallBack")
    public String paymentServiceFallback() {
        return "Payment service is down!";
    }

    @GetMapping("/productServiceFallBack")
    public String productServiceFallback() {
        return "Product service is down!";
    }
}

Order-service logs (Same logs every time):

2023-01-05 10:56:22.465 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : HTTP GET https://dev-89319517.okta.com/oauth2/default/v1/keys
2023-01-05 10:56:22.466 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Accept=[text/plain, */*]
2023-01-05 10:56:23.799 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Response 200 OK
2023-01-05 10:56:23.799 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Reading to [java.lang.String] as "application/json"
2023-01-05 10:56:23.860 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.servlet.DispatcherServlet        : GET "/order/4", parameters={}
2023-01-05 10:56:23.872 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to com.dailycodebuffer.orderservice.controller.OrderController#getOrderDetails(long)
2023-01-05 10:56:23.915  INFO [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] c.d.o.service.OrderServiceImpl           : Get order details for order id: 4
2023-01-05 10:56:24.016  INFO [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] c.d.o.service.OrderServiceImpl           : Invoking product service to fetch the product for id: 2
2023-01-05 10:56:24.018 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : HTTP GET http://PRODUCT-SERVICE/product/2
2023-01-05 10:56:24.019 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Accept=[application/json, application/*+json]
2023-01-05 10:56:24.028 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,1bc48b17dcb26435] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : HTTP POST https://dev-89319517.okta.com/oauth2/default/v1/token
2023-01-05 10:56:24.028 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,1bc48b17dcb26435] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Accept=[application/json, application/*+json]
2023-01-05 10:56:24.029 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,1bc48b17dcb26435] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Writing [{grant_type=[client_credentials], scope=[internal]}] as "application/x-www-form-urlencoded;charset=UTF-8"
2023-01-05 10:56:24.672 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,1bc48b17dcb26435] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Response 200 OK
2023-01-05 10:56:24.672 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,1bc48b17dcb26435] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Reading to [org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse] as "application/json;charset=UTF-8"
2023-01-05 10:56:26.132 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Response 200 OK
2023-01-05 10:56:26.132 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Reading to [com.dailycodebuffer.orderservice.external.response.ProductResponse]
2023-01-05 10:56:26.134  INFO [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] c.d.o.service.OrderServiceImpl           : Getting payment information from payment service
2023-01-05 10:56:26.134 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : HTTP GET http://PAYMENT-SERVICE/payment/order/4
2023-01-05 10:56:26.134 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Accept=[application/json, application/*+json]
2023-01-05 10:56:26.134 DEBUG [ORDER-SERVICE,,] 14072 --- [/api/v2/spans}}] org.springframework.web.HttpLogging      : HTTP POST http://localhost:9411/api/v2/spans
2023-01-05 10:56:26.134 DEBUG [ORDER-SERVICE,,] 14072 --- [/api/v2/spans}}] org.springframework.web.HttpLogging      : Accept=[text/plain, application/json, application/*+json, */*]
2023-01-05 10:56:26.135 DEBUG [ORDER-SERVICE,,] 14072 --- [/api/v2/spans}}] org.springframework.web.HttpLogging      : Writing [[B@397bd980] as "application/json"
2023-01-05 10:56:26.165 DEBUG [ORDER-SERVICE,,] 14072 --- [/api/v2/spans}}] org.springframework.web.HttpLogging      : Response 202 ACCEPTED
2023-01-05 10:56:27.744 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Response 200 OK
2023-01-05 10:56:27.744 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.client.RestTemplate              : Reading to [com.dailycodebuffer.orderservice.external.response.PaymentResponse]
orderResponse = OrderResponse(orderId=4, orderDate=2023-01-02T12:21:48.312429Z, orderStatus=PLACED, amount=2000, productDetails=OrderResponse.ProductDetails(productName=MacBook, productId=2, quantity=1, price=2000), paymentDetails=OrderResponse.PaymentDetails(paymentId=1, paymentMode=CASH, paymentStatus=SUCCESS, paymentDate=2023-01-02T12:21:48.794794Z))
2023-01-05 10:56:27.760 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Using 'application/json', given [*/*] and supported [application/json, application/*+json, application/json, application/*+json]
2023-01-05 10:56:27.763 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Writing [OrderResponse(orderId=4, orderDate=2023-01-02T12:21:48.312429Z, orderStatus=PLACED, amount=2000, pro (truncated)...]
2023-01-05 10:56:27.773 DEBUG [ORDER-SERVICE,03f7ef4ad8f0e497,4a4d18fceb3bada1] 14072 --- [nio-8082-exec-6] o.s.web.servlet.DispatcherServlet        : Completed 200 OK
2023-01-05 10:56:28.168 DEBUG [ORDER-SERVICE,,] 14072 --- [/api/v2/spans}}] org.springframework.web.HttpLogging      : HTTP POST http://localhost:9411/api/v2/spans
2023-01-05 10:56:28.169 DEBUG [ORDER-SERVICE,,] 14072 --- [/api/v2/spans}}] org.springframework.web.HttpLogging      : Accept=[text/plain, application/json, application/*+json, */*]
2023-01-05 10:56:28.169 DEBUG [ORDER-SERVICE,,] 14072 --- [/api/v2/spans}}] org.springframework.web.HttpLogging      : Writing [[B@3460194e] as "application/json"
2023-01-05 10:56:28.176 DEBUG [ORDER-SERVICE,,] 14072 --- [/api/v2/spans}}] org.springframework.web.HttpLogging      : Response 202 ACCEPTED

API-Gateway logs when it fails:

2023-01-05 10:58:24.485 DEBUG [API-GATEWAY,,] 23068 --- [ctor-http-nio-1] o.s.w.s.adapter.HttpWebHandlerAdapter    : [f9b266b7-10] HTTP GET "/order/4"
2023-01-05 10:58:24.496 DEBUG [API-GATEWAY,e7049b94195ecf37,6cf05802f3dca2dc] 23068 --- [     parallel-1] o.s.w.s.s.DefaultWebSessionManager       : Created new WebSession.
2023-01-05 10:58:25.163 DEBUG [API-GATEWAY,,] 23068 --- [/api/v2/spans}}] o.s.w.r.f.client.ExchangeFunctions       : [34ca7d36] HTTP POST http://localhost:9411/api/v2/spans
2023-01-05 10:58:25.168 DEBUG [API-GATEWAY,60dd40f12b9da81d,070b6d8bba49f22f] 23068 --- [ctor-http-nio-4] o.s.core.codec.ByteArrayEncoder          : [34ca7d36] Writing 439 bytes
2023-01-05 10:58:25.181 DEBUG [API-GATEWAY,60dd40f12b9da81d,070b6d8bba49f22f] 23068 --- [ctor-http-nio-4] o.s.w.r.f.client.ExchangeFunctions       : [34ca7d36] [862de7b5-1, L:/127.0.0.1:59384 - R:localhost/127.0.0.1:9411] Response 202 ACCEPTED
2023-01-05 10:58:25.511 DEBUG [API-GATEWAY,b4f5aea2726ff3fb,08f2382b1d8686aa] 23068 --- [     parallel-2] s.w.r.r.m.a.RequestMappingHandlerMapping : [f9b266b7-10] Mapped to com.dailycodebuffer.cloudgateway.controller.FallbackController#orderServiceFallback()
2023-01-05 10:58:25.514 DEBUG [API-GATEWAY,b4f5aea2726ff3fb,08f2382b1d8686aa] 23068 --- [     parallel-2] o.s.w.r.r.m.a.ResponseBodyResultHandler  : [f9b266b7-10] Using 'text/plain;charset=UTF-8' given [*/*] and supported [text/plain;charset=UTF-8, text/event-stream, text/plain;charset=UTF-8, */*]
2023-01-05 10:58:25.514 DEBUG [API-GATEWAY,b4f5aea2726ff3fb,08f2382b1d8686aa] 23068 --- [     parallel-2] o.s.w.r.r.m.a.ResponseBodyResultHandler  : [f9b266b7-10] 0..1 [java.lang.String]
2023-01-05 10:58:25.514 DEBUG [API-GATEWAY,b4f5aea2726ff3fb,08f2382b1d8686aa] 23068 --- [     parallel-2] o.s.core.codec.CharSequenceEncoder       : [f9b266b7-10] Writing "Order service is down!"
2023-01-05 10:58:25.516 DEBUG [API-GATEWAY,,] 23068 --- [ctor-http-nio-1] o.s.w.s.adapter.HttpWebHandlerAdapter    : [f9b266b7-10] Completed 200 OK
2023-01-05 10:58:26.188 DEBUG [API-GATEWAY,,] 23068 --- [/api/v2/spans}}] o.s.w.r.f.client.ExchangeFunctions       : [1c1092e2] HTTP POST http://localhost:9411/api/v2/spans
2023-01-05 10:58:26.190 DEBUG [API-GATEWAY,60dd40f12b9da81d,070b6d8bba49f22f] 23068 --- [ctor-http-nio-4] o.s.core.codec.ByteArrayEncoder          : [1c1092e2] Writing 1268 bytes
2023-01-05 10:58:26.198 DEBUG [API-GATEWAY,60dd40f12b9da81d,070b6d8bba49f22f] 23068 --- [ctor-http-nio-4] o.s.w.r.f.client.ExchangeFunctions       : [1c1092e2] [862de7b5-2, L:/127.0.0.1:59384 - R:localhost/127.0.0.1:9411] Response 202 ACCEPTED

API-Gateway logs when it returns proper results:

2023-01-05 10:59:44.857 DEBUG [API-GATEWAY,b4f5aea2726ff3fb,08f2382b1d8686aa] 23068 --- [ctor-http-nio-1] o.s.w.s.adapter.HttpWebHandlerAdapter    : [f9b266b7-12] HTTP GET "/order/4"
2023-01-05 10:59:44.865 DEBUG [API-GATEWAY,6e2c73066610bdd2,04c9da4375862aa5] 23068 --- [     parallel-3] o.s.w.s.s.DefaultWebSessionManager       : Created new WebSession.
2023-01-05 10:59:44.946 DEBUG [API-GATEWAY,,] 23068 --- [/api/v2/spans}}] o.s.w.r.f.client.ExchangeFunctions       : [c2145ca] HTTP POST http://localhost:9411/api/v2/spans
2023-01-05 10:59:44.947 DEBUG [API-GATEWAY,,] 23068 --- [ctor-http-nio-2] o.s.core.codec.ByteArrayEncoder          : [c2145ca] Writing 439 bytes
2023-01-05 10:59:44.960 DEBUG [API-GATEWAY,,] 23068 --- [ctor-http-nio-2] o.s.w.r.f.client.ExchangeFunctions       : [c2145ca] [fcfb2f85-3, L:/127.0.0.1:59436 - R:localhost/127.0.0.1:9411] Response 202 ACCEPTED
2023-01-05 10:59:45.484 DEBUG [API-GATEWAY,,] 23068 --- [ctor-http-nio-1] o.s.w.s.adapter.HttpWebHandlerAdapter    : [f9b266b7-12] Completed 200 OK
2023-01-05 10:59:45.964 DEBUG [API-GATEWAY,,] 23068 --- [/api/v2/spans}}] o.s.w.r.f.client.ExchangeFunctions       : [143e412e] HTTP POST http://localhost:9411/api/v2/spans
2023-01-05 10:59:45.965 DEBUG [API-GATEWAY,,] 23068 --- [ctor-http-nio-2] o.s.core.codec.ByteArrayEncoder          : [143e412e] Writing 853 bytes
2023-01-05 10:59:45.993 DEBUG [API-GATEWAY,,] 23068 --- [ctor-http-nio-2] o.s.w.r.f.client.ExchangeFunctions       : [143e412e] [fcfb2f85-4, L:/127.0.0.1:59436 - R:localhost/127.0.0.1:9411] Response 202 ACCEPTED

Update: I added Exception in the fallback method argument list and below in the stacktrace:

@GetMapping("/orderServiceFallBack")
    public String orderServiceFallback(Exception e) {
        System.out.println("e.getMessage() = " + e.getMessage()); // This is printing null.
        System.out.println("e.getStackTrace() = " + Arrays.toString(e.getStackTrace()));
        return "Order service is down!";
    }

Below is the stacktrace printed:

[java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211)
    org.springframework.web.reactive.result.method.annotation.ModelAttributeMethodArgumentResolver.constructAttribute(ModelAttributeMethodArgumentResolver.java:225)
    org.springframework.web.reactive.result.method.annotation.ModelAttributeMethodArgumentResolver.createAttribute(ModelAttributeMethodArgumentResolver.java:217)
    org.springframework.web.reactive.result.method.annotation.ModelAttributeMethodArgumentResolver.prepareAttributeMono(ModelAttributeMethodArgumentResolver.java:177)
    org.springframework.web.reactive.result.method.annotation.ModelAttributeMethodArgumentResolver.resolveArgument(ModelAttributeMethodArgumentResolver.java:111)
    org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:119)
    org.springframework.web.reactive.result.method.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:205)
    org.springframework.web.reactive.result.method.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:136)
    org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter.lambda$handle$1(RequestMappingHandlerAdapter.java:200)
    reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:44)
    reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:240)
    reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onComplete(MonoIgnoreThen.java:203)
    reactor.core.publisher.MonoFlatMap$FlatMapMain.onComplete(MonoFlatMap.java:181)
    reactor.core.publisher.Operators.complete(Operators.java:137)
    reactor.core.publisher.MonoZip.subscribe(MonoZip.java:121)
    reactor.core.publisher.Mono.subscribe(Mono.java:4490)
    reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:263)
    reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:51)
    reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:157)
    reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:74)
    reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82)
    reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.innerNext(FluxConcatMap.java:282)
    reactor.core.publisher.FluxConcatMap$ConcatMapInner.onNext(FluxConcatMap.java:863)
    reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)
    reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:180)
    reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2400)
    reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.request(MonoPeekTerminal.java:139)
    reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)
    reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2196)
    reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:2070)
    reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)
    reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onSubscribe(MonoPeekTerminal.java:152)
    reactor.core.publisher.MonoJust.subscribe(MonoJust.java:55)
    reactor.core.publisher.Mono.subscribe(Mono.java:4490)
    reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:451)
    reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onSubscribe(FluxConcatMap.java:219)
    reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:201)
    reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:83)
    reactor.core.publisher.Mono.subscribe(Mono.java:4490)
    reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:103)
    reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onError(MonoPeekTerminal.java:258)
    reactor.core.publisher.SerializedSubscriber.onError(SerializedSubscriber.java:124)
    reactor.core.publisher.SerializedSubscriber.onError(SerializedSubscriber.java:124)
    reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.handleTimeout(FluxTimeout.java:295)
    reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.doTimeout(FluxTimeout.java:280)
    reactor.core.publisher.FluxTimeout$TimeoutTimeoutSubscriber.onNext(FluxTimeout.java:419)
    reactor.core.publisher.FluxOnErrorReturn$ReturnSubscriber.onNext(FluxOnErrorReturn.java:162)
    reactor.core.publisher.MonoDelay$MonoDelayRunnable.propagateDelay(MonoDelay.java:271)
    reactor.core.publisher.MonoDelay$MonoDelayRunnable.run(MonoDelay.java:286)
    reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
    reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
    java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
    java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    java.base/java.lang.Thread.run(Thread.java:833)]

Update2: I enabled the circuitbreakers' status in the actuator and checked before and after hitting the API. the failedCalls numbers are going up. But why? Because in my controller, the SOUT is printing everything perfectly fine.

This is what I am getting in the /actuator/health endpoint:

{
"status": "UP",
"components": {
    "circuitBreakers": {
        "status": "UP",
        "details": {
            "PAYMENT-SERVICE": {
                "status": "UP",
                "details": {
                    "failureRate": "-1.0%",
                    "failureRateThreshold": "50.0%",
                    "slowCallRate": "-1.0%",
                    "slowCallRateThreshold": "100.0%",
                    "bufferedCalls": 0,
                    "slowCalls": 0,
                    "slowFailedCalls": 0,
                    "failedCalls": 0,
                    "notPermittedCalls": 0,
                    "state": "CLOSED"
                }
            },
            "ORDER-SERVICE": {
                "status": "UP",
                "details": {
                    "failureRate": "-1.0%",
                    "failureRateThreshold": "50.0%",
                    "slowCallRate": "-1.0%",
                    "slowCallRateThreshold": "100.0%",
                    "bufferedCalls": 1,
                    "slowCalls": 0,
                    "slowFailedCalls": 0,
                    "failedCalls": 1,
                    "notPermittedCalls": 0,
                    "state": "CLOSED"
                }
            },
            "PRODUCT-SERVICE": {
                "status": "UP",
                "details": {
                    "failureRate": "-1.0%",
                    "failureRateThreshold": "50.0%",
                    "slowCallRate": "-1.0%",
                    "slowCallRateThreshold": "100.0%",
                    "bufferedCalls": 0,
                    "slowCalls": 0,
                    "slowFailedCalls": 0,
                    "failedCalls": 0,
                    "notPermittedCalls": 0,
                    "state": "CLOSED"
                }
            }
        }
    }
}


来源: stackexchange

问:
Why does setting TempData value make the browser change the preferred theme to dark mode?
I'm working on handling errors so I defaulted one to occur when I post my form:

```<code>public async Task<IActionResult> OnPostSaveAsync()
{
    try
    {
        //var newMemberId = await SaveMemberAsync();
        var newMemberId = 0;

        if (newMemberId <= 0)
        {
            TempData["isError"] = true;
            TempData["errorMsg"] = "...";
            return Page();
        }
    }
    catch (Exception ex)
    {
        TempData["isError"] = true;
        // etc.
        return Page();
    }
}
</code>```

This works fine, however, the form values (particularly the selections from dropdownlists) get cleared.

As a fix, I wanted to pass the submitted model back to the page.

I want to be clear: I don't have the faintest idea what's going on with this problem, but when I add TempData["Member"] = this.Member; before the return (as below), the page goes dark mode and doesn't populate the previous selections in the lists.

I don't understand why this happens and I don't have any idea how to diagnose it.

```<code>public async Task<IActionResult> OnPostSaveAsync()
{
    try
    {
        //var newMemberId = await SaveMemberAsync();
        var newMemberId = 0;

        if (newMemberId <= 0)
        {
            TempData["isError"] = true;
            TempData["errorMsg"] = "...";
            TempData["Member"] = this.Member;
            return Page();
        }
    }
    catch (Exception ex)
    {
        TempData["isError"] = true;
        // etc.
        return Page();
    }
}
</code>```

Why does the page set the preferred theme on  to dark mode when I'm submitting the page having this member TempData value set?

Update

Here's the markup on the page (particularly what I'm doing with the error handling as that's what's in question here). I can't show screenshots of the page because it's proprietary.

Simply, I'm rendering a UI element to show the message:

```<code>@if(TempData["isError"] != null && (bool)TempData["isError"])
{
    <div class="callout callout-danger">
        <p>@TempData["errorMsg"].ToString()</p>
    </div>
}
</code>```

Here's related markup as rendered before the dark mode issue:

Here's what it looks like after the dark mode thing happens:

Note the media query in the css has changed to a preference for dark mode. This is not included in my user code, I can't find #dcdcdc anywhere.

ContentLicense: CC BY-SA 4.0

Body:
I'm working on handling errors so I defaulted one to occur when I post my form:

public async Task<IActionResult> OnPostSaveAsync()
{
    try
    {
        //var newMemberId = await SaveMemberAsync();
        var newMemberId = 0;

        if (newMemberId <= 0)
        {
            TempData["isError"] = true;
            TempData["errorMsg"] = "...";
            return Page();
        }
    }
    catch (Exception ex)
    {
        TempData["isError"] = true;
        // etc.
        return Page();
    }
}

This works fine, however, the form values (particularly the selections from dropdownlists) get cleared.

As a fix, I wanted to pass the submitted model back to the page.

I want to be clear: I don't have the faintest idea what's going on with this problem, but when I add TempData["Member"] = this.Member; before the return (as below), the page goes dark mode and doesn't populate the previous selections in the lists.

I don't understand why this happens and I don't have any idea how to diagnose it.

public async Task<IActionResult> OnPostSaveAsync()
{
    try
    {
        //var newMemberId = await SaveMemberAsync();
        var newMemberId = 0;

        if (newMemberId <= 0)
        {
            TempData["isError"] = true;
            TempData["errorMsg"] = "...";
            TempData["Member"] = this.Member;
            return Page();
        }
    }
    catch (Exception ex)
    {
        TempData["isError"] = true;
        // etc.
        return Page();
    }
}

Why does the page set the preferred theme on  to dark mode when I'm submitting the page having this member TempData value set?

Update

Here's the markup on the page (particularly what I'm doing with the error handling as that's what's in question here). I can't show screenshots of the page because it's proprietary.

Simply, I'm rendering a UI element to show the message:

@if(TempData["isError"] != null && (bool)TempData["isError"])
{

@TempData["errorMsg"].ToString()

}

Here's related markup as rendered before the dark mode issue:

Here's what it looks like after the dark mode thing happens:

Note the media query in the css has changed to a preference for dark mode. This is not included in my user code, I can't find #dcdcdc anywhere.


问:
How to use SwiftUI TextFields for Ints of objects
I am using swiftui textfields to allow a user to enter certain values that will be sent to a database. The values are entered using a view for each "mySet" Object. An overlying "Session" object (contained in setsViewModel) has an array of these "mySet"s.

Here is the view that allows a user to input values for a given set:

```<code>struct SetView: View {
    var set_num: Int
    @State var setsViewModel: SetsViewModel

    var body: some View {
        VStack {
            Text("Set " + String(set_num+1))
            Spacer()
            HStack{
                VStack {
                    Text("Weight")
                    TextField("Lbs", value: $setsViewModel.session.sets[set_num].weight, format: .number)
                }
                VStack {
                    Text("Reps")
                    TextField("# Reps", value: $setsViewModel.session.sets[set_num].reps, format: .number)
                }
            }
            HStack{
                VStack {
                    Text("Quality")
                    TextField("1-5", value: $setsViewModel.session.sets[set_num].quality, format: .number)
                }
                VStack {
                    Text("Rep Speed")
                    TextField("1-5", value: $setsViewModel.session.sets[set_num].rep_speed, format: .number)

                }
            }
            HStack{
                VStack {
                    Text("Rest Before")
                    TextField("Seconds", value: $setsViewModel.session.sets[set_num].rest_before, format: .number)
                }
                VStack {
                    Text("Anything else")
                    TextField(text: $setsViewModel.session.sets[set_num].note, label: { Text("Enter note")})
                }
            }
        }
    }
}
</code>```

These SetViews are used in a list in another view called SetsView:

```<code>struct SetsView: View {
    var workout: Workout
    var exercise: Exercise
    var session_id: Int
    @State var setsViewModel: SetsViewModel

    init(workout: Workout, exercise: Exercise, session_id: Int) {
        self.workout = workout
        self.exercise = exercise
        self.session_id = session_id

        self.setsViewModel = SetsViewModel(session_id: session_id, workout_id: workout.workout_id, exercise: exercise)
        }
    }

    var body: some View {
        ScrollView {
            VStack {
                Spacer()
                ForEach(0..<exercise.set_number) {set_index in
                    SetView(set_num: set_index, setsViewModel: setsViewModel)
                }
                submitButton
            }
        }.navigationTitle(exercise.exercise_name)
    }

    var submitButton: some View {
        Button("Submit") {self.setsViewModel.postSets()}
    }
}
</code>```

The setsViewModel just makes a post request to a backend API, and has the relevant structs (whole SetsViewModel requested):

```<code>struct Session: Codable {
    var session_id: Int
    var workout_id: Int
    var sets: [mySet] = []
}

struct mySet: Hashable, Codable {
    var exercise_id: Int = -1
    var weight: Int = -1
    var reps: Int = -1
    var quality: Int = -1
    var rep_speed: Int = -1
    var rest_before: Int = -1
    var note: String = ""
}

class SetsViewModel: ObservableObject {
    var tokenFetcher = TokenFetcher()
    var session: Session
    var exercise: Exercise

    init(tokenFetcher: TokenFetcher = TokenFetcher(), session_id: Int, workout_id: Int, exercise: Exercise) {
        self.exercise = exercise
        self.tokenFetcher = tokenFetcher
        self.session = Session(session_id:session_id, workout_id: workout_id, sets: [])

        for _ in 1...exercise.set_number {
            session.sets.append(mySet())
        }
    }

    func postSets() {
        self.tokenFetcher.getToken()

        print("Adding sets with sesion id", session.session_id)
        guard let url = URL(string: (self.tokenFetcher.ngrokUrl + "/Set"))
        else {
            print("Error: Something wrong with url.")
            return
        }

        var urlRequest = URLRequest(url: url, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10)
        urlRequest.allHTTPHeaderFields = [
            "Token": self.tokenFetcher.token
        ]
        urlRequest.httpMethod = "POST"
        var jsonString = ""
        do {
            let encodedData = try JSONEncoder().encode(session)
            jsonString = String(data: encodedData,
                                encoding: .utf8)!
        }
        catch {
            print("Error: something went wrong encoding sets", error)
        }
        let body = jsonString
        urlRequest.httpBody = body.data(using: String.Encoding.utf8)

        let task = URLSession.shared.dataTask(with: urlRequest) { [weak self] data, _, error in
            guard let data = data, error == nil else {
                return
            }
        }
        task.resume()
    }
}
</code>```

My problem is that in the running app, the initial values (shown above) are displayed in the textfields, and even after changing the value, once I move to the next field, it returns to the initial -1. In addition, I can't type in the "note" text field at all.

enter image description here

Oddly enough, when I hit the submit button, all the values received by the API are the ones I manually entered, and not the initial values, except for the "note" field, which only remembers the last character entered. But even if it works, I'd like a user friendly UI that will show all the correct values before submission.

I have tried various Textfield headers, as well as different ways to pass around the variables to get it to the post call, none with any more success than above.

I'm new to Swift (and in college, so new overall), so please point out any better Views or ways to enable this behavior. In addition, please point out any ways to make this cleaner code, because I feel like I'm cheating in a lot of places here.

Edit: The values now remain in the text field, but as seen in the picture, they are instantiated to the default values. How can I make it so that they show the Title text instead?

Body:
I am using swiftui textfields to allow a user to enter certain values that will be sent to a database. The values are entered using a view for each "mySet" Object. An overlying "Session" object (contained in setsViewModel) has an array of these "mySet"s.

Here is the view that allows a user to input values for a given set:

struct SetView: View {
    var set_num: Int
    @State var setsViewModel: SetsViewModel

    var body: some View {
        VStack {
            Text("Set " + String(set_num+1))
            Spacer()
            HStack{
                VStack {
                    Text("Weight")
                    TextField("Lbs", value: $setsViewModel.session.sets[set_num].weight, format: .number)
                }
                VStack {
                    Text("Reps")
                    TextField("# Reps", value: $setsViewModel.session.sets[set_num].reps, format: .number)
                }
            }
            HStack{
                VStack {
                    Text("Quality")
                    TextField("1-5", value: $setsViewModel.session.sets[set_num].quality, format: .number)
                }
                VStack {
                    Text("Rep Speed")
                    TextField("1-5", value: $setsViewModel.session.sets[set_num].rep_speed, format: .number)

                }
            }
            HStack{
                VStack {
                    Text("Rest Before")
                    TextField("Seconds", value: $setsViewModel.session.sets[set_num].rest_before, format: .number)
                }
                VStack {
                    Text("Anything else")
                    TextField(text: $setsViewModel.session.sets[set_num].note, label: { Text("Enter note")})
                }
            }
        }
    }
}

These SetViews are used in a list in another view called SetsView:

struct SetsView: View {
    var workout: Workout
    var exercise: Exercise
    var session_id: Int
    @State var setsViewModel: SetsViewModel

    init(workout: Workout, exercise: Exercise, session_id: Int) {
        self.workout = workout
        self.exercise = exercise
        self.session_id = session_id

        self.setsViewModel = SetsViewModel(session_id: session_id, workout_id: workout.workout_id, exercise: exercise)
        }
    }

    var body: some View {
        ScrollView {
            VStack {
                Spacer()
                ForEach(0..<exercise.set_number) {set_index in
                    SetView(set_num: set_index, setsViewModel: setsViewModel)
                }
                submitButton
            }
        }.navigationTitle(exercise.exercise_name)
    }

    var submitButton: some View {
        Button("Submit") {self.setsViewModel.postSets()}
    }
}

The setsViewModel just makes a post request to a backend API, and has the relevant structs (whole SetsViewModel requested):

struct Session: Codable {
    var session_id: Int
    var workout_id: Int
    var sets: [mySet] = []
}

struct mySet: Hashable, Codable {
    var exercise_id: Int = -1
    var weight: Int = -1
    var reps: Int = -1
    var quality: Int = -1
    var rep_speed: Int = -1
    var rest_before: Int = -1
    var note: String = ""
}

class SetsViewModel: ObservableObject {
    var tokenFetcher = TokenFetcher()
    var session: Session
    var exercise: Exercise

    init(tokenFetcher: TokenFetcher = TokenFetcher(), session_id: Int, workout_id: Int, exercise: Exercise) {
        self.exercise = exercise
        self.tokenFetcher = tokenFetcher
        self.session = Session(session_id:session_id, workout_id: workout_id, sets: [])

        for _ in 1...exercise.set_number {
            session.sets.append(mySet())
        }
    }

    func postSets() {
        self.tokenFetcher.getToken()

        print("Adding sets with sesion id", session.session_id)
        guard let url = URL(string: (self.tokenFetcher.ngrokUrl + "/Set"))
        else {
            print("Error: Something wrong with url.")
            return
        }

        var urlRequest = URLRequest(url: url, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10)
        urlRequest.allHTTPHeaderFields = [
            "Token": self.tokenFetcher.token
        ]
        urlRequest.httpMethod = "POST"
        var jsonString = ""
        do {
            let encodedData = try JSONEncoder().encode(session)
            jsonString = String(data: encodedData,
                                encoding: .utf8)!
        }
        catch {
            print("Error: something went wrong encoding sets", error)
        }
        let body = jsonString
        urlRequest.httpBody = body.data(using: String.Encoding.utf8)

        let task = URLSession.shared.dataTask(with: urlRequest) { [weak self] data, _, error in
            guard let data = data, error == nil else {
                return
            }
        }
        task.resume()
    }
}

My problem is that in the running app, the initial values (shown above) are displayed in the textfields, and even after changing the value, once I move to the next field, it returns to the initial -1. In addition, I can't type in the "note" text field at all.

enter image description here

Oddly enough, when I hit the submit button, all the values received by the API are the ones I manually entered, and not the initial values, except for the "note" field, which only remembers the last character entered. But even if it works, I'd like a user friendly UI that will show all the correct values before submission.

I have tried various Textfield headers, as well as different ways to pass around the variables to get it to the post call, none with any more success than above.

I'm new to Swift (and in college, so new overall), so please point out any better Views or ways to enable this behavior. In addition, please point out any ways to make this cleaner code, because I feel like I'm cheating in a lot of places here.

Edit: The values now remain in the text field, but as seen in the picture, they are instantiated to the default values. How can I make it so that they show the Title text instead?


问:
I am not able to run test parallel in TestNG
When i run without parallel keyword then it run, no exception occure. But when i use parallel keyword and thread-count then it cant run and throw an exception "StaleElementReferenceException: stale element reference: element is not attached to the page document".

testng.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Test With Akash" parallel="tests" thread-count="2">

  <test name="Login TestCase With Valid Input">
    <parameter name = "username" value = "sachin"></parameter>
    <parameter name = "pass" value = "sanjay123"></parameter>
    <classes>
      <class name="testngwithakash.testcases.LoginWithValidInputTestcase"/>
    </classes>
  </test>

    <test name="Login TestCase With Invalid Input">
    <parameter name = "username" value = "abc"></parameter>
    <parameter name = "pass" value = "xyz"></parameter>
    <classes>
      <class name="testngwithakash.testcases.LoginWithInvalidInputTestcase"/>
    </classes>
  </test>

</suite>
</code>```

LoginPage.java

```<code>public class LoginPage extends AppUtils
{

    public void login(String username, String pass)
    {
        WebElement login_link = driver.findElement(By.linkText("Login"));
        login_link.click();
        WebElement uname = driver.findElement(By.xpath("(//input[@id='id_username'])[1]"));
        uname.sendKeys(username);
        WebElement upass = driver.findElement(By.xpath("(//input[@id='id_password'])[1]"));
        upass.sendKeys(pass);
        WebElement login_button = driver.findElement(By.xpath("//input[@value='Login']"));
        login_button.click();
    }

    public void logout()
    {
        WebElement profileDropButton = driver.findElement(By.xpath("//a[@id='profileDropdown']"));
        profileDropButton.click();
        WebElement logoutButton = driver.findElement(By.linkText("Logout"));
        logoutButton.click();
    }

    public boolean checkUserLogin()
    {
        WebElement displayMsg = driver.findElement(By.xpath("//h3[1]"));
        String msg = displayMsg.getText();
        if(msg.contains("Welcome"))
            return true;
        else
            return false;
    }

    public boolean checkInvalidLogin()
    {
        WebElement displayMsg = driver.findElement(By.xpath("//p[@class='alert alert-danger my-3']"));
        String msg = displayMsg.getText();
        if(msg.contains("Please enter a correct username and password"))
            return true;
        else
            return false;
    }

}
</code>```

Login With Valid Input Testcase java file

```<code>public class LoginWithValidInputTestcase extends AppUtils
{
    @Test()
    @Parameters({"username", "pass"})
    public void checkLogin(String username, String pass)
    {
        LoginPage lp = new LoginPage();
        lp.login(username, pass);
        boolean res = lp.checkUserLogin();
        Assert.assertTrue(res);
        lp.logout();
    }
}
</code>```

Login With Invalid Input Testcase java file

```<code>public class LoginWithInvalidInputTestcase extends AppUtils
{
    @Test()
    @Parameters({"username", "pass"})
    public void checkInvalidLogin(String username, String pass)
    {
    LoginPage lp = new LoginPage();
    lp.login(username, pass);
    boolean res = lp.checkInvalidLogin();
    Assert.assertTrue(res);
}
}
</code>```

AppUtils.java

```<code>public class AppUtils
{
    public static WebDriver driver;
    public static String url = "http://sanjaysabane4.pythonanywhere.com/";

    @BeforeTest
    public static void launchApp()
    {
        System.setProperty("webdriver.driver.chrome", "chromedriver.exe");
        driver = new ChromeDriver();
        driver.manage().deleteAllCookies();
//      driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

        driver.get(url);
    }

    @AfterTest
    public static void closeApp()
    {
        driver.quit();
    }
}
</code>```

I got this Exception: StaleElementReferenceException

```<code>org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
  (Session info: chrome=108.0.5359.125)
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/stale_element_reference.html
</code>```

Body:
When i run without parallel keyword then it run, no exception occure. But when i use parallel keyword and thread-count then it cant run and throw an exception "StaleElementReferenceException: stale element reference: element is not attached to the page document".

testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Test With Akash" parallel="tests" thread-count="2">

  <test name="Login TestCase With Valid Input">
    <parameter name = "username" value = "sachin"></parameter>
    <parameter name = "pass" value = "sanjay123"></parameter>
    <classes>
      <class name="testngwithakash.testcases.LoginWithValidInputTestcase"/>
    </classes>
  </test>

    <test name="Login TestCase With Invalid Input">
    <parameter name = "username" value = "abc"></parameter>
    <parameter name = "pass" value = "xyz"></parameter>
    <classes>
      <class name="testngwithakash.testcases.LoginWithInvalidInputTestcase"/>
    </classes>
  </test>

</suite>

LoginPage.java

public class LoginPage extends AppUtils
{

    public void login(String username, String pass)
    {
        WebElement login_link = driver.findElement(By.linkText("Login"));
        login_link.click();
        WebElement uname = driver.findElement(By.xpath("(//input[@id='id_username'])[1]"));
        uname.sendKeys(username);
        WebElement upass = driver.findElement(By.xpath("(//input[@id='id_password'])[1]"));
        upass.sendKeys(pass);
        WebElement login_button = driver.findElement(By.xpath("//input[@value='Login']"));
        login_button.click();
    }

    public void logout()
    {
        WebElement profileDropButton = driver.findElement(By.xpath("//a[@id='profileDropdown']"));
        profileDropButton.click();
        WebElement logoutButton = driver.findElement(By.linkText("Logout"));
        logoutButton.click();
    }

    public boolean checkUserLogin()
    {
        WebElement displayMsg = driver.findElement(By.xpath("//h3[1]"));
        String msg = displayMsg.getText();
        if(msg.contains("Welcome"))
            return true;
        else
            return false;
    }

    public boolean checkInvalidLogin()
    {
        WebElement displayMsg = driver.findElement(By.xpath("//p[@class='alert alert-danger my-3']"));
        String msg = displayMsg.getText();
        if(msg.contains("Please enter a correct username and password"))
            return true;
        else
            return false;
    }

}

Login With Valid Input Testcase java file

public class LoginWithValidInputTestcase extends AppUtils
{
    @Test()
    @Parameters({"username", "pass"})
    public void checkLogin(String username, String pass)
    {
        LoginPage lp = new LoginPage();
        lp.login(username, pass);
        boolean res = lp.checkUserLogin();
        Assert.assertTrue(res);
        lp.logout();
    }
}

Login With Invalid Input Testcase java file

public class LoginWithInvalidInputTestcase extends AppUtils
{
    @Test()
    @Parameters({"username", "pass"})
    public void checkInvalidLogin(String username, String pass)
    {
    LoginPage lp = new LoginPage();
    lp.login(username, pass);
    boolean res = lp.checkInvalidLogin();
    Assert.assertTrue(res);
}
}

AppUtils.java

public class AppUtils
{
    public static WebDriver driver;
    public static String url = "http://sanjaysabane4.pythonanywhere.com/";

    @BeforeTest
    public static void launchApp()
    {
        System.setProperty("webdriver.driver.chrome", "chromedriver.exe");
        driver = new ChromeDriver();
        driver.manage().deleteAllCookies();
//      driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

        driver.get(url);
    }

    @AfterTest
    public static void closeApp()
    {
        driver.quit();
    }
}

I got this Exception: StaleElementReferenceException

org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
  (Session info: chrome=108.0.5359.125)
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/stale_element_reference.html


问:
Rolling back to previous version of npm package doesn't work?
(This question revolves more around npm and how dependencies and versions work in this ecosystem; commitlint is just an example of the issue at hand, but I imagine it could happen with any npm package.)

I was using commitlint npm package happily for the past few months to lint my commit messages. I even developed some commitlint plugins in TypeScript to enhance it with our repo's policies.

Now comes version 17.4.0 of commitlint: apparently they raised the version of their TypeScript dependency, so my plugins don't compile anymore (some issue with any types that I will look into later).

So then I decide to rollback to commitlint v17.3.0 in my CI recipe, as a temporary workaround until I can look into fixing our plugins, via:

```<code>npm install @commitlint/config-conventional@17.3.0
</code>```

But, it doesn't work! I keep getting the TypeScript compiler error. Oh, then I try with -g:

```<code>npm install -g @commitlint/config-conventional@17.3.0
</code>```

Same thing, I keep getting the error. Oh, maybe -g requires sudo?

```<code>sudo npm install -g @commitlint/config-conventional@17.3.0
</code>```

No! Still same error. What the hell might be going on here? Then I look at the CI log and I notice this in the npx call:

```<code>npm WARN exec The following package was not found and will be installed: commitlint@17.4.0
</code>```

Aha! So, somehow, npx is not seeing the recently installed commitlint version that the previous npm install step performed. How is this possible? Any ideas?

Well, then I thought, let's do a workaround, removing the npm install step and just specifying the version in the npx call:

```<code>npx commitlint@17.3.0 --from HEAD~1 --to HEAD --verbose
</code>```

...and guess what? It doesn't work either! This is the log:

```<code>Run npx commitlint@17.3.0 --from HEAD~1 --to HEAD --verbose
npm WARN exec The following package was not found and will be installed: commitlint@17.3.0
/home/runner/.npm/_npx/f46b942c1a6d2ab7/node_modules/ts-node/src/index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
...
</code>```

How is this possible? Is it that previous versions of npm packages still point to the dependencies of the latest version? Wouldn't this be an npm/npx bug?

UPDATE: Interesting discovery so far: commitlint package seems to depend on package commitlint/types, which doesn't seem to have a 17.3.0 version.

Body:
(This question revolves more around npm and how dependencies and versions work in this ecosystem; commitlint is just an example of the issue at hand, but I imagine it could happen with any npm package.)

I was using commitlint npm package happily for the past few months to lint my commit messages. I even developed some commitlint plugins in TypeScript to enhance it with our repo's policies.

Now comes version 17.4.0 of commitlint: apparently they raised the version of their TypeScript dependency, so my plugins don't compile anymore (some issue with any types that I will look into later).

So then I decide to rollback to commitlint v17.3.0 in my CI recipe, as a temporary workaround until I can look into fixing our plugins, via:

npm install @commitlint/config-conventional@17.3.0

But, it doesn't work! I keep getting the TypeScript compiler error. Oh, then I try with -g:

npm install -g @commitlint/config-conventional@17.3.0

Same thing, I keep getting the error. Oh, maybe -g requires sudo?

sudo npm install -g @commitlint/config-conventional@17.3.0

No! Still same error. What the hell might be going on here? Then I look at the CI log and I notice this in the npx call:

npm WARN exec The following package was not found and will be installed: commitlint@17.4.0

Aha! So, somehow, npx is not seeing the recently installed commitlint version that the previous npm install step performed. How is this possible? Any ideas?

Well, then I thought, let's do a workaround, removing the npm install step and just specifying the version in the npx call:

npx commitlint@17.3.0 --from HEAD~1 --to HEAD --verbose

...and guess what? It doesn't work either! This is the log:

Run npx commitlint@17.3.0 --from HEAD~1 --to HEAD --verbose
npm WARN exec The following package was not found and will be installed: commitlint@17.3.0
/home/runner/.npm/_npx/f46b942c1a6d2ab7/node_modules/ts-node/src/index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
...

How is this possible? Is it that previous versions of npm packages still point to the dependencies of the latest version? Wouldn't this be an npm/npx bug?

UPDATE: Interesting discovery so far: commitlint package seems to depend on package commitlint/types, which doesn't seem to have a 17.3.0 version.


问:
Debezium DB2 connector only sync data once initially and stops syncing
I am trying to sync data from a DB2 instance. When I create the connector, the sync starts and all the data from the DB2 is read. The problem happens when I add more data into the DB2 afterward. The new data is not being captured. I do not get any errors regarding the connector.

My Connector configuration :

```<code>{
  "name": "core-banking-DB2-source-v3",
  "config": {
    "connector.class": "io.debezium.connector.db2.Db2Connector",
    "database.hostname": "102.10.12.90",
    "database.port": "50000",
    "database.user": "db2inst1",
    "database.password": "12345@",
    "database.server.id": "1",
    "database.server.name": "DB2-command",
    "database.dbname": "monolith",
    "table.include.list": "DB2INST1.BANKING_CORE_USER",
    "database.history.kafka.bootstrap.servers": "localhost:9092",
    "database.history.kafka.topic": "dbhistory.DB2INST1" ,
    "include.schema.changes": "true",
    "decimal.handling.mode": "double",

    "key.converter":"io.confluent.connect.avro.AvroConverter",
    "key.converter.schema.registry.url":"http://localhost:8070",
    "value.converter":"io.confluent.connect.avro.AvroConverter",
    "value.converter.schema.registry.url":"http://localhost:8070",

    "transforms": "unwrap,addTopicPrefix",
    "transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState",
    "transforms.addTopicPrefix.type":"org.apache.kafka.connect.transforms.RegexRouter",
    "transforms.addTopicPrefix.regex":"(.*)",
    "transforms.addTopicPrefix.replacement":"core-DB2-$1"
  }
}
</code>```

I tried changing configurations according to this answer, but got the same problem. I also tried using the JDBC connector, which gave errors in creating the connector.

Body:
I am trying to sync data from a DB2 instance. When I create the connector, the sync starts and all the data from the DB2 is read. The problem happens when I add more data into the DB2 afterward. The new data is not being captured. I do not get any errors regarding the connector.

My Connector configuration :

{
  "name": "core-banking-DB2-source-v3",
  "config": {
    "connector.class": "io.debezium.connector.db2.Db2Connector",
    "database.hostname": "102.10.12.90",
    "database.port": "50000",
    "database.user": "db2inst1",
    "database.password": "12345@",
    "database.server.id": "1",
    "database.server.name": "DB2-command",
    "database.dbname": "monolith",
    "table.include.list": "DB2INST1.BANKING_CORE_USER",
    "database.history.kafka.bootstrap.servers": "localhost:9092",
    "database.history.kafka.topic": "dbhistory.DB2INST1" ,
    "include.schema.changes": "true",
    "decimal.handling.mode": "double",

    "key.converter":"io.confluent.connect.avro.AvroConverter",
    "key.converter.schema.registry.url":"http://localhost:8070",
    "value.converter":"io.confluent.connect.avro.AvroConverter",
    "value.converter.schema.registry.url":"http://localhost:8070",

    "transforms": "unwrap,addTopicPrefix",
    "transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState",
    "transforms.addTopicPrefix.type":"org.apache.kafka.connect.transforms.RegexRouter",
    "transforms.addTopicPrefix.regex":"(.*)",
    "transforms.addTopicPrefix.replacement":"core-DB2-$1"
  }
}

I tried changing configurations according to this answer, but got the same problem. I also tried using the JDBC connector, which gave errors in creating the connector.


问:
When using x11vnc, how to fix copy Chinese but messy code
I use noVNC as the client, x11VNC as the server

But after copying through the clipboard, there are many messy codes

Image

I want to show Chinese


问:
How to pass and get the data from one component to another while using Link tag on Class based component in React JS?
<Link to={{pathname: "/gateway", state: "hello world"}}></Link>

how to get this "hello world" data in another Class based component?


问:
Combine Explicit and Implicit Join Spring jpa
Is combining explicit and implicit join in spring data jpa causes any performance issues?</p>


问:
Can Liquibase (core and built-in SQLcl) commands be run using Oracle REST JDBC Driver?
I connected my Liquibase to My Oracle (OCI Cloud) Database using REST JDBC driver (https://www.oracle.com/database/sqldeveloper/technologies/db-actions/download/).

I have ORDS and rest enabled schema.

SQLcl Liquibase

I can, without problems, connect to it with SQLcl and run queries (through REST JDBC driver) But, when I try to run, e.g. "lb status" command, I receive an error message "Method getSchema() in ORest connection not supported."

Core Liquibase

In my properties file, I defined "driver: oracle.dbtools.jdbc.Driver", and I have this driver in my liquibase/lib directory. When I run, e.g. "liquibase status" command, I receive an error:

```<code>Unexpected error running Liquibase: oracle/dbtools/http/SessionException
  - Caused by: oracle.dbtools.http.SessionException

java.lang.NoClassDefFoundError: oracle/dbtools/http/SessionException
        at oracle.dbtools.jdbc.Driver.connect(Driver.java:54)
        at liquibase.database.jvm.JdbcConnection.open(JdbcConnection.java:83)
        at com.datical.liquibase.ext.database.jvm.ProJdbcConnection.open(Unknown Source)
        at liquibase.database.ConnectionServiceFactory.create(ConnectionServiceFactory.java:32)
        at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:217)
        at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:178)
        at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:143)
        at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:93)
        at liquibase.integration.commandline.Main.doMigration(Main.java:1484)
        at liquibase.integration.commandline.Main$1.lambda$run$0(Main.java:396)
        at liquibase.Scope.lambda$child$0(Scope.java:180)
        at liquibase.Scope.child(Scope.java:189)
        at liquibase.Scope.child(Scope.java:179)
        at liquibase.Scope.child(Scope.java:158)
        at liquibase.integration.commandline.Main$1.run(Main.java:395)
        at liquibase.integration.commandline.Main$1.run(Main.java:217)
        at liquibase.Scope.child(Scope.java:189)
        at liquibase.Scope.child(Scope.java:165)
        at liquibase.integration.commandline.Main.run(Main.java:217)
        at liquibase.command.AbstractCliWrapperCommandStep.run(AbstractCliWrapperCommandStep.java:33)
        at liquibase.command.CommandScope.execute(CommandScope.java:172)
        at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:55)
        at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:24)
        at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
        at picocli.CommandLine.access$1500(CommandLine.java:148)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
        at picocli.CommandLine.execute(CommandLine.java:2170)
        at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$1(LiquibaseCommandLine.java:352)
        at liquibase.Scope.child(Scope.java:189)
        at liquibase.Scope.child(Scope.java:165)
        at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:317)
        at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:84)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at liquibase.integration.commandline.LiquibaseLauncher.main(LiquibaseLauncher.java:107)
Caused by: java.lang.ClassNotFoundException: oracle.dbtools.http.SessionException
        at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)

</code>```

Body:
I connected my Liquibase to My Oracle (OCI Cloud) Database using REST JDBC driver (https://www.oracle.com/database/sqldeveloper/technologies/db-actions/download/).

I have ORDS and rest enabled schema.

SQLcl Liquibase

I can, without problems, connect to it with SQLcl and run queries (through REST JDBC driver) But, when I try to run, e.g. "lb status" command, I receive an error message "Method getSchema() in ORest connection not supported."

Core Liquibase

In my properties file, I defined "driver: oracle.dbtools.jdbc.Driver", and I have this driver in my liquibase/lib directory. When I run, e.g. "liquibase status" command, I receive an error:

Unexpected error running Liquibase: oracle/dbtools/http/SessionException
  - Caused by: oracle.dbtools.http.SessionException

java.lang.NoClassDefFoundError: oracle/dbtools/http/SessionException
        at oracle.dbtools.jdbc.Driver.connect(Driver.java:54)
        at liquibase.database.jvm.JdbcConnection.open(JdbcConnection.java:83)
        at com.datical.liquibase.ext.database.jvm.ProJdbcConnection.open(Unknown Source)
        at liquibase.database.ConnectionServiceFactory.create(ConnectionServiceFactory.java:32)
        at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:217)
        at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:178)
        at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:143)
        at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:93)
        at liquibase.integration.commandline.Main.doMigration(Main.java:1484)
        at liquibase.integration.commandline.Main$1.lambda$run$0(Main.java:396)
        at liquibase.Scope.lambda$child$0(Scope.java:180)
        at liquibase.Scope.child(Scope.java:189)
        at liquibase.Scope.child(Scope.java:179)
        at liquibase.Scope.child(Scope.java:158)
        at liquibase.integration.commandline.Main$1.run(Main.java:395)
        at liquibase.integration.commandline.Main$1.run(Main.java:217)
        at liquibase.Scope.child(Scope.java:189)
        at liquibase.Scope.child(Scope.java:165)
        at liquibase.integration.commandline.Main.run(Main.java:217)
        at liquibase.command.AbstractCliWrapperCommandStep.run(AbstractCliWrapperCommandStep.java:33)
        at liquibase.command.CommandScope.execute(CommandScope.java:172)
        at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:55)
        at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:24)
        at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
        at picocli.CommandLine.access$1500(CommandLine.java:148)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
        at picocli.CommandLine.execute(CommandLine.java:2170)
        at liquibase.integration.commandline.LiquibaseCommandLine.lambda$execute$1(LiquibaseCommandLine.java:352)
        at liquibase.Scope.child(Scope.java:189)
        at liquibase.Scope.child(Scope.java:165)
        at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:317)
        at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:84)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at liquibase.integration.commandline.LiquibaseLauncher.main(LiquibaseLauncher.java:107)
Caused by: java.lang.ClassNotFoundException: oracle.dbtools.http.SessionException
        at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)


问:
how to edit the elements of a list of dictionaries in python
d={'sym':'A'}

leg = [d for i in range(2)]

for i in range(2):

```<code>leg[i]['sym'] = leg[i]['sym']+str(i)
</code>```

print(leg)

outut: [{'sym': 'A01'}, {'sym': 'A01'}]

Expected output:  [{'sym': 'A0'}, {'sym': 'A1'}]

Body:
d={'sym':'A'}

leg = [d for i in range(2)]

for i in range(2):

leg[i]['sym'] = leg[i]['sym']+str(i)

print(leg)

outut: [{'sym': 'A01'}, {'sym': 'A01'}]

Expected output:  [{'sym': 'A0'}, {'sym': 'A1'}]


问:
Cursor based pagination spec is inefficient
I am looking cursor based pagination https://relay.dev/graphql/connections.htm#ApplyCursorsToEdges()

The ApplyCursorsToEdges function initializes edges to contain all edges.

However, if we are using a database with 1 billion entries in it, it will require us fetching 1 billion edges.

Even if these are column indexes, this is very inefficient.

How do people actually implement cursor based pagination, in a way that is not garbage?


问:
Trying GET request (size: 142mb) and receive the error: 'Failed to allocate a 296011104 byte allocation with 25165824 free' bytes
The error :-

```<code>FATAL EXCEPTION: OkHttp Dispatcher
    Process: com.android.kepr, PID: 11206
    java.lang.OutOfMemoryError: Failed to allocate a 296011104 byte allocation with 25165824 free bytes and 220MB until OOM, target footprint 330823816, growth limit 536870912
        at java.lang.StringFactory.newStringFromUtf8Bytes(Native Method)
        at java.lang.StringFactory.newStringFromBytes(StringFactory.java:80)
        at java.lang.StringFactory.newStringFromBytes(StringFactory.java:101)
        at okio.Buffer.readString(Buffer.kt:313)
        at okio.Buffer.readString(Buffer.kt:302)
        at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.kt:270)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
        at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
</code>```

Size of API

Size of API is 142mb and I have tried every possible thing like cursor allocation of 500mb, etc.
but didn't work.

My question: Is there any possible way to allocate this to it's expected size.

OR

Any alternate solution is appreciated.

My retrofit code:

    if (checkInternetRepository.isNetworkConnected()) {
        try {
            isNotesUnderAssetsData = false

            emit(
                BuildingRoomAssetsViewModel.Action.FetchNotesUnderAssetsDataAPIResponse(
                    buildingRoomAssetsRepository.fetchNotesUnderAssets()
                )
            )

        }

if (state.listAllNotesUnderAssetsTabsData != null) {
    Log.d("listNotesUnderAssets", "" + state.listAllNotesUnderAssetsTabsData)
    AppExecutors.getInstance().diskIO().execute {

            agentDatabase.daoAccess()
                .insertNotesUnderAssetsData(state.listAllNotesUnderAssetsTabsData!!)
        state.listAllNotesUnderAssetsTabsData = null
        buildingRoomAssetsViewModel.sendAction(BuildingRoomAssetsViewModel.Action.CallHistoryVerificationUnderAssetsTabData)
    }
    return@onEach
}`

//Below is my retrofit builder code

` public static ApiInterfaceForAuth getApiInterface(Context context) {
        if (retrofitApi == null) {
            try {
                retrofitApi = new Retrofit.Builder()
                        .baseUrl(CommonStrings.BASE_URL)
//                        .baseUrl(Config.AppMode.LIVE.getServerUrl())
                        .addConverterFactory(GsonConverterFactory.create())
                        .client(httpClient(context).build())
                        .build();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return retrofitApi.create(ApiInterfaceForAuth.class);
    }`

```

Body:
The error :-

FATAL EXCEPTION: OkHttp Dispatcher
    Process: com.android.kepr, PID: 11206
    java.lang.OutOfMemoryError: Failed to allocate a 296011104 byte allocation with 25165824 free bytes and 220MB until OOM, target footprint 330823816, growth limit 536870912
        at java.lang.StringFactory.newStringFromUtf8Bytes(Native Method)
        at java.lang.StringFactory.newStringFromBytes(StringFactory.java:80)
        at java.lang.StringFactory.newStringFromBytes(StringFactory.java:101)
        at okio.Buffer.readString(Buffer.kt:313)
        at okio.Buffer.readString(Buffer.kt:302)
        at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.kt:270)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
        at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)

Size of API

Size of API is 142mb and I have tried every possible thing like cursor allocation of 500mb, etc.
but didn't work.

My question: Is there any possible way to allocate this to it's expected size.

OR

Any alternate solution is appreciated.

My retrofit code:

    if (checkInternetRepository.isNetworkConnected()) {
        try {
            isNotesUnderAssetsData = false

            emit(
                BuildingRoomAssetsViewModel.Action.FetchNotesUnderAssetsDataAPIResponse(
                    buildingRoomAssetsRepository.fetchNotesUnderAssets()
                )
            )

        }

if (state.listAllNotesUnderAssetsTabsData != null) {
    Log.d("listNotesUnderAssets", "" + state.listAllNotesUnderAssetsTabsData)
    AppExecutors.getInstance().diskIO().execute {

            agentDatabase.daoAccess()
                .insertNotesUnderAssetsData(state.listAllNotesUnderAssetsTabsData!!)
        state.listAllNotesUnderAssetsTabsData = null
        buildingRoomAssetsViewModel.sendAction(BuildingRoomAssetsViewModel.Action.CallHistoryVerificationUnderAssetsTabData)
    }
    return@onEach
}`

//Below is my retrofit builder code

` public static ApiInterfaceForAuth getApiInterface(Context context) {
        if (retrofitApi == null) {
            try {
                retrofitApi = new Retrofit.Builder()
                        .baseUrl(CommonStrings.BASE_URL)
//                        .baseUrl(Config.AppMode.LIVE.getServerUrl())
                        .addConverterFactory(GsonConverterFactory.create())
                        .client(httpClient(context).build())
                        .build();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return retrofitApi.create(ApiInterfaceForAuth.class);
    }`