@@ -115,15 +115,36 @@ public List<RevocationInfo> validateCertificateNotRevoked(X509Certificate subjec
115115
116116 List <RevocationInfo > revocationInfoList = new ArrayList <>();
117117
118- CheckedSupplier <RevocationInfo > primarySupplier = () -> request (ocspService , subjectCertificate , issuerCertificate , false );
118+ CheckedSupplier <RevocationInfo > primarySupplier = () -> {
119+ try {
120+ return request (ocspService , subjectCertificate , issuerCertificate , false );
121+ } catch (Exception e ) {
122+ createAndAddRevocationInfoToList (e , revocationInfoList );
123+ throw e ;
124+ }
125+ };
119126 OcspService firstFallbackService = ocspService .getFallbackService ();
120- CheckedSupplier <RevocationInfo > firstFallbackSupplier = () -> request (firstFallbackService , subjectCertificate , issuerCertificate , true );
127+ CheckedSupplier <RevocationInfo > firstFallbackSupplier = () -> {
128+ try {
129+ return request (firstFallbackService , subjectCertificate , issuerCertificate , true );
130+ } catch (Exception e ) {
131+ createAndAddRevocationInfoToList (e , revocationInfoList );
132+ throw e ;
133+ }
134+ };
121135 OcspService secondFallbackService = getOcspServiceProvider ().getFallbackService (firstFallbackService .getAccessLocation ());
122136 CheckedSupplier <RevocationInfo > fallbackSupplier ;
123137 if (secondFallbackService == null ) {
124138 fallbackSupplier = firstFallbackSupplier ;
125139 } else {
126- CheckedSupplier <RevocationInfo > secondFallbackSupplier = () -> request (secondFallbackService , subjectCertificate , issuerCertificate , true );
140+ CheckedSupplier <RevocationInfo > secondFallbackSupplier = () -> {
141+ try {
142+ return request (secondFallbackService , subjectCertificate , issuerCertificate , true );
143+ } catch (Exception e ) {
144+ createAndAddRevocationInfoToList (e , revocationInfoList );
145+ throw e ;
146+ }
147+ };
127148 fallbackSupplier = () -> {
128149 try {
129150 return firstFallbackSupplier .get ();
@@ -133,47 +154,28 @@ public List<RevocationInfo> validateCertificateNotRevoked(X509Certificate subjec
133154 // be swallowed, and the second fallback could silently override it with a "good" response.
134155 throw e ;
135156 } catch (Exception e ) {
136- if (e instanceof ResilientUserCertificateOCSPCheckFailedException exception ) {
137- revocationInfoList .addAll ((exception .getValidationInfo ().revocationInfoList ()));
138- } else {
139- revocationInfoList .add (new RevocationInfo (null , Map .ofEntries (
140- Map .entry (RevocationInfo .KEY_OCSP_ERROR , e )
141- )));
142- }
143157 return secondFallbackSupplier .get ();
144158 }
145159 };
146160 }
147161 Decorators .DecorateCheckedSupplier <RevocationInfo > decorateCheckedSupplier = Decorators .ofCheckedSupplier (primarySupplier );
148162 if (retryRegistry != null ) {
149163 Retry retry = retryRegistry .retry (ocspService .getAccessLocation ().toASCIIString ());
150- retry .getEventPublisher ().onError (event -> {
151- Throwable throwable = event .getLastThrowable ();
152- if (throwable == null ) {
153- return ;
154- }
155- createAndAddRevocationInfoToList (throwable , revocationInfoList );
156- });
157164 decorateCheckedSupplier .withRetry (retry );
158165 }
159166 decorateCheckedSupplier .withCircuitBreaker (circuitBreaker )
160- .withFallback (List .of (ResilientUserCertificateOCSPCheckFailedException .class , CallNotPermittedException .class ), e -> {
161- createAndAddRevocationInfoToList (e , revocationInfoList );
162- return fallbackSupplier .get ();
163- });
167+ .withFallback (List .of (ResilientUserCertificateOCSPCheckFailedException .class , CallNotPermittedException .class ), e -> fallbackSupplier .get ());
164168
165169 CheckedSupplier <RevocationInfo > decoratedSupplier = decorateCheckedSupplier .decorate ();
166170
167171 Try <RevocationInfo > result = Try .of (decoratedSupplier ::get );
168172
169173 RevocationInfo revocationInfo = result .getOrElseThrow (throwable -> {
170174 if (throwable instanceof ResilientUserCertificateOCSPCheckFailedException exception ) {
171- revocationInfoList .addAll (exception .getValidationInfo ().revocationInfoList ());
172175 exception .setValidationInfo (new ValidationInfo (subjectCertificate , revocationInfoList ));
173176 return exception ;
174177 }
175178 if (throwable instanceof ResilientUserCertificateRevokedException exception ) {
176- revocationInfoList .addAll (exception .getValidationInfo ().revocationInfoList ());
177179 exception .setValidationInfo (new ValidationInfo (subjectCertificate , revocationInfoList ));
178180 return exception ;
179181 }
0 commit comments