Skip to content

LoggingRequestInterceptor does not catch exception in intercepting methods and causes ED indexing failure

  • Call of org.springframework.util.StreamUtils.copyToString in logResponse throws exception which causes that restTemplate and restClient are not able to

  • The request and response against remote flatdb is correct but gets lost because of missing exception handling in LoggingRequestInterceptor

  • HTTP GET http://svko-exploredata-staging.gesis.intra:8088/getElement?study=ZA5100_SU&type=StatementItem&elementid=ZA5100_Construct_Q2 causes ResourceAccessException in ED indexer

      16:02:11.164 [main] DEBUG org.gesis.stardat.ddiflatdb.client.LoggingRequestInterceptor - ===== Request =====
      16:02:11.164 [main] DEBUG org.gesis.stardat.ddiflatdb.client.LoggingRequestInterceptor - URI         : http://svko-exploredata-staging.gesis.intra:8088/getElement?study=ZA5100_SU&type=StatementItem&elementid=ZA5100_Construct_Q2
      16:02:11.164 [main] DEBUG org.gesis.stardat.ddiflatdb.client.LoggingRequestInterceptor - Method      : GET
      16:02:11.164 [main] DEBUG org.gesis.stardat.ddiflatdb.client.LoggingRequestInterceptor - Headers     : {Accept=[application/json, application/*+json], Content-Length=[0]}
      16:02:11.164 [main] DEBUG org.gesis.stardat.ddiflatdb.client.LoggingRequestInterceptor - Request body:
      16:02:13.156 [main] DEBUG org.gesis.stardat.ddiflatdb.client.LoggingRequestInterceptor - ===== Response ====
      16:02:13.156 [main] DEBUG org.gesis.stardat.ddiflatdb.client.LoggingRequestInterceptor - Status code  : 404
      16:02:13.156 [main] DEBUG org.gesis.stardat.ddiflatdb.client.LoggingRequestInterceptor - Status text  : null
      16:02:13.156 [main] DEBUG org.gesis.stardat.ddiflatdb.client.LoggingRequestInterceptor - Headers      : {Content-Length=[0], Date=[Wed, 04 Nov 2020 15:02:13 GMT]}
      Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://svko-exploredata-staging.gesis.intra:8088/getElement": http://svko-exploredata-staging.gesis.intra:8088/getElement?study=ZA5100_SU&type=StatementItem&elementid=ZA5100_Construct_Q2; nested exception is java.io.FileNotFoundException: http://svko-exploredata-staging.gesis.intra:8088/getElement?study=ZA5100_SU&type=StatementItem&elementid=ZA5100_Construct_Q2
          at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:675)
     ...
      Caused by: java.io.FileNotFoundException: http://svko-exploredata-staging.gesis.intra:8088/getElement?study=ZA5100_SU&type=StatementItem&elementid=ZA5100_Construct_Q2
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    ...
      Caused by: java.io.FileNotFoundException: http://svko-exploredata-staging.gesis.intra:8088/getElement?study=ZA5100_SU&type=StatementItem&elementid=ZA5100_Construct_Q2
    ...
          at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:112)
          at org.gesis.stardat.ddiflatdb.client.LoggingRequestInterceptor.intercept(LoggingRequestInterceptor.java:30)
          ... 13 more
  • Status code 404 is actually catched and solved by:

        	catch (HttpStatusCodeException e)
         	{
            	if ( HttpStatus.NOT_FOUND.equals( e.getStatusCode() ) )
           	{
                  	return null;
              	}
              	else
              	{
                     	throw new FlatdbServerException( e );
             	}
       	}
  • Statt dessen wird daraus eine ResourceAccessException, welche in Indexing von ExploreData einen Abbruch erzwingt, obgleich eine Behandlung von Null, wie sie ja eigentlich erfolgen sollte, eingebaut ist, bzw. alle anderen Exceptions nur das aktuelle Element auslassen, der Indexierungsvorgang aber ansonsten fortgeführt wird.

  • Dies passiert bei StatementItem und bisher bei allen Studien, welche ich getestet habe.

  • Der Code bezüglich StatementItem ist seit Anlage von Indexing unverändert.

Edited by Alexander Mühlbauer