Refactor tidy error and log messages - part 2

This commit is contained in:
Rob Bygrave committed 2022-08-27 17:15:08 +12:00
1 parent e51ac7de36
commit e3e30cafdd
8 files changed
+7 -25

No files matched your search

@@ -16,7 +16,6 @@ import static java.lang.System.Logger.Level.ERROR;
final class DbContext { final class DbContext {
private static final System.Logger log = EbeanVersion.log; private static final System.Logger log = EbeanVersion.log;
static { static {
EbeanVersion.getVersion(); EbeanVersion.getVersion();
} }
@@ -24,14 +23,9 @@ final class DbContext {
private static final DbContext INSTANCE = new DbContext(); private static final DbContext INSTANCE = new DbContext();
private final ConcurrentHashMap<String, Database> concMap = new ConcurrentHashMap<>(); private final ConcurrentHashMap<String, Database> concMap = new ConcurrentHashMap<>();
private final HashMap<String, Database> syncMap = new HashMap<>(); private final HashMap<String, Database> syncMap = new HashMap<>();
private final ReentrantLock lock = new ReentrantLock(); private final ReentrantLock lock = new ReentrantLock();
/**
* The 'default' Database.
*/
private Database defaultDatabase; private Database defaultDatabase;
private DbContext() { private DbContext() {
@@ -70,9 +64,9 @@ final class DbContext {
*/ */
Database getDefault() { Database getDefault() {
if (defaultDatabase == null) { if (defaultDatabase == null) {
String msg = "The default Database has not been defined?"; String msg = "The default Database has not been defined?"
msg += " This is normally set via the ebean.datasource.default property."; + " This is normally set via the ebean.datasource.default property."
msg += " Otherwise it should be registered programmatically via registerServer()"; + " Otherwise it should be registered programmatically via registerServer()";
throw new PersistenceException(msg); throw new PersistenceException(msg);
} }
return defaultDatabase; return defaultDatabase;
@@ -122,9 +122,7 @@ public final class ShutdownManager {
// Already run shutdown... // Already run shutdown...
return; return;
} }
if (log.isLoggable(DEBUG)) { log.log(DEBUG, "Ebean shutting down");
log.log(DEBUG, "Ebean shutting down");
}
stopping = true; stopping = true;
deregisterShutdownHook(); deregisterShutdownHook();
@@ -117,7 +117,7 @@ public final class LoadManyRequest extends LoadRequest {
if (log.isLoggable(DEBUG)) { if (log.isLoggable(DEBUG)) {
EntityBean ownerBean = bc.getOwnerBean(); EntityBean ownerBean = bc.getOwnerBean();
Object parentId = desc.getId(ownerBean); Object parentId = desc.getId(ownerBean);
log.log(DEBUG, "BeanCollection after lazy load was empty. type:" + ownerBean.getClass().getName() + " id:" + parentId + " owner:" + ownerBean); log.log(DEBUG, "BeanCollection after lazy load was empty. type:{0} id:{1} owner:{2}", ownerBean.getClass().getName(), parentId, ownerBean);
} }
} else if (loadCache && many.isUseCache()) { } else if (loadCache && many.isUseCache()) {
desc.cacheManyPropPut(many, bc, desc.getId(bc.getOwnerBean())); desc.cacheManyPropPut(many, bc, desc.getId(bc.getOwnerBean()));
@@ -110,7 +110,7 @@ final class DefaultBeanLoader {
if (beanCollection != null) { if (beanCollection != null) {
if (beanCollection.checkEmptyLazyLoad()) { if (beanCollection.checkEmptyLazyLoad()) {
if (log.isLoggable(DEBUG)) { if (log.isLoggable(DEBUG)) {
log.log(DEBUG, "BeanCollection after load was empty. Owner:" + beanCollection.getOwnerBean()); log.log(DEBUG, "BeanCollection after load was empty. Owner:{0}", beanCollection.getOwnerBean());
} }
} else if (useManyIdCache) { } else if (useManyIdCache) {
parentDesc.cacheManyPropPut(many, beanCollection, parentId); parentDesc.cacheManyPropPut(many, beanCollection, parentId);
@@ -207,7 +207,7 @@ public class BootupClasses implements Predicate<Class<?>> {
try { try {
return cls.getConstructor().newInstance(); return cls.getConstructor().newInstance();
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
log.log(DEBUG, "Ignore/expected - no default constructor: " + e.getMessage()); log.log(DEBUG, "Ignore/expected - no default constructor: {0}", e.getMessage());
return null; return null;
} catch (Exception e) { } catch (Exception e) {
@@ -868,11 +868,6 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
if (possibleLower.contains(searchName)) { if (possibleLower.contains(searchName)) {
// we have a match // we have a match
prop.setMappedBy(possibleMappedBy); prop.setMappedBy(possibleMappedBy);
if (log.isLoggable(DEBUG)) {
String m = "Implicitly found mappedBy for " + targetDesc + "." + prop;
m += " by searching for [" + searchName + "] against " + matchSet;
log.log(DEBUG, m);
}
return true; return true;
} }
} }
@@ -1,13 +1,10 @@
package io.ebeaninternal.server.deploy; package io.ebeaninternal.server.deploy;
import io.ebeaninternal.api.CoreLog;
import io.ebeaninternal.server.core.InternString; import io.ebeaninternal.server.core.InternString;
import io.ebeaninternal.server.deploy.meta.DeployBeanTable; import io.ebeaninternal.server.deploy.meta.DeployBeanTable;
import io.ebeaninternal.server.deploy.meta.DeployTableJoin; import io.ebeaninternal.server.deploy.meta.DeployTableJoin;
import io.ebeaninternal.server.deploy.meta.DeployTableJoinColumn; import io.ebeaninternal.server.deploy.meta.DeployTableJoinColumn;
import static java.lang.System.Logger.Level.DEBUG;
/** /**
* Used for associated beans in place of a BeanDescriptor. This is done to avoid * Used for associated beans in place of a BeanDescriptor. This is done to avoid
@@ -107,7 +104,6 @@ public final class BeanTable {
if (complexKey) { if (complexKey) {
// just to copy the column name rather than prefix with the foreignKeyPrefix. // just to copy the column name rather than prefix with the foreignKeyPrefix.
// I think that with complex keys this is the more common approach. // I think that with complex keys this is the more common approach.
CoreLog.internal.log(DEBUG, "On table[{0}] foreign key column [{1}]", baseTable, lc);
fk = lc; fk = lc;
} }
if (sqlFormulaSelect != null) { if (sqlFormulaSelect != null) {
@@ -28,7 +28,6 @@ public final class DefaultBackgroundExecutor implements SpiBackgroundExecutor {
this.schedulePool = new DaemonScheduleThreadPool(schedulePoolSize, shutdownWaitSeconds, namePrefix + "-periodic-"); this.schedulePool = new DaemonScheduleThreadPool(schedulePoolSize, shutdownWaitSeconds, namePrefix + "-periodic-");
this.pool = new DaemonExecutorService(shutdownWaitSeconds, namePrefix); this.pool = new DaemonExecutorService(shutdownWaitSeconds, namePrefix);
this.wrapper = wrapper; this.wrapper = wrapper;
log.log(DEBUG, "Created backgroundExecutor {0} (schedulePoolSize={1}, shutdownWaitSeconds={2})", namePrefix, schedulePoolSize, shutdownWaitSeconds);
} }
/** /**