@@ -621,86 +621,86 @@ public void doScope(
621
621
HttpServletResponse response )
622
622
throws IOException , ServletException {
623
623
624
- org .eclipse .jetty .server .Request .addCompletionListener (
625
- baseRequest .getCoreRequest (),
626
- t -> {
627
- try {
628
- // a special hook with direct access to the container instance
629
- // we invoke this only after the normal request processing,
630
- // in order to generate a valid response
631
- if (request .getRequestURI ().startsWith (AH_URL_RELOAD )) {
632
- try {
633
- reloadWebApp ();
634
- log .info ("Reloaded the webapp context: " + request .getParameter ("info" ));
635
- } catch (Exception ex ) {
636
- log .log (Level .WARNING , "Failed to reload the current webapp context." , ex );
637
- }
638
- }
639
- } finally {
640
-
641
- LocalEnvironment env =
642
- (LocalEnvironment ) request .getAttribute (LocalEnvironment .class .getName ());
643
- if (env != null ) {
644
- environments .remove (env );
645
-
646
- // Acquire all of the semaphores back, which will block if any are outstanding.
647
- Semaphore semaphore =
648
- (Semaphore ) env .getAttributes ().get (LocalEnvironment .API_CALL_SEMAPHORE );
649
- try {
650
- semaphore .acquire (MAX_SIMULTANEOUS_API_CALLS );
651
- } catch (InterruptedException ex ) {
652
- Thread .currentThread ().interrupt ();
653
- log .log (
654
- Level .WARNING , "Interrupted while waiting for API calls to complete:" , ex );
655
- }
656
-
657
- try {
658
- ApiProxy .setEnvironmentForCurrentThread (env );
659
-
660
- // Invoke all of the registered RequestEndListeners.
661
- env .callRequestEndListeners ();
662
-
663
- if (apiProxyDelegate instanceof ApiProxyLocal ) {
664
- // If apiProxyDelegate is not instanceof ApiProxyLocal, we are presumably
665
- // running in
666
- // the devappserver2 environment, where the master web server in Python will
667
- // take care
668
- // of logging requests.
669
- ApiProxyLocal apiProxyLocal = (ApiProxyLocal ) apiProxyDelegate ;
670
- String appId = env .getAppId ();
671
- String versionId = env .getVersionId ();
672
- String requestId = DevLogHandler .getRequestId ();
673
-
674
- LocalLogService logService =
675
- (LocalLogService ) apiProxyLocal .getService (LocalLogService .PACKAGE );
676
-
677
- @ SuppressWarnings ("NowMillis" )
678
- long nowMillis = System .currentTimeMillis ();
679
- logService .addRequestInfo (
680
- appId ,
681
- versionId ,
682
- requestId ,
683
- request .getRemoteAddr (),
684
- request .getRemoteUser (),
685
- baseRequest .getTimeStamp () * 1000 ,
686
- nowMillis * 1000 ,
687
- request .getMethod (),
688
- request .getRequestURI (),
689
- request .getProtocol (),
690
- request .getHeader ("User-Agent" ),
691
- true ,
692
- response .getStatus (),
693
- request .getHeader ("Referrer" ));
694
- logService .clearResponseSize ();
624
+ if (baseRequest .getDispatcherType () == DispatcherType .REQUEST ) {
625
+ org .eclipse .jetty .server .Request .addCompletionListener (
626
+ baseRequest .getCoreRequest (),
627
+ t -> {
628
+ try {
629
+ // a special hook with direct access to the container instance
630
+ // we invoke this only after the normal request processing,
631
+ // in order to generate a valid response
632
+ if (request .getRequestURI ().startsWith (AH_URL_RELOAD )) {
633
+ try {
634
+ reloadWebApp ();
635
+ log .info ("Reloaded the webapp context: " + request .getParameter ("info" ));
636
+ } catch (Exception ex ) {
637
+ log .log (Level .WARNING , "Failed to reload the current webapp context." , ex );
638
+ }
639
+ }
640
+ } finally {
641
+
642
+ LocalEnvironment env =
643
+ (LocalEnvironment ) request .getAttribute (LocalEnvironment .class .getName ());
644
+ if (env != null ) {
645
+ environments .remove (env );
646
+
647
+ // Acquire all of the semaphores back, which will block if any are outstanding.
648
+ Semaphore semaphore =
649
+ (Semaphore ) env .getAttributes ().get (LocalEnvironment .API_CALL_SEMAPHORE );
650
+ try {
651
+ semaphore .acquire (MAX_SIMULTANEOUS_API_CALLS );
652
+ } catch (InterruptedException ex ) {
653
+ Thread .currentThread ().interrupt ();
654
+ log .log (
655
+ Level .WARNING , "Interrupted while waiting for API calls to complete:" , ex );
656
+ }
657
+
658
+ try {
659
+ ApiProxy .setEnvironmentForCurrentThread (env );
660
+
661
+ // Invoke all of the registered RequestEndListeners.
662
+ env .callRequestEndListeners ();
663
+
664
+ if (apiProxyDelegate instanceof ApiProxyLocal ) {
665
+ // If apiProxyDelegate is not instanceof ApiProxyLocal, we are presumably
666
+ // running in
667
+ // the devappserver2 environment, where the master web server in Python will
668
+ // take care
669
+ // of logging requests.
670
+ ApiProxyLocal apiProxyLocal = (ApiProxyLocal ) apiProxyDelegate ;
671
+ String appId = env .getAppId ();
672
+ String versionId = env .getVersionId ();
673
+ String requestId = DevLogHandler .getRequestId ();
674
+
675
+ LocalLogService logService =
676
+ (LocalLogService ) apiProxyLocal .getService (LocalLogService .PACKAGE );
677
+
678
+ @ SuppressWarnings ("NowMillis" )
679
+ long nowMillis = System .currentTimeMillis ();
680
+ logService .addRequestInfo (
681
+ appId ,
682
+ versionId ,
683
+ requestId ,
684
+ request .getRemoteAddr (),
685
+ request .getRemoteUser (),
686
+ baseRequest .getTimeStamp () * 1000 ,
687
+ nowMillis * 1000 ,
688
+ request .getMethod (),
689
+ request .getRequestURI (),
690
+ request .getProtocol (),
691
+ request .getHeader ("User-Agent" ),
692
+ true ,
693
+ response .getStatus (),
694
+ request .getHeader ("Referrer" ));
695
+ logService .clearResponseSize ();
696
+ }
697
+ } finally {
698
+ ApiProxy .clearEnvironmentForCurrentThread ();
699
+ }
700
+ }
695
701
}
696
- } finally {
697
- ApiProxy .clearEnvironmentForCurrentThread ();
698
- }
699
- }
700
- }
701
- });
702
+ });
702
703
703
- if (baseRequest .getDispatcherType () == DispatcherType .REQUEST ) {
704
704
Semaphore semaphore = new Semaphore (MAX_SIMULTANEOUS_API_CALLS );
705
705
706
706
LocalEnvironment env =
0 commit comments