Issue Details (XML | Word | Printable)

Key: JAMES-609
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Stefano Bagnara
Reporter: Stefano Bagnara
Votes: 0
Watchers: 0
Operations

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

MailImpl.setMessage and possible NPE: regression from 2.2.0 and 2.3.0rc1

Created: 08/Sep/06 05:28 PM   Updated: 21/Nov/07 08:31 AM
Return to search
Component/s: James Core
Affects Version/s: 2.3.0
Fix Version/s: 2.3.0

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works JAMES-609.diff 2006-09-08 06:50 PM Stefano Bagnara 20 kB

Resolution Date: 12/Sep/06 12:44 PM


 Description  « Hide
The change introduced in rc2 to fix the file leaks has produced an NPE in a custom mailet.

I suggest to revert the setMessage changes removing the dispose() call for the old message and to put the dispose code in the bundled calling mailets.

This is not a good fix in the long term, but for 2.3.0 I would prefer to keep compatibility with 2.2.0 and to have a leak instead of NPE (difficult to understand by most users).


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Stefano Bagnara added a comment - 08/Sep/06 05:49 PM
I believe the NPE could be thrown when saving the message after having called SMIMECheckSignature when "stripSignature && strippedMessage != null" because it calls setMessage with the same message.

Stefano Bagnara added a comment - 08/Sep/06 06:50 PM
This is a possible fix to the problem.
Few changes are on the tests to solve some temporary file not release (24 before the fix, 20 after the fix).

Now that I wrote it I'm not sure about this in 2.3: they are a lot of changes... maybe it is better to add a check in setMessage to see if the new message is the same of the old one...

I have to think more about this...

Stefano Bagnara made changes - 08/Sep/06 06:50 PM
Field Original Value New Value
Attachment JAMES-609.diff [ 12340476 ]
Noel J. Bergman added a comment - 10/Sep/06 02:15 PM
I agree that it would be better to check in setMessage if this.message == message.

None of these is a perfect solution, since the explicit dispose call reintroduces the problems that exist in other languages with explicit deallocation: how to know when it is safe to deallocate (and clean-up). What if someone were to call getMessage, put the old message object into a new Mail, and put a new message in the old Mail?

But the least objectionable change for now is probably the check in setMessage. The logic for that one is clear: if we are setting the message to the one we already have, do nothing.

Repository Revision Date User Message
ASF #442571 Tue Sep 12 12:38:57 UTC 2006 bago Fixed a cause of NPEs in MailImpl.setMessage when the new message was the same of the previous message (JAMES-609)
Files Changed
MODIFY /james/server/branches/v2.3/src/java/org/apache/james/core/MailImpl.java

Stefano Bagnara added a comment - 12/Sep/06 12:44 PM
We agreed to fix this with the small "identity check" fix.
Applied to both 2.3 branch and trunk.

Stefano Bagnara made changes - 12/Sep/06 12:44 PM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Assignee Stefano Bagnara [ bago ]
Repository Revision Date User Message
ASF #442573 Tue Sep 12 12:45:35 UTC 2006 bago Fixed a cause of NPEs in MailImpl.setMessage when the new message was the same of the previous message (JAMES-609)
Files Changed
MODIFY /james/server/trunk/src/java/org/apache/james/core/MailImpl.java

Danny Angus added a comment - 21/Nov/07 08:31 AM
Closing issue fixed in released version.

Danny Angus made changes - 21/Nov/07 08:31 AM
Status Resolved [ 5 ] Closed [ 6 ]