|
8 | 8 | import io.sentry.protocol.SentryTransaction; |
9 | 9 | import io.sentry.protocol.User; |
10 | 10 | import io.sentry.util.HintUtils; |
11 | | -import java.io.Closeable; |
12 | | -import java.io.IOException; |
13 | 11 | import java.util.ArrayList; |
14 | 12 | import java.util.List; |
15 | 13 | import java.util.Map; |
16 | 14 | import org.jetbrains.annotations.ApiStatus; |
17 | 15 | import org.jetbrains.annotations.NotNull; |
18 | 16 | import org.jetbrains.annotations.Nullable; |
19 | | -import org.jetbrains.annotations.VisibleForTesting; |
20 | 17 |
|
21 | 18 | @ApiStatus.Internal |
22 | | -public final class MainEventProcessor implements EventProcessor, Closeable { |
| 19 | +public final class MainEventProcessor implements EventProcessor { |
23 | 20 |
|
24 | 21 | private final @NotNull SentryOptions options; |
25 | 22 | private final @NotNull SentryThreadFactory sentryThreadFactory; |
26 | 23 | private final @NotNull SentryExceptionFactory sentryExceptionFactory; |
27 | | - private volatile @Nullable HostnameCache hostnameCache = null; |
28 | 24 |
|
29 | 25 | public MainEventProcessor(final @NotNull SentryOptions options) { |
30 | 26 | this.options = options; |
@@ -163,16 +159,7 @@ private void setServerName(final @NotNull SentryBaseEvent event) { |
163 | 159 | } |
164 | 160 |
|
165 | 161 | if (options.isAttachServerName() && event.getServerName() == null) { |
166 | | - ensureHostnameCache(); |
167 | | - if (hostnameCache != null) { |
168 | | - event.setServerName(hostnameCache.getHostname()); |
169 | | - } |
170 | | - } |
171 | | - } |
172 | | - |
173 | | - private void ensureHostnameCache() { |
174 | | - if (hostnameCache == null) { |
175 | | - hostnameCache = options.getHostnameCache(); |
| 162 | + event.setServerName(options.getHostnameCache().getHostname()); |
176 | 163 | } |
177 | 164 | } |
178 | 165 |
|
@@ -271,31 +258,6 @@ private boolean isCachedHint(final @NotNull Hint hint) { |
271 | 258 | return HintUtils.hasType(hint, Cached.class); |
272 | 259 | } |
273 | 260 |
|
274 | | - @Override |
275 | | - public void close() throws IOException { |
276 | | - if (hostnameCache != null) { |
277 | | - hostnameCache.close(); |
278 | | - // Both this processor and the options outlive a restart, so a closed cache left in either |
279 | | - // place would never refresh the hostname again. |
280 | | - hostnameCache = null; |
281 | | - options.resetHostnameCache(); |
282 | | - } |
283 | | - } |
284 | | - |
285 | | - boolean isClosed() { |
286 | | - if (hostnameCache != null) { |
287 | | - return hostnameCache.isClosed(); |
288 | | - } else { |
289 | | - return true; |
290 | | - } |
291 | | - } |
292 | | - |
293 | | - @VisibleForTesting |
294 | | - @Nullable |
295 | | - HostnameCache getHostnameCache() { |
296 | | - return hostnameCache; |
297 | | - } |
298 | | - |
299 | 261 | @Override |
300 | 262 | public @Nullable Long getOrder() { |
301 | 263 | return 0L; |
|
0 commit comments