Skip to content

Commit 4573e79

Browse files
committed
removes the behaviour of the core not starting in case can't connect to db during license check
1 parent 0762aa3 commit 4573e79

File tree

5 files changed

+4
-45
lines changed

5 files changed

+4
-45
lines changed

ee/src/main/java/io/supertokens/ee/EEFeatureFlag.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void updateEnabledFeaturesValueReadFromDbTime(long newTime) {
7373
}
7474

7575
@Override
76-
public void constructor(Main main) throws StorageQueryException {
76+
public void constructor(Main main) {
7777
this.main = main;
7878
Cronjobs.addCronjob(main, EELicenseCheck.getInstance(main));
7979
try {
@@ -85,12 +85,6 @@ public void constructor(Main main) throws StorageQueryException {
8585
// the license key that was in the db was invalid. If this error is thrown,
8686
// it means that the key was removed from the db anyway.. so we can just ignore
8787
// here.
88-
} catch (StorageQueryException e) {
89-
ProcessState.getInstance(main)
90-
.addState(ProcessState.PROCESS_STATE.INIT_FAILURE_DUE_TO_LICENSE_KEY_DB_CHECK, e);
91-
// we intentionally throw this error so that the core stops
92-
// since we need to know the initial state of the license and features from the db
93-
throw e;
9488
} catch (Throwable ignored) {
9589
}
9690
}

ee/src/test/java/io/supertokens/ee/test/EETest.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -950,36 +950,6 @@ public void testVariousOpaqueKeys()
950950
}
951951
}
952952

953-
@Test
954-
public void testDbQueryOnCoreStartStopsCore()
955-
throws Exception {
956-
String[] args = {"../../"};
957-
958-
{
959-
TestingProcessManager.TestingProcess process = TestingProcessManager.start(args, false);
960-
process.main.waitToEnableFeatureFlag();
961-
process.startProcess();
962-
Thread.sleep(4000);
963-
process.main.deleteAllInformationForTesting();
964-
process.main.proceedToEnableFeatureFlag();
965-
if (StorageLayer.getStorage(process.getProcess()).getType() == STORAGE_TYPE.SQL
966-
&& !Version.getVersion(process.getProcess()).getPluginName().equals("sqlite")) {
967-
ProcessState.EventAndException coreFailure = process.checkOrWaitForEvent(
968-
ProcessState.PROCESS_STATE.INIT_FAILURE);
969-
ProcessState.EventAndException fromEE = process.checkOrWaitForEvent(
970-
ProcessState.PROCESS_STATE.INIT_FAILURE_DUE_TO_LICENSE_KEY_DB_CHECK);
971-
assertNotNull(coreFailure);
972-
assertNotNull(fromEE);
973-
assertEquals(coreFailure.exception.getCause(), fromEE.exception);
974-
} else {
975-
Assert.assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STARTED));
976-
}
977-
978-
process.kill();
979-
Assert.assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STOPPED));
980-
}
981-
}
982-
983953
@Test
984954
public void testThatInvalidOpaqueKeyOnCoreStartCausesNoFeaturesToBeLoaded() throws Exception {
985955
String[] args = {"../../"};

src/main/java/io/supertokens/ProcessState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public enum PROCESS_STATE {
8484
CREATING_NEW_TABLE, SENDING_TELEMETRY, SENT_TELEMETRY, SETTING_ACCESS_TOKEN_SIGNING_KEY_TO_NULL,
8585
PASSWORD_HASH_BCRYPT, PASSWORD_HASH_ARGON, PASSWORD_VERIFY_BCRYPT, PASSWORD_VERIFY_ARGON,
8686
PASSWORD_VERIFY_FIREBASE_SCRYPT, ADDING_REMOTE_ADDRESS_FILTER, LICENSE_KEY_CHECK_NETWORK_CALL,
87-
INVALID_LICENSE_KEY, SERVER_ERROR_DURING_LICENSE_KEY_CHECK_FAIL, INIT_FAILURE_DUE_TO_LICENSE_KEY_DB_CHECK
87+
INVALID_LICENSE_KEY, SERVER_ERROR_DURING_LICENSE_KEY_CHECK_FAIL
8888
}
8989

9090
public static class EventAndException {

src/main/java/io/supertokens/featureflag/EEFeatureFlagInterface.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public interface EEFeatureFlagInterface {
3030
@TestOnly
3131
void updateEnabledFeaturesValueReadFromDbTime(long newTime);
3232

33-
void constructor(Main main) throws StorageQueryException;
33+
void constructor(Main main);
3434

3535
EE_FEATURES[] getEnabledFeatures() throws StorageQueryException;
3636

src/main/java/io/supertokens/featureflag/FeatureFlag.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import com.google.gson.JsonObject;
2020
import io.supertokens.Main;
2121
import io.supertokens.ResourceDistributor;
22-
import io.supertokens.exceptions.QuitProgramException;
2322
import io.supertokens.featureflag.exceptions.InvalidLicenseKeyException;
2423
import io.supertokens.featureflag.exceptions.NoLicenseKeyFoundException;
2524
import io.supertokens.httpRequest.HttpResponseException;
@@ -73,11 +72,7 @@ private FeatureFlag(Main main, String eeFolderPath) throws MalformedURLException
7372

7473
if (eeLayerTemp != null) {
7574
this.eeFeatureFlag = eeLayerTemp;
76-
try {
77-
this.eeFeatureFlag.constructor(main);
78-
} catch (StorageQueryException e) {
79-
throw new QuitProgramException(e);
80-
}
75+
this.eeFeatureFlag.constructor(main);
8176
} else {
8277
eeFeatureFlag = null;
8378
}

0 commit comments

Comments
 (0)