Skip to content

Commit

Permalink
fixes issue with logging memory leak (#726)
Browse files Browse the repository at this point in the history
Co-authored-by: rishabhpoddar <[email protected]>
  • Loading branch information
sattvikc and rishabhpoddar authored Jun 19, 2023
1 parent 94b00f5 commit c7ebc57
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/main/java/io/supertokens/output/Logging.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import io.supertokens.Main;
import io.supertokens.ResourceDistributor;
import io.supertokens.config.Config;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;
import io.supertokens.pluginInterface.LOG_LEVEL;
import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.multitenancy.TenantIdentifier;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;
import io.supertokens.storageLayer.StorageLayer;
import io.supertokens.utils.Utils;
import io.supertokens.webserver.Webserver;
Expand Down Expand Up @@ -174,7 +174,8 @@ public static void error(Main main, TenantIdentifier tenantIdentifier, String er
}
}

public static void error(Main main, TenantIdentifier tenantIdentifier, String message, boolean toConsoleAsWell, Exception e) {
public static void error(Main main, TenantIdentifier tenantIdentifier, String message, boolean toConsoleAsWell,
Exception e) {
try {
if (!Config.getConfig(new TenantIdentifier(null, null, null), main).getLogLevels(main)
.contains(LOG_LEVEL.ERROR)) {
Expand Down Expand Up @@ -220,6 +221,10 @@ public static void stopLogging(Main main) {
if (getInstance(main) == null) {
return;
}
getInstance(main).infoLogger.getLoggerContext().stop();
getInstance(main).errorLogger.getLoggerContext().stop();
getInstance(main).infoLogger.getLoggerContext().getStatusManager().clear();
getInstance(main).errorLogger.getLoggerContext().getStatusManager().clear();
getInstance(main).infoLogger.detachAndStopAllAppenders();
getInstance(main).errorLogger.detachAndStopAllAppenders();
Webserver.getInstance(main).closeLogger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void beforeEach() {
}

@Test
public void testCreating100StorageLayersUsage()
public void testCreating100TenantsAndCheckOnlyOneInstanceOfStorageLayerIsCreated()
throws InterruptedException {
String[] args = {"../"};

Expand Down

0 comments on commit c7ebc57

Please sign in to comment.