Skip to content

Commit ecd1901

Browse files
committed
Bug 32567417 - [32503887->14.1.1.0.6-CE] DOS COM.TANGOSOL.RUN.XML.SIMPLEDOCUMENT etc
[git-p4: depot-paths = "//dev/coherence-ce/release/coherence-ce-v14.1.1.0/": change = 87357]
1 parent c0b0c2c commit ecd1901

File tree

28 files changed

+867
-137
lines changed

28 files changed

+867
-137
lines changed

prj/coherence-core/src/main/java/com/oracle/coherence/common/internal/util/Histogram.java

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* http://oss.oracle.com/licenses/upl.
@@ -8,6 +8,8 @@
88

99
import com.oracle.coherence.common.base.Converter;
1010

11+
import com.tangosol.util.Base;
12+
1113
import java.io.DataInput;
1214
import java.io.DataOutput;
1315
import java.io.Externalizable;
@@ -335,18 +337,12 @@ public void readExternal(DataInput dataInput)
335337
throws IOException
336338
{
337339
int c = dataInput.readInt();
338-
long[] alResults = m_alResults = new long[c];
339-
for (int i = 0; i < c; )
340-
{
341-
long n = dataInput.readLong();
342-
if (n < 0)
343-
{
344-
// skip over gaps
345-
i += -n;
346-
continue;
347-
}
348-
alResults[i++] = n;
349-
}
340+
341+
m_alResults = c <= 0 ? new long[0] :
342+
c < 0x7FFFFFF >> 3
343+
? readHistgram(dataInput, c)
344+
: readLargeHistgram(dataInput, c);
345+
350346
}
351347

352348
@Override
@@ -390,6 +386,65 @@ public void writeExternal(DataOutput dataOutput)
390386
}
391387
}
392388

389+
/**
390+
* Read histgram from a DataInput stream.
391+
*
392+
* @param in a DataInput stream to read from
393+
*
394+
* @return an array of longs
395+
*
396+
* @throws IOException if an I/O exception occurs
397+
*/
398+
private long[] readHistgram(DataInput in, int c)
399+
throws IOException
400+
{
401+
long[] alResults = new long[c];
402+
for (int i = 0; i < c; )
403+
{
404+
long n = in.readLong();
405+
if (n < 0)
406+
{
407+
// skip over gaps
408+
i += -n;
409+
continue;
410+
}
411+
alResults[i++] = n;
412+
}
413+
414+
return alResults;
415+
}
416+
417+
/**
418+
* Read a histogram with large array.
419+
*
420+
* @param in a DataInput stream to read from
421+
* @param cLength length to read
422+
*
423+
* @return an array of longs
424+
*
425+
* @throws IOException if an I/O exception occurs
426+
*/
427+
private long[] readLargeHistgram(DataInput in, int cLength)
428+
throws IOException
429+
{
430+
int cBatchMax = 0x3FFFFFF >> 3;
431+
int cBatch = cLength / cBatchMax + 1;
432+
long[] aMerged = null;
433+
int cRead = 0;
434+
int cAllocate = cBatchMax;
435+
long[] al;
436+
for (int i = 0; i < cBatch && cRead < cLength; i++)
437+
{
438+
al = readHistgram(in, cAllocate);
439+
aMerged = Base.mergeLongArray(aMerged, al);
440+
cRead += al.length;
441+
442+
cAllocate = Math.min(cLength - cRead, cBatchMax);
443+
}
444+
445+
return aMerged;
446+
}
447+
393448
// ----- inner class Snapshot -------------------------------------------
394449

395450
public static class Snapshot

prj/coherence-core/src/main/java/com/tangosol/coherence/memcached/processor/AppendPrependProcessor.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* http://oss.oracle.com/licenses/upl.
@@ -21,6 +21,8 @@
2121

2222
import com.tangosol.util.Binary;
2323
import com.tangosol.util.BinaryEntry;
24+
import com.tangosol.util.ExternalizableHelper;
25+
2426
import com.tangosol.util.InvocableMap.Entry;
2527

2628
import java.io.DataInput;
@@ -112,12 +114,8 @@ public void readExternal(DataInput in)
112114
throws IOException
113115
{
114116
super.readExternal(in);
115-
int len = in.readInt();
116-
if (len > 0)
117-
{
118-
m_abDelta = new byte[len];
119-
in.readFully(m_abDelta);
120-
}
117+
118+
m_abDelta = ExternalizableHelper.readByteArray(in);
121119
m_fAppend = in.readBoolean();
122120
}
123121

