Openwings Home
Introduction
Search
In the News
Frequently Asked Questions
Registration
Open Forum
Openwings Tutorial
Bug Database
Openwings API
Download
Expert Teams
Process Management Office
Projects
Links
Terms of Use
Comment on this bug

03106:

ConnectorClassJarer does not copy entire .class files

Category: Connector
Status: Closed

Severity: HIGH
Reported against release: 0.8
Fixed in release: 0.8.2 (Beta Refresh 2)

PROBLEM:

com.mot.openwings.connector.ConnectorClassJarer uses 
InputStream.available to determine how may bytes are in the stream.  
However, available() only returns the number of bytes currently 
available to read, hence the current implementation could copy partial 
files instead of whole files.  

NOTE:
This defect was first written based on code review comments. It was not 
actually observed until connector generation was performed on Solaris 
and Linux platforms. The problem occurred intermittently and the 
symptom is that a java.lang.ClassFormatError is thrown when the 
connector is being loaded.

ANALYSIS:

The ConnectorClassJarer copies classes that the interface is dependent 
on into the connector jar file. For each class, the ConnectorClassJarer 
obtains an input stream, allocates a byte array where the length is 
determined by InputStream.available(), reads into the array, and then 
writes the array to the connector jar file. 

Usually available() returns the number of bytes in the file, but when 
the class is located in a .class or .jar file on a mounted filesystem, 
this may not be the case. What happens is that the JarEntry is written 
to the JarFile with the correct length, but fewer bytes may be written 
to the stream depending on what is returned from available(). The the 
JarEntry is closed. When you unzip the resulting jar file and look at 
the .class files, they have the right length, but if you look at them 
in a hex editor, you'll see that the .class file ends in 0's. 
 
This is an error-prone algorithm and should be corrected so as not to 
rely on available().

WORKAROUND:

Make sure that all classes that your connector interface depends on are 
available in files on the local (not mounted) filesystem. Also, this 
problem has only been observed on UNIX platforms, so try building your 
connectors on Windows.

back to top

home | vision | search | in the news | faq | registration | open forum | tutorial | bug database
 API | download | expert teams | process management office | projects | links | terms of use

© Copyright 2001-2006 General Dynamics C4 Systems. All rights reserved.