Unnecessary byte case while reading the attachements
----------------------------------------------------

                 Key: AXIOM-364
                 URL: https://issues.apache.org/jira/browse/AXIOM-364
             Project: Axiom
          Issue Type: Bug
          Components: API
    Affects Versions: 1.2.12
            Reporter: Ivan


In the class org.apache.axiom.attachments.Attachments line 237
--->
while (true) {
            int value;
            try {
                value = pushbackInStream.read();
                if ((byte) value == boundary[0]) {
                    int boundaryIndex = 0;
                    while ((boundaryIndex < boundary.length)
                            && ((byte) value == boundary[boundaryIndex])) {
                        value = pushbackInStream.read();
                        if (value == -1) {
                            throw new OMException(
                                    "Unexpected End of Stream while searching 
for first Mime Boundary");
                        }
                        boundaryIndex++;
                    }
                    if (boundaryIndex == boundary.length) { // boundary found
                        pushbackInStream.read();
                        break;
                    }
                } else if ((byte) value == -1) {  <--- this byte case is 
unnecessary, e.g. if the value is 255, after the cast from int to byte, then 
from byte to int, it will be finally equal to -1
                    throw new OMException(
                            "Mime parts not found. Stream ended while searching 
for the boundary");
                }
            } catch (IOException e1) {
                throw new OMException("Stream Error" + e1.toString(), e1);
            }
        }
<---

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to