prj/coherence-core/src/main/java/com/tangosol/coherence/memcached/processor/PutProcessor.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* http://oss.oracle.com/licenses/upl.
@@ -126,12 +126,7 @@ public Object process(Entry entry)
126126
public void readExternal(DataInput in)
127127
throws IOException
128128
{
129-
int len = in.readInt();
130-
if (len > 0)
131-
{
132-
m_abValue = new byte[len];
133-
in.readFully(m_abValue);
134-
}
129+
m_abValue = ExternalizableHelper.readByteArray(in);
135130
m_nFlag = in.readInt();
136131
m_lVersion = in.readLong();
137132
m_nExpiry = in.readInt();

prj/coherence-core/src/main/java/com/tangosol/coherence/memcached/server/DataHolder.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* http://oss.oracle.com/licenses/upl.
@@ -12,6 +12,8 @@
1212
import com.tangosol.io.pof.PofWriter;
1313
import com.tangosol.io.pof.PortableObject;
1414

15+
import com.tangosol.util.ExternalizableHelper;
16+
1517
import java.io.DataInput;
1618
import java.io.DataOutput;
1719
import java.io.IOException;
@@ -91,13 +93,7 @@ public long getVersion()
9193
public void readExternal(DataInput in)
9294
throws IOException
9395
{
94-
int cb = in.readInt();
95-
if (cb > 0)
96-
{
97-
m_abValue = new byte[cb];
98-
in.readFully(m_abValue);
99-
}
100-
96+
m_abValue = ExternalizableHelper.readByteArray(in);
10197
m_nFlag = in.readInt();
10298
m_lVersion = in.readLong();
10399
}

prj/coherence-core/src/main/java/com/tangosol/config/expression/ChainedParameterResolver.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* http://oss.oracle.com/licenses/upl.
@@ -11,6 +11,7 @@
1111
import com.tangosol.io.pof.PofWriter;
1212
import com.tangosol.io.pof.PortableObject;
1313

14+
import com.tangosol.util.Base;
1415
import com.tangosol.util.ExternalizableHelper;
1516

1617
import java.io.DataInput;
@@ -101,7 +102,9 @@ protected String getDescription()
101102
@Override
102103
public void readExternal(DataInput in) throws IOException
103104
{
104-
int cResolver = ExternalizableHelper.readInt(in);
105+
int cResolver = ExternalizableHelper.readInt(in);
106+
Base.azzert(cResolver < 16384, "Unexpected number of parameter resolvers.");
107+
105108
ParameterResolver[] aResolver = new ParameterResolver[cResolver];
106109

107110
for (int i = 0; i < cResolver; i++)

prj/coherence-core/src/main/java/com/tangosol/internal/util/DoubleBag.java

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* http://oss.oracle.com/licenses/upl.
66
*/
77
package com.tangosol.internal.util;
88

99
import com.tangosol.io.ExternalizableLite;
10-
1110
import com.tangosol.io.pof.PofReader;
1211
import com.tangosol.io.pof.PofWriter;
1312
import com.tangosol.io.pof.PortableObject;
1413

14+
import com.tangosol.util.Base;
15+
1516
import java.io.DataInput;
1617
import java.io.DataOutput;
1718
import java.io.IOException;
@@ -119,13 +120,12 @@ public double[] toArray()
119120
public void readExternal(DataInput in)
120121
throws IOException
121122
{
122-
int c = m_c = in.readInt();
123-
double[] a = new double[c];
124-
for (int i = 0; i < c; ++i)
125-
{
126-
a[i] = in.readDouble();
127-
}
128-
m_a = a;
123+
int c = m_c = in.readInt();
124+
125+
m_a = c <= 0 ? new double[0] :
126+
c < 0x7FFFFFF >> 3
127+
? readDoubleArray(in, c)
128+
: readLargeDoubleArray(in, c);
129129
}
130130

131131
@Override
@@ -245,6 +245,59 @@ protected double[] ensureStorage(int c)
245245
return a;
246246
}
247247

248+
/**
249+
* Read an array of doubles for the specified length from a DataInput stream.
250+
*
251+
* @param in a DataInput stream to read from
252+
* @param c length to read
253+
*
254+
* @return an array of ints
255+
*
256+
* @throws IOException if an I/O exception occurs
257+
*/
258+
private double[] readDoubleArray(DataInput in, int c)
259+
throws IOException
260+
{
261+
double[] ad = new double[c];
262+
for (int i = 0; i < c; i++)
263+
{
264+
ad[i] = in.readDouble();
265+
}
266+
267+
return ad;
268+
}
269+
270+
/**
271+
* Read an array of doubles with larger length.
272+
*
273+
* @param in a DataInput stream to read from
274+
* @param cLength length to read
275+
*
276+
* @return an array of doubles
277+
*
278+
* @throws IOException if an I/O exception occurs
279+
*/
280+
private double[] readLargeDoubleArray(DataInput in, int cLength)
281+
throws IOException
282+
{
283+
int cBatchMax = 0x3FFFFFF >> 3;
284+
int cBatch = cLength / cBatchMax + 1;
285+
double[] aMerged = null;
286+
int cRead = 0;
287+
int cAllocate = cBatchMax;
288+
289+
double[] ad;
290+
for (int i = 0; i < cBatch && cRead < cLength; i++)
291+
{
292+
ad = readDoubleArray(in, cAllocate);
293+
aMerged = Base.mergeDoubleArray(aMerged, ad);
294+
cRead += ad.length;
295+
296+
cAllocate = Math.min(cLength - cRead, cBatchMax);
297+
}
298+
299+
return aMerged;
300+
}
248301

249302
// ----- constants ------------------------------------------------------
250303

prj/coherence-core/src/main/java/com/tangosol/internal/util/IntBag.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* http://oss.oracle.com/licenses/upl.
@@ -12,6 +12,7 @@
1212
import com.tangosol.io.pof.PofWriter;
1313
import com.tangosol.io.pof.PortableObject;
1414

15+
import com.tangosol.util.ExternalizableHelper;
1516
import com.tangosol.util.HashHelper;
1617

1718
import java.io.DataInput;
@@ -121,13 +122,8 @@ public int[] toArray()
121122
public void readExternal(DataInput in)
122123
throws IOException
123124
{
124-
int c = m_c = in.readInt();
125-
int[] a = new int[c];
126-
for (int i = 0; i < c; ++i)
127-
{
128-
a[i] = in.readInt();
129-
}
130-
m_a = a;
125+
m_a = ExternalizableHelper.readIntArray(in);
126+
m_c = m_a.length;
131127
}
132128

133129
@Override

prj/coherence-core/src/main/java/com/tangosol/internal/util/LongBag.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* http://oss.oracle.com/licenses/upl.
@@ -12,6 +12,7 @@
1212
import com.tangosol.io.pof.PofWriter;
1313
import com.tangosol.io.pof.PortableObject;
1414

15+
import com.tangosol.util.ExternalizableHelper;
1516
import com.tangosol.util.HashHelper;
1617

1718
import java.io.DataInput;
@@ -121,13 +122,8 @@ public long[] toArray()
121122
public void readExternal(DataInput in)
122123
throws IOException
123124
{
124-
int c = m_c = in.readInt();
125-
long[] a = new long[c];
126-
for (int i = 0; i < c; ++i)
127-
{
128-
a[i] = in.readLong();
129-
}
130-
m_a = a;
125+
m_a = ExternalizableHelper.readLongArray(in);
126+
m_c = m_a.length;
131127
}
132128

133129
@Override

prj/coherence-core/src/main/java/com/tangosol/internal/util/invoke/RemoteConstructor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* http://oss.oracle.com/licenses/upl.
@@ -185,7 +185,10 @@ public void readExternal(DataInput in)
185185
{
186186
m_definition = ExternalizableHelper.readObject(in);
187187

188-
Object[] aoArgs = m_aoArgs = new Object[ExternalizableHelper.readInt(in)];
188+
int cArgs = ExternalizableHelper.readInt(in);
189+
Base.azzert(cArgs < 256, "Unexpected number of constructor arguments.");
190+
191+
Object[] aoArgs = m_aoArgs = new Object[cArgs];
189192
for (int i = 0; i < aoArgs.length; i++)
190193
{
191194
aoArgs[i] = ExternalizableHelper.readObject(in);

0 commit comments

Comments
 (0)