Route all Variant construction thorough single constructor
Removed read and write methods in Variant since serialization is not actually supported
This commit is contained in:
@@ -77,12 +77,6 @@
|
||||
<td width="87%" valign="top"><em>Identified 1.11.1</em> Process affinity may have to be set on
|
||||
dual core machines to avoid com exceptions.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="13%" valign="top">1504120 </td>
|
||||
<td width="87%" valign="top"><em>Identified 1.11.1</em>Microsoft 2003 Server crashes. Server crashes on MS 2003 Server have been reported over time.
|
||||
Some users have had say that Jacob must be built on MS2003 Server to run reliably.
|
||||
The Jacob distribution on Sourceforge is built on Windows XP SP2 (No code change. Just a documentation updat)</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- --------- -->
|
||||
|
||||
@@ -1346,11 +1346,7 @@ public class Variant extends JacobObject {
|
||||
* public constructor, initializes and sets type to VariantEmpty
|
||||
*/
|
||||
public Variant() {
|
||||
init();
|
||||
putEmpty();
|
||||
if (isDebugEnabled()) {
|
||||
debug("Variant: " + "create " + this );
|
||||
}
|
||||
this(null,false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1358,8 +1354,7 @@ public class Variant extends JacobObject {
|
||||
* @param in
|
||||
*/
|
||||
public Variant(int in) {
|
||||
init();
|
||||
putInt(in);
|
||||
this(new Integer(in));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1367,8 +1362,7 @@ public class Variant extends JacobObject {
|
||||
* @param in
|
||||
*/
|
||||
public Variant(double in) {
|
||||
init();
|
||||
putDouble(in);
|
||||
this(new Double(in));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1376,8 +1370,7 @@ public class Variant extends JacobObject {
|
||||
* @param in
|
||||
*/
|
||||
public Variant(boolean in) {
|
||||
init();
|
||||
putBoolean(in);
|
||||
this(new Boolean(in));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1588,48 +1581,6 @@ public class Variant extends JacobObject {
|
||||
throw new NotImplementedException("Not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* custom serialization support
|
||||
* @param oos
|
||||
*/
|
||||
private void writeObject(java.io.ObjectOutputStream oos) {
|
||||
try {
|
||||
byte[] ourBytes = SerializationWriteToBytes();
|
||||
int count = ourBytes.length;
|
||||
if (JacobObject.isDebugEnabled()){
|
||||
JacobObject.debug("writing out "+count+" bytes");
|
||||
}
|
||||
oos.writeInt(count);
|
||||
oos.write(ourBytes);
|
||||
//Save(oos);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* custom serialization support
|
||||
* @param ois
|
||||
*/
|
||||
private void readObject(java.io.ObjectInputStream ois) {
|
||||
try {
|
||||
// Load will do this if we don't but lets do it
|
||||
// from here so that the variant is set up exactly
|
||||
// the same as the ones not created from a stream
|
||||
init();
|
||||
int numBytes = ois.readInt();
|
||||
byte[] ourBytes = new byte[numBytes];
|
||||
if (JacobObject.isDebugEnabled()){
|
||||
JacobObject.debug("reading in "+numBytes+" bytes");
|
||||
}
|
||||
ois.read(ourBytes);
|
||||
SerializationReadFromBytes(ourBytes);
|
||||
//Load(ois);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* is the variant null or empty or error or null dispatch
|
||||
* @return true if it is null or false if not
|
||||
|
||||
@@ -22,6 +22,7 @@ class VariantTest {
|
||||
testJig.testObjectIsAConstant();
|
||||
testJig.testSomeChangeVT();
|
||||
testJig.testByRefToJavaObject();
|
||||
testJig.testManyThreadedInit();
|
||||
System.out.println("Testing Complete");
|
||||
|
||||
}
|
||||
@@ -389,4 +390,88 @@ class VariantTest {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Spin up a lot of threads and have them all create variants
|
||||
* 3/2007 there have been several reports in multi-threaded servers that show init() failing
|
||||
*
|
||||
*/
|
||||
public void testManyThreadedInit(){
|
||||
VariantInitTestThread threads[] = new VariantInitTestThread[75];
|
||||
|
||||
System.out.println("Starting thread test ("+threads.length
|
||||
+ " threads each creating 10000 objects)."
|
||||
+ " This may take 30 seconds or more.");
|
||||
for (int i = 0; i < threads.length; i++)
|
||||
{
|
||||
threads[i] = new VariantInitTestThread("thread-" + i, 10000);
|
||||
}
|
||||
for (int i = 0; i < threads.length; i++)
|
||||
{
|
||||
threads[i].start();
|
||||
}
|
||||
int numComplete = 0;
|
||||
while (numComplete < threads.length){
|
||||
// give the works time to work
|
||||
try {
|
||||
Thread.sleep(333);
|
||||
} catch (InterruptedException ie){
|
||||
// do nothing
|
||||
}
|
||||
numComplete = 0;
|
||||
for ( int i = 0; i < threads.length; i++){
|
||||
if (threads[i].isComplete){
|
||||
numComplete++;
|
||||
}
|
||||
}
|
||||
//System.out.print("["+numComplete+"/"+threads.length+"]");
|
||||
}
|
||||
System.out.println("Finished thread test");
|
||||
}
|
||||
|
||||
/**
|
||||
* a class to create variants in seperate threads
|
||||
* @author joe
|
||||
*
|
||||
*/
|
||||
class VariantInitTestThread extends Thread
|
||||
{
|
||||
private boolean isComplete = false;
|
||||
|
||||
private int initialRunSize = 0;
|
||||
/**
|
||||
* @param arg0
|
||||
*/
|
||||
public VariantInitTestThread(String newThreadName, int iStartCount)
|
||||
{
|
||||
super(newThreadName);
|
||||
initialRunSize = iStartCount;
|
||||
|
||||
}
|
||||
|
||||
public boolean isComplete(){
|
||||
return isComplete;
|
||||
}
|
||||
/**
|
||||
* Blow out a bunch of Variants
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
for (int variantIndex = 0; variantIndex < initialRunSize; variantIndex ++ ){
|
||||
try {
|
||||
Thread.yield();
|
||||
Thread.sleep(0);
|
||||
} catch (InterruptedException ie){
|
||||
// do nothing
|
||||
}
|
||||
//System.out.println(Thread.currentThread().getName());
|
||||
Variant testSubject = new Variant(variantIndex);
|
||||
testSubject.getvt();
|
||||
testSubject.getInt();
|
||||
}
|
||||
isComplete = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user