Skip to content

Commit

Permalink
fixup: shorten javadoc links, shutdown tasks, use methods refs
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
  • Loading branch information
toddbaert committed Jul 10, 2023
1 parent d8ea14b commit b5c1ab5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/main/java/dev/openfeature/sdk/EventProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void attach(TriConsumer<EventProvider, ProviderEvent, ProviderEventDetails> onEm
}

/**
* Emit the specified {@link dev.openfeature.sdk.ProviderEvent}.
* Emit the specified {@link ProviderEvent}.
*
* @param event The event type
* @param details The details of the event
Expand All @@ -41,7 +41,7 @@ public void emit(ProviderEvent event, ProviderEventDetails details) {
}

/**
* Emit a {@link dev.openfeature.sdk.ProviderEvent#PROVIDER_READY} event.
* Emit a {@link ProviderEvent#PROVIDER_READY} event.
* Shorthand for {@link #emit(ProviderEvent, ProviderEventDetails)}
*
* @param details The details of the event
Expand All @@ -52,7 +52,7 @@ public void emitProviderReady(ProviderEventDetails details) {

/**
* Emit a
* {@link dev.openfeature.sdk.ProviderEvent#PROVIDER_CONFIGURATION_CHANGED}
* {@link ProviderEvent#PROVIDER_CONFIGURATION_CHANGED}
* event. Shorthand for {@link #emit(ProviderEvent, ProviderEventDetails)}
*
* @param details The details of the event
Expand All @@ -62,7 +62,7 @@ public void emitProviderConfigurationChanged(ProviderEventDetails details) {
}

/**
* Emit a {@link dev.openfeature.sdk.ProviderEvent#PROVIDER_STALE} event.
* Emit a {@link ProviderEvent#PROVIDER_STALE} event.
* Shorthand for {@link #emit(ProviderEvent, ProviderEventDetails)}
*
* @param details The details of the event
Expand All @@ -72,7 +72,7 @@ public void emitProviderStale(ProviderEventDetails details) {
}

/**
* Emit a {@link dev.openfeature.sdk.ProviderEvent#PROVIDER_ERROR} event.
* Emit a {@link ProviderEvent#PROVIDER_ERROR} event.
* Shorthand for {@link #emit(ProviderEvent, ProviderEventDetails)}
*
* @param details The details of the event
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/dev/openfeature/sdk/EventSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public void runHandler(Consumer<EventDetails> handler, EventDetails eventDetails
});
}

public void shutdown() {
taskExecutor.shutdown();
}

static class HandlerStore {

private final Map<ProviderEvent, List<Consumer<EventDetails>>> handlerMap;
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/dev/openfeature/sdk/OpenFeatureAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class OpenFeatureAPI implements EventHandling<OpenFeatureAPI> {
private EvaluationContext evaluationContext;
private final List<Hook> apiHooks;
private ProviderRepository providerRepository = new ProviderRepository();
private final EventSupport eventSupport = new EventSupport();
private EventSupport eventSupport = new EventSupport();

protected OpenFeatureAPI() {
apiHooks = new ArrayList<>();
Expand Down Expand Up @@ -119,7 +119,7 @@ public void setProvider(String clientName, FeatureProvider provider) {
this::attachEventProvider,
this::emitReady,
this::detachEventProvider,
this::emitError)
this::emitError);
}
}

Expand Down Expand Up @@ -192,7 +192,7 @@ public void clearHooks() {

public void shutdown() {
providerRepository.shutdown();
// TODO: shutdown events
eventSupport.shutdown();
}

/**
Expand Down Expand Up @@ -268,8 +268,9 @@ void addHandler(String clientName, ProviderEvent event, Consumer<EventDetails> h
* This method is only here for testing as otherwise all tests after the API
* shutdown test would fail.
*/
final void resetProviderRepository() {
final void reset() {
providerRepository = new ProviderRepository();
eventSupport = new EventSupport();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void mustShutdownAllProvidersOnShuttingDownApi() {
verify(namedProvider).shutdown();
});

api.resetProviderRepository();
api.reset();
}
}
}
Expand Down

0 comments on commit b5c1ab5

Please sign in to comment.