@@ -11380,46 +11380,52 @@ public ModelAndView getView(ExternalSourcesForm form, boolean reshow, BindExcept
1138011380 return new VBox (newView , existingView );
1138111381 }
1138211382
11383+ private static final Object HOST_LOCK = new Object ();
11384+
1138311385 @ Override
1138411386 public boolean handlePost (ExternalSourcesForm form , BindException errors ) throws Exception
1138511387 {
1138611388 List <AllowedHost > allowedHosts = null ;
1138711389
11388- //handle delete of existing value
11389- if ( form . isDelete () )
11390+ // Multiple requests could access this in parallel, so synchronize access, Issue 53457
11391+ synchronized ( HOST_LOCK )
1139011392 {
11391- AllowedHost subToDelete = form .getExistingAllowedHost (errors );
11392- if (errors .hasErrors ())
11393- return false ;
11394- allowedHosts = form .getSavedAllowedHosts ();
11395- var iter = allowedHosts .listIterator ();
11396- while (iter .hasNext ())
11393+ //handle delete of an existing value
11394+ if (form .isDelete ())
1139711395 {
11398- AllowedHost sub = iter .next ();
11399- if (sub .equals (subToDelete ))
11396+ AllowedHost subToDelete = form .getExistingAllowedHost (errors );
11397+ if (errors .hasErrors ())
11398+ return false ;
11399+ allowedHosts = form .getSavedAllowedHosts ();
11400+ var iter = allowedHosts .listIterator ();
11401+ while (iter .hasNext ())
1140011402 {
11401- iter .remove ();
11402- break ;
11403+ AllowedHost sub = iter .next ();
11404+ if (sub .equals (subToDelete ))
11405+ {
11406+ iter .remove ();
11407+ break ;
11408+ }
1140311409 }
1140411410 }
11405- }
11406- //handle updates - clicking on Save button under Existing will save the updated urls
11407- else if (form .isSaveAll ())
11408- {
11409- allowedHosts = form .getExistingAllowedHosts (errors );
11411+ //handle updates - clicking on Save button under Existing will save the updated hosts
11412+ else if (form .isSaveAll ())
11413+ {
11414+ allowedHosts = form .getExistingAllowedHosts (errors );
11415+ if (errors .hasErrors ())
11416+ return false ;
11417+ }
11418+ //save new external value
11419+ else if (form .isSaveNew ())
11420+ {
11421+ allowedHosts = form .validateNewAllowedHost (errors );
11422+ }
11423+
1141011424 if (errors .hasErrors ())
1141111425 return false ;
11412- }
11413- //save new external value
11414- else if (form .isSaveNew ())
11415- {
11416- allowedHosts = form .validateNewAllowedHost (errors );
11417- }
1141811426
11419- if (errors .hasErrors ())
11420- return false ;
11421-
11422- AllowedExternalResourceHosts .saveAllowedHosts (allowedHosts , getUser ());
11427+ AllowedExternalResourceHosts .saveAllowedHosts (allowedHosts , getUser ());
11428+ }
1142311429
1142411430 return true ;
1142511431 }
0 commit comments