• Post Reply Bookmark Topic Watch Topic
  • New Topic

CipherOutputStream problem  RSS feed

 
Alex Belt
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an application that sends an object over MQ. If for some reason this object isn't sent, I need to have it written to a local file after it's been encrypted. When I don't encrypt the object and wrap an ObjectOutputStream around a FileOutputStream, it works great. If I try to wrap an ObjectOutputStream around a CipherOutputStream which wraps a FileOutputStream, the FileOutputStream is created, the CipherOutputStream is created, and then it just fails. No exceptions are thrown, no error messages of any kind, it just fails to create the ObjectOutputStream wrapping the CipherOutputStream. I've searched Sun's bug database and done a Google search, but can't find any mention of this problem. If it makes a difference, I'm limited to 1.4.2_11, upgrading is not an option at this time.

TIA,
Alex
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you know that the ObjectOutputStream was not created? How do you know anything has failed? It would help if you could show the code you use to create the streams and write the encrypted file.
 
Alex Belt
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the code the way I'm currently testing it:


It prints the fileoutputstream message, prints the outputstream message, does not print the null message, and does not print the objectoutputstream message. The catch block not only displays an error, it sends an email also, neither of which is occurring.
 
Alex Belt
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found the problem. Turns out the Cipher used to initialize the CipherOutputStream was null due to a local variable masking the class variable holding the Cipher. I hate debugging code I didn't write.

Thanks,
Alex
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!