- 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
No longer block the tomcat thread when waiting for import or export (servlet 3.0+ AsyncContext) #695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…er the computations This requires to reorganize the code and the transactions the fully load the data, hence the changes in NetworkModificationRepository with the new intermediate methods. Add testInsertCompositeModifications for symmetry with other code paths duplicate/move/ in the switch/case of ModificationController ?action=...
…pool for large modifications)
5afdbb3    to
    a72ef8d      
    Compare
  
    …servlet 3.0+ AsyncContext) Add no timeout configuration to behave like before this change Spring forces us to adapt the tests with boilerplate code (asyncStarted() and asyncDispatch()) as per https://docs.spring.io/spring-framework/reference/testing/mockmvc/hamcrest/async-requests.html to mimic the servlet 3.0 redispatch Add more andReturn and assignement to variables to avoid potential mistakes The two mvc result represent the same request, inside they hold the same request/response objects, but some other fields are different (asyncResult for example) and tests may be unreliable if they use the first one (representing the state before the async split)
a72ef8d    to
    79b4b61      
    Compare
  
    3449380    to
    fb438ca      
    Compare
  
    | example of parallel schedule in NetworkModificationService (drop in replacement in scheduleApplyModifications) private static CompletableFuture<Void> scheduleApplyModifications(
        Function<ModificationApplicationContext, CompletableFuture<Optional<NetworkModificationResult>>> func,
        List<ModificationApplicationContext> applicationContexts,
        List<CompletableFuture<Optional<NetworkModificationResult>>> results) {
    return CompletableFuture.completedFuture(null).thenCompose(unused -> {
        for (ModificationApplicationContext applicationContext : applicationContexts) {
            var cf = func.apply(applicationContext);
            results.add(cf);
        }
        return CompletableFuture.allOf(results.toArray(new CompletableFuture[0]));
    });
}Behaves the same with respect to exceptions (completes execeptionally, doesn't throw) | 
621c489    to
    7d5828e      
    Compare
  
    3733c57    to
    8cd1350      
    Compare
  
    | when waiting for import or export ? | 
8cd1350    to
    a893a61      
    Compare
  
    a893a61    to
    1b3984d      
    Compare
  
    | } | ||
| } | ||
|  | ||
| public NetworkModificationResult applyModificationsBlocking(ModificationApplicationGroup modificationInfosGroup, NetworkInfos networkInfos) { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this code in a test class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch thanks
| 
 | 



No longer block the tomcat thread when waiting for import or export (servlet 3.0+ AsyncContext)
Add no timeout configuration to behave like before this change
Spring forces us to adapt the tests with boilerplate code (asyncStarted() and asyncDispatch()) as per
https://docs.spring.io/spring-framework/reference/testing/mockmvc/hamcrest/async-requests.html
to mimic the servlet 3.0 redispatch
We avoid to store the return of the first perform in an MvcResult variable to avoid confusion (
The two mvc result represent the same request, inside they hold the same request/response
objects, but some other fields are different (asyncResult for example) and tests may
be unreliable if they use the first one (representing the state before the async split)
)