You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2014/06/26 12:16:59 UTC

svn commit: r1605723 - /tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java

Author: remm
Date: Thu Jun 26 10:16:59 2014
New Revision: 1605723

URL: http://svn.apache.org/r1605723
Log:
Avoid NPE with storeconfig.

Modified:
    tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java

Modified: tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java?rev=1605723&r1=1605722&r2=1605723&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java (original)
+++ tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java Thu Jun 26 10:16:59 2014
@@ -592,7 +592,7 @@ public class StandardRoot extends Lifecy
     // ----------------------------------------------------------- JMX Lifecycle
     @Override
     protected String getDomainInternal() {
-        return context.getDomain();
+        return (context != null) ? context.getDomain() : null;
     }
 
     @Override



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1605723 - /tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java

Posted by Konstantin Kolinko <kn...@gmail.com>.
2014-06-26 15:40 GMT+04:00 Rémy Maucherat <re...@apache.org>:
> 2014-06-26 13:32 GMT+02:00 Konstantin Kolinko <kn...@gmail.com>:
>
>> What are the circumstances when this NPE happens?
>>
>> StandardRoot.initInternal() throws an IllegalStateException if the
>> context is null. How can it be without a context?
>>
>
> "Avoid NPE with storeconfig": storeconfig creates instances to determine
> default values for properties.

(Just from description.
I do not know, maybe there is already some special processing for this
case in the storeconfig code).

I this case the logic is flawed

1. Even though there is a setter (LifecycleMBeanBase.setDomain()),
this value is not expected to be configured in a configuration file.

2. The default value in this case is not  Globals.DEFAULT_MBEAN_DOMAIN
 (as will be returned by LifecycleMBeanBase.getDomain()  with this
patch),
 but context.getDomain() (for StandardRoot),  parent.getDomain() (for
ContainerBase).

Ultimately it is StandardEngine.getDomainInternal() which returns getName().

So if the Engine has a non-default name,  will there be domain=""
properties written everywhere in the configuration files?

So my expectation is that the "domain" property has to be ignored by
storeconfig.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1605723 - /tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java

Posted by Rémy Maucherat <re...@apache.org>.
2014-06-26 13:32 GMT+02:00 Konstantin Kolinko <kn...@gmail.com>:

> What are the circumstances when this NPE happens?
>
> StandardRoot.initInternal() throws an IllegalStateException if the
> context is null. How can it be without a context?
>

"Avoid NPE with storeconfig": storeconfig creates instances to determine
default values for properties.

Rémy

Re: svn commit: r1605723 - /tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java

Posted by Konstantin Kolinko <kn...@gmail.com>.
2014-06-26 14:16 GMT+04:00  <re...@apache.org>:
> Author: remm
> Date: Thu Jun 26 10:16:59 2014
> New Revision: 1605723
>
> URL: http://svn.apache.org/r1605723
> Log:
> Avoid NPE with storeconfig.
>
> Modified:
>     tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java
>
> Modified: tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java
> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java?rev=1605723&r1=1605722&r2=1605723&view=diff
> ==============================================================================
> --- tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java (original)
> +++ tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java Thu Jun 26 10:16:59 2014
> @@ -592,7 +592,7 @@ public class StandardRoot extends Lifecy
>      // ----------------------------------------------------------- JMX Lifecycle
>      @Override
>      protected String getDomainInternal() {
> -        return context.getDomain();
> +        return (context != null) ? context.getDomain() : null;
>      }


What are the circumstances when this NPE happens?

StandardRoot.initInternal() throws an IllegalStateException if the
context is null. How can it be without a context?

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org