23
23
import java .time .Instant ;
24
24
import java .util .Objects ;
25
25
import java .util .function .Consumer ;
26
- import java .util .function .Function ;
27
26
import java .util .function .Supplier ;
28
27
import software .amazon .awssdk .annotations .SdkInternalApi ;
29
28
import software .amazon .awssdk .annotations .SdkTestInternalApi ;
@@ -44,12 +43,10 @@ public final class ProfileFileRefresher {
44
43
private volatile ProfileFileRefreshRecord currentRefreshRecord ;
45
44
private final Supplier <ProfileFile > profileFile ;
46
45
private final Path profileFilePath ;
47
- private final Function <RuntimeException , ProfileFile > exceptionHandler ;
48
46
private final Consumer <ProfileFile > onProfileFileReload ;
49
47
private final Clock clock ;
50
48
51
49
private ProfileFileRefresher (Builder builder ) {
52
- this .exceptionHandler = builder .exceptionHandler ;
53
50
this .clock = builder .clock ;
54
51
this .profileFile = builder .profileFile ;
55
52
this .profileFilePath = builder .profileFilePath ;
@@ -81,18 +78,7 @@ public ProfileFile refreshIfStale() {
81
78
}
82
79
83
80
private RefreshResult <ProfileFileRefreshRecord > refreshResult () {
84
- try {
85
- return reloadAsRefreshResultIfStale ();
86
- } catch (RuntimeException exception ) {
87
- Instant now = Instant .now ();
88
- ProfileFile exceptionProfileFile = exceptionHandler .apply (exception );
89
- ProfileFileRefreshRecord refreshRecord = ProfileFileRefreshRecord .builder ()
90
- .profileFile (exceptionProfileFile )
91
- .refreshTime (now )
92
- .build ();
93
-
94
- return wrapIntoRefreshResult (refreshRecord , now );
95
- }
81
+ return reloadAsRefreshResultIfStale ();
96
82
}
97
83
98
84
private RefreshResult <ProfileFileRefreshRecord > reloadAsRefreshResultIfStale () {
@@ -156,7 +142,6 @@ public static final class Builder {
156
142
private Supplier <ProfileFile > profileFile ;
157
143
private Path profileFilePath ;
158
144
private Consumer <ProfileFile > onProfileFileReload = p -> { };
159
- private Function <RuntimeException , ProfileFile > exceptionHandler ;
160
145
private Clock clock = Clock .systemUTC ();
161
146
162
147
private Builder () {
@@ -181,15 +166,6 @@ public Builder clock(Clock clock) {
181
166
return this ;
182
167
}
183
168
184
- /**
185
- * @param exceptionHandler Handler which takes action when a Runtime exception occurs while loading a profile file.
186
- * Handler can return a previously stored profile file or throw back the exception.
187
- */
188
- public Builder exceptionHandler (Function <RuntimeException , ProfileFile > exceptionHandler ) {
189
- this .exceptionHandler = exceptionHandler ;
190
- return this ;
191
- }
192
-
193
169
/**
194
170
* Sets a custom action to perform when a profile file is reloaded. This action is executed when both the cache is stale
195
171
* and the disk file associated with the profile file has been modified since the last load.
0 commit comments