TransactionResponse: getServiceLevel() is ORed and not ANDed

Description

The code in question:

i.e.
if( (request.getWFS().getServiceLevel() | WFSDTO.TRANSACTIONAL ) == 0 ) {

where getServiceLevel() is compared and ORed version against the constant. This makes the statement true as long as getServiceLevel() returns any number except for zero. This is probably not what was intended, but rather a comparison against the ANDed value (so that the parameter is retrieved correctly). Hopefully this patch will resolve this issue:

http://software.e-mats.org/TransactionResponse.java.diff - http://software.e-mats.org/TransactionResponse.java.diff

Which is a diff against the current CVS version that hopefully corrects this.

Environment

None

Activity

Show:
codehaus
April 10, 2015, 3:53 PM

CodeHaus Comment From: dzwiers - Time: Sun, 29 Feb 2004 16:26:22 -0600
---------------------
<p>EXTERNAL MESSAGE:

SUBJECT: Re: <span class="error">&#91;Geoserver-devel&#93;</span> <span class="error">&#91;jira&#93;</span> Created: (<a href="https://jira.codehaus.org/browse/GEOS-102" title="TransactionResponse: getServiceLevel() is ORed and not ANDed" class="issue-link" data-issue-key="GEOS-102"><del>GEOS-102</del></a>) TransactionResponse: getServiceLevel() is ORed and not ANDed

Although the original code had an error, so does your solution.</p>

<p>"if( (request.getWFS().getServiceLevel() &amp; WFSDTO.TRANSACTIONAL ) == 0 ){" would

never work, as WFSDTO.TRANSACTIONAL!=0.

(see equations below).</p>

<p>Use this if you want it to work, use this condition

(request.getWFS().getServiceLevel() &amp; WFSDTO.TRANSACTIONAL ) == WFSDTO.TRANSACTIONAL</p>

<p>4&amp;4 == 4 != 0

6&amp;4 == 4 != 0</p>

<p>Conversely you could use

(~(request.getWFS().getServiceLevel() &amp; WFSDTO.TRANSACTIONAL )) &amp;

WFSDTO.TRANSACTIONAL == 0</p>

<p>4 &amp; 4 == 4

~4 &amp; 4 == 0</p>

<p>6 &amp; 4 == 4

~4 &amp; 4 == 0</p>

<p>Either option will return true iff transactions are allowed. (the first is

faster to compute).</p>

<p>David</p>

<p>Quoting jira@codehaus.org:</p>

codehaus
April 10, 2015, 3:53 PM

CodeHaus Comment From: mats - Time: Sun, 29 Feb 2004 19:37:06 -0600
---------------------
<p>Yes, I misunderstood the line in question (and being a bit late at night), your solution does what was intended. </p>

codehaus
April 10, 2015, 3:53 PM

CodeHaus Comment From: jgarnett - Time: Tue, 2 Mar 2004 12:40:25 -0600
---------------------
<p>Thanks for catching that, nice obvious mistake on my part</p>

Assignee

Unassigned

Reporter

codehaus

Triage

None

Fix versions

Affects versions

Components

Priority

Medium
Configure