Skip to content

Commit fb7d234

Browse files
committed
feat: retry on error with minio client and log okhttp errors
1 parent 1ad2dff commit fb7d234

3 files changed

Lines changed: 245 additions & 96 deletions

File tree

arc-utils/src/main/java/fr/insee/arc/utils/exception/ArcExceptionMessage.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ public enum ArcExceptionMessage {
66

77
FILE_IS_EMPTY("Le fichier %s est vide"),
88
FILE_RENAME_FAILED("Le fichier %s n'a pas pu être renommé vers %s "),
9-
FILE_COPY_FAILED("Le fichier %s n'a pas pu être copié vers %s "),
9+
FILE_S3_OPERATION_FAILED("Erreur operation s3 : %s %s"),
10+
FILE_COPY_FAILED("Le fichier %s n'a pas pu être copié vers %s"),
11+
FILE_COPY_FAILED_RETRY("Le fichier %s n'a pas pu être copié vers %s - RETRY %s"),
1012
FILE_DELETE_FAILED("Le fichier %s n'a pas pu être effacé"),
13+
FILE_DELETE_FAILED_RETRY("Le fichier %s n'a pas pu être effacé - RETRY %s"),
1114
FILE_READ_FAILED("Le fichier %s n'a pas pu être lu"),
1215
FILE_EXTRACT_FAILED("Le fichier archive %s n'a pas pu être extrait"),
1316
FILE_WRITE_FAILED("Le fichier %s n'a pas pu être écrit"),
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package fr.insee.arc.utils.minio;
2+
3+
import java.io.IOException;
4+
5+
import org.apache.logging.log4j.LogManager;
6+
import org.apache.logging.log4j.Logger;
7+
8+
import fr.insee.arc.utils.utils.LoggerHelper;
9+
import okhttp3.Interceptor;
10+
import okhttp3.Response;
11+
12+
public class OkHttpInterceptor implements Interceptor {
13+
14+
private static final Logger LOGGER = LogManager.getLogger(S3Template.class);
15+
16+
17+
public OkHttpInterceptor() {
18+
}
19+
20+
@Override
21+
public Response intercept(Chain chain) throws IOException {
22+
23+
Response response = chain.proceed(chain.request());
24+
25+
if (!response.isSuccessful() && response.code()!=404) {
26+
LoggerHelper.error(LOGGER, "Error okhttp : " + response);
27+
}
28+
29+
return response;
30+
}
31+
32+
}

0 commit comments

Comments
 (0)