exception during EXISTS in DPML if

Poster Content
nk4um Moderator
Posts: 901
June 20, 2013 12:04

Hi Menzo - the DPML update is available in the apposite repositories now.

Cheers,

P.

Like · Post Reply
nk4um User
Posts: 111
June 19, 2013 14:20

Great Tony, many thanks in advance!

Menzo

Like · Post Reply
nk4um Administrator
Posts: 607
June 19, 2013 14:09

Hi Menzo, I agree with you. The exception going missing is the biggest problem for me - the number of times I've criticised other code for doing that, it would be hypocritical of me to allow the same to happen.

We'll get this sorted. Thanks for reporting.

Like · Post Reply
nk4um User
Posts: 111
June 19, 2013 14:01

Hi, Tony,

The problem is that the exception is completely unrelated to the (non) existence of the resource. In this case its debugging going wrong, but it could be a database connection failing or whatever. And you wouldn't notice as the exception disappears along the way ... So I would like to see the exception and only get true/false if the EXIST worked out properly.

Cheers,

Menzo

Like · Post Reply
nk4um Administrator
Posts: 607
June 19, 2013 13:53

Hi Menzo,

yes this is a feature. :-) That is the way it was designed at least. Now I'm not 100% convinced that is the best design . I think the rationale is that if you test if something exists and you get an error then it probably doesn't exist. What do you think?

This is the DPML source code:

catch (NKFException e)
{   if (mVerb==INKFRequestReadOnly.VERB_EXISTS)
    {   returnnew ValueImpl(Boolean.FALSE,new MetaImpl(ExpiryFactory.getDependentExpiry()));
    }
    else
    {   throw e;
    }
}       

Cheers, Tony

Like · Post Reply
nk4um User
Posts: 111
June 19, 2013 13:42exception during EXISTS in DPML if

Hi, All,

I get the following erroneous, I think, behavior. I've tried to isolate the steps. I've a DPML that checks if an user exists, if so retrieve the user info and otherwise create the user. This boils down to something like this:

<sequence>
  <if>
    <cond>
      <request>
        <verb>EXISTS</verb>
        <identifier>active:test-check</identifier>
      </request>
    </cond>
    <then>
      <request>
        <identifier>active:dpml</identifier>
        <argumentname="operator">test-inner.dpml</argument>
      </request>
    </then>
    <else>
      <log>
        <level>INFO</level>
        <message>
          <literaltype="string">ERROR: shouldn't come here!</literal>
        </message>
      </log>
    </else>
  </if>
</sequence>

If the EXISTS active:test-check fails and throws an exception, e.g., using this script which tries to dump some debug info to a non-existing directory:

<sequence>
  <!-- some debug dump to a non-existing director ... will raise an exception -->
  <request>
    <verb>SINK</verb>
    <identifier>res:/void/test.xml</identifier>
    <argumentname="primary">
      <literaltype="xml">
        <hello>world</hello>
      </literal>
    </argument>
  </request>
</sequence>

One doesn't get an exception, instead the if goes into the else branch and you get

I 15:30:26 LogAccessor   ERROR: shouldn't come here!
on your console. This looks like a bug to me.

Do notice that if I use

<cond>
  <request>
    <!--<verb>EXISTS</verb>-->
    <identifier>active:test-check</identifier>
  </request>
</cond>
I do get the exception. Can an EXISTS never throw an exception and falls back to false? Maybe that's a feature and not a bug?

Thanks in advance,

Menzo

Like · Post Reply