New and Improved 3.13 Beta. Highlights: Shareable filters and dashboards and lots of other goodies. Any feedback can be raised as JIRA issues in the JIRA project.
Issue Details (XML | Word | Printable)

Key: JRA-10601
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Dushan Hanuska [Atlassian]
Reporter: Yuen-Chi Lian [Atlassian]
Votes: 2
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
JIRA

XML-RPC to fix/improve String casting

Created: 13/Jul/06 11:46 AM   Updated: 04/Nov/07 09:59 PM
Component/s: Remote API (SOAP & XML-RPC)
Affects Version/s: None
Fix Version/s: 3.6.4

Time Tracking:
Original Estimate: Not Specified
Remaining Estimate: 0 minutes
Time Spent - 1 hour
Time Spent: 1 hour
Time Spent - 1 hour

File Attachments: 1. GZip Archive com.atlassian.jira.rpc.xmlrpc.tar.gz (7 kB)

Issue Links:
Reference
 

Participants: Dushan Hanuska [Atlassian], Jeff Turner [Atlassian], Ted Pietrzak and Yuen-Chi Lian [Atlassian]
Since last comment: 1 year, 48 weeks, 3 days ago
Resolution Date: 21/Jul/06 01:11 AM
Labels:


 Description  « Hide
The current XML-RPC (JiraXmlRpcService) does not do type-checking before casting an Object to String, e.g.
private RemoteCustomFieldValue makeCustomFieldValue(Hashtable struct) throws IllegalAccessException, InvocationTargetException
{
  RemoteCustomFieldValue customFieldValue = new RemoteCustomFieldValue();
  customFieldValue.setCustomfieldId((String) struct.get("customfieldId"));
  customFieldValue.setKey((String) struct.get("key"));
  customFieldValue.setValues(makeStringVector((Vector) struct.get("values")));
  return customFieldValue;
}

private String[] makeStringVector(Vector vector)
{
  final String[] strings = new String[vector.size()];
  int i = 0;
  for (Iterator iterator = vector.iterator(); iterator.hasNext();)
  {
    Object j = iterator.next();
    strings[i] = (String) j;
    i++;
  }
  return strings;
}

This should not be a problem, however, say, if a client is using Perl's XMLRPC::Lite, a string-type integer will be converted to and sent as integer-type, e.g.

...
<name>customFieldValues</name>
  <value>
    <array>
      <data>
        <value>
        <value>
          <struct>
            <member>
              <name>customfieldId</name>
              <value>
                <string>customfield_10100</string>
              </value>
            </member>
            <member>
              <name>values</name>
              <value>
                <array>
                  <data>
                    <value>
                      <int>10194</int>
                    </value>
                  </data>
                </array>
              </value>
            </member>
            <member>
              <name>key</name>
              <value>
                <int>1</int>
              </value>
            </member>
          </struct>
        </value>
      </data>
    </array>
  </value>
</member>
...

The client will then receive an InfraStructureException.

There should be type checking before casting, if it is not a String object, use the toString() function.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Yuen-Chi Lian [Atlassian] added a comment - 18/Jul/06 06:16 PM
Attached Java classes and source.

Cheers,
Yuen-Chi


Ted Pietrzak added a comment - 20/Jul/06 09:50 AM
Yuen-Chi,
Are the attached classes meant to be a patch?

Ted


Yuen-Chi Lian [Atlassian] added a comment - 20/Jul/06 10:46 PM
Hello Ted,

They work fine on mine. You can try replacing the files in the JAR file with these.


Cheers,
Yuen-Chi Lian

"I do not seek. I find." - Pablo Picasso


Jeff Turner [Atlassian] added a comment - 23/Aug/06 02:06 AM
Did Perl used to fail? If so, what did the error look like?

Ted Pietrzak added a comment - 23/Aug/06 09:35 AM
Jeff,
Yes...for cascading selects, Perl fails without this patch. The error returned is as follows:

java.lang.Exception: com.atlassian.jira.InfrastructureException: Could not create RemoteIssue from struct

There is a slightly more detailed discussion in this thread: http://forums.atlassian.com/thread.jspa?threadID=12150&tstart=105

Cheers,
Ted


Yuen-Chi Lian [Atlassian] added a comment - 25/Sep/06 08:43 AM
Perl will not fail if we explicitly set the type, e.g. SOAP::Data->type(string => "10010"). Auto-Typing is the culprit anyway.

Regards,
Yuen-Chi