[prev in list] [next in list] [prev in thread] [next in thread]
List: openejb-cvs
Subject: tomee git commit: Check if debug logging is enabled, and avoid a NPE
From: jgallimore () apache ! org
Date: 2018-02-28 14:48:52
Message-ID: 3cd61597eafc48f6b1f40983684c1a0d () git ! apache ! org
[Download RAW message or body]
Repository: tomee
Updated Branches:
refs/heads/tomee-1.7.x ed3584cc9 -> 1f8adb75f
Check if debug logging is enabled, and avoid a NPE
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/1f8adb75
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/1f8adb75
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/1f8adb75
Branch: refs/heads/tomee-1.7.x
Commit: 1f8adb75feb825ce9adbea8d618bcb318242c4c5
Parents: ed3584c
Author: Jonathan Gallimore <jon@jrg.me.uk>
Authored: Wed Feb 28 14:48:25 2018 +0000
Committer: Jonathan Gallimore <jon@jrg.me.uk>
Committed: Wed Feb 28 14:48:25 2018 +0000
----------------------------------------------------------------------
.../org/apache/openejb/config/AutoConfig.java | 99 ++++++++++++--------
1 file changed, 61 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/1f8adb75/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java \
b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java \
index cffcf1e..6e960a7 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
@@ -851,7 +851,7 @@ public class AutoConfig implements DynamicDeployer, JndiConstants \
{
containerId = createContainer(containerInfoType, ejbDeployment, \
bean); }
- logger.debug("Setting container ID {0} for bean {0}", containerId, \
bean.getEjbName()); + logger.debug("Setting container ID {0} for bean \
{1}", containerId, bean.getEjbName()); ejbDeployment.setContainerId(containerId);
}
@@ -866,7 +866,7 @@ public class AutoConfig implements DynamicDeployer, JndiConstants \
{ }
if (!containerIds.contains(ejbDeployment.getContainerId()) && \
!skipMdb(bean)) {
- logger.debug("Desired container {0} not found. Containers availble: \
{1}. Creating a new container.", + logger.debug("Desired container {0} \
not found. Containers available: {1}. Creating a new container.", \
ejbDeployment.getContainerId(), Join.join(", ", containerIds)
);
@@ -2216,51 +2216,66 @@ public class AutoConfig implements DynamicDeployer, \
JndiConstants { }
private String getUsableContainer(final Class<? extends ContainerInfo> \
containerInfoType, final EnterpriseBean bean, final AppResources \
appResources) {
- logger.debug("Searching for usable container for bean: {0}. Available \
application containers: {1}, available system containers {2}",
- bean.getEjbName(),
- getContainerIds(appResources.getContainerInfos()),
- getContainerIds(configFactory.getContainerInfos())
- );
+ if (logger.isDebugEnabled()) {
+ logger.debug("Searching for usable container for bean: {0}. Available \
application containers: {1}, available system containers {2}", + \
bean.getEjbName(), + \
getContainerIds(appResources.getContainerInfos()), + \
getContainerIds(configFactory.getContainerInfos()) + );
+ }
if (MessageDrivenBean.class.isInstance(bean)) {
final MessageDrivenBean messageDrivenBean = (MessageDrivenBean) bean;
final String messagingType = messageDrivenBean.getMessagingType();
final List<String> containerIds = \
appResources.containerIdsByType.get(messagingType);
- logger.debug("Searching for usable container for bean: {0} by messaging \
type: {1}. Potential application containers: {2}",
- bean.getEjbName(),
- messagingType,
- Join.join(",", containerIds));
+ if (logger.isDebugEnabled()) {
+ logger.debug("Searching for usable container for bean: {0} by \
messaging type: {1}. Potential application containers: {2}", + \
bean.getEjbName(), + messagingType,
+ containerIds == null ? "" : Join.join(",", containerIds));
+ }
if (containerIds != null && !containerIds.isEmpty()) {
- logger.debug("Returning first application container matching by \
type: {0} - {1}",
- messagingType,
- containerIds.get(0));
+ if (logger.isDebugEnabled()) {
+ logger.debug("Returning first application container matching by \
type: {0} - {1}", + messagingType,
+ containerIds.get(0));
+ }
return containerIds.get(0);
}
}
- logger.debug("Attempting to find a matching container for bean: {0} from \
application containers {1}",
- bean.getEjbName(),
- getContainerIds(appResources.getContainerInfos()));
+ if (logger.isDebugEnabled()) {
+ logger.debug("Attempting to find a matching container for bean: {0} from \
application containers {1}", + bean.getEjbName(),
+ getContainerIds(appResources.getContainerInfos()));
+ }
String containerInfo = matchContainer(containerInfoType, bean, \
appResources.getContainerInfos());
if (containerInfo == null) { // avoid to build \
configFactory.getContainerInfos() if not needed
- logger.debug("Matching application container not found. Attempting to \
find a matching container for bean: {0} from system containers {1}",
- bean.getEjbName(),
- getContainerIds(appResources.getContainerInfos()));
+ if (logger.isDebugEnabled()) {
+ logger.debug("Matching application container not found. Attempting \
to find a matching container for bean: {0} from system containers {1}", + \
bean.getEjbName(), + \
getContainerIds(appResources.getContainerInfos())); + }
containerInfo = matchContainer(containerInfoType, bean, \
configFactory.getContainerInfos()); }
if (containerInfo != null) {
- logger.debug("Using container {0} for bean {1}", containerInfo, \
bean.getEjbName()); + if (logger.isDebugEnabled()) {
+ logger.debug("Using container {0} for bean {1}", containerInfo, \
bean.getEjbName()); + }
return containerInfo;
}
- logger.debug("No suitable existing container found for bean {0}", \
bean.getEjbName()); + if (logger.isDebugEnabled()) {
+ logger.debug("No suitable existing container found for bean {0}", \
bean.getEjbName()); + }
+
return null;
}
@@ -2283,34 +2298,42 @@ public class AutoConfig implements DynamicDeployer, \
JndiConstants {
final String messagingType = \
messageDrivenBean.getMessagingType();
if \
(containerInfo.properties.get("MessageListenerInterface").equals(messagingType)) \
{
- logger.debug("Container {0} matches container type {1} and \
MessageListenerInterface {2} for bean {3}, this container will be \
used.",
- containerInfo.id,
- containerInfoType.getName(),
- messagingType,
- bean.getEjbName());
+ if (logger.isDebugEnabled()) {
+ logger.debug("Container {0} matches container type {1} \
and MessageListenerInterface {2} for bean {3}, this container will be used.", + \
containerInfo.id, + containerInfoType.getName(),
+ messagingType,
+ bean.getEjbName());
+ }
return containerInfo.id;
} else {
- logger.debug("Container {0} of type {1} does not have the \
matching MessageListenerInterface. Bean listener interface is {2}, " \
+
- "container listener interface is {3} for \
bean {4}. Skipping.", + if (logger.isDebugEnabled()) {
+ logger.debug("Container {0} of type {1} does not have \
the matching MessageListenerInterface. Bean listener interface is {2}, " + + \
"container listener interface is {3} for bean {4}. Skipping.", + \
containerInfo.id, + containerInfoType.getName(),
+ messagingType,
+ \
containerInfo.properties.get("MessageListenerInterface"), + \
bean.getEjbName()); + }
+
+ }
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Container {0} matches container type {1} for \
bean {2}, this container will be used.", containerInfo.id,
containerInfoType.getName(),
- messagingType,
- \
containerInfo.properties.get("MessageListenerInterface"), bean.getEjbName());
-
}
- } else {
- logger.debug("Container {0} matches container type {1} for bean \
{2}, this container will be used.",
- containerInfo.id,
- containerInfoType.getName(),
- bean.getEjbName());
return containerInfo.id;
}
}
- logger.debug("Skipping container {0} of type {1}", containerInfo.id, \
containerInfoType.getName()); + if (logger.isDebugEnabled()) {
+ logger.debug("Skipping container {0} of type {1}", containerInfo.id, \
containerInfoType.getName()); + }
}
return null;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic