WARNING: Fix a big bug in Load_File() method: all previous MQSLoad versions can corrupt messages during loading !!!

This commit is contained in:
agibert 2008-11-14 00:00:51 +00:00
parent 67b4a7aa8b
commit f12bcae985
2 changed files with 87 additions and 73 deletions

View File

@ -1,7 +1,7 @@
// $RCSfile: MQSLoad.java,v $
// $Revision: 1.12 $
// $Revision: 1.13 $
// $Name: $
// $Date: 2008/11/10 01:50:19 $
// $Date: 2008/11/14 00:00:51 $
// $Author: agibert $
/*
@ -45,9 +45,9 @@ public class MQSLoad
private String Message_Break = "\r\n";
private String Message_Tail = "";
private boolean Keep_Message_Break = false;
private String MQSLoad_Revision = "$Revision: 1.12 $";
private String MQSLoad_Revision = "$Revision: 1.13 $";
private String MQSLoad_Tag = "$Name: $";
private String MQSLoad_Date = "$Date: 2008/11/10 01:50:19 $";
private String MQSLoad_Date = "$Date: 2008/11/14 00:00:51 $";
private String MQSLoad_Author = "$Author: agibert $";
private Integer Sleep_Time = 0;
@ -457,6 +457,7 @@ public class MQSLoad
output_msg.format = MQC.MQFMT_STRING;
/* Default window size */
window_size = 1024 * 64;
prefetch_size = Field_Break.length() + Message_Break.length();
buffer_size = window_size + prefetch_size;
@ -470,14 +471,20 @@ public class MQSLoad
read_size = Input_File.read( buffer_byte, buffer_offset, buffer_size - buffer_offset);
// System.out.println( "Load buffer read_size: (" + read_size + ") asked: (" + (buffer_size - buffer_offset) + ")");
if( read_size > 0)
if( read_size == -1)
{
read_size = 0;
}
/* Compute current buffer and window size */
cur_window_size = Math.min( ( read_size + buffer_offset), window_size);
cur_buffer_size = ( read_size + buffer_offset);
buffer_string = new String( buffer_byte, 0, cur_buffer_size);
cur_pos = 0;
// System.out.println( " CurWS: (" + cur_window_size + ") CurBS: (" + cur_buffer_size + ") Buffer: [" + buffer_string + "]");
while( cur_pos < cur_window_size)
{
// System.out.println( "- CurPos: (" + cur_pos + ")");
@ -519,10 +526,13 @@ public class MQSLoad
}
output_msg.writeString( out_string);
// System.out.println( "* Msg: [" + out_string + "]");
}
if( next_message <= cur_window_size)
{
/* A message break has been found: send the data... */
// System.out.println( "* Write Msg CurPos: (" + cur_pos + ")");
output_msg.writeString( Message_Tail);
@ -543,14 +553,16 @@ public class MQSLoad
}
}
if( cur_buffer_size > cur_window_size)
buffer_offset = cur_buffer_size - cur_pos;
// System.out.println( "% CurPos: (" + cur_pos + ") BufOff: (" + buffer_offset + ")");
if( buffer_offset > 0)
{
buffer_offset = cur_buffer_size - cur_window_size;
System.arraycopy( buffer_byte, cur_window_size, buffer_byte, 0, buffer_offset);
/* Copy back prefetch area */
System.arraycopy( buffer_byte, cur_pos, buffer_byte, 0, buffer_offset);
}
}
}
while( read_size > 0);
while( cur_buffer_size > 0);
if( out_string != null)
{

View File

@ -1,7 +1,7 @@
# $RCSfile: ReleaseNotes.txt,v $
# $Revision: 1.10 $
# $Revision: 1.11 $
# $Name: $
# $Date: 2008/11/10 01:50:19 $
# $Date: 2008/11/14 00:00:51 $
# $Author: agibert $
@ -9,10 +9,12 @@
--------------------------------------------------------------------------------
MQSLoad V 1.3.2 - A. Gibert - 2008/11/10
MQSLoad V 1.3.2 - A. Gibert - 2008/11/14
--------------------------------------------------------------------------------
Fix elapsed time computation !
- WARNING: Fix a big bug in Load_File() method: all previous MQSLoad versions
can corrupt messages during loading !!!
- Fix elapsed time computation !