You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Felix Meschberger <Fe...@day.com> on 2008/01/08 08:48:23 UTC

Re: svn commit: r609670 - /incubator/sling/trunk/launcher/app/src/main/java/org/apache/sling/launcher/app/Sling.java

Hi Bertrand

I think, if the osgiProp is missing, the StringBuffer should just be
initialized empty. This IMHO is not a failure situation and thus not
warrant an Exception (of course NPE is wrong either, so catching the not
(yet) existing osgiProp is quite correct).

Regards
Felix

Am Montag, den 07.01.2008, 16:26 +0000 schrieb bdelacretaz@apache.org:
> Author: bdelacretaz
> Date: Mon Jan  7 08:26:37 2008
> New Revision: 609670
> 
> URL: http://svn.apache.org/viewvc?rev=609670&view=rev
> Log:
> For SLING-149: fail more gracefully if sling.properties is missing
> 
> Modified:
>     incubator/sling/trunk/launcher/app/src/main/java/org/apache/sling/launcher/app/Sling.java
> 
> Modified: incubator/sling/trunk/launcher/app/src/main/java/org/apache/sling/launcher/app/Sling.java
> URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launcher/app/src/main/java/org/apache/sling/launcher/app/Sling.java?rev=609670&r1=609669&r2=609670&view=diff
> ==============================================================================
> --- incubator/sling/trunk/launcher/app/src/main/java/org/apache/sling/launcher/app/Sling.java (original)
> +++ incubator/sling/trunk/launcher/app/src/main/java/org/apache/sling/launcher/app/Sling.java Mon Jan  7 08:26:37 2008
> @@ -335,7 +335,7 @@
>       *         an error.
>       */
>      private Map<String, String> loadConfigProperties(
> -            Map<String, String> propOverwrite) {
> +            Map<String, String> propOverwrite) throws BundleException {
>          // The config properties file is either specified by a system
>          // property or it is in the same directory as the Felix JAR file.
>          // Try to load it from one of these places.
> @@ -511,8 +511,12 @@
>       * @param prefix The prefix of properties to handle.
>       */
>      private void resolve(Map<String, String> props, String osgiProp,
> -            String prefix) {
> -        StringBuffer prop = new StringBuffer(props.get(osgiProp));
> +            String prefix) throws BundleException {
> +        final String propVal = props.get(osgiProp);
> +        if(propVal == null) {
> +            throw new BundleException(osgiProp + " property is null, Sling.resolve() fails");
> +        }
> +        StringBuffer prop = new StringBuffer(propVal);
>          boolean mod = false;
>          for (Entry<String, String> pEntry : props.entrySet()) {
>              String key = pEntry.getKey();
> 
> 


Re: svn commit: r609670 - /incubator/sling/trunk/launcher/app/src/main/java/org/apache/sling/launcher/app/Sling.java

Posted by Felix Meschberger <fm...@gmail.com>.
Cool. Thanks.

Regards
Felix

Am Dienstag, den 08.01.2008, 10:51 +0100 schrieb Bertrand Delacretaz:
> Hi Felix,
> 
> On Jan 8, 2008 8:48 AM, Felix Meschberger <Fe...@day.com> wrote:
> > ...I think, if the osgiProp is missing, the StringBuffer should just be
> > initialized empty. This IMHO is not a failure situation and thus not
> > warrant an Exception...
> 
> Ok, so in revision 609916 I have changed that code to
> 
>     private void resolve(Map<String, String> props, String osgiProp,
>             String prefix) throws BundleException {
>         final String propVal = props.get(osgiProp);
>         StringBuffer prop = new StringBuffer(propVal == null ? "" : propVal);
> 
> -Bertrand


Re: svn commit: r609670 - /incubator/sling/trunk/launcher/app/src/main/java/org/apache/sling/launcher/app/Sling.java

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Felix,

On Jan 8, 2008 8:48 AM, Felix Meschberger <Fe...@day.com> wrote:
> ...I think, if the osgiProp is missing, the StringBuffer should just be
> initialized empty. This IMHO is not a failure situation and thus not
> warrant an Exception...

Ok, so in revision 609916 I have changed that code to

    private void resolve(Map<String, String> props, String osgiProp,
            String prefix) throws BundleException {
        final String propVal = props.get(osgiProp);
        StringBuffer prop = new StringBuffer(propVal == null ? "" : propVal);

-Bertrand