Skip to content

Commit 04a9fb3

Browse files
author
Rishabh
committed
fixes null pointer exception in last PR
1 parent 14a8696 commit 04a9fb3

File tree

1 file changed

+7
-4
lines changed
  • src/main/java/io/supertokens/storage/postgresql

1 file changed

+7
-4
lines changed

src/main/java/io/supertokens/storage/postgresql/Start.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ public <T> T startTransaction(TransactionLogic<T> logic)
168168
} else if (e instanceof StorageTransactionLogicException) {
169169
actualException = ((StorageTransactionLogicException) e).actualException;
170170
}
171+
String exceptionMessage = actualException.getMessage();
172+
if (exceptionMessage == null) {
173+
exceptionMessage = "";
174+
}
171175
// see: https://github.com/supertokens/supertokens-postgresql-plugin/pull/3
172176

173177
// We set this variable to the current (or cause) exception casted to PSQLException if we can safely
@@ -184,12 +188,11 @@ public <T> T startTransaction(TransactionLogic<T> logic)
184188
// We could get here if the new logic hits a false negative, e.g., in case someone renamed
185189
// constraints/tables
186190
boolean isDeadlockException = actualException instanceof SQLTransactionRollbackException
187-
|| actualException.getMessage().toLowerCase().contains("concurrent update") || actualException
188-
.getMessage().toLowerCase().contains("the transaction might succeed if retried")
189-
||
191+
|| exceptionMessage.toLowerCase().contains("concurrent update")
192+
|| exceptionMessage.toLowerCase().contains("the transaction might succeed if retried") ||
190193

191194
// we have deadlock as well due to the DeadlockTest.java
192-
actualException.getMessage().toLowerCase().contains("deadlock");
195+
exceptionMessage.toLowerCase().contains("deadlock");
193196

194197
if ((isPSQLRollbackException || isDeadlockException) && tries < 3) {
195198
try {

0 commit comments

Comments
 (0)