Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

CipherOutputStream problem

 
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
 
Wanderer
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
 
When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic