Bug 613216

Summary: Python API crashes when it handles messages with content-type "text/plain" and empty content
Product: Red Hat Enterprise MRG Reporter: Ted Ross <tross>
Component: python-qpidAssignee: Rafael H. Schloming <rafaels>
Status: CLOSED CURRENTRELEASE QA Contact: MRG Quality Engineering <mrgqe-bugs>
Severity: medium Docs Contact:
Priority: high    
Version: DevelopmentCC: jross, rafaels, tross
Target Milestone: 1.3   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 613647 613648 (view as bug list) Environment:
Last Closed: 2013-02-25 10:46:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 613647, 613648    

Description Ted Ross 2010-07-10 03:44:56 UTC
Description of problem:

The Python API can't send or receive a message with content-type "text/plain" if the content length is zero.

Version-Release number of selected component (if applicable):

MRG1.3 beta4

How reproducible:

100%

Steps to Reproduce:

Use the following Python script:

>>> from qpid.messaging import Connection,Message
>>> conn = Connection("localhost")
>>> conn.open()
>>> sess = conn.session()
>>> xmt = sess.sender("amq.direct/key")
>>> m = Message()
>>> m.content_type = "text/plain"
>>> xmt.send(m)
  
Actual results:

Stack trace:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 6, in send
  File "/home/ross/svn5/qpid/python/qpid/messaging/endpoints.py", line 858, in send
    self.sync()
  File "<string>", line 6, in sync
  File "/home/ross/svn5/qpid/python/qpid/messaging/endpoints.py", line 869, in sync
    if not self._ewait(lambda: self.acked >= mno, timeout=timeout):
  File "/home/ross/svn5/qpid/python/qpid/messaging/endpoints.py", line 783, in _ewait
    result = self.session._ewait(lambda: self.error or predicate(), timeout)
  File "/home/ross/svn5/qpid/python/qpid/messaging/endpoints.py", line 550, in _ewait
    result = self.connection._ewait(lambda: self.error or predicate(), timeout)
  File "/home/ross/svn5/qpid/python/qpid/messaging/endpoints.py", line 194, in _ewait
    self.check_error()
  File "/home/ross/svn5/qpid/python/qpid/messaging/endpoints.py", line 187, in check_error
    raise self.error
qpid.messaging.exceptions.InternalError: Traceback (most recent call last):
  File "/home/ross/svn5/qpid/python/qpid/messaging/driver.py", line 468, in dispatch
    self.engine.dispatch()
  File "/home/ross/svn5/qpid/python/qpid/messaging/driver.py", line 757, in dispatch
    self.process(ssn)
  File "/home/ross/svn5/qpid/python/qpid/messaging/driver.py", line 977, in process
    self.send(snd, msg)
  File "/home/ross/svn5/qpid/python/qpid/messaging/driver.py", line 1188, in send
    body = enc(msg.content)
  File "/home/ross/svn5/qpid/python/qpid/messaging/message.py", line 56, in <lambda>
    "text/plain": (lambda x: x.encode("utf8"), lambda x: x.decode("utf8")),
AttributeError: 'NoneType' object has no attribute 'encode'


Expected results:

message sent