Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/sql/BatchUpdateException.java
38829 views
1
/*
2
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package java.sql;
27
28
import java.io.IOException;
29
import java.io.InvalidObjectException;
30
import java.io.ObjectInputStream;
31
import java.io.ObjectOutputStream;
32
import java.util.Arrays;
33
34
/**
35
* The subclass of {@link SQLException} thrown when an error
36
* occurs during a batch update operation. In addition to the
37
* information provided by {@link SQLException}, a
38
* <code>BatchUpdateException</code> provides the update
39
* counts for all commands that were executed successfully during the
40
* batch update, that is, all commands that were executed before the error
41
* occurred. The order of elements in an array of update counts
42
* corresponds to the order in which commands were added to the batch.
43
* <P>
44
* After a command in a batch update fails to execute properly
45
* and a <code>BatchUpdateException</code> is thrown, the driver
46
* may or may not continue to process the remaining commands in
47
* the batch. If the driver continues processing after a failure,
48
* the array returned by the method
49
* <code>BatchUpdateException.getUpdateCounts</code> will have
50
* an element for every command in the batch rather than only
51
* elements for the commands that executed successfully before
52
* the error. In the case where the driver continues processing
53
* commands, the array element for any command
54
* that failed is <code>Statement.EXECUTE_FAILED</code>.
55
* <P>
56
* A JDBC driver implementation should use
57
* the constructor {@code BatchUpdateException(String reason, String SQLState,
58
* int vendorCode, long []updateCounts,Throwable cause) } instead of
59
* constructors that take {@code int[]} for the update counts to avoid the
60
* possibility of overflow.
61
* <p>
62
* If {@code Statement.executeLargeBatch} method is invoked it is recommended that
63
* {@code getLargeUpdateCounts} be called instead of {@code getUpdateCounts}
64
* in order to avoid a possible overflow of the integer update count.
65
* @since 1.2
66
*/
67
68
public class BatchUpdateException extends SQLException {
69
70
/**
71
* Constructs a <code>BatchUpdateException</code> object initialized with a given
72
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code> and
73
* <code>updateCounts</code>.
74
* The <code>cause</code> is not initialized, and may subsequently be
75
* initialized by a call to the
76
* {@link Throwable#initCause(java.lang.Throwable)} method.
77
* <p>
78
* <strong>Note:</strong> There is no validation of {@code updateCounts} for
79
* overflow and because of this it is recommended that you use the constructor
80
* {@code BatchUpdateException(String reason, String SQLState,
81
* int vendorCode, long []updateCounts,Throwable cause) }.
82
* </p>
83
* @param reason a description of the error
84
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
85
* @param vendorCode an exception code used by a particular
86
* database vendor
87
* @param updateCounts an array of <code>int</code>, with each element
88
* indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
89
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
90
* the batch for JDBC drivers that continue processing
91
* after a command failure; an update count or
92
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
93
* prior to the failure for JDBC drivers that stop processing after a command
94
* failure
95
* @since 1.2
96
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
97
* java.lang.Throwable)
98
*/
99
public BatchUpdateException( String reason, String SQLState, int vendorCode,
100
int[] updateCounts ) {
101
super(reason, SQLState, vendorCode);
102
this.updateCounts = (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
103
this.longUpdateCounts = (updateCounts == null) ? null : copyUpdateCount(updateCounts);
104
}
105
106
/**
107
* Constructs a <code>BatchUpdateException</code> object initialized with a given
108
* <code>reason</code>, <code>SQLState</code> and
109
* <code>updateCounts</code>.
110
* The <code>cause</code> is not initialized, and may subsequently be
111
* initialized by a call to the
112
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
113
* is initialized to 0.
114
* <p>
115
* <strong>Note:</strong> There is no validation of {@code updateCounts} for
116
* overflow and because of this it is recommended that you use the constructor
117
* {@code BatchUpdateException(String reason, String SQLState,
118
* int vendorCode, long []updateCounts,Throwable cause) }.
119
* </p>
120
* @param reason a description of the exception
121
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
122
* @param updateCounts an array of <code>int</code>, with each element
123
* indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
124
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
125
* the batch for JDBC drivers that continue processing
126
* after a command failure; an update count or
127
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
128
* prior to the failure for JDBC drivers that stop processing after a command
129
* failure
130
* @since 1.2
131
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
132
* java.lang.Throwable)
133
*/
134
public BatchUpdateException(String reason, String SQLState,
135
int[] updateCounts) {
136
this(reason, SQLState, 0, updateCounts);
137
}
138
139
/**
140
* Constructs a <code>BatchUpdateException</code> object initialized with a given
141
* <code>reason</code> and <code>updateCounts</code>.
142
* The <code>cause</code> is not initialized, and may subsequently be
143
* initialized by a call to the
144
* {@link Throwable#initCause(java.lang.Throwable)} method. The
145
* <code>SQLState</code> is initialized to <code>null</code>
146
* and the vendor code is initialized to 0.
147
* <p>
148
* <strong>Note:</strong> There is no validation of {@code updateCounts} for
149
* overflow and because of this it is recommended that you use the constructor
150
* {@code BatchUpdateException(String reason, String SQLState,
151
* int vendorCode, long []updateCounts,Throwable cause) }.
152
* </p>
153
* @param reason a description of the exception
154
* @param updateCounts an array of <code>int</code>, with each element
155
* indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
156
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
157
* the batch for JDBC drivers that continue processing
158
* after a command failure; an update count or
159
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
160
* prior to the failure for JDBC drivers that stop processing after a command
161
* failure
162
* @since 1.2
163
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
164
* java.lang.Throwable)
165
*/
166
public BatchUpdateException(String reason, int[] updateCounts) {
167
this(reason, null, 0, updateCounts);
168
}
169
170
/**
171
* Constructs a <code>BatchUpdateException</code> object initialized with a given
172
* <code>updateCounts</code>.
173
* initialized by a call to the
174
* {@link Throwable#initCause(java.lang.Throwable)} method. The <code>reason</code>
175
* and <code>SQLState</code> are initialized to null and the vendor code
176
* is initialized to 0.
177
* <p>
178
* <strong>Note:</strong> There is no validation of {@code updateCounts} for
179
* overflow and because of this it is recommended that you use the constructor
180
* {@code BatchUpdateException(String reason, String SQLState,
181
* int vendorCode, long []updateCounts,Throwable cause) }.
182
* </p>
183
* @param updateCounts an array of <code>int</code>, with each element
184
* indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
185
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
186
* the batch for JDBC drivers that continue processing
187
* after a command failure; an update count or
188
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
189
* prior to the failure for JDBC drivers that stop processing after a command
190
* failure
191
* @since 1.2
192
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
193
* java.lang.Throwable)
194
*/
195
public BatchUpdateException(int[] updateCounts) {
196
this(null, null, 0, updateCounts);
197
}
198
199
/**
200
* Constructs a <code>BatchUpdateException</code> object.
201
* The <code>reason</code>, <code>SQLState</code> and <code>updateCounts</code>
202
* are initialized to <code>null</code> and the vendor code is initialized to 0.
203
* The <code>cause</code> is not initialized, and may subsequently be
204
* initialized by a call to the
205
* {@link Throwable#initCause(java.lang.Throwable)} method.
206
* <p>
207
*
208
* @since 1.2
209
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
210
* java.lang.Throwable)
211
*/
212
public BatchUpdateException() {
213
this(null, null, 0, null);
214
}
215
216
/**
217
* Constructs a <code>BatchUpdateException</code> object initialized with
218
* a given <code>cause</code>.
219
* The <code>SQLState</code> and <code>updateCounts</code>
220
* are initialized
221
* to <code>null</code> and the vendor code is initialized to 0.
222
* The <code>reason</code> is initialized to <code>null</code> if
223
* <code>cause==null</code> or to <code>cause.toString()</code> if
224
* <code>cause!=null</code>.
225
* @param cause the underlying reason for this <code>SQLException</code>
226
* (which is saved for later retrieval by the <code>getCause()</code> method);
227
* may be null indicating the cause is non-existent or unknown.
228
* @since 1.6
229
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
230
* java.lang.Throwable)
231
*/
232
public BatchUpdateException(Throwable cause) {
233
this((cause == null ? null : cause.toString()), null, 0, (int[])null, cause);
234
}
235
236
/**
237
* Constructs a <code>BatchUpdateException</code> object initialized with a
238
* given <code>cause</code> and <code>updateCounts</code>.
239
* The <code>SQLState</code> is initialized
240
* to <code>null</code> and the vendor code is initialized to 0.
241
* The <code>reason</code> is initialized to <code>null</code> if
242
* <code>cause==null</code> or to <code>cause.toString()</code> if
243
* <code>cause!=null</code>.
244
* <p>
245
* <strong>Note:</strong> There is no validation of {@code updateCounts} for
246
* overflow and because of this it is recommended that you use the constructor
247
* {@code BatchUpdateException(String reason, String SQLState,
248
* int vendorCode, long []updateCounts,Throwable cause) }.
249
* </p>
250
* @param updateCounts an array of <code>int</code>, with each element
251
* indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
252
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
253
* the batch for JDBC drivers that continue processing
254
* after a command failure; an update count or
255
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
256
* prior to the failure for JDBC drivers that stop processing after a command
257
* failure
258
* @param cause the underlying reason for this <code>SQLException</code>
259
* (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
260
* the cause is non-existent or unknown.
261
* @since 1.6
262
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
263
* java.lang.Throwable)
264
*/
265
public BatchUpdateException(int []updateCounts , Throwable cause) {
266
this((cause == null ? null : cause.toString()), null, 0, updateCounts, cause);
267
}
268
269
/**
270
* Constructs a <code>BatchUpdateException</code> object initialized with
271
* a given <code>reason</code>, <code>cause</code>
272
* and <code>updateCounts</code>. The <code>SQLState</code> is initialized
273
* to <code>null</code> and the vendor code is initialized to 0.
274
* <p>
275
* <strong>Note:</strong> There is no validation of {@code updateCounts} for
276
* overflow and because of this it is recommended that you use the constructor
277
* {@code BatchUpdateException(String reason, String SQLState,
278
* int vendorCode, long []updateCounts,Throwable cause) }.
279
* </p>
280
* @param reason a description of the exception
281
* @param updateCounts an array of <code>int</code>, with each element
282
*indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
283
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
284
* the batch for JDBC drivers that continue processing
285
* after a command failure; an update count or
286
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
287
* prior to the failure for JDBC drivers that stop processing after a command
288
* failure
289
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method);
290
* may be null indicating
291
* the cause is non-existent or unknown.
292
* @since 1.6
293
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
294
* java.lang.Throwable)
295
*/
296
public BatchUpdateException(String reason, int []updateCounts, Throwable cause) {
297
this(reason, null, 0, updateCounts, cause);
298
}
299
300
/**
301
* Constructs a <code>BatchUpdateException</code> object initialized with
302
* a given <code>reason</code>, <code>SQLState</code>,<code>cause</code>, and
303
* <code>updateCounts</code>. The vendor code is initialized to 0.
304
*
305
* @param reason a description of the exception
306
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
307
* @param updateCounts an array of <code>int</code>, with each element
308
* indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
309
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
310
* the batch for JDBC drivers that continue processing
311
* after a command failure; an update count or
312
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
313
* prior to the failure for JDBC drivers that stop processing after a command
314
* failure
315
* <p>
316
* <strong>Note:</strong> There is no validation of {@code updateCounts} for
317
* overflow and because of this it is recommended that you use the constructor
318
* {@code BatchUpdateException(String reason, String SQLState,
319
* int vendorCode, long []updateCounts,Throwable cause) }.
320
* </p>
321
* @param cause the underlying reason for this <code>SQLException</code>
322
* (which is saved for later retrieval by the <code>getCause()</code> method);
323
* may be null indicating
324
* the cause is non-existent or unknown.
325
* @since 1.6
326
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
327
* java.lang.Throwable)
328
*/
329
public BatchUpdateException(String reason, String SQLState,
330
int []updateCounts, Throwable cause) {
331
this(reason, SQLState, 0, updateCounts, cause);
332
}
333
334
/**
335
* Constructs a <code>BatchUpdateException</code> object initialized with
336
* a given <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
337
* <code>cause</code> and <code>updateCounts</code>.
338
*
339
* @param reason a description of the error
340
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
341
* @param vendorCode an exception code used by a particular
342
* database vendor
343
* @param updateCounts an array of <code>int</code>, with each element
344
*indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
345
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
346
* the batch for JDBC drivers that continue processing
347
* after a command failure; an update count or
348
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
349
* prior to the failure for JDBC drivers that stop processing after a command
350
* failure
351
* <p>
352
* <strong>Note:</strong> There is no validation of {@code updateCounts} for
353
* overflow and because of this it is recommended that you use the constructor
354
* {@code BatchUpdateException(String reason, String SQLState,
355
* int vendorCode, long []updateCounts,Throwable cause) }.
356
* </p>
357
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method);
358
* may be null indicating
359
* the cause is non-existent or unknown.
360
* @since 1.6
361
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
362
* java.lang.Throwable)
363
*/
364
public BatchUpdateException(String reason, String SQLState, int vendorCode,
365
int []updateCounts,Throwable cause) {
366
super(reason, SQLState, vendorCode, cause);
367
this.updateCounts = (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
368
this.longUpdateCounts = (updateCounts == null) ? null : copyUpdateCount(updateCounts);
369
}
370
371
/**
372
* Retrieves the update count for each update statement in the batch
373
* update that executed successfully before this exception occurred.
374
* A driver that implements batch updates may or may not continue to
375
* process the remaining commands in a batch when one of the commands
376
* fails to execute properly. If the driver continues processing commands,
377
* the array returned by this method will have as many elements as
378
* there are commands in the batch; otherwise, it will contain an
379
* update count for each command that executed successfully before
380
* the <code>BatchUpdateException</code> was thrown.
381
*<P>
382
* The possible return values for this method were modified for
383
* the Java 2 SDK, Standard Edition, version 1.3. This was done to
384
* accommodate the new option of continuing to process commands
385
* in a batch update after a <code>BatchUpdateException</code> object
386
* has been thrown.
387
*
388
* @return an array of <code>int</code> containing the update counts
389
* for the updates that were executed successfully before this error
390
* occurred. Or, if the driver continues to process commands after an
391
* error, one of the following for every command in the batch:
392
* <OL>
393
* <LI>an update count
394
* <LI><code>Statement.SUCCESS_NO_INFO</code> to indicate that the command
395
* executed successfully but the number of rows affected is unknown
396
* <LI><code>Statement.EXECUTE_FAILED</code> to indicate that the command
397
* failed to execute successfully
398
* </OL>
399
* @since 1.3
400
* @see #getLargeUpdateCounts()
401
*/
402
public int[] getUpdateCounts() {
403
return (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
404
}
405
406
/**
407
* Constructs a <code>BatchUpdateException</code> object initialized with
408
* a given <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
409
* <code>cause</code> and <code>updateCounts</code>.
410
* <p>
411
* This constructor should be used when the returned update count may exceed
412
* {@link Integer#MAX_VALUE}.
413
* <p>
414
* @param reason a description of the error
415
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
416
* @param vendorCode an exception code used by a particular
417
* database vendor
418
* @param updateCounts an array of <code>long</code>, with each element
419
*indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
420
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
421
* the batch for JDBC drivers that continue processing
422
* after a command failure; an update count or
423
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
424
* prior to the failure for JDBC drivers that stop processing after a command
425
* failure
426
* @param cause the underlying reason for this <code>SQLException</code>
427
* (which is saved for later retrieval by the <code>getCause()</code> method);
428
* may be null indicating the cause is non-existent or unknown.
429
* @since 1.8
430
*/
431
public BatchUpdateException(String reason, String SQLState, int vendorCode,
432
long []updateCounts,Throwable cause) {
433
super(reason, SQLState, vendorCode, cause);
434
this.longUpdateCounts = (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
435
this.updateCounts = (longUpdateCounts == null) ? null : copyUpdateCount(longUpdateCounts);
436
}
437
438
/**
439
* Retrieves the update count for each update statement in the batch
440
* update that executed successfully before this exception occurred.
441
* A driver that implements batch updates may or may not continue to
442
* process the remaining commands in a batch when one of the commands
443
* fails to execute properly. If the driver continues processing commands,
444
* the array returned by this method will have as many elements as
445
* there are commands in the batch; otherwise, it will contain an
446
* update count for each command that executed successfully before
447
* the <code>BatchUpdateException</code> was thrown.
448
* <p>
449
* This method should be used when {@code Statement.executeLargeBatch} is
450
* invoked and the returned update count may exceed {@link Integer#MAX_VALUE}.
451
* <p>
452
* @return an array of <code>long</code> containing the update counts
453
* for the updates that were executed successfully before this error
454
* occurred. Or, if the driver continues to process commands after an
455
* error, one of the following for every command in the batch:
456
* <OL>
457
* <LI>an update count
458
* <LI><code>Statement.SUCCESS_NO_INFO</code> to indicate that the command
459
* executed successfully but the number of rows affected is unknown
460
* <LI><code>Statement.EXECUTE_FAILED</code> to indicate that the command
461
* failed to execute successfully
462
* </OL>
463
* @since 1.8
464
*/
465
public long[] getLargeUpdateCounts() {
466
return (longUpdateCounts == null) ? null :
467
Arrays.copyOf(longUpdateCounts, longUpdateCounts.length);
468
}
469
470
/**
471
* The array that describes the outcome of a batch execution.
472
* @serial
473
* @since 1.2
474
*/
475
private int[] updateCounts;
476
477
/*
478
* Starting with Java SE 8, JDBC has added support for returning an update
479
* count > Integer.MAX_VALUE. Because of this the following changes were made
480
* to BatchUpdateException:
481
* <ul>
482
* <li>Add field longUpdateCounts</li>
483
* <li>Add Constructorr which takes long[] for update counts</li>
484
* <li>Add getLargeUpdateCounts method</li>
485
* </ul>
486
* When any of the constructors are called, the int[] and long[] updateCount
487
* fields are populated by copying the one array to each other.
488
*
489
* As the JDBC driver passes in the updateCounts, there has always been the
490
* possiblity for overflow and BatchUpdateException does not need to account
491
* for that, it simply copies the arrays.
492
*
493
* JDBC drivers should always use the constructor that specifies long[] and
494
* JDBC application developers should call getLargeUpdateCounts.
495
*/
496
497
/**
498
* The array that describes the outcome of a batch execution.
499
* @serial
500
* @since 1.8
501
*/
502
private long[] longUpdateCounts;
503
504
private static final long serialVersionUID = 5977529877145521757L;
505
506
/*
507
* Utility method to copy int[] updateCount to long[] updateCount
508
*/
509
private static long[] copyUpdateCount(int[] uc) {
510
long[] copy = new long[uc.length];
511
for(int i= 0; i< uc.length; i++) {
512
copy[i] = uc[i];
513
}
514
return copy;
515
}
516
517
/*
518
* Utility method to copy long[] updateCount to int[] updateCount.
519
* No checks for overflow will be done as it is expected a user will call
520
* getLargeUpdateCounts.
521
*/
522
private static int[] copyUpdateCount(long[] uc) {
523
int[] copy = new int[uc.length];
524
for(int i= 0; i< uc.length; i++) {
525
copy[i] = (int) uc[i];
526
}
527
return copy;
528
}
529
/**
530
* readObject is called to restore the state of the
531
* {@code BatchUpdateException} from a stream.
532
*/
533
private void readObject(ObjectInputStream s)
534
throws IOException, ClassNotFoundException {
535
536
ObjectInputStream.GetField fields = s.readFields();
537
int[] tmp = (int[])fields.get("updateCounts", null);
538
long[] tmp2 = (long[])fields.get("longUpdateCounts", null);
539
if(tmp != null && tmp2 != null && tmp.length != tmp2.length)
540
throw new InvalidObjectException("update counts are not the expected size");
541
if (tmp != null)
542
updateCounts = tmp.clone();
543
if (tmp2 != null)
544
longUpdateCounts = tmp2.clone();
545
if(updateCounts == null && longUpdateCounts != null)
546
updateCounts = copyUpdateCount(longUpdateCounts);
547
if(longUpdateCounts == null && updateCounts != null)
548
longUpdateCounts = copyUpdateCount(updateCounts);
549
550
}
551
552
/**
553
* writeObject is called to save the state of the {@code BatchUpdateException}
554
* to a stream.
555
*/
556
private void writeObject(ObjectOutputStream s)
557
throws IOException, ClassNotFoundException {
558
559
ObjectOutputStream.PutField fields = s.putFields();
560
fields.put("updateCounts", updateCounts);
561
fields.put("longUpdateCounts", longUpdateCounts);
562
s.writeFields();
563
}
564
}
565
566