Skip to content

Commit 8dac6f3

Browse files
committed
fix null pointer exception when max-prepared-templates is zero
1 parent 38f231b commit 8dac6f3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

embedded-database-spring-test/src/main/java/io/zonky/test/db/provider/common/TemplatingDatabaseProvider.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,11 @@ private TemplateWrapper createTemplateIfPossible(CompositeDatabasePreparer prepa
150150

151151
if (templateCount() >= config.getMaxTemplateCount()) {
152152
TemplateKey templateToRemove = findTemplateToRemove();
153+
if (templateToRemove == null) {
154+
return null;
155+
}
153156
PreparerStats templateToRemoveStats = stats.get(templateToRemove);
154-
if (templateToRemove == null || preparerStats.getTotalLoadTime() < templateToRemoveStats.getTotalLoadTime() + config.getDurationThreshold()) {
157+
if (preparerStats.getTotalLoadTime() < templateToRemoveStats.getTotalLoadTime() + config.getDurationThreshold()) {
155158
return null;
156159
}
157160
oldTemplate = templates.remove(templateToRemove);

0 commit comments

Comments
 (0)